示例#1
0
        // Append a vertex before LowestVisibilityVertex or after HighestVisibilityVertex.
        internal void AppendVisibilityVertex(VisibilityGraph vg, VisibilityVertex newVertex)
        {
            Debug.Assert(null != newVertex, "newVertex must not be null");
            Debug.Assert((null == LowestVisibilityVertex) == (null == HighestVisibilityVertex), "Mismatched null Lowest/HighestVisibilityVertex");
            Debug.Assert(StaticGraphUtility.PointIsOnSegment(this, newVertex.Point), "newVertex is out of segment range");
            if (null == HighestVisibilityVertex)
            {
                if (!AddGroupCrossingsBeforeHighestVisibilityVertex(vg, newVertex))
                {
                    SetInitialVisibilityVertex(newVertex);
                }
            }
            else
            {
                // In the event of overlaps where ScanSegments share a Start/End at a border, SegmentIntersector
                // may be appending the same Vertex twice.  If that point is on the border of a group,
                // then we may have just added the border-crossing edge as well.
                if (PointComparer.IsPureLower(newVertex.Point, HighestVisibilityVertex.Point))
                {
                    Debug.Assert(null != vg.FindEdge(newVertex.Point, HighestVisibilityVertex.Point)
                                 , "unexpected low/middle insertion to ScanSegment");
                    return;
                }

                // Add the new edge.  This will always be in the ascending direction.
                if (!AddGroupCrossingsBeforeHighestVisibilityVertex(vg, newVertex))
                {
                    AppendHighestVisibilityVertex(newVertex);
                }
            }
        }
示例#2
0
        internal void VerifyVisibilityGraph(RectilinearEdgeRouterWrapper router)
        {
            Validate.AreEqual(this.fileVertexCount, router.VisibilityGraph.VertexCount, "Graph vertex count difference");
            Validate.AreEqual(this.fileEdgeCount, router.VisibilityGraph.EdgeCount, "Graph edge count difference");

            // If the vertices and edges were stored to the file, verify them.
            if (0 != this.VisibilityGraph.VertexCount)
            {
                foreach (var fileVertex in this.VisibilityGraph.Vertices())
                {
                    Validate.IsNotNull(router.VisibilityGraph.FindVertex(fileVertex.Point), "Cannot find file vertex in router graph");
                }
                foreach (var routerVertex in router.VisibilityGraph.Vertices())
                {
                    Validate.IsNotNull(this.VisibilityGraph.FindVertex(routerVertex.Point), "Cannot find router vertex in file graph");
                }
                foreach (var fileEdge in this.VisibilityGraph.Edges)
                {
                    Validate.IsNotNull(VisibilityGraph.FindEdge(fileEdge), "Cannot find file edge in router graph");
                }
                foreach (var routerEdge in router.VisibilityGraph.Edges)
                {
                    Validate.IsNotNull(VisibilityGraph.FindEdge(routerEdge), "Cannot find router edge in file graph");
                }
            }
        }
 void AddIntersectionOfBothDirectionSweepsToTheResult(VisibilityGraph vg0, VisibilityGraph vg1)
 {
     foreach (var edge in vg0.Edges)
     {
         if (vg1.FindEdge(edge.SourcePoint, edge.TargetPoint) != null)
         {
             _visibilityGraph.AddEdge(edge.SourcePoint, edge.TargetPoint);
         }
     }
 }
示例#4
0
        internal List <VisibilityEdge> GetEdgesOfPath(List <Point> pathPoints)
        {
            var edges = new List <VisibilityEdge>();

            for (int i = 0; i < pathPoints.Count - 1; i++)
            {
                var v0 = GetOrFindVisibilityVertex(pathPoints[i]);
                if (v0 == null)
                {
                    continue;
                }
                var v1 = GetOrFindVisibilityVertex(pathPoints[i + 1]);
                if (v1 == null)
                {
                    continue;
                }
                var edge = _visGraph.FindEdge(v0.Point, v1.Point);
                if (edge != null)
                {
                    edges.Add(edge);
                }
            }
            return(edges);
        }
示例#5
0
        private void AddCrossingEdge(VisibilityGraph vg, VisibilityVertex lowVertex, VisibilityVertex highVertex, GroupBoundaryCrossing[] crossings)
        {
            VisibilityEdge edge = null;

            if (null != HighestVisibilityVertex)
            {
                // We may have a case where point xx.xxxxx8 has added an ascending-direction crossing, and now we're on
                // xx.xxxxx9 adding a descending-direction crossing.  In that case there should already be a VisibilityEdge
                // in the direction we want.
                if (PointComparer.Equal(this.HighestVisibilityVertex.Point, highVertex.Point))
                {
                    edge = vg.FindEdge(lowVertex.Point, highVertex.Point);
                    Debug.Assert(edge != null, "Inconsistent forward-backward sequencing in HighVisibilityVertex");
                }
                else
                {
                    AppendHighestVisibilityVertex(lowVertex);
                }
            }
            if (edge == null)
            {
                edge = AddVisibilityEdge(lowVertex, highVertex);
            }

            var crossingsArray = crossings.Select(c => c.Group.InputShape).ToArray();
            var prevIsPassable = edge.IsPassable;

            if (prevIsPassable == null)
            {
                edge.IsPassable = delegate { return(crossingsArray.Any(s => s.IsTransparent)); }
            }
            ;
            else
            {
                // Because we don't have access to the previous delegate's internals, we have to chain.  Fortunately this
                // will never be more than two deep.  File Test: Groups_Forward_Backward_Between_Same_Vertices.
                edge.IsPassable = delegate { return(crossingsArray.Any(s => s.IsTransparent) || prevIsPassable()); };
            }
            if (null == LowestVisibilityVertex)
            {
                SetInitialVisibilityVertex(lowVertex);
            }

            HighestVisibilityVertex = highVertex;
        }
示例#6
0
        static internal VisibilityEdge FindNextEdge(VisibilityGraph vg, VisibilityVertex vertex, Directions dir)
        {
            VisibilityVertex nextVertex = FindNextVertex(vertex, dir);

            return((null == nextVertex) ? null : vg.FindEdge(vertex.Point, nextVertex.Point));
        }