/// <summary>
 /// Snaps (nodes) all interacting segments to this hot pixel.
 /// The hot pixel may represent a vertex of an edge,
 /// in which case this routine uses the optimization
 /// of not noding the vertex itself
 /// </summary>
 /// <param name="hotPixel">The hot pixel to snap to.</param>
 /// <param name="parentEdge">The edge containing the vertex, if applicable, or <c>null</c>.</param>
 /// <param name="vertexIndex"></param>
 /// <returns><c>true</c> if a node was added for this pixel.</returns>
 public bool Snap(HotPixel hotPixel, SegmentString parentEdge, int vertexIndex)
 {
     IEnvelope pixelEnv = hotPixel.GetSafeEnvelope();
     HotPixelSnapAction hotPixelSnapAction = new HotPixelSnapAction(hotPixel, parentEdge, vertexIndex);
     index.Query(pixelEnv, new QueryVisitor(pixelEnv, hotPixelSnapAction));
     return hotPixelSnapAction.IsNodeAdded;
 }
示例#2
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);
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Snaps (nodes) all interacting segments to this hot pixel.
        /// The hot pixel may represent a vertex of an edge,
        /// in which case this routine uses the optimization
        /// of not noding the vertex itself
        /// </summary>
        /// <param name="hotPixel">The hot pixel to snap to.</param>
        /// <param name="parentEdge">The edge containing the vertex, if applicable, or <c>null</c>.</param>
        /// <param name="vertexIndex"></param>
        /// <returns><c>true</c> if a node was added for this pixel.</returns>
        public bool Snap(HotPixel hotPixel, SegmentString parentEdge, int vertexIndex)
        {
            IEnvelope          pixelEnv           = hotPixel.GetSafeEnvelope();
            HotPixelSnapAction hotPixelSnapAction = new HotPixelSnapAction(hotPixel, parentEdge, vertexIndex);

            index.Query(pixelEnv, new QueryVisitor(pixelEnv, hotPixelSnapAction));
            return(hotPixelSnapAction.IsNodeAdded);
        }
示例#4
0
 /// <summary>
 /// Computes nodes introduced as a result of snapping segments to snap points (hot pixels).
 /// </summary>
 /// <param name="snapPts"></param>
 private void ComputeIntersectionSnaps(IList snapPts)
 {
     foreach (ICoordinate snapPt in snapPts)
     {
         HotPixel hotPixel = new HotPixel(snapPt, scaleFactor, li);
         pointSnapper.Snap(hotPixel);
     }
 }
示例#5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ss"></param>
 /// <param name="snapPts"></param>
 private void ComputeSnaps(SegmentString ss, IList snapPts)
 {
     foreach (ICoordinate snapPt in snapPts)
     {
         HotPixel hotPixel = new HotPixel(snapPt, scaleFactor, li);
         for (int i = 0; i < ss.Count - 1; i++)
         {
             AddSnappedNode(hotPixel, ss, i);
         }
     }
 }
示例#6
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);
        }
示例#7
0
 /// <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);
         }
     }
 }
示例#8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="hotPixel"></param>
 /// <returns></returns>
 public bool Snap(HotPixel hotPixel)
 {
     return(Snap(hotPixel, null, -1));
 }
示例#9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HotPixelSnapAction"/> class.
 /// </summary>
 /// <param name="hotPixel"></param>
 /// <param name="parentEdge"></param>
 /// <param name="vertexIndex"></param>
 public HotPixelSnapAction(HotPixel hotPixel, SegmentString parentEdge, int vertexIndex)
 {
     this.hotPixel    = hotPixel;
     this.parentEdge  = parentEdge;
     this.vertexIndex = vertexIndex;
 }
示例#10
0
 /// <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);
     }
 }
示例#11
0
 /// <summary>
 /// Computes nodes introduced as a result of snapping segments to snap points (hot pixels).
 /// </summary>
 /// <param name="snapPts"></param>
 private void ComputeIntersectionSnaps(IList snapPts)
 {
     foreach (ICoordinate snapPt in snapPts)
     {
         HotPixel hotPixel = new HotPixel(snapPt, scaleFactor, li);
         pointSnapper.Snap(hotPixel);
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="hotPixel"></param>
 /// <returns></returns>
 public bool Snap(HotPixel hotPixel)
 {
     return Snap(hotPixel, null, -1);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HotPixelSnapAction"/> class.
 /// </summary>
 /// <param name="hotPixel"></param>
 /// <param name="parentEdge"></param>
 /// <param name="vertexIndex"></param>
 public HotPixelSnapAction(HotPixel hotPixel, SegmentString parentEdge, int vertexIndex)
 {
     this.hotPixel = hotPixel;
     this.parentEdge = parentEdge;
     this.vertexIndex = vertexIndex;
 }
示例#14
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;
        }
示例#15
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);                    
         }
     }
 }
示例#16
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="ss"></param>
 /// <param name="snapPts"></param>
 private void ComputeSnaps(SegmentString ss, IList snapPts)
 {
     foreach (ICoordinate snapPt in snapPts)
     {
         HotPixel hotPixel = new HotPixel(snapPt, scaleFactor, li);
         for (int i = 0; i < ss.Count - 1; i++)
             AddSnappedNode(hotPixel, ss, i);
     }
 }