Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometrySurface.cs
===================================================================
diff -u -r7045 -r7077
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometrySurface.cs (.../GeometrySurface.cs) (revision 7045)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometrySurface.cs (.../GeometrySurface.cs) (revision 7077)
@@ -1,4 +1,4 @@
-// Copyright (C) Stichting Deltares 2025. All rights reserved.
+// Copyright (C) Stichting Deltares 2026. All rights reserved.
//
// This file is part of the Dam Engine.
//
@@ -159,15 +159,6 @@
}
///
- /// Gets the geometry bounds.
- ///
- ///
- public override GeometryBounds GetGeometryBounds()
- {
- return OuterLoop.GetGeometryBounds();
- }
-
- ///
/// Determines a point within the outer loop of the new surface and that is not in an inner loop of that surface
/// so it can be used to determine the old surface.
///
@@ -186,19 +177,29 @@
point = FindValidTestPoint(geometryPointString, offset);
offset /= 2.0;
}
-
+
// if no valid point is found (this can happen in case of very thin layer), try using the centroid of the outer loop
if (point == null && InnerLoops.Count == 0)
{
point = Routines2D.ComputeCentroid(geometryPointString.Points);
}
+
return point;
}
+ ///
+ /// Gets the geometry bounds.
+ ///
+ ///
+ public override GeometryBounds GetGeometryBounds()
+ {
+ return OuterLoop.GetGeometryBounds();
+ }
+
private Point2D FindValidTestPoint(GeometryPointString geometryPointString, double offset)
{
var point = new Point2D();
- for (int i = 0; i < geometryPointString.Count - 1; i++)
+ for (var i = 0; i < geometryPointString.Count - 1; i++)
{
// look if point just below the top line is in the outer loop and if so, is not in a inner loop
// If both are true, then a valid test point is found, else keep looking
@@ -214,18 +215,21 @@
isInInnerLoop = true;
}
}
+
if (!isInInnerLoop)
{
break;
}
}
+
if (i == geometryPointString.Count - 2)
{
// if no valid point is yet found, then the shape is very awkward or the surface is terribly small.
// In that case, return null so the routine can try again with a smaller offset.
point = null;
}
}
+
return point;
}