Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/GeometryHelperTests.cs =================================================================== diff -u -r5621 -r5634 --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/GeometryHelperTests.cs (.../GeometryHelperTests.cs) (revision 5621) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/GeometryHelperTests.cs (.../GeometryHelperTests.cs) (revision 5634) @@ -148,7 +148,14 @@ } [Test] + [TestCase(-40, 3, 12, 12, 2)] + [TestCase(-30, 3, 12, 13, 1)] [TestCase(-20, 3, 12, 13, 1)] + [TestCase(-10, 2, 10, 10, 1)] + [TestCase(0, 2, 8, 8, 1)] + [TestCase(10, 2, 8, 9, 0)] + [TestCase(20, 2, 8, 9, 0)] + [TestCase(45, 1, 4, 4, 0)] public void GivenInnerLoopLayerGeometryWhenCuttingLeftThenLeftBoundaryIsChanged(double atX, int surfacesCount, int pointsCount, int curvesCount, int innerLoopsCount) { // Given @@ -179,14 +186,58 @@ { 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)); }); } + + [Test] + [TestCase(-45, 3, 10, 11, 2)] + [TestCase(-40, 3, 10, 12, 0)] + [TestCase(-30, 3, 10, 12, 0)] + [TestCase(-20, 3, 10, 12, 0)] + [TestCase(-10, 3, 10, 12, 0)] + [TestCase(0, 2, 8, 9, 0)] + [TestCase(10, 2, 8, 9, 0)] + [TestCase(20, 2, 8, 9, 0)] + [TestCase(40, 1, 5, 5, 0)] + [TestCase(45, 1, 4, 4, 0)] + public void GivenInnerLoopLayerGeometryWithConnectedLoopsWhenCuttingLeftThenLeftBoundaryIsChanged(double atX, int surfacesCount, int pointsCount, int curvesCount, int innerLoopsCount) + { + // Given + SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithThreeLayersOfWhichTwoAreConnectedInnerLoops(); + 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(10)); + // At first there are 12 curves + Assert.That(soilProfile2D.Geometry.Curves, Has.Count.EqualTo(11)); + // 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)); + Assert.That(soilProfile2D.Geometry.Surfaces, Has.Count.EqualTo(surfacesCount)); + Assert.That(soilProfile2D.Geometry.Points, Has.Count.EqualTo(pointsCount)); + Assert.That(soilProfile2D.Geometry.Curves, Has.Count.EqualTo(curvesCount)); + Assert.That(soilProfile2D.Geometry.InnerLoopsCount, Is.EqualTo(innerLoopsCount)); + }); + } } \ No newline at end of file