コード例 #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>
        /// <param name="ei0"></param>
        /// <param name="ei1"></param>
        public Edge CreateSplitEdge(EdgeIntersection ei0, EdgeIntersection ei1)
        {
            int npts           = ei1.SegmentIndex - ei0.SegmentIndex + 2;
            var lastSegStartPt = edge.Points[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.Distance > 0.0 || !ei1.Coordinate.Equals2D(lastSegStartPt);

            if (!useIntPt1)
            {
                npts--;
            }

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

            pts[ipt++] = ei0.Coordinate.Copy();
            for (int i = ei0.SegmentIndex + 1; i <= ei1.SegmentIndex; i++)
            {
                pts[ipt++] = edge.Points[i];
            }

            if (useIntPt1)
            {
                pts[ipt] = ei1.Coordinate;
            }
            return(new Edge(pts, new Label(edge.Label)));
        }
コード例 #2
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>
        /// <param name="intPt"></param>
        /// <param name="segmentIndex"></param>
        /// <param name="dist"></param>
        /// <returns>The EdgeIntersection found or added.</returns>
        public EdgeIntersection Add(Coordinate intPt, int segmentIndex, double dist)
        {
            var eiNew = new EdgeIntersection(intPt, segmentIndex, dist);
            EdgeIntersection ei;

            if (nodeMap.TryGetValue(eiNew, out ei))
            {
                return(ei);
            }
            nodeMap[eiNew] = eiNew;
            return(eiNew);
        }