Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs =================================================================== diff -u -r5662 -r5760 --- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs (.../FactoryForSoilProfiles.cs) (revision 5662) +++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs (.../FactoryForSoilProfiles.cs) (revision 5760) @@ -1173,29 +1173,29 @@ /// | | | 6 | /// |------------------------|----------------------|--------------| Level -15 m /// - public static SoilProfile2D CreateSoilProfile2DWithSixSurfacesFormingTwoLayers() + public static SoilProfile2D CreateSoilProfile2DWithSixSurfacesFormingTwoLayers(double xLeft = -50) { var soilProfile2D = new SoilProfile2D { Geometry = new GeometryData { - Left = -50, - Right = 60, + Left = xLeft, + Right = xLeft + 110, Bottom = -15 } }; var soil1 = new Soil("Soil1"); - SoilLayer2D soilLayer1 = CreateRectangularSoilLayer2D(10, 0, -50, -20, soil1, soilProfile2D); + SoilLayer2D soilLayer1 = CreateRectangularSoilLayer2D(10, 0, xLeft, xLeft + 30, soil1, soilProfile2D); var soil2 = new Soil("Soil2"); - SoilLayer2D soilLayer2 = CreatePentagonSoilLayer2D(new Point2D(-20, 10), new Point2D(0, 10), new Point2D(0, 0), new Point2D(-10, 0), new Point2D(-20, 0), soil2, soilProfile2D); + SoilLayer2D soilLayer2 = CreatePentagonSoilLayer2D(new Point2D(xLeft + 30, 10), new Point2D(xLeft + 50, 10), new Point2D(xLeft + 50, 0), new Point2D(xLeft + 40, 0), new Point2D(xLeft + 30, 0), soil2, soilProfile2D); var soil3 = new Soil("Soil3"); - SoilLayer2D soilLayer3 = CreatePentagonSoilLayer2D(new Point2D(0, 10), new Point2D(60, 10), new Point2D(60, 0), new Point2D(35, 0), new Point2D(0, 0), soil3, soilProfile2D); + SoilLayer2D soilLayer3 = CreatePentagonSoilLayer2D(new Point2D(xLeft + 50, 10), new Point2D(xLeft + 110, 10), new Point2D(xLeft + 110, 0), new Point2D(xLeft + 85, 0), new Point2D(xLeft + 50, 0), soil3, soilProfile2D); var soil4 = new Soil("Soil4"); - SoilLayer2D soilLayer4 = CreatePentagonSoilLayer2D(new Point2D(-50, 0), new Point2D(-20, 0), new Point2D(-10, 0), new Point2D(-10, -15), new Point2D(-50, -15), soil4, soilProfile2D); + SoilLayer2D soilLayer4 = CreatePentagonSoilLayer2D(new Point2D(xLeft, 0), new Point2D(xLeft + 30, 0), new Point2D(xLeft + 40, 0), new Point2D(xLeft + 40, -15), new Point2D(xLeft, -15), soil4, soilProfile2D); var soil5 = new Soil("Soil5"); - SoilLayer2D soilLayer5 = CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(0, 0), new Point2D(35, 0), new Point2D(35, -15), new Point2D(-10, -15), soil5, soilProfile2D); + SoilLayer2D soilLayer5 = CreatePentagonSoilLayer2D(new Point2D(xLeft + 40, 0), new Point2D(xLeft + 50, 0), new Point2D(xLeft + 85, 0), new Point2D(xLeft + 85, -15), new Point2D(xLeft + 40, -15), soil5, soilProfile2D); var soil6 = new Soil("Soil6"); - SoilLayer2D soilLayer6 = CreateRectangularSoilLayer2D(0, -15, 35, 60, soil6, soilProfile2D, true); + SoilLayer2D soilLayer6 = CreateRectangularSoilLayer2D(0, -15, xLeft + 85, xLeft + 110, soil6, soilProfile2D, true); soilProfile2D.Surfaces.Add(soilLayer1); soilProfile2D.Surfaces.Add(soilLayer2); Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfile2D.cs =================================================================== diff -u -r5755 -r5760 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfile2D.cs (.../SoilProfile2D.cs) (revision 5755) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfile2D.cs (.../SoilProfile2D.cs) (revision 5760) @@ -322,18 +322,17 @@ private static bool IsPointWithinOldSurfaces(Point2D point, IEnumerable oldSurfaces, double shift, double verticalShift) { - point.X -= shift; - point.Z += verticalShift; + var shiftedPoint = new Point2D(point.X - shift, point.Z + verticalShift); foreach (SoilLayer2D oldSurface in oldSurfaces) { GeometryLoop outerLoop = oldSurface.GeometrySurface.OuterLoop; List innerLoops = oldSurface.GeometrySurface.InnerLoops; - var isPointInSurface = IsPointInGivenOuterLoopOfOldSurface(point, outerLoop, innerLoops); + var isPointInSurface = IsPointInGivenOuterLoopOfOldSurface(shiftedPoint, outerLoop, innerLoops); if (!isPointInSurface) { GeometryLoop previousOuterLoop = oldSurface.GeometrySurface.PreviousOuterLoop; List previousInnerLoops = oldSurface.GeometrySurface.PreviousInnerLoops; - isPointInSurface = IsPointInGivenOuterLoopOfOldSurface(point, previousOuterLoop, previousInnerLoops); + isPointInSurface = IsPointInGivenOuterLoopOfOldSurface(shiftedPoint, previousOuterLoop, previousInnerLoops); } if (isPointInSurface) return true; Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs =================================================================== diff -u -r5755 -r5760 --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 5755) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 5760) @@ -103,7 +103,8 @@ { TestNumber = 1, GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, 10), - GivenShift = 0, + GivenXStartOfSoilProfile = -60, + GivenShift = 10, ExpectedSurfaceCount = 10, // 4 extra surfaces created : 2 below the highest corners of the "zigzag" surface line + 2 on the left side (between Z=60 and 70) ExpectedFilling1 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(-50, 10), new Point2D(-30, 12), new Point2D(-10, 10), new Point2D(-20, 10), soilFilling), @@ -119,14 +120,16 @@ ExpectedSurface5 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(0, 0), new Point2D(35, 0), new Point2D(35, -15), new Point2D(-10, -15), soil5), ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 60, soil6) - }).SetName("Test 1: Surface line intersects the original surface line of soil profile (and shift = 0)"); + }).SetName("Test 1: Surface line intersects the surface line of the shifted soil profile and starts at the " + + "same point (X=-50)"); yield return new TestCaseData( new TestCaseZigZagSurfaceLine() { TestNumber = 2, GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, 13), - GivenShift = 0, + GivenXStartOfSoilProfile = -60, + GivenShift = 10, ExpectedSurfaceCount = 9, // 3 extra surfaces created: 1 below the "zigzag" surface line + 2 on the left side (between Z=60 and 70) ExpectedFilling1 = FactoryForSoilProfiles.CreatePolygoneSoilLayer2D([ @@ -155,14 +158,16 @@ ExpectedSurface4 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-50, 0), new Point2D(-20, 0), new Point2D(-10, 0), new Point2D(-10, -15), new Point2D(-50, -15), soil4), ExpectedSurface5 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(0, 0), new Point2D(35, 0), new Point2D(35, -15), new Point2D(-10, -15), soil5), ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 60, soil6) - }).SetName("Test 2: Surface line is completely above original surface line of soil profile (and shift = 0)"); + }).SetName("Test 2: Surface line is completely above the surface line of shifted soil profile (shift = 10) " + + "and starts at the same point (X=-50)"); yield return new TestCaseData( new TestCaseZigZagSurfaceLine { TestNumber = 3, GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, 5), - GivenShift = 0, + GivenXStartOfSoilProfile = -60, + GivenShift = 10, ExpectedSurfaceCount = 8, // 2 extra surfaces created on the left side (between Z=60 and 70) ExpectedFilling1 = null, @@ -177,14 +182,16 @@ ExpectedSurface4 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-50, 0), new Point2D(-20, 0), new Point2D(-10, 0), new Point2D(-10, -15), new Point2D(-50, -15), soil4), ExpectedSurface5 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(0, 0), new Point2D(35, 0), new Point2D(35, -15), new Point2D(-10, -15), soil5), ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 60, soil6) - }).SetName("Test 3: Surface line is completely in the top layer of the soil profile (and shift = 0)"); + }).SetName("Test 3: Surface line is completely in the top layer of the shifted soil profile (shift = 10) and " + + "starts at the same point (X=-50)"); yield return new TestCaseData( new TestCaseZigZagSurfaceLine { TestNumber = 4, GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, 0), - GivenShift = 0, + GivenXStartOfSoilProfile = -60, + GivenShift = 10, ExpectedSurfaceCount = 8, // 2 extra surfaces created on the left side (between Z=60 and 70) ExpectedFilling1 = null, @@ -199,14 +206,16 @@ ExpectedSurface4 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-50, 0), new Point2D(-20, 0), new Point2D(-10, 0), new Point2D(-10, -15), new Point2D(-50, -15), soil4), ExpectedSurface5 = FactoryForSoilProfiles.CreateHexagonSoilLayer2D(new Point2D(-10, 0), new Point2D(10, -2), new Point2D(30, 0), new Point2D(35, 0), new Point2D(35, -15), new Point2D(-10, -15), soil5), ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 60, soil6) - }).SetName("Test 4: Surface line intersects the original layer separation of soil profile (and shift = 0)"); + }).SetName("Test 4: Surface line intersects the layer separation of shifted soil profile (shift = 10) " + + "and starts at the same point (X=-50)"); yield return new TestCaseData( new TestCaseZigZagSurfaceLine { TestNumber = 5, GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-40, 10), - GivenShift = 0, + GivenXStartOfSoilProfile = -65, + GivenShift = 15, ExpectedSurfaceCount = 10, // Only few surfaces are tested ExpectedFilling1 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(-40, 10), new Point2D(-20, 12), new Point2D(0, 10), new Point2D(-20, 10), soilFilling), @@ -221,14 +230,16 @@ ExpectedSurface4 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-40, 0), new Point2D(-20, 0), new Point2D(-10, 0), new Point2D(-10, -15), new Point2D(-40, -15), soil4), ExpectedSurface5 = null, // not null but not tested ExpectedSurface6 = null // not null but not tested - }).SetName("Test 5: Surface line intersects the original surface line of soil profile (and shift = +10)"); + }).SetName("Test 5: Surface line intersects the surface line of shifted soil profile (shift = 15) and" + + "starts at X=-40 (i.e. 10 m right)"); yield return new TestCaseData( new TestCaseZigZagSurfaceLine { TestNumber = 6, GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(10, 10), - GivenShift = 0, + GivenXStartOfSoilProfile = -30, + GivenShift = -20, ExpectedSurfaceCount = 7, // Only few surfaces are tested ExpectedFilling1 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(10, 10), new Point2D(30, 12), new Point2D(50, 10), soilFilling), @@ -243,14 +254,16 @@ ExpectedSurface4 = null, ExpectedSurface5 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 10, 35, soil5), ExpectedSurface6 = null // not null but not tested - }).SetName("Test 6: Surface line intersects the original surface line of soil profile (and shift = +60)"); + }).SetName("Test 6: Surface line intersects the surface line of shifted soil profile (shift = -20) and" + + "starts at X=10 (i.e. 60 m right)"); yield return new TestCaseData( new TestCaseZigZagSurfaceLine { TestNumber = 7, GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-60, 10), - GivenShift = 0, + GivenXStartOfSoilProfile = -80, + GivenShift = 30, ExpectedSurfaceCount = 10, // Only few surfaces are tested ExpectedFilling1 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(-60, 10), new Point2D(-40, 12), new Point2D(-20, 10), new Point2D(-50, 10), soilFilling), @@ -265,14 +278,16 @@ ExpectedSurface4 = null, // not null but not tested ExpectedSurface5 = null, // not null but not tested ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 60, soil6) - }).SetName("Test 7: Surface line intersects the original surface line of soil profile (and shift = -10)"); + }).SetName("Test 7: Surface line intersects the surface line of shifted soil profile (shift = 30) and" + + "starts at X=-60 (i.e. 10 m left)"); yield return new TestCaseData( new TestCaseZigZagSurfaceLine { TestNumber = 8, GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-110, 10), - GivenShift = 0, + GivenXStartOfSoilProfile = -25, + GivenShift = -25, ExpectedSurfaceCount = 9, // Only few surfaces are tested ExpectedFilling1 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(-110, 10), new Point2D(-90, 12), new Point2D(-70, 10), soilFilling), @@ -287,13 +302,15 @@ ExpectedSurface4 = null, //not null but not tested ExpectedSurface5 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(0, 0), new Point2D(10, 0), new Point2D(10, -15), new Point2D(-10, -15), soil5), ExpectedSurface6 = null - }).SetName("Test 8: Surface line intersects the original surface line of soil profile (and shift = -60)"); + }).SetName("Test 8: Surface line intersects the surface line of shifted soil profile (shift = -25) and" + + "starts at X=-110 (i.e. 60 m left)"); yield return new TestCaseData( new TestCaseZigZagSurfaceLine { TestNumber = 9, GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(50, -5), + GivenXStartOfSoilProfile = -50, GivenShift = 0, ExpectedSurfaceCount = 2, ExpectedFilling1 = null, @@ -308,32 +325,8 @@ ExpectedSurface4 = null, ExpectedSurface5 = null, ExpectedSurface6 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(50, -5), new Point2D(60, -4), new Point2D(60, -15), new Point2D(50, -15), soil6) - }).SetName("Test 9: Surface line starts inside surface line 6 (right bottom) of soil profile"); + }).SetName("Test 9: Surface line starts inside surface 6 (right bottom) of the soil profile"); - yield return new TestCaseData( - new TestCaseZigZagSurfaceLine - { - TestNumber = 10, - GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-40, 10), - GivenShift = 10, - ExpectedSurfaceCount = 10, - // 4 extra surfaces created : 2 below the highest corners of the "zigzag" surface line + 2 on the left side (between Z=70 and 80) - ExpectedFilling1 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(-40, 10), new Point2D(-20, 12), new Point2D(0, 10), new Point2D(-10, 10), soilFilling), - ExpectedFilling2 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(40, 10), new Point2D(60, 12), new Point2D(80, 10), new Point2D(70, 10), soilFilling), - ExpectedExtendedSurface1 = null, - ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, 70, 80, soil3), - ExpectedExtendedSurface4 = null, - ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 70, 80, soil6), - ExpectedSurface1 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, -40, -10, soil1), - ExpectedSurface2 = FactoryForSoilProfiles.CreateHexagonSoilLayer2D(new Point2D(-10, 10), new Point2D(0, 10), new Point2D(10, 9), new Point2D(10, 0),new Point2D(0, 0), new Point2D(-10, 0), soil2), - ExpectedSurface3 = FactoryForSoilProfiles.CreateHeptagonSoilLayer2D(new Point2D(10, 9), new Point2D(20, 8), new Point2D(40, 10), new Point2D(70, 10), new Point2D(70, 0), new Point2D(45, 0), new Point2D(10, 0), soil3), - ExpectedSurface4 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-40, 0), new Point2D(-10, 0), new Point2D(0, 0), new Point2D(0, -15), new Point2D(-40, -15), soil4), - ExpectedSurface5 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(0, 0), new Point2D(10, 0), new Point2D(45, 0), new Point2D(45, -15), new Point2D(0, -15), soil5), - ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 45, 70, soil6) - - }).SetName("Test 10: Surface line is shifted by +10 m compared to the original surface line and the geometry " + - "is shifted with 10 m. So the expected soil profile should be identical to test case 1 " + - "but should start at -40 instead of -50."); } } @@ -368,10 +361,10 @@ } [Test, TestCaseSource(nameof(ZigZagSurfaceLinesTestCases))] - public void GivenComplexSoilProfile2D_WhenCombiningWithZigZagSurfaceLine_ThenCorrectNewSoilProfile2DIsCreated(TestCaseZigZagSurfaceLine testCaseSurfaceLine) + public void GivenComplexShiftedSoilProfile2D_WhenCombiningWithZigZagSurfaceLine_ThenCorrectNewSoilProfile2DIsCreated(TestCaseZigZagSurfaceLine testCaseSurfaceLine) { // Given - SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithSixSurfacesFormingTwoLayers(); + SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithSixSurfacesFormingTwoLayers(testCaseSurfaceLine.GivenXStartOfSoilProfile); var defaultSoil = new Soil { Name = "Filling material" @@ -458,6 +451,7 @@ public class TestCaseZigZagSurfaceLine { public SurfaceLine2 GivenZigZagSurfaceLine { get; init; } + public double GivenXStartOfSoilProfile { get; init; } public double GivenShift { get; init; } public int ExpectedSurfaceCount { get; init; } public SoilLayer2D ExpectedSurface1 { get; init; }