Example #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);
                    }
                }
            }
        }
 /// <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)
 {
     Envelope pixelEnv = hotPixel.GetSafeEnvelope();
     HotPixelSnapAction hotPixelSnapAction = new HotPixelSnapAction(hotPixel, parentEdge, vertexIndex);
     _index.Query(pixelEnv, new QueryVisitor(pixelEnv, hotPixelSnapAction));
     return hotPixelSnapAction.IsNodeAdded;
 }
Example #3
0
 /// <summary>
 /// Computes nodes introduced as a result of
 /// snapping segments to vertices of other segments.
 /// </summary>
 /// <param name="edges"></param>
 public void ComputeVertexSnaps(IList edges)
 {
     foreach (object obj in edges)
     {
         SegmentString edge0 = (SegmentString)obj;
         ComputeVertexSnaps(edge0);
     }
 }
Example #4
0
 /// <summary>
 /// Computes nodes introduced as a result of snapping segments
 /// to snap points (hot pixels).
 /// </summary>
 /// <param name="li">
 /// </param>
 private void ComputeSnaps(IList segStrings, IList snapPts)
 {
     for (IEnumerator i0 = segStrings.GetEnumerator(); i0.MoveNext();)
     {
         SegmentString ss = (SegmentString)i0.Current;
         ComputeSnaps(ss, snapPts);
     }
 }
Example #5
0
 /// <summary>
 /// Computes nodes introduced as a result of snapping segments to snap points (hot pixels).
 /// </summary>
 /// <param name="segStrings"></param>
 /// <param name="snapPts"></param>
 private void ComputeSnaps(IList segStrings, IList snapPts)
 {
     foreach (object obj in segStrings)
     {
         SegmentString ss = (SegmentString)obj;
         ComputeSnaps(ss, snapPts);
     }
 }
 /// <summary>
 /// Computes nodes introduced as a result of snapping segments to
 /// vertices of other segments.
 /// </summary>
 /// <param name="segStrings">
 /// The list of segment strings to snap together.
 /// </param>
 public void ComputeVertexSnaps(IList edges)
 {
     for (IEnumerator i0 = edges.GetEnumerator(); i0.MoveNext();)
     {
         SegmentString edge0 = (SegmentString)i0.Current;
         ComputeVertexSnaps(edge0);
     }
 }
Example #7
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);
        }
Example #8
0
            public HotPixelSnapAction(MCIndexPointSnapper pointSnapper,
                                      HotPixel hotPixel, SegmentString parentEdge, int vertexIndex)
            {
                this.enclosingInstance = pointSnapper;

                this.hotPixel    = hotPixel;
                this.parentEdge  = parentEdge;
                this.vertexIndex = vertexIndex;
            }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputSegmentStrings"></param>
        private void CheckCorrectness(IList inputSegmentStrings)
        {
            IList           resultSegStrings = SegmentString.GetNodedSubstrings(inputSegmentStrings);
            NodingValidator nv = new NodingValidator(resultSegStrings);

            try
            {
                nv.CheckValid();
            }
            catch (Exception ex) { Trace.WriteLine(ex.ToString()); }
        }
Example #10
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);
         }
     }
 }
Example #11
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 <code>null</code>
        /// </param>
        /// <param name="vertexIndex">the index of the vertex, if applicable, or -1
        /// </param>
        /// <returns> <see langword="true"/> if a node was added for this pixel
        /// </returns>
        public bool Snap(HotPixel hotPixel, SegmentString parentEdge, int vertexIndex)
        {
            Envelope pixelEnv = hotPixel.SafeEnvelope;

            HotPixelSnapAction hotPixelSnapAction = new HotPixelSnapAction(
                this, hotPixel, parentEdge, vertexIndex);

            index.Query(pixelEnv, new PointSnapperItemVisitor(pixelEnv,
                                                              hotPixelSnapAction, this));

            return(hotPixelSnapAction.NodeAdded);
        }
        /// <summary>
        /// Creates a {SegmentString} for a coordinate list which is a raw offset curve,
        /// and adds it to the list of buffer curves.
        /// The SegmentString is tagged with a Label giving the topology of the curve.
        /// The curve may be oriented in either direction.
        /// If the curve is oriented CW, the locations will be:
        /// Left: Location.Exterior.
        /// Right: Location.Interior.
        /// </summary>
        private void AddCurve(ICoordinate[] coord, Locations leftLoc, Locations rightLoc)
        {
            // don't add null curves!
            if (coord.Length < 2)
            {
                return;
            }
            // add the edge for a coordinate list which is a raw offset curve
            var e = new SegmentString(coord, new Label(0, Locations.Boundary, leftLoc, rightLoc));

            curveList.Add(e);
        }
