コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startDE"></param>
        /// <returns></returns>
        private EdgeRing FindEdgeRing(PolygonizeDirectedEdge startDE)
        {
            var er = new EdgeRing(_factory);

            er.Build(startDE);
            return(er);
        }
コード例 #2
0
        /// <summary>
        /// Add a <c>LineString</c> forming an edge of the polygon graph.
        /// </summary>
        /// <param name="line">The line to add.</param>
        public void AddEdge(LineString line)
        {
            if (line.IsEmpty)
            {
                return;
            }

            var linePts = CoordinateArrays.RemoveRepeatedPoints(line.Coordinates);

            if (linePts.Length < 2)
            {
                return; // see #87
            }
            var startPt = linePts[0];
            var endPt   = linePts[linePts.Length - 1];

            var nStart = GetNode(startPt);
            var nEnd   = GetNode(endPt);

            var de0  = new PolygonizeDirectedEdge(nStart, nEnd, linePts[1], true);
            var de1  = new PolygonizeDirectedEdge(nEnd, nStart, linePts[linePts.Length - 2], false);
            var edge = new PolygonizeEdge(line);

            edge.SetDirectedEdges(de0, de1);
            Add(edge);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        private static void ComputeNextCWEdges(Node node)
        {
            var deStar = node.OutEdges;
            PolygonizeDirectedEdge startDE = null;
            PolygonizeDirectedEdge prevDE  = null;

            // the edges are stored in CCW order around the star
            foreach (PolygonizeDirectedEdge outDE in deStar.Edges)
            {
                if (outDE.IsMarked)
                {
                    continue;
                }

                if (startDE == null)
                {
                    startDE = outDE;
                }

                if (prevDE != null)
                {
                    var sym = (PolygonizeDirectedEdge)prevDE.Sym;
                    sym.Next = outDE;
                }
                prevDE = outDE;
            }
            if (prevDE != null)
            {
                var sym = (PolygonizeDirectedEdge)prevDE.Sym;
                sym.Next = startDE;
            }
        }
コード例 #4
0
        /// <summary>
        /// Computes the next edge pointers going CCW around the given node, for the
        /// given edgering label.
        /// This algorithm has the effect of converting maximal edgerings into minimal edgerings
        /// </summary>
        /// <param name="node"></param>
        /// <param name="label"></param>
        private static void ComputeNextCCWEdges(Node node, long label)
        {
            var deStar = node.OutEdges;
            //PolyDirectedEdge lastInDE = null;
            PolygonizeDirectedEdge firstOutDE = null;
            PolygonizeDirectedEdge prevInDE   = null;

            // the edges are stored in CCW order around the star
            var edges = deStar.Edges;

            //for (IEnumerator i = deStar.Edges.GetEnumerator(); i.MoveNext(); ) {
            for (int i = edges.Count - 1; i >= 0; i--)
            {
                var de  = (PolygonizeDirectedEdge)edges[i];
                var sym = (PolygonizeDirectedEdge)de.Sym;

                PolygonizeDirectedEdge outDE = null;
                if (de.Label == label)
                {
                    outDE = de;
                }

                PolygonizeDirectedEdge inDE = null;
                if (sym.Label == label)
                {
                    inDE = sym;
                }

                if (outDE == null && inDE == null)
                {
                    continue;                                 // this edge is not in edgering
                }
                if (inDE != null)
                {
                    prevInDE = inDE;
                }

                if (outDE != null)
                {
                    if (prevInDE != null)
                    {
                        prevInDE.Next = outDE;
                        prevInDE      = null;
                    }
                    if (firstOutDE == null)
                    {
                        firstOutDE = outDE;
                    }
                }
            }
            if (prevInDE != null)
            {
                Assert.IsTrue(firstOutDE != null);
                prevInDE.Next = firstOutDE;
            }
        }
コード例 #5
0
 /// <summary>
 /// Traverses the polygonized edge rings in the graph
 /// and computes the depth parity (odd or even)
 /// relative to the exterior of the graph.
 ///
 /// If the client has requested that the output
 /// be polygonally valid, only odd polygons will be constructed.
 /// </summary>
 public void ComputeDepthParity()
 {
     while (true)
     {
         PolygonizeDirectedEdge de = null; //findLowestDirEdge();
         if (de == null)
         {
             return;
         }
         ComputeDepthParity(de);
     }
 }
コード例 #6
0
        public void Build(PolygonizeDirectedEdge startDE)
        {
            var de = startDE;

            do
            {
                Add(de);
                de.Ring = this;
                de      = de.Next;
                Assert.IsTrue(de != null, "found null DE in ring");
                Assert.IsTrue(de == startDE || !de.IsInRing, "found DE already in ring");
            } while (de != startDE);
        }
コード例 #7
0
        /**
         * Traverses a ring of DirectedEdges, accumulating them into a list.
         * This assumes that all dangling directed edges have been removed
         * from the graph, so that there is always a next dirEdge.
         *
         * @param startDE the DirectedEdge to start traversing at
         * @return a List of DirectedEdges that form a ring
         */

        public static List <DirectedEdge> FindDirEdgesInRing(PolygonizeDirectedEdge startDE)
        {
            var de    = startDE;
            var edges = new List <DirectedEdge>();

            do
            {
                edges.Add(de);
                de = de.Next;
                Assert.IsTrue(de != null, "found null DE in ring");
                Assert.IsTrue(de == startDE || !de.IsInRing, "found DE already in ring");
            } while (de != startDE);
            return(edges);
        }
コード例 #8
0
        /// <summary>
        /// Finds all nodes in a maximal edgering which are self-intersection nodes
        /// </summary>
        /// <param name="startDE"></param>
        /// <param name="label"></param>
        /// <returns>
        /// The list of intersection nodes found,
        /// or null if no intersection nodes were found.
        /// </returns>
        private static IEnumerable <Node> FindIntersectionNodes(PolygonizeDirectedEdge startDE, long label)
        {
            var          de       = startDE;
            IList <Node> intNodes = null;

            do
            {
                var node = de.FromNode;
                if (GetDegree(node, label) > 1)
                {
                    if (intNodes == null)
                    {
                        intNodes = new List <Node>();
                    }
                    intNodes.Add(node);
                }

                de = de.Next;
                Assert.IsTrue(de != null, "found null DE in ring");
                Assert.IsTrue(de == startDE || !de.IsInRing, "found DE already in ring");
            }while (de != startDE);
            return(intNodes);
        }
コード例 #9
0
 /// <summary>
 /// Traverses all connected edges, computing the depth parity of the associated polygons.
 /// </summary>
 /// <param name="de"></param>
 private void ComputeDepthParity(PolygonizeDirectedEdge de)
 {
 }