Exemplo n.º 1
0
        /// <summary> Create a new "split edge" with the section of points between
        /// (and including) the two intersections.
        /// The label for the new edge is the same as the label for the parent edge.
        /// </summary>
        internal Edge CreateSplitEdge(EdgeIntersection ei0, EdgeIntersection ei1)
        {
            //Debug.Print("\ncreateSplitEdge"); Debug.Print(ei0); Debug.Print(ei1);
            int npts = ei1.segmentIndex - ei0.segmentIndex + 2;

            Coordinate lastSegStartPt = edge.pts[ei1.segmentIndex];
            // if the last intersection point is not equal to the its segment start pt,
            // Add it to the points list as well.
            // (This check is needed because the Distance metric is not totally reliable!)
            // The check for point equality is 2D only - Z values are ignored
            bool useIntPt1 = ei1.dist > 0.0 || !ei1.coord.Equals(lastSegStartPt);

            if (!useIntPt1)
            {
                npts--;
            }

            Coordinate[] pts = new Coordinate[npts];
            int          ipt = 0;

            pts[ipt++] = new Coordinate(ei0.coord);
            for (int i = ei0.segmentIndex + 1; i <= ei1.segmentIndex; i++)
            {
                pts[ipt++] = edge.pts[i];
            }
            if (useIntPt1)
            {
                pts[ipt] = ei1.coord;
            }

            return(new Edge(new CoordinateCollection(pts), new Label(edge.m_objLabel)));
        }
Exemplo n.º 2
0
 /// <summary> Tests if the given point is an edge intersection
 ///
 /// </summary>
 /// <param name="pt">the point to test
 /// </param>
 /// <returns> true if the point is an intersection
 /// </returns>
 public bool IsIntersection(Coordinate pt)
 {
     for (IEnumerator it = Iterator(); it.MoveNext();)
     {
         EdgeIntersection ei = (EdgeIntersection)it.Current;
         if (ei.coord.Equals(pt))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 3
0
        private void AddSelfIntersectionNodes(int argIndex)
        {
            for (IEdgeEnumerator i = edges.GetEnumerator(); i.MoveNext();)
            {
                Edge e    = i.Current;
                int  eLoc = e.Label.GetLocation(argIndex);

                for (IEnumerator eiIt = e.eiList.Iterator(); eiIt.MoveNext();)
                {
                    EdgeIntersection ei = (EdgeIntersection)eiIt.Current;
                    AddSelfIntersectionNode(argIndex, ei.coord, eLoc);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary> Adds an intersection into the list, if it isn't already there.
        /// The input segmentIndex and dist are expected to be normalized.
        /// </summary>
        /// <returns> the EdgeIntersection found or added
        /// </returns>
        public EdgeIntersection Add(Coordinate intPt, int segmentIndex, double dist)
        {
            EdgeIntersection eiNew = new EdgeIntersection(intPt, segmentIndex, dist);

            EdgeIntersection ei = (EdgeIntersection)nodeMap[eiNew];

            if (ei != null)
            {
                return(ei);
            }

            nodeMap[eiNew] = eiNew;

            return(eiNew);
        }
Exemplo n.º 5
0
        /// <summary> Creates new edges for all the edges that the intersections in this
        /// list split the parent edge into.
        /// Adds the edges to the input list (this is so a single list
        /// can be used to accumulate all split edges for a Geometry).
        /// </summary>
        /// <param name="edgeList">a list of EdgeIntersections
        /// </param>
        public void AddSplitEdges(EdgeCollection edgeList)
        {
            // ensure that the list has entries for the first and last point of the edge
            AddEndpoints();

            IEnumerator it = Iterator();

            // there should always be at least two entries in the list
            it.MoveNext();                //TODO--PAUL
            EdgeIntersection eiPrev = (EdgeIntersection)it.Current;

            while (it.MoveNext())
            {
                EdgeIntersection ei      = (EdgeIntersection)it.Current;
                Edge             newEdge = CreateSplitEdge(eiPrev, ei);
                edgeList.Add(newEdge);

                eiPrev = ei;
            }
        }
Exemplo n.º 6
0
        public int CompareTo(object obj)
        {
            EdgeIntersection other = (EdgeIntersection)obj;

            return(Compare(other.segmentIndex, other.dist));
        }