Beispiel #1
0
        /// <summary>
        /// Performs a brute-force comparison of every segment in each <see cref="SegmentString" />.
        /// This has n^2 performance.
        /// </summary>
        /// <param name="e0"></param>
        /// <param name="e1"></param>
        private void ComputeVertexSnaps(SegmentString e0, SegmentString e1)
        {
            ICoordinate[] pts0 = e0.Coordinates;
            ICoordinate[] pts1 = e1.Coordinates;
            for (int i0 = 0; i0 < pts0.Length - 1; i0++)
            {
                HotPixel hotPixel = new HotPixel(pts0[i0], scaleFactor, li);
                for (int i1 = 0; i1 < pts1.Length - 1; i1++)
                {
                    // don't snap a vertex to itself
                    if (e0 == e1)
                    {
                        if (i0 == i1)
                        {
                            continue;
                        }
                    }

                    bool isNodeAdded = AddSnappedNode(hotPixel, e1, i1);
                    // if a node is created for a vertex, that vertex must be noded too
                    if (isNodeAdded)
                    {
                        e0.AddIntersection(pts0[i0], i0);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Adds a new node (equal to the snap pt) to the segment
        /// if the segment passes through the hot pixel.
        /// </summary>
        /// <param name="hotPix"></param>
        /// <param name="segStr"></param>
        /// <param name="segIndex"></param>
        /// <returns></returns>
        public static bool AddSnappedNode(HotPixel hotPix, SegmentString segStr, int segIndex)
        {
            ICoordinate p0 = segStr.GetCoordinate(segIndex);
            ICoordinate p1 = segStr.GetCoordinate(segIndex + 1);

            if (hotPix.Intersects(p0, p1))
            {
                segStr.AddIntersection(hotPix.Coordinate, segIndex);
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Adds a new node (equal to the snap pt) to the segment
        /// if the segment passes through the hot pixel.
        /// </summary>
        /// <param name="hotPix"></param>
        /// <param name="segStr"></param>
        /// <param name="segIndex"></param>
        /// <returns></returns>
        public static bool AddSnappedNode(HotPixel hotPix, SegmentString segStr, int segIndex)
        {
            ICoordinate p0 = segStr.GetCoordinate(segIndex);
            ICoordinate p1 = segStr.GetCoordinate(segIndex + 1);

            if (hotPix.Intersects(p0, p1))
            {
                segStr.AddIntersection(hotPix.Coordinate, segIndex);
                return true;
            }
            return false;
        }
 /// <summary>
 /// Performs a brute-force comparison of every segment in each <see cref="SegmentString" />.
 /// This has n^2 performance.
 /// </summary>
 /// <param name="e"></param>
 private void ComputeVertexSnaps(SegmentString e)
 {
     ICoordinate[] pts0 = e.Coordinates;
     for (int i = 0; i < pts0.Length - 1; i++)
     {
         HotPixel hotPixel    = new HotPixel(pts0[i], scaleFactor, li);
         bool     isNodeAdded = pointSnapper.Snap(hotPixel, e, i);
         // if a node is created for a vertex, that vertex must be noded too
         if (isNodeAdded)
         {
             e.AddIntersection(pts0[i], i);
         }
     }
 }
 /// <summary>
 /// Performs a brute-force comparison of every segment in each <see cref="SegmentString" />.
 /// This has n^2 performance.
 /// </summary>
 /// <param name="e"></param>
 private void ComputeVertexSnaps(SegmentString e)
 {
     ICoordinate[] pts0 = e.Coordinates;
     for(int i = 0; i < pts0.Length - 1; i++)
     {
         HotPixel hotPixel = new HotPixel(pts0[i], scaleFactor, li);
         bool isNodeAdded = pointSnapper.Snap(hotPixel, e, i);
         // if a node is created for a vertex, that vertex must be noded too
         if (isNodeAdded)
             e.AddIntersection(pts0[i], i);
     }
 }
Beispiel #6
0
 /// <summary>
 /// Performs a brute-force comparison of every segment in each <see cref="SegmentString" />.
 /// This has n^2 performance.
 /// </summary>
 /// <param name="e0"></param>
 /// <param name="e1"></param>
 private void ComputeVertexSnaps(SegmentString e0, SegmentString e1)
 {
     ICoordinate[] pts0 = e0.Coordinates;
     ICoordinate[] pts1 = e1.Coordinates;
     for (int i0 = 0; i0 < pts0.Length - 1; i0++)
     {
         HotPixel hotPixel = new HotPixel(pts0[i0], scaleFactor, li);
         for (int i1 = 0; i1 < pts1.Length - 1; i1++)
         {
             // don't snap a vertex to itself
             if (e0 == e1)
                 if (i0 == i1) 
                     continue;
             
             bool isNodeAdded = AddSnappedNode(hotPixel, e1, i1);
             // if a node is created for a vertex, that vertex must be noded too
             if (isNodeAdded)
                 e0.AddIntersection(pts0[i0], i0);                    
         }
     }
 }