Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs
===================================================================
diff -u -r5036 -r5057
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs (.../GeometryData.cs) (revision 5036)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs (.../GeometryData.cs) (revision 5057)
@@ -136,6 +136,18 @@
}
///
+ /// Deletes all the loose points.
+ ///
+ public void DeleteLoosePoints()
+ {
+ foreach (Point2D geometryPoint in Points.ToArray())
+ {
+ if (this.GetDependentCurveCount(geometryPoint) == 0)
+ this.Remove((IGeometryObject) geometryPoint, true);
+ }
+ }
+
+ ///
/// Deletes all the loose curves.
/// Returns true when the loose curve is inside publisherEventArgs surface.
/// Calls Regeneration if the funtion returns true.
@@ -1246,23 +1258,15 @@
public bool DeletePoint(Point2D aPoint)
{
- int num = 0;
+
bool flag = false;
List source = new List();
if (Curves.Count > 0)
{
source.AddRange(Curves.Where((Func) (c => c.HeadPoint == aPoint || c.EndPoint == aPoint)));
- if (num + source.Count == 2)
+ if (source.Count == 2)
{
- Point2D line1Point1 = new Point2D();
- Point2D line2Point1 = new Point2D();
- line1Point1.Init(source[0].HeadPoint != aPoint ? source[0].HeadPoint : source[0].EndPoint);
- line2Point1.Init(source[1].HeadPoint != aPoint ? source[1].HeadPoint : source[1].EndPoint);
- double angle = Routines2D.FindAngle(line1Point1, aPoint, line2Point1, aPoint);
- if (angle.IsGreaterThanOrEqualTo(179.0) && angle.IsLessThanOrEqualTo(181.0))
- {
- FixCurvesWherePointIsOnBothConnectedCurvesInLineWithEachOther(aPoint, source);
- }
+ CheckForCurvesWherePointIsOnBothConnectedCurvesInLineWithEachOther(aPoint, source);
}
Remove(aPoint, false);
if (source.Exists((curve => curve.SurfaceAtLeft != null || curve.SurfaceAtRight != null)))
@@ -1275,6 +1279,19 @@
return false;
}
+ private void CheckForCurvesWherePointIsOnBothConnectedCurvesInLineWithEachOther(Point2D aPoint, List source)
+ {
+ Point2D line1Point1 = new Point2D();
+ Point2D line2Point1 = new Point2D();
+ line1Point1.Init(source[0].HeadPoint != aPoint ? source[0].HeadPoint : source[0].EndPoint);
+ line2Point1.Init(source[1].HeadPoint != aPoint ? source[1].HeadPoint : source[1].EndPoint);
+ double angle = Routines2D.FindAngle(line1Point1, aPoint, line2Point1, aPoint);
+ if (angle.IsGreaterThanOrEqualTo(179.0) && angle.IsLessThanOrEqualTo(181.0))
+ {
+ FixCurvesWherePointIsOnBothConnectedCurvesInLineWithEachOther(aPoint, source);
+ }
+ }
+
private void FixCurvesWherePointIsOnBothConnectedCurvesInLineWithEachOther(Point2D aPoint, List source)
{
for (int index = 0; index < Curves.Count - 1; ++index)
@@ -1346,32 +1363,10 @@
}
else
{
- for (int index = 0; index < points.Count - 1; ++index)
- {
- Point2D geometryPoint2 = index != 0 ? geometryPoint1 : CreatePoint(points[index], true);
- geometryPoint1 = CreatePoint(points[index + 1], true);
- bool flag = false;
- foreach (GeometryCurve curve in Curves)
- {
- if (curve.HeadPoint == geometryPoint2 && curve.EndPoint == geometryPoint1 ||
- curve.HeadPoint == geometryPoint1 && curve.EndPoint == geometryPoint2)
- {
- flag = true;
- }
- }
- if (!flag)
- {
- GeometryCurve geometryCurve = new GeometryCurve();
- geometryGenerator.SetIsUsed(geometryCurve, CurveDirection.Forward, false);
- geometryGenerator.SetIsUsed(geometryCurve, CurveDirection.Reverse, false);
- geometryCurve.HeadPoint = geometryPoint2;
- geometryCurve.EndPoint = geometryPoint1;
- Create((IGeometryObject) geometryCurve);
- NewlyEffectedCurves.Add(geometryCurve);
- }
- }
+ HandleEmptyPointsGeometryCurveNewWithMoreThanOnePointMethod(points, geometryPoint1);
}
// #Bka: this is a direct call instead of a delayed invoke. Can lead to problems (endless spinning)
+ // Possibly check the isgeneratinggeometry flag
RegenerateGeometry();
geometryCurve1 = Curves.Count > 0 ? Curves[0] : (GeometryCurve) null;
return true;
@@ -1380,8 +1375,41 @@
return false;
}
- private void GetCurvesCoincidingInputPoint(Point2D aPoint, ref List aCurveList)
+ private void HandleEmptyPointsGeometryCurveNewWithMoreThanOnePointMethod(List points, Point2D geometryPoint1)
{
+ for (int index = 0; index < points.Count - 1; ++index)
+ {
+ Point2D geometryPoint2 = index != 0 ? geometryPoint1 : CreatePoint(points[index], true);
+ geometryPoint1 = CreatePoint(points[index + 1], true);
+ bool flag = false;
+ foreach (GeometryCurve curve in Curves)
+ {
+ if (curve.HeadPoint == geometryPoint2 && curve.EndPoint == geometryPoint1 ||
+ curve.HeadPoint == geometryPoint1 && curve.EndPoint == geometryPoint2)
+ {
+ flag = true;
+ }
+ }
+ if (!flag)
+ {
+ GeometryCurve geometryCurve = new GeometryCurve();
+ geometryGenerator.SetIsUsed(geometryCurve, CurveDirection.Forward, false);
+ geometryGenerator.SetIsUsed(geometryCurve, CurveDirection.Reverse, false);
+ geometryCurve.HeadPoint = geometryPoint2;
+ geometryCurve.EndPoint = geometryPoint1;
+ Create((IGeometryObject) geometryCurve);
+ NewlyEffectedCurves.Add(geometryCurve);
+ }
+ }
+ }
+
+ ///
+ /// Returns a list of curves that contain the input point.
+ ///
+ ///
+ ///
+ public void GetCurvesCoincidingInputPoint(Point2D aPoint, ref List aCurveList)
+ {
aCurveList.Clear();
int count = Curves.Count;
for (int index = 0; index < count; ++index)