Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs =================================================================== diff -u -r5010 -r5053 --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 5010) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 5053) @@ -24,7 +24,6 @@ using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.TestHelpers.Factories; -using Deltares.DamEngine.TestHelpers.Geometry; using NUnit.Framework; namespace Deltares.DamEngine.Data.Tests.Geotechnics; @@ -85,6 +84,206 @@ }).SetName("Surface is partially above and below original surfaceline of soil profile"); } } + + private static IEnumerable ZigZagSurfaceLinesTestCases + { + get + { + yield return new TestCaseData( + new TestCaseZigZagSurfaceLine + { + GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, 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.CreateTriangularSoilLayer2D(new Point2D(-50, 10), new Point2D(-30, 12), new Point2D(-10, 10), "Filling material"), + ExpectedFilling2 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(350, 10), new Point2D(50, 12), new Point2D(60, 11), new Point2D(60, 10), "Filling material"), + ExpectedExtendedSurface1 = null, + ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, 60, 70, "Surface 3"), + ExpectedExtendedSurface4 = null, + ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 70, "Surface 6"), + ExpectedSurface1 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, -50, -20, "Surface 1"), + ExpectedSurface2 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-20, 10), new Point2D(-10, 10), new Point2D(0, 9), new Point2D(0, 0), new Point2D(-20, 0), "Surface 2"), + ExpectedSurface3 = FactoryForSoilProfiles.CreateHexagonSoilLayer2D(new Point2D(0, 9), new Point2D(10, 8), new Point2D(30, 10), new Point2D(60, 10), new Point2D(60, 0), new Point2D(0, 0), "Surface 3"), + ExpectedSurface4 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -50, -10, "Surface 4"), + ExpectedSurface5 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -50, -10, "Surface 5"), + ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 600, "Surface 6") + + }).SetName("Test 1: Surface line intersects the original surface line of soil profile (and shift = 0)"); + + yield return new TestCaseData( + new TestCaseZigZagSurfaceLine() + { + GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, 13), + ExpectedSurfaceCount = 9, + // 3 extra surfaces created: 1 below the "zigzag" surface line + 2 on the left side (between Z=60 and 70) + ExpectedFilling1 = FactoryForSoilProfiles.CreateHeptagonSoilLayer2D(new Point2D(-50, 13), new Point2D(-30, 15), new Point2D(10, 11), new Point2D(50, 15), new Point2D(70, 13), new Point2D(70, 10), new Point2D(-50, 10), "Filling material"), + ExpectedFilling2 = null, + ExpectedExtendedSurface1 = null, + ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, 60, 70, "Surface 3"), + ExpectedExtendedSurface4 = null, + ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 70, "Surface 6"), + ExpectedSurface1 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, -50, -20, "Surface 1"), + ExpectedSurface2 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, -20, 0, "Surface 2"), + ExpectedSurface3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, 0, 60, "Surface 3"), + ExpectedSurface4 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -50, -10, "Surface 4"), + ExpectedSurface5 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -50, -10, "Surface 5"), + ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 600, "Surface 6") + }).SetName("Test 2: Surface line is completely above original surface line of soil profile (and shift = 0)"); + + yield return new TestCaseData( + new TestCaseZigZagSurfaceLine + { + GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, 5), + ExpectedSurfaceCount = 8, + // 2 extra surfaces created on the left side (between Z=60 and 70) + ExpectedFilling1 = null, + ExpectedFilling2 = null, + ExpectedExtendedSurface1 = null, + ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, 60, 70, "Surface 3"), + ExpectedExtendedSurface4= null, + ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 70, "Surface 6"), + ExpectedSurface1 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-50, 5), new Point2D(-30, 7), new Point2D(-20, 6), new Point2D(-20, 0), new Point2D(-50, 0),"Surface 1"), + ExpectedSurface2 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(-20, 6), new Point2D(0, 4), new Point2D(0, 0), new Point2D(-20, 0), "Surface 2"), + ExpectedSurface3 = FactoryForSoilProfiles.CreateHexagonSoilLayer2D(new Point2D(0, 4), new Point2D(10, 3), new Point2D(50, 7), new Point2D(60, 6), new Point2D(60, 0), new Point2D(0, 0), "Surface 3"), + ExpectedSurface4 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -50, -10, "Surface 4"), + ExpectedSurface5 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -50, -10, "Surface 5"), + ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 600, "Surface 6") + }).SetName("Test 3: Surface line is completely in the top layer of the soil profile (and shift = 0)"); + + yield return new TestCaseData( + new TestCaseZigZagSurfaceLine + { + GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, 0), + ExpectedSurfaceCount = 8, + // 2 extra surfaces created on the left side (between Z=60 and 70) + ExpectedFilling1 = null, + ExpectedFilling2 = null, + ExpectedExtendedSurface1 = null, + ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(60, 1), new Point2D(70, 0), new Point2D(60, 0), "Surface 3"), + ExpectedExtendedSurface4 = null, + ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 70, "Surface 6"), + ExpectedSurface1 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-50, 5), new Point2D(-30, 7), new Point2D(-20, 6), new Point2D(-20, 0), new Point2D(-50, 0),"Surface 1"), + ExpectedSurface2 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(-20, 1), new Point2D(-10, 0), new Point2D(-20, 0), "Surface 2"), + ExpectedSurface3 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(35, 0), new Point2D(50, 2), new Point2D(60, 1), new Point2D(60, 0), "Surface 3"), + ExpectedSurface4 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -50, -10, "Surface 4"), + ExpectedSurface5 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(10, -2), new Point2D(35, 0), new Point2D(35, -15), new Point2D(-10, -15), "Surface 5"), + ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 600, "Surface 6") + }).SetName("Test 4: Surface line intersects the original layer separation of soil profile (and shift = 0)"); + + yield return new TestCaseData( + new TestCaseZigZagSurfaceLine + { + GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, -15), + ExpectedSurfaceCount = 0 + }).SetName("Test 5: Surface line partly below soil profile (and shift = 0)"); + + yield return new TestCaseData( + new TestCaseZigZagSurfaceLine + { + GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, -20), + ExpectedSurfaceCount = 0 + }).SetName("Test 6: Surface line completely below soil profile (and shift = 0)"); + + yield return new TestCaseData( + new TestCaseZigZagSurfaceLine + { + GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-40, 10), + ExpectedSurfaceCount = 10, + // Only few surfaces are tested + ExpectedFilling1 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(-60, 10), new Point2D(-40, 12), new Point2D(-20, 10), "Filling material"), + ExpectedFilling2 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(40, 10), new Point2D(60, 12), new Point2D(80, 10), "Filling material"), + ExpectedExtendedSurface1 = null, + ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, 60, 80, "Surface 3"), + ExpectedExtendedSurface4 = null, + ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 80, "Surface 6"), + ExpectedSurface1 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, -40, -20, "Surface 1"), + ExpectedSurface2 = null, // not null but not tested + ExpectedSurface3 = null, // not null but not tested + ExpectedSurface4 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -40, -10, "Surface 4"), + ExpectedSurface5 = null, // not null but not tested + ExpectedSurface6 = null // not null but not tested + }).SetName("Test 7: Surface line intersects the original surface line of soil profile (and shift = +10)"); + + yield return new TestCaseData( + new TestCaseZigZagSurfaceLine + { + GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(10, 10), + ExpectedSurfaceCount = 7, + // Only few surfaces are tested + ExpectedFilling1 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(10, 10), new Point2D(30, 12), new Point2D(50, 10), "Filling material"), + ExpectedFilling2 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(90, 10), new Point2D(110, 12), new Point2D(130, 10), "Filling material"), + ExpectedExtendedSurface1 = null, + ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, 60, 120, "Surface 3"), + ExpectedExtendedSurface4 = null, + ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 120, "Surface 6"), + ExpectedSurface1 = null, + ExpectedSurface2 = null, + ExpectedSurface3 = FactoryForSoilProfiles.CreateHexagonSoilLayer2D(new Point2D(10, 9), new Point2D(20, 8), new Point2D(40, 10), new Point2D(60, 10), new Point2D(60, 0), new Point2D(10, 0), "Surface 3"), + ExpectedSurface4 = null, + ExpectedSurface5 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 10, 35, "Surface 5"), + ExpectedSurface6 = null // not null but not tested + }).SetName("Test 8: Surface line intersects the original surface line of soil profile (and shift = +60)"); + + yield return new TestCaseData( + new TestCaseZigZagSurfaceLine + { + GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-60, 10), + ExpectedSurfaceCount = 10, + // Only few surfaces are tested + ExpectedFilling1 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(-60, 10), new Point2D(-40, 12), new Point2D(-20, 10), "Filling material"), + ExpectedFilling2 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(20, 10), new Point2D(40, 12), new Point2D(60, 10), "Filling material"), + ExpectedExtendedSurface1 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, -60, -50, "Surface 1"), + ExpectedExtendedSurface3 = null, + ExpectedExtendedSurface4 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -60, -50, "Surface 4"), + ExpectedExtendedSurface6 = null, + ExpectedSurface1 = null, // not null but not tested + ExpectedSurface2 = null, // not null but not tested + ExpectedSurface3 = null, // not null but not tested + ExpectedSurface4 = null, // not null but not tested + ExpectedSurface5 = null, // not null but not tested + ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 60, "Surface 6") + }).SetName("Test 9: Surface line intersects the original surface line of soil profile (and shift = -10)"); + + yield return new TestCaseData( + new TestCaseZigZagSurfaceLine + { + GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-60, 10), + ExpectedSurfaceCount = 9, + // Only few surfaces are tested + ExpectedFilling1 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(-110, 10), new Point2D(-90, 11), new Point2D(-70, 10), "Filling material"), + ExpectedFilling2 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(-30, 10), new Point2D(-10, 12), new Point2D(10, 10), "Filling material"), + ExpectedExtendedSurface1 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, -110, -50, "Surface 1"), + ExpectedExtendedSurface3 = null, + ExpectedExtendedSurface4 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -110, -50, "Surface 4"), + ExpectedExtendedSurface6 = null, + ExpectedSurface1 = null, // not null but not tested + ExpectedSurface2 = null, // not null but not tested + ExpectedSurface3 = null, // not null but not tested + ExpectedSurface4 = null, //not null but not tested + ExpectedSurface5 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -10, 10, "Surface 5"), + ExpectedSurface6 = null + }).SetName("Test 10: Surface line intersects the original surface line of soil profile (and shift = -60)"); + + yield return new TestCaseData( + new TestCaseZigZagSurfaceLine + { + GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(50, -5), + ExpectedSurfaceCount = 2, + ExpectedFilling1 = null, + ExpectedFilling2 = null, + ExpectedExtendedSurface1 = null, + ExpectedExtendedSurface3 = null, + ExpectedExtendedSurface4 = null, + ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateHeptagonSoilLayer2D(new Point2D(60, -4), new Point2D(70, -3), new Point2D(110, -5), new Point2D(150, -3), new Point2D(190, -5), new Point2D(190, -15), new Point2D(60, -15),"Surface 6"), + ExpectedSurface1 = null, + ExpectedSurface2 = null, + ExpectedSurface3 = null, + ExpectedSurface4 = null, + ExpectedSurface5 = null, + ExpectedSurface6 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(50, -5), new Point2D(60, -4), new Point2D(60, -15), new Point2D(50, -15), "Surface 6") + }).SetName("Test 11: Surface line starts inside surface line 6 (right bottom) of soil profile"); + } + } [Test] [TestCase(PositionToSoilProfile2D.LeftOfSoilProfile, false)] @@ -119,6 +318,43 @@ Assert.That(newSoilProfile2D, Is.Not.Null); Assert.That(newSoilProfile2D.Surfaces, Has.Count.EqualTo(testCaseSurfaceLine.SurfaceCount)); } + + [Test, TestCaseSource(nameof(ZigZagSurfaceLinesTestCases))] + [Ignore("Work in progress")] + public void GivenComplexSoilProfile2D_WhenCombiningWithZigZagSurfaceLine_ThenCorrectNewSoilProfile2DIsCreated(TestCaseZigZagSurfaceLine testCaseSurfaceLine) + { + // Given + SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithSixSurfacesFormingTwoLayers(); + var defaultSoil = new Soil + { + Name = "Filling material" + }; + // When + SoilProfile2D newSoilProfile2D = SoilProfile2DSurfaceLineHelper.CombineSurfaceLineWithSoilProfile2D( + testCaseSurfaceLine.GivenZigZagSurfaceLine, soilProfile2D, defaultSoil, 0); + // Then + if (testCaseSurfaceLine.ExpectedSurfaceCount == 0) + { + Assert.That(newSoilProfile2D, Is.Null); + } + else + { + Assert.That(newSoilProfile2D, Is.Not.Null); + Assert.That(newSoilProfile2D.Surfaces, Has.Count.EqualTo(testCaseSurfaceLine.ExpectedSurfaceCount)); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedFilling1); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedFilling2); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedExtendedSurface1); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedExtendedSurface3); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedExtendedSurface4); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedExtendedSurface6); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedSurface1); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedSurface2); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedSurface3); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedSurface4); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedSurface5); + CheckSoilProfileContainsSoilLayer(newSoilProfile2D, testCaseSurfaceLine.ExpectedSurface6); + } + } [Test] [TestCase(0, true)] // Surface line is above the bottom of the soil profile @@ -140,6 +376,27 @@ public SurfaceLine2 SurfaceLine { get; set; } public int SurfaceCount { get; set; } } + + /// + /// Test case class for GivenComplexSoilProfile2D_WhenCombiningWithZigZagSurfaceLine_ThenCorrectNewSoilProfile2DIsCreated + /// + public class TestCaseZigZagSurfaceLine + { + public SurfaceLine2 GivenZigZagSurfaceLine { get; init; } + public int ExpectedSurfaceCount { get; init; } + public SoilLayer2D ExpectedSurface1 { get; init; } + public SoilLayer2D ExpectedSurface2 { get; init; } + public SoilLayer2D ExpectedSurface3 { get; init; } + public SoilLayer2D ExpectedSurface4 { get; init; } + public SoilLayer2D ExpectedSurface5 { get; init; } + public SoilLayer2D ExpectedSurface6 { get; init; } + public SoilLayer2D ExpectedExtendedSurface1 { get; init; } + public SoilLayer2D ExpectedExtendedSurface3 { get; init; } + public SoilLayer2D ExpectedExtendedSurface4 { get; init; } + public SoilLayer2D ExpectedExtendedSurface6 { get; init; } + public SoilLayer2D ExpectedFilling1 { get; init; } + public SoilLayer2D ExpectedFilling2 { get; init; } + } /// /// To indicate the position of the surface line to the soil profile. @@ -187,4 +444,12 @@ surfaceLine.CharacteristicPoints.Annotate(1, CharacteristicPointType.SurfaceLevelInside); return surfaceLine; } + + private void CheckSoilProfileContainsSoilLayer(SoilProfile2D soilProfile2D, SoilLayer2D expectedSoilLayer) + { + if (expectedSoilLayer != null) + { + Assert.That(soilProfile2D.Surfaces.Contains(expectedSoilLayer)); + } + } } \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs =================================================================== diff -u -r4903 -r5053 --- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs (.../FactoryForSoilProfiles.cs) (revision 4903) +++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs (.../FactoryForSoilProfiles.cs) (revision 5053) @@ -1073,8 +1073,41 @@ return soilProfile2D; } - private static string GetNewUniqueLayerId(SoilProfile1D soilProfile1D) + // -50 -20 -10 0 35 60 + // |-----------------|--------------|-----------------------------| Level 10 m + // | surface 1 | surface 2 | surface 3 | + // |-----------------|------|-------|--------------|--------------| Level 0 m + // | surface 4 | surface 5 | surface | + // | | | 6 | + // |------------------------|----------------------|--------------| Level -15 m + public static SoilProfile2D CreateSoilProfile2DWithSixSurfacesFormingTwoLayers() { + SoilLayer2D soilLayer1 = CreateRectangularSoilLayer2D(10, 0, -50, -20, "Surface 1"); + SoilLayer2D soilLayer2 = CreateRectangularSoilLayer2D(10, 0, -20, 0, "Surface 2"); + SoilLayer2D soilLayer3 = CreateRectangularSoilLayer2D(10, 0, 0, 60, "Surface 3"); + SoilLayer2D soilLayer4 = CreateRectangularSoilLayer2D(0, -15, -50, -10, "Surface 4"); + SoilLayer2D soilLayer5 = CreateRectangularSoilLayer2D(0, -15, -10, 35, "Surface 5"); + SoilLayer2D soilLayer6 = CreateRectangularSoilLayer2D(0, -15, 35, 60, "Surface 6"); + var soilProfile2D = new SoilProfile2D + { + Geometry = new GeometryData + { + Left = -50, + Right = 60, + Bottom = -15 + } + }; + soilProfile2D.Surfaces.Add(soilLayer1); + soilProfile2D.Surfaces.Add(soilLayer2); + soilProfile2D.Surfaces.Add(soilLayer3); + soilProfile2D.Surfaces.Add(soilLayer4); + soilProfile2D.Surfaces.Add(soilLayer5); + soilProfile2D.Surfaces.Add(soilLayer6); + return soilProfile2D; +} + +private static string GetNewUniqueLayerId(SoilProfile1D soilProfile1D) + { var num = 0; string id; do @@ -1084,4 +1117,140 @@ return id; } + + public static SoilLayer2D CreateRectangularSoilLayer2D(double topCoord, double bottomCoord, double leftCoord, double rightCoord, string soilName) + { + var topLeftPoint = new Point2D(leftCoord, topCoord); + var topRightPoint = new Point2D(rightCoord, topCoord); + var bottomRightPoint = new Point2D(rightCoord, bottomCoord); + var bottomLeftPoint = new Point2D(leftCoord, bottomCoord); + + return new SoilLayer2D + { + GeometrySurface = new GeometrySurface + { + OuterLoop = new GeometryLoop + { + CurveList = + { + new GeometryCurve(topLeftPoint, topRightPoint), + new GeometryCurve(topRightPoint, bottomRightPoint), + new GeometryCurve(bottomRightPoint, bottomLeftPoint), + new GeometryCurve(bottomLeftPoint, topLeftPoint) + } + } + }, + SoilName = soilName + }; + } + + public static SoilLayer2D CreateTriangularSoilLayer2D(Point2D point1, Point2D point2, Point2D point3, string soilName) + { + return new SoilLayer2D + { + GeometrySurface = new GeometrySurface + { + OuterLoop = new GeometryLoop + { + CurveList = + { + new GeometryCurve(point1, point2), + new GeometryCurve(point2, point3), + new GeometryCurve(point3, point1) + } + } + }, + SoilName = soilName + }; + } + + public static SoilLayer2D CreateQuadrilateralSoilLayer2D(Point2D point1, Point2D point2, Point2D point3, Point2D point4, string soilName) + { + return new SoilLayer2D + { + GeometrySurface = new GeometrySurface + { + OuterLoop = new GeometryLoop + { + CurveList = + { + new GeometryCurve(point1, point2), + new GeometryCurve(point2, point3), + new GeometryCurve(point3, point4), + new GeometryCurve(point4, point1) + } + } + }, + SoilName = soilName + }; + } + + public static SoilLayer2D CreatePentagonSoilLayer2D(Point2D point1, Point2D point2, Point2D point3, Point2D point4, Point2D point5, string soilName) + { + return new SoilLayer2D + { + GeometrySurface = new GeometrySurface + { + OuterLoop = new GeometryLoop + { + CurveList = + { + new GeometryCurve(point1, point2), + new GeometryCurve(point2, point3), + new GeometryCurve(point3, point4), + new GeometryCurve(point4, point5), + new GeometryCurve(point5, point1) + } + } + }, + SoilName = soilName + }; + } + + public static SoilLayer2D CreateHexagonSoilLayer2D(Point2D point1, Point2D point2, Point2D point3, Point2D point4, Point2D point5, Point2D point6, string soilName) + { + return new SoilLayer2D + { + GeometrySurface = new GeometrySurface + { + OuterLoop = new GeometryLoop + { + CurveList = + { + new GeometryCurve(point1, point2), + new GeometryCurve(point2, point3), + new GeometryCurve(point3, point4), + new GeometryCurve(point4, point5), + new GeometryCurve(point5, point6), + new GeometryCurve(point6, point1) + } + } + }, + SoilName = soilName + }; + } + + public static SoilLayer2D CreateHeptagonSoilLayer2D(Point2D point1, Point2D point2, Point2D point3, Point2D point4, Point2D point5, Point2D point6, Point2D point7, string soilName) + { + return new SoilLayer2D + { + GeometrySurface = new GeometrySurface + { + OuterLoop = new GeometryLoop + { + CurveList = + { + new GeometryCurve(point1, point2), + new GeometryCurve(point2, point3), + new GeometryCurve(point3, point4), + new GeometryCurve(point4, point5), + new GeometryCurve(point5, point6), + new GeometryCurve(point6, point7), + new GeometryCurve(point7, point1) + } + } + }, + SoilName = soilName + }; + } } \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSurfaceLines.cs =================================================================== diff -u -r5019 -r5053 --- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSurfaceLines.cs (.../FactoryForSurfaceLines.cs) (revision 5019) +++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSurfaceLines.cs (.../FactoryForSurfaceLines.cs) (revision 5053) @@ -66,236 +66,27 @@ } /// - /// Creates a surface line like in tutorial 2. + /// Creates a surface line as regular "zig zag" line of 120 m length with the highest corners 2 m above the middle line + /// and lowest corners 2 m below. Each corner has a width of 40 m. There are 3 corners in total. /// /// surface line - public static SurfaceLine2 CreateSurfaceLineTutorial2() + public static SurfaceLine2 CreateSurfaceLineInZigZag(double xCoordLeftPoint, double zCoordLeftPoint) { - //Surface line tutorial 2 var surfaceLine = new SurfaceLine2 - { - Name = "Tutorial2" + { + Name = "Surface line in zig zag" }; - // Next point adjusted so create PL line can be tested better - surfaceLine.EnsurePointOfType(0.0, 0, CharacteristicPointType.SurfaceLevelOutside); - surfaceLine.EnsurePointOfType(10.0, 0, CharacteristicPointType.DikeToeAtRiver); - surfaceLine.EnsurePointOfType(34.5, 5, CharacteristicPointType.DikeTopAtRiver); - surfaceLine.EnsurePointOfType(40.5, 5, CharacteristicPointType.DikeTopAtPolder); - surfaceLine.EnsurePointOfType(50.5, 0, CharacteristicPointType.DikeToeAtPolder); - surfaceLine.EnsurePointOfType(58.5, 0, CharacteristicPointType.DitchDikeSide); - surfaceLine.EnsurePointOfType(59.5, -2, CharacteristicPointType.BottomDitchDikeSide); - surfaceLine.EnsurePointOfType(61.5, -2, CharacteristicPointType.BottomDitchPolderSide); - surfaceLine.EnsurePointOfType(61.5, 0, CharacteristicPointType.DitchPolderSide); - surfaceLine.EnsurePointOfType(75.0, 0, CharacteristicPointType.SurfaceLevelInside); - + surfaceLine.EnsurePoint(xCoordLeftPoint, zCoordLeftPoint); + surfaceLine.EnsurePoint(xCoordLeftPoint + 20, zCoordLeftPoint + 2); + surfaceLine.EnsurePoint(xCoordLeftPoint + 60, zCoordLeftPoint -2); + surfaceLine.EnsurePoint(xCoordLeftPoint + 100, zCoordLeftPoint + 2); + surfaceLine.EnsurePoint(xCoordLeftPoint + 120, zCoordLeftPoint); surfaceLine.Geometry.SyncCalcPoints(); return surfaceLine; } /// - /// Creates a surface line like in tutorial 1 with outside shoulder. - /// - /// surface line - public static SurfaceLine2 CreateSurfaceLineTutorial1WithOutsideShoulder() - { - //Surface line tutorial 1 - var surfaceLine = new SurfaceLine2 - { - Name = "Tutorial1", - Geometry = new GeometryPointString(), - CharacteristicPoints = - { - GeometryMustContainPoint = true - } - }; - - surfaceLine.EnsurePointOfType(0, 0, CharacteristicPointType.SurfaceLevelOutside); - surfaceLine.EnsurePointOfType(10, 0, CharacteristicPointType.DikeToeAtRiver); - //Berm - surfaceLine.EnsurePointOfType(10, 2, CharacteristicPointType.ShoulderTopOutside); - surfaceLine.EnsurePointOfType(27.5, 3, CharacteristicPointType.ShoulderBaseInside); - //End Berm - surfaceLine.EnsurePointOfType(34.5, 5, CharacteristicPointType.DikeTopAtRiver); - surfaceLine.EnsurePointOfType(40.5, 5, CharacteristicPointType.DikeTopAtPolder); - surfaceLine.EnsurePointOfType(50.5, 0, CharacteristicPointType.DikeToeAtPolder); - surfaceLine.EnsurePointOfType(58.5, 0, CharacteristicPointType.DitchDikeSide); - surfaceLine.EnsurePointOfType(59.5, -2, CharacteristicPointType.BottomDitchDikeSide); - surfaceLine.EnsurePointOfType(61.5, -2, CharacteristicPointType.BottomDitchPolderSide); - surfaceLine.EnsurePointOfType(61.5, 0, CharacteristicPointType.DitchPolderSide); - surfaceLine.EnsurePointOfType(75.00, 0, CharacteristicPointType.SurfaceLevelInside); - - surfaceLine.Geometry.SyncCalcPoints(); - return surfaceLine; - } - - /// - /// Creates a surface line like in tutorial 1 missing characteristic point dike top at river. - /// - /// surface line - public static SurfaceLine2 CreateSurfaceLineTutorial1MissingCharacteristicPointDikeTopAtRiver() - { - //Surface line tutorial 1 - var surfaceLine = new SurfaceLine2 - { - Geometry = new GeometryPointString(), - CharacteristicPoints = - { - GeometryMustContainPoint = true - } - }; - - surfaceLine.EnsurePointOfType(0, 0, CharacteristicPointType.SurfaceLevelOutside); - surfaceLine.EnsurePointOfType(17, 0, CharacteristicPointType.DikeTopAtPolder); - surfaceLine.EnsurePointOfType(34.5, 5, CharacteristicPointType.DikeToeAtPolder); - surfaceLine.Geometry.SyncCalcPoints(); - return surfaceLine; - } - - /// - /// Creates a surface line like in tutorial 1 missing characteristic point dike top at polder. - /// - /// surface line - public static SurfaceLine2 CreateSurfaceLineTutorial1MissingCharacteristicPointDikeTopAtPolder() - { - //Surface line tutorial 1 - var surfaceLine = new SurfaceLine2 - { - Geometry = new GeometryPointString(), - CharacteristicPoints = - { - GeometryMustContainPoint = true - } - }; - - surfaceLine.EnsurePoint(0, 0); - surfaceLine.EnsurePointOfType(17, 0, CharacteristicPointType.DikeTopAtRiver); - surfaceLine.EnsurePointOfType(34.5, 5, CharacteristicPointType.DikeToeAtPolder); - surfaceLine.Geometry.SyncCalcPoints(); - return surfaceLine; - } - - /// - /// Creates a surface line like in tutorial 1 missing characteristic point dike toe at polder. - /// - /// surface line - public static SurfaceLine2 CreateSurfaceLineTutorial1MissingCharacteristicPointDikeToeAtPolder() - { - //Surface line tutorial 1 - var surfaceLine = new SurfaceLine2 - { - Geometry = new GeometryPointString(), - CharacteristicPoints = - { - GeometryMustContainPoint = true - } - }; - - surfaceLine.EnsurePointOfType(0, 0, CharacteristicPointType.SurfaceLevelOutside); - surfaceLine.EnsurePointOfType(17, 0, CharacteristicPointType.DikeTopAtRiver); - surfaceLine.EnsurePointOfType(34.5, 5, CharacteristicPointType.DikeTopAtPolder); - surfaceLine.Geometry.SyncCalcPoints(); - return surfaceLine; - } - - /// - /// Creates a surface line like in tutorial 1 with phreatic lower polder water level. - /// - /// surface line - public static SurfaceLine2 CreateSurfaceLineTutorial1PhreaticLowerPolderWaterLevel() - { - //Surface line tutorial 1 - var surfaceLine = new SurfaceLine2 - { - Geometry = new GeometryPointString(), - CharacteristicPoints = - { - GeometryMustContainPoint = true - } - }; - - surfaceLine.EnsurePointOfType(0, -1, CharacteristicPointType.SurfaceLevelOutside); - surfaceLine.EnsurePointOfType(17, -1, CharacteristicPointType.DikeToeAtRiver); - surfaceLine.EnsurePointOfType(34.5, 5, CharacteristicPointType.DikeTopAtRiver); - surfaceLine.EnsurePointOfType(40.5, 5, CharacteristicPointType.DikeTopAtPolder); - surfaceLine.EnsurePointOfType(50.5, 0, CharacteristicPointType.DikeToeAtPolder); - surfaceLine.EnsurePointOfType(58.5, 0, CharacteristicPointType.DitchDikeSide); - surfaceLine.EnsurePointOfType(59.5, -2, CharacteristicPointType.BottomDitchDikeSide); - surfaceLine.EnsurePointOfType(61.5, -2, CharacteristicPointType.BottomDitchPolderSide); - surfaceLine.EnsurePointOfType(61.5, 0, CharacteristicPointType.DitchPolderSide); - surfaceLine.EnsurePointOfType(75.0, 0, CharacteristicPointType.SurfaceLevelInside); - - surfaceLine.Geometry.SyncCalcPoints(); - return surfaceLine; - } - - /// - /// Creates s surface line like in tutorial 1 with phreatic above surface. - /// - /// surface line - public static SurfaceLine2 CreateSurfaceLineTutorial1PhreaticAboveSurface() - { - //Surface line tutorial 1 - var surfaceLine = new SurfaceLine2 - { - Geometry = new GeometryPointString(), - CharacteristicPoints = - { - GeometryMustContainPoint = true - } - }; - - surfaceLine.EnsurePointOfType(0, 0, CharacteristicPointType.SurfaceLevelOutside); - surfaceLine.EnsurePointOfType(17, 0, CharacteristicPointType.DikeToeAtRiver); - surfaceLine.EnsurePointOfType(34.5, 5, CharacteristicPointType.DikeTopAtRiver); - surfaceLine.EnsurePointOfType(40.5, 5, CharacteristicPointType.DikeTopAtPolder); - //Evil point (phreatic above surface) - surfaceLine.EnsurePoint(46, 0.250); - surfaceLine.EnsurePointOfType(50.5, 0, CharacteristicPointType.DikeToeAtPolder); - surfaceLine.EnsurePointOfType(58.5, 0, CharacteristicPointType.DitchDikeSide); - surfaceLine.EnsurePointOfType(59.5, -2, CharacteristicPointType.BottomDitchDikeSide); - surfaceLine.EnsurePointOfType(60.5, -2, CharacteristicPointType.BottomDitchPolderSide); - surfaceLine.EnsurePointOfType(61.5, 0, CharacteristicPointType.DitchPolderSide); - surfaceLine.EnsurePointOfType(75.0, 0, CharacteristicPointType.SurfaceLevelInside); - - surfaceLine.Geometry.SyncCalcPoints(); - return surfaceLine; - } - - /// - /// Creates s surface line like in tutorial1 with shoulder. - /// - /// surface line - public static SurfaceLine2 CreateSurfaceLineTutorial1WithShoulder() - { - //Surface line tutorial 1 - var surfaceLine = new SurfaceLine2 - { - Geometry = new GeometryPointString(), - CharacteristicPoints = - { - GeometryMustContainPoint = true - } - }; - - surfaceLine.EnsurePointOfType(0, 0, CharacteristicPointType.SurfaceLevelOutside); - surfaceLine.EnsurePointOfType(17, 0, CharacteristicPointType.DikeToeAtRiver); - surfaceLine.EnsurePointOfType(34.5, 5, CharacteristicPointType.DikeTopAtRiver); - surfaceLine.EnsurePointOfType(40.5, 5, CharacteristicPointType.DikeTopAtPolder); - surfaceLine.EnsurePointOfType(48.25, 1.25, CharacteristicPointType.DikeToeAtPolder); - surfaceLine.EnsurePointOfType(52.25, 1.25, CharacteristicPointType.ShoulderTopInside); - surfaceLine.EnsurePointOfType(54.75, 0.0, CharacteristicPointType.ShoulderBaseInside); - surfaceLine.EnsurePointOfType(58.5, 0, CharacteristicPointType.DitchDikeSide); - surfaceLine.EnsurePointOfType(59.5, -2, CharacteristicPointType.BottomDitchDikeSide); - surfaceLine.EnsurePointOfType(61.5, -2, CharacteristicPointType.BottomDitchPolderSide); - surfaceLine.EnsurePointOfType(61.5, 0, CharacteristicPointType.DitchPolderSide); - surfaceLine.EnsurePointOfType(75.0, 0, CharacteristicPointType.SurfaceLevelInside); - - surfaceLine.Geometry.SyncCalcPoints(); - return surfaceLine; - } - - /// /// Creates a surface line for piping bligh. /// /// surface line