Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometrySurface.cs =================================================================== diff -u -r6559 -r6560 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometrySurface.cs (.../GeometrySurface.cs) (revision 6559) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometrySurface.cs (.../GeometrySurface.cs) (revision 6560) @@ -175,11 +175,13 @@ /// The point or null when no valid point is found. public Point2D DetermineValidTestPointBasedOnNewSurface() { - double offset = 0.002; + const double initialOffset = 0.002; + const double stopCriteriumOffset = 1e-8; + double offset = initialOffset; Point2D point = null; var geometryPointString = DetermineTopGeometrySurface(); geometryPointString.SortPointsByXAscending(); - while (point == null && offset > 1e-8) + while (point == null && offset > stopCriteriumOffset) { // Just keep looking by halving the offset until found. point = FindValidTestPoint(geometryPointString, offset); @@ -214,8 +216,8 @@ } if (i == geometryPointString.Count - 2) { - // if no valid point is found, then the shape is very awkward or the surface is terribly small. - // In that case, return null. + // 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; } } Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geometry/GeometrySurfaceTests.cs =================================================================== diff -u -r6559 -r6560 --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geometry/GeometrySurfaceTests.cs (.../GeometrySurfaceTests.cs) (revision 6559) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geometry/GeometrySurfaceTests.cs (.../GeometrySurfaceTests.cs) (revision 6560) @@ -47,13 +47,13 @@ } [Test] - public void TestDetermineValidTestPointBasedOnNewSurfaceWithPointedGeomertyForCenterPoint() + public void TestDetermineValidTestPointBasedOnNewSurfaceWithPointedGeometryToTestOffsetReduction() { GeometryData geometry = CreatePointedGeometry(); Point2D testPoint = geometry.Surfaces[0].DetermineValidTestPointBasedOnNewSurface(); Assert.Multiple(() => { - Assert.That(testPoint.X, Is.EqualTo(5.500000).Within(cTolerance)); + Assert.That(testPoint.X, Is.EqualTo(5.000000).Within(cTolerance)); Assert.That(testPoint.Z, Is.EqualTo(9.999500).Within(cTolerance)); }); } @@ -132,15 +132,15 @@ Right = 20 }; - /* The following model looks as follows + /* The following model looks as follows and forces offset reduction * * |----------------------------------------------------------------------------------------------------------| - * -----------------------------| + * ----------------------------| */ - var point1 = new Point2D(-8, 10); - var point2 = new Point2D(19, 10); - var point3 = new Point2D(18, 9.999); + var point1 = new Point2D(-10, 10); + var point2 = new Point2D(20, 10); + var point3 = new Point2D(19.8, 9.999); var curve1 = new GeometryCurve(point1, point2); var curve2 = new GeometryCurve(point2, point3);