/// <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); } } } }
/// <summary> /// /// </summary> /// <param name="mc"></param> /// <param name="startIndex"></param> public override void Select(MonotoneChain mc, int startIndex) { var ss = (INodableSegmentString)mc.Context; /** * Check to avoid snapping a hotPixel vertex to the same vertex. * This method is called for segments which intersects the * hot pixel, * so need to check if either end of the segment is equal to the hot pixel * and if so, do not snap. * * Sep 22 2012 - MD - currently do need to snap to every vertex, * since otherwise the testCollapse1 test in SnapRoundingTest fails. */ if (_parentEdge != null) { if (ss == _parentEdge && (startIndex == _hotPixelVertexIndex) ) { return; } } _isNodeAdded = _hotPixel.AddSnappedNode(ss, startIndex); }
/// <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> /// 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); } }