Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/GeometryHelperTests.cs =================================================================== diff -u -r5386 -r5619 --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/GeometryHelperTests.cs (.../GeometryHelperTests.cs) (revision 5386) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/GeometryHelperTests.cs (.../GeometryHelperTests.cs) (revision 5619) @@ -21,6 +21,7 @@ using System; using Deltares.DamEngine.Data.Geometry; +using Deltares.DamEngine.Data.GeometryExport; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.TestHelpers.Factories; using NUnit.Framework; @@ -145,4 +146,47 @@ Assert.That(soilProfile2D.Geometry.Curves, Has.Count.EqualTo(14)); }); } + + [Test] + [TestCase(-20, 3, 12, 13, 1)] + public void GivenInnerLoopLayerGeometryWhenCuttingLeftThenLeftBoundaryIsChanged(double atX, int surfacesCount, int pointsCount, int curvesCount, int innerLoopsCount) + { + // Given + SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithThreeLayersOfWhichTwoAreInnerLoops(); + GeometryBounds originalGeometryBounds = soilProfile2D.Geometry.GetGeometryBounds(); + Assert.Multiple(() => + { + Assert.That(originalGeometryBounds.Left, Is.EqualTo(-50).Within(cTolerance)); + Assert.That(soilProfile2D.Geometry.Left, Is.EqualTo(-50).Within(cTolerance)); + // At first there are 3 surfaces + Assert.That(soilProfile2D.Geometry.Surfaces, Has.Count.EqualTo(3)); + // At first there are 12 points + Assert.That(soilProfile2D.Geometry.Points, Has.Count.EqualTo(12)); + // At first there are 12 curves + Assert.That(soilProfile2D.Geometry.Curves, Has.Count.EqualTo(12)); + // At first there are 2 inner loops + Assert.That(soilProfile2D.Geometry.InnerLoopsCount, Is.EqualTo(2)); + }); + GeometryExporter.ExportToFile(soilProfile2D.Geometry, GeometryExporter.VisualizationFolder + "GeometryBefore.txt"); + // When + GeometryHelper.CutGeometryLeft(soilProfile2D.Geometry, atX); + GeometryExporter.ExportToFile(soilProfile2D.Geometry, GeometryExporter.VisualizationFolder + "GeometryAfter.txt"); + GeometryExporter.ExportWithSurfaceLineToJsonFile(GeometryExporter.VisualizationFolder + + GeometryExporter.ExportJasonFile, soilProfile2D.Geometry, null); + // Then + GeometryBounds geometryBounds = soilProfile2D.Geometry.GetGeometryBounds(); + Assert.Multiple(() => + { + Assert.That(geometryBounds.Left, Is.EqualTo(atX).Within(cTolerance)); + Assert.That(soilProfile2D.Geometry.Left, Is.EqualTo(atX).Within(cTolerance)); + // At first there are 3 surfaces, after cutting the boundary, there still must be 3 surfaces + Assert.That(soilProfile2D.Geometry.Surfaces, Has.Count.EqualTo(surfacesCount)); + // At first there are 12 points, after cutting the boundary, there still must be 12 points + Assert.That(soilProfile2D.Geometry.Points, Has.Count.EqualTo(pointsCount)); + // At first there are 14 curves, after cutting the boundary, there must be 13 curves + Assert.That(soilProfile2D.Geometry.Curves, Has.Count.EqualTo(curvesCount)); + // At first there are 2 inner loops, after cutting the boundary, there must be 1 inner loop + Assert.That(soilProfile2D.Geometry.InnerLoopsCount, Is.EqualTo(innerLoopsCount)); + }); + } } \ No newline at end of file