示例#1
0
        /// <summary>
        /// Check that a ring does not self-intersect, except at its endpoints.
        /// Algorithm is to count the number of times each node along edge occurs.
        /// If any occur more than once, that must be a self-intersection.
        /// </summary>
        private void CheckNoSelfIntersectingRing(EdgeIntersectionList eiList)
        {
            ISet nodeSet = new HashedSet();
            bool isFirst = true;

            for (IEnumerator i = eiList.Iterator(); i.MoveNext();)
            {
                EdgeIntersection ei = (EdgeIntersection)i.Current;
                if (isFirst)
                {
                    isFirst = false;
                    continue;
                }
                if (nodeSet.Contains(ei.coord))
                {
                    validErr = new ValidationError(
                        ValidationErrorType.RingSelfIntersection, ei.coord);

                    return;
                }
                else
                {
                    nodeSet.Add(ei.coord);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Creates stub edges for all the intersections in this
        /// Edge (if any) and inserts them into the graph.
        /// </summary>
        public void ComputeEdgeEnds(Edge edge, ArrayList l)
        {
            EdgeIntersectionList eiList = edge.EdgeIntersectionList;

            // ensure that the list has entries for the first and last point of the edge
            eiList.AddEndpoints();

            IEnumerator      it     = eiList.Iterator();
            EdgeIntersection eiPrev = null;
            EdgeIntersection eiCurr = null;

            // no intersections, so there is nothing to do
            if (!it.MoveNext())
            {
                return;
            }

            EdgeIntersection eiNext = (EdgeIntersection)it.Current;

            do
            {
                eiPrev = eiCurr;
                eiCurr = eiNext;
                eiNext = null;

                if (it.MoveNext())
                {
                    eiNext = (EdgeIntersection)it.Current;
                }

                if (eiCurr != null)
                {
                    CreateEdgeEndForPrev(edge, l, eiCurr, eiPrev);
                    CreateEdgeEndForNext(edge, l, eiCurr, eiNext);
                }
            }while (eiCurr != null);
        }