Example #13
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;
        }
Example #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);
        }
Example #15
0
 private void ComputeSnaps(SegmentString ss, IList snapPts)
 {
     for (IEnumerator it = snapPts.GetEnumerator(); it.MoveNext();)
     {
         Coordinate snapPt   = (Coordinate)it.Current;
         HotPixel   hotPixel = new HotPixel(snapPt, scaleFactor, li);
         for (int i = 0; i < ss.Count - 1; i++)
         {
             AddSnappedNode(hotPixel, ss, i);
         }
     }
 }
Example #16
0
 /// <summary>
 /// Computes nodes introduced as a result of
 /// snapping segments to vertices of other segments.
 /// </summary>
 /// <param name="edges"></param>
 public void ComputeVertexSnaps(IList edges)
 {
     foreach (object obj0 in edges)
     {
         SegmentString edge0 = (SegmentString)obj0;
         foreach (object obj1 in edges)
         {
             SegmentString edge1 = (SegmentString)obj1;
             ComputeVertexSnaps(edge0, edge1);
         }
     }
 }
        /// <summary>
        /// Creates a {SegmentString} for a coordinate list which is a raw offset curve,
        /// and adds it to the list of buffer curves.
        /// The SegmentString is tagged with a Label giving the topology of the curve.
        /// The curve may be oriented in either direction.
        /// If the curve is oriented CW, the locations will be:
        /// Left: Location.Exterior.
        /// Right: Location.Interior.
        /// </summary>
        private void AddCurve(IList <Coordinate> coord, LocationType leftLoc, LocationType rightLoc)
        {
            // don't add null curves!
            if (coord.Count < 2)
            {
                return;
            }
            // add the edge for a coordinate list which is a raw offset curve
            SegmentString e = new SegmentString(coord, new Label(0, LocationType.Boundary, leftLoc, rightLoc));

            _curveList.Add(e);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="ss"></param>
 /// <param name="snapPts"></param>
 private void ComputeSnaps(SegmentString ss, IList snapPts)
 {
     foreach (object objo in snapPts)
     {
         Coordinate snapPt   = (Coordinate)objo;
         HotPixel   hotPixel = new HotPixel(snapPt, _scaleFactor, _li);
         for (int i = 0; i < ss.Count - 1; i++)
         {
             AddSnappedNode(hotPixel, ss, i);
         }
     }
 }
        private void AddCurve(ICoordinateList coords, int leftLoc, int rightLoc)
        {
            // don't Add null curves!
            if (coords.Count < 2)
            {
                return;
            }

            // Add the edge for a coordinate list which is a raw offset curve
            SegmentString e = new SegmentString(coords,
                                                new Label(0, LocationType.Boundary, leftLoc, rightLoc));

            curveList.Add(e);
        }
 /// <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);
         }
     }
 }
