/// <summary>
 /// 
 /// </summary>
 /// <param name="er"></param>
 /// <returns></returns>
 public virtual int GetOutgoingDegree(EdgeRing er)
 {
     int degree = 0;
     for (IEnumerator it = GetEnumerator(); it.MoveNext(); ) 
     {
         DirectedEdge de = (DirectedEdge)it.Current;
         if (de.EdgeRing == er) 
             degree++;
     }
     return degree;
 }
Exemplo n.º 2
0
        /// <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, OR
        /// null if no containing EdgeRing is found.</returns>
        private static EdgeRing FindEdgeRingContaining(EdgeRing testEr, IEnumerable shellList)
        {
            ILinearRing teString = testEr.LinearRing;
            IEnvelope testEnv = teString.EnvelopeInternal;
            Coordinate testPt = teString.Coordinates[0];

            EdgeRing minShell = null;
            IEnvelope minEnv = null;
            for (IEnumerator it = shellList.GetEnumerator(); it.MoveNext(); )
            {
                EdgeRing tryShell = (EdgeRing)it.Current;
                ILinearRing tryRing = tryShell.LinearRing;
                IEnvelope 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;
        }
Exemplo n.º 3
0
 /// <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 minEdgeRings)
 {
     for (IEnumerator it = minEdgeRings.GetEnumerator(); it.MoveNext(); )
     {
         MinimalEdgeRing er = (MinimalEdgeRing)it.Current;
         if (er.IsHole) 
             er.Shell = shell;
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="er"></param>
        public virtual 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 = (DirectedEdge)_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;
                        if (incoming != null) incoming.NextMin = nextOut;
                        state = ScanningForIncoming;
                        break;
	                default:
		                break;
                }
            }        
            if (state == LinkingToOutgoing) 
            {
                Assert.IsTrue(firstOut != null, "found null for first outgoing dirEdge");
                if (firstOut != null)
                {
                    Assert.IsTrue(firstOut.EdgeRing == er, "unable to link last incoming dirEdge");
                    if (incoming != null) incoming.NextMin = firstOut;
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="de"></param>
 /// <param name="er"></param>
 public override void SetEdgeRing(DirectedEdge de, EdgeRing er)
 {
     de.EdgeRing = er;
 }
Exemplo n.º 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="de"></param>
 /// <param name="er"></param>
 abstract public void SetEdgeRing(DirectedEdge de, EdgeRing er);
Exemplo n.º 7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="ring"></param>
 public virtual void AddHole(EdgeRing ring) 
 {
     _holes.Add(ring); 
 }