static internal Point FindBendPointBetween(Point sourcePoint, Point targetPoint, Directions finalEdgeDir)
        {
            Directions targetDir = PointComparer.GetDirections(sourcePoint, targetPoint);

            Debug.Assert(!PointComparer.IsPureDirection(targetDir), "pure direction has no bend");
            Directions firstDir = targetDir & ~finalEdgeDir;

            Debug.Assert(PointComparer.IsPureDirection(firstDir), "firstDir is not pure");

            // Move along the first direction. If the first direction is horizontal then
            // targetPoint is at the correct horizontal position, and vice-versa.
            return(IsVertical(firstDir)
                    ? new Point(sourcePoint.X, targetPoint.Y)
                    : new Point(targetPoint.X, sourcePoint.Y));
        }
        internal VisibilityVertex AddEdgeToTargetEdge(VisibilityVertex sourceVertex, VisibilityEdge targetEdge
                                                      , Point targetIntersect)
        {
            StaticGraphUtility.Assert(PointComparer.Equal(sourceVertex.Point, targetIntersect) ||
                                      PointComparer.IsPureDirection(sourceVertex.Point, targetIntersect)
                                      , "non-orthogonal edge request", ObstacleTree, VisGraph);
            StaticGraphUtility.Assert(StaticGraphUtility.PointIsOnSegment(targetEdge.SourcePoint, targetEdge.TargetPoint, targetIntersect)
                                      , "targetIntersect is not on targetEdge", ObstacleTree, VisGraph);

            // If the target vertex does not exist, we must split targetEdge to add it.
            VisibilityVertex targetVertex = VisGraph.FindVertex(targetIntersect);

            if (null == targetVertex)
            {
                targetVertex = AddVertex(targetIntersect);
                SplitEdge(targetEdge, targetVertex);
            }
            FindOrAddEdge(sourceVertex, targetVertex);
            return(targetVertex);
        }
Esempio n. 3
0
 private static void EnsureNonNullPath(Path edgePath)
 {
     if (null == edgePath.PathPoints)
     {
         // Probably a fully-landlocked obstacle such as RectilinearTests.Route_Between_Two_Separately_Landlocked_Obstacles
         // or disconnected subcomponents due to excessive overlaps, such as Rectilinear(File)Tests.*Disconnected*.  In this
         // case, just put the single-bend path in there, even though it most likely cuts across unrelated obstacles.
         if (PointComparer.IsPureDirection(edgePath.EdgeGeometry.SourcePort.Location, edgePath.EdgeGeometry.TargetPort.Location))
         {
             edgePath.PathPoints = new[] {
                 edgePath.EdgeGeometry.SourcePort.Location,
                 edgePath.EdgeGeometry.TargetPort.Location
             };
             return;
         }
         edgePath.PathPoints = new[] {
             edgePath.EdgeGeometry.SourcePort.Location,
             new Point(edgePath.EdgeGeometry.SourcePort.Location.X, edgePath.EdgeGeometry.TargetPort.Location.Y),
             edgePath.EdgeGeometry.TargetPort.Location
         };
     }
 }