/// <summary> /// /// </summary> /// <param name="er"></param> /// <returns></returns> public int GetOutgoingDegree(EdgeRing er) { int degree = 0; foreach (DirectedEdge de in Edges) if (de.EdgeRing == er) degree++; return degree; }
/// <summary> /// /// </summary> /// <param name="de"></param> /// <param name="er"></param> public abstract void SetEdgeRing(DirectedEdge de, EdgeRing er);
/// <summary> /// /// </summary> /// <param name="ring"></param> public void AddHole(EdgeRing ring) { _holes.Add(ring); }
/// <summary> /// /// </summary> /// <param name="er"></param> public void LinkMinimalDirectedEdges(EdgeRing er) { // find first area edge (if any) to start linking at DirectedEdge firstOut = null; DirectedEdge incoming = null; int state = ScanningForIncoming; // link edges in CW order for (int i = _resultAreaEdgeList.Count - 1; i >= 0; i--) { DirectedEdge nextOut = this._resultAreaEdgeList[i]; DirectedEdge nextIn = nextOut.Sym; // record first outgoing edge, in order to link the last incoming edge if (firstOut == null && nextOut.EdgeRing == er) firstOut = nextOut; switch (state) { case ScanningForIncoming: if (nextIn.EdgeRing != er) continue; incoming = nextIn; state = LinkingToOutgoing; break; case LinkingToOutgoing: if (nextOut.EdgeRing != er) continue; incoming.NextMin = nextOut; state = ScanningForIncoming; break; default: break; } } if (state == LinkingToOutgoing) { Assert.IsTrue(firstOut != null, "found null for first outgoing dirEdge"); Assert.IsTrue(firstOut.EdgeRing == er, "unable to link last incoming dirEdge"); incoming.NextMin = firstOut; } }
/// <summary> /// /// </summary> /// <param name="de"></param> /// <param name="er"></param> public override void SetEdgeRing(DirectedEdge de, EdgeRing er) { de.MinEdgeRing = er; }
/// <summary> /// /// </summary> /// <param name="de"></param> /// <param name="er"></param> abstract public void SetEdgeRing(DirectedEdge de, EdgeRing er);
/// <summary> /// /// </summary> /// <param name="ring"></param> public void AddHole(EdgeRing ring) { _holes.Add(ring); }
/// <summary> /// This method assigns the holes for a Polygon (formed from a list of /// MinimalEdgeRings) to its shell. /// Determining the holes for a MinimalEdgeRing polygon serves two purposes: /// it is faster than using a point-in-polygon check later on. /// 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. /// </summary> /// <param name="shell"></param> /// <param name="minEdgeRings"></param> private static void PlacePolygonHoles(EdgeRing shell, IEnumerable<EdgeRing> minEdgeRings) { foreach (MinimalEdgeRing er in minEdgeRings) { if (er.IsHole) er.Shell = shell; } }
/// <summary> /// Find the innermost enclosing shell EdgeRing containing the argument EdgeRing, if any. /// The innermost enclosing ring is the <i>smallest</i> enclosing ring. /// The algorithm used depends on the fact that: /// ring A contains ring B iff envelope(ring A) contains envelope(ring B). /// 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> /// <param name="testEr"></param> /// <param name="shellList"></param> /// <returns>Containing EdgeRing, if there is one <br/> or /// <value>null</value> if no containing EdgeRing is found.</returns> private static EdgeRing FindEdgeRingContaining(EdgeRing testEr, IEnumerable<EdgeRing> shellList) { ILinearRing teString = testEr.LinearRing; Envelope testEnv = teString.EnvelopeInternal; Coordinate testPt = teString.GetCoordinateN(0); EdgeRing minShell = null; Envelope minEnv = null; foreach (EdgeRing tryShell in shellList) { ILinearRing tryRing = tryShell.LinearRing; Envelope tryEnv = tryRing.EnvelopeInternal; if (minShell != null) minEnv = minShell.LinearRing.EnvelopeInternal; bool isContained = false; 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; }