Exemplo n.º 1
0
        /// <summary>
        /// Performs a brute-force comparison of every segment in each <see cref="ISegmentString" />.
        /// This has n^2 performance.
        /// </summary>
        /// <param name="e0"></param>
        /// <param name="e1"></param>
        private void ComputeVertexSnaps(INodableSegmentString e0, INodableSegmentString e1)
        {
            Coordinate[] pts0 = e0.Coordinates;
            Coordinate[] 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);
                                       hotPixel.AddSnappedNode(e1, i1);
                    // if a node is created for a vertex, that vertex must be noded too
                    if (isNodeAdded)
                    {
                        e0.AddIntersection(pts0[i0], i0);
                    }
                }
            }
        }
Exemplo n.º 2
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="hotPixelVertexIndex"></param>
        /// <returns><c>true</c> if a node was added for this pixel.</returns>
        public bool Snap(HotPixel hotPixel, ISegmentString parentEdge, int hotPixelVertexIndex)
        {
            var pixelEnv           = hotPixel.GetSafeEnvelope();
            var hotPixelSnapAction = new HotPixelSnapAction(hotPixel, parentEdge, hotPixelVertexIndex);

            _index.Query(pixelEnv, new QueryVisitor(pixelEnv, hotPixelSnapAction));
            return(hotPixelSnapAction.IsNodeAdded);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Snaps segments to nodes created by segment intersections.
 /// </summary>
 /// <param name="snapPts"></param>
 private void ComputeIntersectionSnaps(IEnumerable <Coordinate> snapPts)
 {
     foreach (var snapPt in snapPts)
     {
         var hotPixel = new HotPixel(snapPt, _scaleFactor, _li);
         _pointSnapper.Snap(hotPixel);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ss"></param>
 /// <param name="snapPts"></param>
 private void ComputeSnaps(INodableSegmentString ss, IEnumerable <Coordinate> snapPts)
 {
     foreach (Coordinate snapPt in snapPts)
     {
         HotPixel hotPixel = new HotPixel(snapPt, _scaleFactor, _li);
         for (int i = 0; i < ss.Count - 1; i++)
         {
             //AddSnappedNode(hotPixel, ss, i);
             hotPixel.AddSnappedNode(ss, i);
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Snaps segments to the vertices of a Segment String.
        /// </summary>
        /// <param name="e"></param>
        private void ComputeVertexSnaps(INodableSegmentString e)
        {
            var pts0 = e.Coordinates;

            for (var i = 0; i < pts0.Length; i++)
            {
                var hotPixel    = new HotPixel(pts0[i], _scaleFactor, _li);
                var 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);
                }
            }
        }
Exemplo n.º 6
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>
 /// <returns><c>true</c> if a node was added for this pixel.</returns>
 public bool Snap(HotPixel hotPixel)
 {
     return(Snap(hotPixel, null, -1));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HotPixelSnapAction"/> class.
 /// </summary>
 /// <param name="hotPixel"></param>
 /// <param name="parentEdge"></param>
 /// <param name="hotPixelVertexIndex"></param>
 public HotPixelSnapAction(HotPixel hotPixel, ISegmentString parentEdge, int hotPixelVertexIndex)
 {
     _hotPixel            = hotPixel;
     _parentEdge          = parentEdge;
     _hotPixelVertexIndex = hotPixelVertexIndex;
 }