Example #21
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="mc"></param>
            /// <param name="startIndex"></param>
            public override void Select(MonotoneChain mc, int startIndex)
            {
                SegmentString ss = (SegmentString)mc.Context;

                // don't snap a vertex to itself
                if (parentEdge != null)
                {
                    if (ss == parentEdge && startIndex == vertexIndex)
                    {
                        return;
                    }
                }
                isNodeAdded = SimpleSnapRounder.AddSnappedNode(hotPixel, ss, startIndex);
            }
        /// <summary>
        /// Creates a <see cref="SegmentString"/> for a coordinate list which is a raw offset curve,
        /// and adds it to the list of Buffer curves.
        /// The SegmentString is tagged with a Label giving the topology of the curve.
        /// The curve may be oriented in either direction.
        /// If the curve is oriented CW, the locations will be:
        /// <list type="bullet">
        /// <item>
        /// <description>
        /// Left: LocationType.Exterior
        /// </description>
        /// </item>
        /// <item>
        /// <description>
        /// Right: LocationType.Interior
        /// </description>
        /// </item>
        /// </list>
        /// </summary>
        private void AddCurve(Coordinate[] coord, int leftLoc, int rightLoc)
        {
            // don't Add null curves!
            if (coord.Length < 2)
            {
                return;
            }

            // Add the edge for a coordinate list which is a raw offset curve
            SegmentString e = new SegmentString(new CoordinateCollection(coord),
                                                new Label(0, LocationType.Boundary, leftLoc, rightLoc));

            curveList.Add(e);
        }
        private void CheckCorrectness(IList inputSegmentStrings)
        {
            IList resultSegStrings =
                SegmentString.GetNodedSubstrings(inputSegmentStrings);
            NodingValidator nv = new NodingValidator(resultSegStrings);

            try
            {
                nv.CheckValid();
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
Example #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bufferSegStrList"></param>
        /// <param name="precisionModel"></param>
        private void ComputeNodedEdges(IList bufferSegStrList, IPrecisionModel precisionModel)
        {
            INoder noder = GetNoder(precisionModel);

            noder.ComputeNodes(bufferSegStrList);
            IList nodedSegStrings = noder.GetNodedSubstrings();

            foreach (object obj in nodedSegStrings)
            {
                SegmentString segStr   = (SegmentString)obj;
                Label         oldLabel = (Label)segStr.Data;
                Edge          edge     = new Edge(segStr.Coordinates, new Label(oldLabel));
                InsertEdge(edge);
            }
        }
Example #25
0
		private void ComputeNodedEdges(IList bufferSegStrList, PrecisionModel precisionModel)
		{
            INoder noder = CreateNoder(precisionModel);
            noder.ComputeNodes(bufferSegStrList);

            IList nodedSegStrings = noder.NodedSubstrings;
	
            int nCount = nodedSegStrings.Count;
			for (int i = 0; i < nCount; i++)
			{
				SegmentString segStr = (SegmentString)nodedSegStrings[i];
                Label oldLabel       = (Label)segStr.Data;
                Edge edge = new Edge(segStr.Coordinates, new Label(oldLabel));

				InsertEdge(edge);
			}
		}
 /// <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)
 {
     _hotPixel = hotPixel;
     _parentEdge = parentEdge;
     _vertexIndex = vertexIndex;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="ss"></param>
 /// <param name="snapPts"></param>
 private void ComputeSnaps(SegmentString ss, IList snapPts)
 {
     foreach (object objo in snapPts)
     {
         Coordinate snapPt = (Coordinate)objo;
         HotPixel hotPixel = new HotPixel(snapPt, _scaleFactor, _li);
         for (int i = 0; i < ss.Count - 1; i++)
             AddSnappedNode(hotPixel, ss, i);
     }
 }
Example #28
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;
 }
Example #29
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)
 {
     _hotPixel    = hotPixel;
     _parentEdge  = parentEdge;
     _vertexIndex = vertexIndex;
 }
Example #30
0
 /// <summary>
 /// Returns a <see cref="IList"/> of fully noded <see cref="SegmentString"/>s.
 /// The <see cref="SegmentString"/>s have the same context as their parent.
 /// </summary>
 /// <returns></returns>
 public IList GetNodedSubstrings()
 {
     return(SegmentString.GetNodedSubstrings(nodedSegStrings));
 }
Example #31
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);
     }
 }
Example #32
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);                    
         }
     }
 }
 /// <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;
 }
 /// <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);
     }
 }