Example #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)
        {
            var pts0 = e0.Coordinates;
            var pts1 = e1.Coordinates;

            for (int i0 = 0; i0 < pts0.Length - 1; i0++)
            {
                var hotPixel = new HotPixel(pts0[i0], _scaleFactor);
                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);
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SegmentNode"/> class.
 /// </summary>
 /// <param name="segString"></param>
 /// <param name="coord"></param>
 /// <param name="segmentIndex"></param>
 /// <param name="segmentOctant"></param>
 public SegmentNode(INodableSegmentString segString, Coordinate coord, int segmentIndex, Octants segmentOctant)
 {
     Coord          = null;
     _segString     = segString;
     Coord          = new Coordinate(coord.X, coord.Y, coord.Z);
     SegmentIndex   = segmentIndex;
     _segmentOctant = segmentOctant;
     _isInterior    = !coord.Equals2D(segString.Coordinates[segmentIndex]);
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SegmentNode"/> class.
 /// </summary>
 /// <param name="segString"></param>
 /// <param name="coord"></param>
 /// <param name="segmentIndex"></param>
 /// <param name="segmentOctant"></param>
 public SegmentNode(INodableSegmentString segString, Coordinate coord, int segmentIndex, Octants segmentOctant) 
 {
     Coord = null;
     _segString = segString;
     Coord = new Coordinate(coord.X, coord.Y, coord.Z);
     SegmentIndex = segmentIndex;
     _segmentOctant = segmentOctant;
     _isInterior = !coord.Equals2D(segString.Coordinates[segmentIndex]);
 }
 /// <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);
         }
     }
 }
        /// <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);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Adds a new node (equal to the snap pt) to the specified segment
        /// if the segment passes through the hot pixel
        /// </summary>
        /// <param name="segStr"></param>
        /// <param name="segIndex"></param>
        /// <returns><c>true</c> if a node was added to the segment</returns>
        public bool AddSnappedNode(INodableSegmentString segStr, int segIndex)
        {
            var coords = segStr.Coordinates;
            var p0     = coords[segIndex];
            var p1     = coords[segIndex + 1];

            if (Intersects(p0, p1))
            {
                //System.out.println("snapped: " + snapPt);
                //System.out.println("POINT (" + snapPt.x + " " + snapPt.y + ")");
                segStr.AddIntersection(Coordinate, segIndex);

                return(true);
            }
            return(false);
        }
 /// <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);
     }
 }
        /// <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);
                }
            }
        }
 /// <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);
     }
 }
Example #10
0
        ///<summary>
        /// Adds a new node (equal to the snap pt) to the specified segment
        /// if the segment passes through the hot pixel
        ///</summary>
        /// <param name="segStr"></param>
        /// <param name="segIndex"></param>
        /// <returns><c>true</c> if a node was added to the segment</returns>
        public bool AddSnappedNode(INodableSegmentString segStr, int segIndex)
        {
            var coords = segStr.Coordinates;
            var p0 = coords[segIndex];
            var p1 = coords[segIndex + 1];

            if (Intersects(p0, p1))
            {
                //System.out.println("snapped: " + snapPt);
                //System.out.println("POINT (" + snapPt.x + " " + snapPt.y + ")");
                segStr.AddIntersection(Coordinate, segIndex);

                return true;
            }
            return false;
        }