Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="edgeRingList"></param>
 private void FindShellsAndHoles(IEnumerable edgeRingList)
 {
     _holeList  = new ArrayList();
     _shellList = new ArrayList();
     for (IEnumerator i = edgeRingList.GetEnumerator(); i.MoveNext();)
     {
         EdgeRing er = (EdgeRing)i.Current;
         if (er.IsHole)
         {
             _holeList.Add(er);
         }
         else
         {
             _shellList.Add(er);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startDe"></param>
        /// <returns></returns>
        private EdgeRing FindEdgeRing(PolygonizeDirectedEdge startDe)
        {
            PolygonizeDirectedEdge de = startDe;
            EdgeRing er = new EdgeRing(_factory);

            do
            {
                er.Add(de);
                de.Ring = er;
                de      = de.Next;
                if (de == null)
                {
                    throw new NullEdgeException();
                }
                if (de != startDe && de.IsInRing)
                {
                    throw new DuplicateEdgeException();
                }
            }while (de != startDe);
            return(er);
        }
Ejemplo n.º 3
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">The EdgeRing to test.</param>
        /// <param name="shellList">The list of shells to test.</param>
        /// <returns>Containing EdgeRing, if there is one, OR
        /// null if no containing EdgeRing is found.</returns>
        public static EdgeRing FindEdgeRingContaining(EdgeRing testEr, IList shellList)
        {
            ILinearRing teString = testEr.Ring;
            IEnvelope   testEnv  = teString.EnvelopeInternal;

            EdgeRing  minShell = null;
            IEnvelope minEnv   = null;

            for (IEnumerator it = shellList.GetEnumerator(); it.MoveNext();)
            {
                EdgeRing    tryShell = (EdgeRing)it.Current;
                ILinearRing tryRing  = tryShell.Ring;
                IEnvelope   tryEnv   = tryRing.EnvelopeInternal;
                if (minShell != null)
                {
                    minEnv = minShell.Ring.EnvelopeInternal;
                }
                bool isContained = false;
                // the hole envelope cannot equal the shell envelope
                if (tryEnv.Equals(testEnv))
                {
                    continue;
                }

                Coordinate testPt = PtNotInList(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);
        }
Ejemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="holeEr"></param>
 /// <param name="shellList"></param>
 private static void AssignHoleToShell(EdgeRing holeEr, IList shellList)
 {
     EdgeRing shell = EdgeRing.FindEdgeRingContaining(holeEr, shellList);
     if (shell != null)
         shell.AddHole(holeEr.Ring);
 }
Ejemplo n.º 5
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">The EdgeRing to test.</param>
        /// <param name="shellList">The list of shells to test.</param>
        /// <returns>Containing EdgeRing, if there is one, OR
        /// null if no containing EdgeRing is found.</returns>
        public static EdgeRing FindEdgeRingContaining(EdgeRing testEr, IList shellList)
        {
            ILinearRing teString = testEr.Ring;
            IEnvelope testEnv = teString.EnvelopeInternal;

            EdgeRing minShell = null;
            IEnvelope minEnv = null;
            for (IEnumerator it = shellList.GetEnumerator(); it.MoveNext(); )
            {
                EdgeRing tryShell = (EdgeRing)it.Current;
                ILinearRing tryRing = tryShell.Ring;
                IEnvelope tryEnv = tryRing.EnvelopeInternal;
                if (minShell != null)
                    minEnv = minShell.Ring.EnvelopeInternal;
                bool isContained = false;
                // the hole envelope cannot equal the shell envelope
                if (tryEnv.Equals(testEnv)) continue;

                Coordinate testPt = PtNotInList(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;
        }
Ejemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="startDe"></param>
 /// <returns></returns>
 private EdgeRing FindEdgeRing(PolygonizeDirectedEdge startDe)
 {
     PolygonizeDirectedEdge de = startDe;
     EdgeRing er = new EdgeRing(_factory);
     do
     {
         er.Add(de);
         de.Ring = er;
         de = de.Next;
         if (de == null) throw new NullEdgeException();
         if (de != startDe && de.IsInRing) throw new DuplicateEdgeException();
     }
     while (de != startDe);
     return er;
 }