Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geometry/GeometryLoopTests.cs =================================================================== diff -u -r5158 -r5619 --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geometry/GeometryLoopTests.cs (.../GeometryLoopTests.cs) (revision 5158) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geometry/GeometryLoopTests.cs (.../GeometryLoopTests.cs) (revision 5619) @@ -408,11 +408,7 @@ public void IsPointInLoop_PointIsOutsideLoop_ReturnFalse(double x, double z) { // setup - var loop = new GeometryLoop(); - loop.CurveList.Add(new GeometryCurve(new Point2D(0.0, 0.0), new Point2D(10.0, 0.0))); - loop.CurveList.Add(new GeometryCurve(loop.CurveList[0].EndPoint, new Point2D(10.0, 10.0))); - loop.CurveList.Add(new GeometryCurve(loop.CurveList[1].EndPoint, new Point2D(0.0, 10.0))); - loop.CurveList.Add(new GeometryCurve(loop.CurveList[2].EndPoint, loop.CurveList[0].HeadPoint)); + GeometryLoop loop = GenerateSquareGeometryLoop(); var point = new Point2D(x, z); @@ -707,4 +703,40 @@ Assert.That(loop.IsContinuous(), Is.True); } + + [Test] + public void TestHasSameCurvesByReference() + { + // setup + GeometryLoop loop1 = GenerateSquareGeometryLoop(); + // create identical loop but with also new (and thus different) curves + GeometryLoop loop2 = GenerateSquareGeometryLoop(); + + // call + bool isEqual = loop1.HasSameCurvesByReference(loop2); + + // assert that result is False as it should be + Assert.That(isEqual, Is.False); + + // setup for next test, now with same curves + GeometryLoop loop3 = new GeometryLoop(); + loop3.CurveList.AddRange(loop1.CurveList); + + // call + isEqual = loop1.HasSameCurvesByReference(loop3); + + // assert that result is now True + Assert.That(isEqual, Is.True); + + } + + private static GeometryLoop GenerateSquareGeometryLoop() + { + var loop = new GeometryLoop(); + loop.CurveList.Add(new GeometryCurve(new Point2D(0.0, 0.0), new Point2D(10.0, 0.0))); + loop.CurveList.Add(new GeometryCurve(loop.CurveList[0].EndPoint, new Point2D(10.0, 10.0))); + loop.CurveList.Add(new GeometryCurve(loop.CurveList[1].EndPoint, new Point2D(0.0, 10.0))); + loop.CurveList.Add(new GeometryCurve(loop.CurveList[2].EndPoint, loop.CurveList[0].HeadPoint)); + return loop; + } } \ No newline at end of file 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