Index: src/Common/NetTopologySuite/Noding/Snapround/MCIndexSnapRounder.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/Common/NetTopologySuite/Noding/Snapround/MCIndexSnapRounder.cs (.../MCIndexSnapRounder.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/Common/NetTopologySuite/Noding/Snapround/MCIndexSnapRounder.cs (.../MCIndexSnapRounder.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -7,7 +7,6 @@ namespace GisSharpBlog.NetTopologySuite.Noding.Snapround { - /// /// Uses Snap Rounding to compute a rounded, /// fully noded arrangement from a set of {@link SegmentString}s. @@ -24,9 +23,9 @@ /// /// public class MCIndexSnapRounder : INoder - { - private LineIntersector li = null; + { private readonly double scaleFactor; + private readonly LineIntersector li = null; private MCIndexNoder noder = null; private MCIndexPointSnapper pointSnapper = null; private IList nodedSegStrings = null; @@ -35,14 +34,27 @@ /// Initializes a new instance of the class. /// /// The to use. - public MCIndexSnapRounder(PrecisionModel pm) + public MCIndexSnapRounder(PrecisionModel pm) { li = new RobustLineIntersector(); li.PrecisionModel = pm; scaleFactor = pm.Scale; } /// + /// Computes nodes introduced as a result of + /// snapping segments to vertices of other segments. + /// + /// + public void ComputeVertexSnaps(IList edges) + { + foreach (SegmentString edge in edges) + { + ComputeVertexSnaps(edge); + } + } + + /// /// Returns a of fully noded s. /// The s have the same context as their parent. /// @@ -60,10 +72,10 @@ /// public void ComputeNodes(IList inputSegmentStrings) { - this.nodedSegStrings = inputSegmentStrings; + nodedSegStrings = inputSegmentStrings; noder = new MCIndexNoder(); pointSnapper = new MCIndexPointSnapper(noder.MonotoneChains, noder.Index); - SnapRound(inputSegmentStrings, li); + SnapRound(inputSegmentStrings, li); } /// @@ -78,7 +90,10 @@ { nv.CheckValid(); } - catch (Exception ex) { Trace.WriteLine(ex.ToString()); } + catch (Exception ex) + { + Trace.WriteLine(ex.ToString()); + } } /// @@ -90,7 +105,7 @@ { IList intersections = FindInteriorIntersections(segStrings, li); ComputeIntersectionSnaps(intersections); - ComputeVertexSnaps(segStrings); + ComputeVertexSnaps(segStrings); } /// @@ -124,32 +139,23 @@ } /// - /// Computes nodes introduced as a result of - /// snapping segments to vertices of other segments. - /// - /// - public void ComputeVertexSnaps(IList edges) - { - foreach (SegmentString edge in edges) - ComputeVertexSnaps(edge); - } - - /// /// Performs a brute-force comparison of every segment in each . /// This has n^2 performance. /// /// private void ComputeVertexSnaps(SegmentString e) { ICoordinate[] pts0 = e.Coordinates; - for(int i = 0; i < pts0.Length - 1; i++) + 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); + } } } } -} +} \ No newline at end of file