Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/LineHelper.cs
===================================================================
diff -u -r4897 -r4905
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/LineHelper.cs (.../LineHelper.cs) (revision 4897)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/LineHelper.cs (.../LineHelper.cs) (revision 4905)
@@ -174,4 +174,29 @@
return intersectPoint;
}
+
+ ///
+ /// Deletes the duplicated points.
+ ///
+ /// List of points
+ /// The tolerance.
+ public static void RemoveDuplicatedPoints(IList points, double tolerance)
+ {
+ // First build a list of indices of points that have to be removed (from end of list to start)
+ var indicesToDelete = new List();
+ for (int pointIndex = points.Count - 1; pointIndex > 0; pointIndex--)
+ {
+ int nextPointIndex = pointIndex - 1;
+ if (points[pointIndex].LocationEquals(points[pointIndex - 1], tolerance))
+ {
+ indicesToDelete.Add(nextPointIndex);
+ }
+ }
+
+ // Remove duplicated points beginning from the end
+ foreach (int index in indicesToDelete)
+ {
+ points.RemoveAt(index);
+ }
+ }
}
\ No newline at end of file