Example #1
0
        /// <summary>
        /// Finds and removes all cut edges from the graph.
        /// </summary>
        /// <returns>A list of the <c>LineString</c>s forming the removed cut edges.</returns>
        public virtual IList DeleteCutEdges()
        {
            ComputeNextCwEdges();
            // label the current set of edgerings
            FindLabeledEdgeRings(DirectedEdges);

            /*
             * Cut Edges are edges where both dirEdges have the same label.
             * Delete them, and record them
             */
            IList cutLines = new ArrayList();

            for (IEnumerator i = DirectedEdges.GetEnumerator(); i.MoveNext();)
            {
                PolygonizeDirectedEdge de = (PolygonizeDirectedEdge)i.Current;
                if (de.IsMarked)
                {
                    continue;
                }

                PolygonizeDirectedEdge sym = (PolygonizeDirectedEdge)de.Sym;
                if (de.Label == sym.Label)
                {
                    de.IsMarked  = true;
                    sym.IsMarked = true;

                    // save the line as a cut edge
                    PolygonizeEdge e = (PolygonizeEdge)de.Edge;
                    cutLines.Add(e.Line);
                }
            }
            return(cutLines);
        }
Example #2
0
        /// <summary>
        /// Computes the EdgeRings formed by the edges in this graph.
        /// </summary>
        /// <returns>A list of the{EdgeRings found by the polygonization process.</returns>
        public virtual IList GetEdgeRings()
        {
            // maybe could optimize this, since most of these pointers should be set correctly already by deleteCutEdges()
            ComputeNextCwEdges();
            // clear labels of all edges in graph
            Label(DirectedEdges, -1);
            IList maximalRings = FindLabeledEdgeRings(DirectedEdges);

            ConvertMaximalToMinimalEdgeRings(maximalRings);

            // find all edgerings
            IList edgeRingList = new ArrayList();

            for (IEnumerator i = DirectedEdges.GetEnumerator(); i.MoveNext();)
            {
                PolygonizeDirectedEdge de = (PolygonizeDirectedEdge)i.Current;
                if (de.IsMarked)
                {
                    continue;
                }
                if (de.IsInRing)
                {
                    continue;
                }

                EdgeRing er = FindEdgeRing(de);
                edgeRingList.Add(er);
            }
            return(edgeRingList);
        }