コード例 #1
0
        void CreatePortObstacles(Node node, Port port, out LineSegment filterLine)
        {
            var bp = port as CurvePort;

            if (bp != null)
            {
                var    padding      = router.Padding;
                var    closedCurve  = node.BoundaryCurve;
                Curve  paddingCurve = GetPaddedPolyline(closedCurve, padding).ToCurve();
                Point  portPoint    = node.BoundaryCurve[bp.Parameter];
                double length       = node.BoundaryCurve.BoundingBox.Width + node.BoundaryCurve.BoundingBox.Height;
                double leftTipPar   = GetLeftTipParam(bp.Parameter, portPoint, paddingCurve, node, length);
                double rightTipPar  = GetRightTipParam(bp.Parameter, portPoint, paddingCurve, node, length);
                paddingCurve = TrimCurve(paddingCurve, rightTipPar, leftTipPar);
                //a simplifying hack here. I know that the parameter start from 0 and advances by 1 on every segment
                int n = paddingCurve.Segments.Count / 2;
                Debug.Assert(n > 0);
                Curve rightChunk = TrimCurve(paddingCurve, 0, n);
                Curve leftChunk  = TrimCurve(paddingCurve, n + 0.8, paddingCurve.ParEnd);
                filterLine = new LineSegment(0.5 * (leftChunk.Start + leftChunk.End),
                                             0.5 * (rightChunk.Start + rightChunk.End));
                Polyline pol = Polyline.PolylineFromCurve(leftChunk);
                pol.Closed = true;
                portObstacles.Insert(pol);
                TightObstacles.Insert(pol);
                pol        = Polyline.PolylineFromCurve(rightChunk);
                pol.Closed = true;
                portObstacles.Insert(pol);
                TightObstacles.Insert(pol);

                /*
                 * Polyline padded = CreatePaddedCurve(Anchor.PolylineAroundClosedCurve(node.BoundaryCurve), this.router.MinimalPadding);
                 *
                 *
                 *
                 *
                 * PolylinePoint polyRightBottomPoint = FindPolyPointToCutAt(node, bp.Parameter, padded);
                 * PolylinePoint nextToRightTopTip;
                 * Point rightTopTip = GetRightTopTip(node, bp.Parameter, padded, out nextToRightTopTip);
                 *
                 * PolylinePoint prevToLeftTopTip;
                 * Point leftTopTip = GetLeftTopTip(node, bp.Parameter, padded, out prevToLeftTopTip);
                 * double al = 0.25;
                 * Point rightLow = (1 - al) * polyRightBottomPoint.Point + al * polyRightBottomPoint.NextOnPolyline.Point;
                 * Point leftLow = al * polyRightBottomPoint.Point + (1 - al) * polyRightBottomPoint.NextOnPolyline.Point;
                 * filterLine = new LineSegment(0.5 * (rightTopTip + rightLow), 0.5 * (leftTopTip + leftLow));
                 * AddRightObstacle(rightTopTip, nextToRightTopTip, polyRightBottomPoint, rightLow);
                 * AddLeftObstacle(leftLow, polyRightBottomPoint.NextOnPolyline, prevToLeftTopTip, leftTopTip);
                 */
            }
            else
            {
                filterLine = null;
                portObstacles.Insert(node.BoundaryCurve);
            }
        }
コード例 #2
0
 /// <summary>
 ///
 /// </summary>
 void CreateInitialTightObstacles()
 {
     tightObstacles = new Set <Polyline>();
     foreach (Node node in router.Graph.Nodes)
     {
         if (node == router.Source)
         {
             CreatePortObstacles(router.Source, router.SourcePort, out sourceFilterLine);
         }
         else if (node == router.Target)
         {
             CreatePortObstacles(router.Target, router.TargetPort, out targetFilterLine);
         }
         else
         {
             TightObstacles.Insert(PaddedPolylineBoundaryOfNode(node, router.Padding));
         }
     }
 }
コード例 #3
0
        void RemoveTightObstaclesOverlappingPortTightObstacles()
        {
            var toRemove = new List <Polyline>();

            foreach (Polyline poly in TightObstaclesMinusPortObstacles())
            {
                foreach (ICurve portObstacle in portObstacles)
                {
                    if (poly.BoundingBox.Intersects(portObstacle.BoundingBox))
                    {
                        if (Curve.GetAllIntersections(poly, portObstacle, false).Count > 0 ||
                            OneCurveLiesInsideOfOther(poly, portObstacle))
                        {
                            toRemove.Add(poly);
                        }
                    }
                }
            }

            foreach (Polyline poly in toRemove)
            {
                TightObstacles.Remove(poly);
            }
        }
コード例 #4
0
        void CreatePortObstacles(Node node, Port port, out LineSegment filterLine)
        {
            var bp = port as CurvePort;

            if (bp != null)
            {
                var    padding      = router.Padding;
                var    closedCurve  = node.BoundaryCurve;
                Curve  paddingCurve = GetPaddedPolyline(closedCurve, padding).ToCurve();
                Point  portPoint    = node.BoundaryCurve[bp.Parameter];
                double length       = node.BoundaryCurve.BoundingBox.Width + node.BoundaryCurve.BoundingBox.Height;
                double leftTipPar   = GetLeftTipParam(bp.Parameter, portPoint, paddingCurve, node, length);
                double rightTipPar  = GetRightTipParam(bp.Parameter, portPoint, paddingCurve, node, length);
                paddingCurve = TrimCurve(paddingCurve, rightTipPar, leftTipPar);
                //a simplifying hack here. I know that the parameter start from 0 and advances by 1 on every segment
                int n = paddingCurve.Segments.Count / 2;
                Debug.Assert(n > 0);
                Curve rightChunk = TrimCurve(paddingCurve, 0, n);
                Curve leftChunk  = TrimCurve(paddingCurve, n + 0.8, paddingCurve.ParEnd);
                filterLine = new LineSegment(0.5 * (leftChunk.Start + leftChunk.End),
                                             0.5 * (rightChunk.Start + rightChunk.End));
                Polyline pol = Polyline.PolylineFromCurve(leftChunk);
                pol.Closed = true;
                portObstacles.Insert(pol);
                TightObstacles.Insert(pol);
                pol        = Polyline.PolylineFromCurve(rightChunk);
                pol.Closed = true;
                portObstacles.Insert(pol);
                TightObstacles.Insert(pol);
            }
            else
            {
                filterLine = null;
                portObstacles.Insert(node.BoundaryCurve);
            }
        }