private EdgeRing FindEdgeRing(PolygonizeDirectedEdge startDE) { PolygonizeDirectedEdge de = startDE; EdgeRing er = new EdgeRing(factory); do { er.Add(de); de.Ring = er; de = de.Next; Debug.Assert(de != null, "found null DE in ring"); Debug.Assert(de == startDE || !de.InRing, "found DE already in ring"); }while (de != startDE); return(er); }
/// <summary> /// Find the innermost enclosing shell EdgeRing containing the argument /// EdgeRing, if any. /// The innermost enclosing ring is the smallest enclosing ring. /// The algorithm used depends on the fact that: /// <para> /// ring A Contains ring B iff envelope(ring A) Contains envelope(ring B) /// </para> /// This routine is only safe to use if the chosen point of the hole /// is known to be properly contained in a shell /// (which is guaranteed to be the case if the hole does not touch its shell) /// </summary> /// <returns> Returns a containing EdgeRing, if there is one or /// <see langword="null"/> if no containing EdgeRing is found. /// </returns> public static EdgeRing FindEdgeRingContaining(EdgeRing testEr, ArrayList shellList) { LinearRing testRing = testEr.Ring; Envelope testEnv = testRing.Bounds; Coordinate testPt = testRing.GetCoordinate(0); EdgeRing minShell = null; Envelope minEnv = null; for (IEnumerator it = shellList.GetEnumerator(); it.MoveNext();) { EdgeRing tryShell = (EdgeRing)it.Current; LinearRing tryRing = tryShell.Ring; Envelope tryEnv = tryRing.Bounds; if (minShell != null) { minEnv = minShell.Ring.Bounds; } bool isContained = false; // the hole envelope cannot equal the shell envelope if (tryEnv.Equals(testEnv)) { continue; } testPt = PointNotInList(testRing.Coordinates, tryRing.Coordinates); if (tryEnv.Contains(testEnv) && CGAlgorithms.IsPointInRing(testPt, tryRing.Coordinates)) { isContained = true; } // check if this new containing ring is smaller than the current minimum ring if (isContained) { if (minShell == null || minEnv.Contains(tryEnv)) { minShell = tryShell; } } } return(minShell); }