/// <summary> /// For the set of minimal rings comprising a maximal ring, /// assigns the holes to the shell known to contain them. /// Assigning the holes directly to the shell serves two purposes: /// <list type="bullet"> /// <item><description>it is faster than using a point-in-polygon check later on.</description></item> /// <item><description>it ensures correctness, since if the PIP test was used the point /// chosen might lie on the shell, which might return an incorrect result from the /// PIP test</description></item> /// </list> /// </summary> private static void AssignHoles(OverlayEdgeRing shell, IEnumerable <OverlayEdgeRing> edgeRings) { foreach (var er in edgeRings) { if (er.IsHole) { er.Shell = shell; } } }
/// <summary> /// Finds the single shell, if any, out of /// a list of minimal rings derived from a maximal ring. /// The other possibility is that they are a set of (connected) holes, /// in which case no shell will be found. /// </summary> /// <returns>The shell ring, if there is one /// or <c>null</c>, if all rings are holes /// </returns> private OverlayEdgeRing FindSingleShell(IEnumerable <OverlayEdgeRing> edgeRings) { int shellCount = 0; OverlayEdgeRing shell = null; foreach (var er in edgeRings) { if (!er.IsHole) { shell = er; shellCount++; } } Assert.IsTrue(shellCount <= 1, "found two shells in EdgeRing list"); return(shell); }
public List <OverlayEdgeRing> BuildMinimalRings(GeometryFactory geometryFactory) { LinkMinimalRings(); var minEdgeRings = new List <OverlayEdgeRing>(); var e = _startEdge; do { if (e.EdgeRing == null) { var minEr = new OverlayEdgeRing(e, geometryFactory); minEdgeRings.Add(minEr); } e = e.NextResultMax; } while (e != _startEdge); return(minEdgeRings); }