// Copyright (C) Stichting Deltares 2024. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System.Collections.Generic; using System.Linq; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Data.Standard; using Deltares.DamEngine.TestHelpers.Factories; using NUnit.Framework; namespace Deltares.DamEngine.Data.Tests.Geotechnics; [TestFixture] public class SoilProfile2DSurfaceLineHelperTests { private static IEnumerable SurfaceLinesTestCases { get { yield return new TestCaseData( new TestCaseSurfaceLine { SurfaceLine = FactoryForSoilProfiles.CreateSurfaceLine(new[] { new Point2D(0, 0), new Point2D(5, 10), new Point2D(10, 10) }), SurfaceCount = 3, TestNumber = 1 }).SetName("Surface is same as original surfaceline of soil profile"); yield return new TestCaseData( new TestCaseSurfaceLine { SurfaceLine = FactoryForSoilProfiles.CreateSurfaceLine(new[] { new Point2D(0, 1), new Point2D(5, 11), new Point2D(10, 11) }), SurfaceCount = 4, TestNumber = 2 }).SetName("Surface is completely above original surfaceline of soil profile"); yield return new TestCaseData( new TestCaseSurfaceLine { SurfaceLine = FactoryForSoilProfiles.CreateSurfaceLine(new[] { new Point2D(0, -1), new Point2D(5, 9), new Point2D(10, 9) }), SurfaceCount = 3, TestNumber = 3 }).SetName("Surface is completely below original surfaceline of soil profile"); yield return new TestCaseData( new TestCaseSurfaceLine { SurfaceLine = FactoryForSoilProfiles.CreateSurfaceLine(new[] { new Point2D(0, 1), new Point2D(5, 9), new Point2D(10, 11) }), SurfaceCount = 5, TestNumber = 4 }).SetName("Surface is partially above and below original surfaceline of soil profile"); } } [Test] [TestCase(PositionToSoilProfile2D.LeftOfSoilProfile, false)] [TestCase(PositionToSoilProfile2D.RightOfSoilProfile, false)] [TestCase(PositionToSoilProfile2D.OnSoilProfile, true)] [TestCase(PositionToSoilProfile2D.InsideOfSoilProfile, true)] public void GivenSurfaceLineAndSoilProfile2D_WhenCheckIsSurfaceLineInsideSoilProfile2D_ThenReturnCorrectResult(PositionToSoilProfile2D positionToSoilProfile2D, bool result) { // Given SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithTwoLayers(); SurfaceLine2 surfaceLine = CreateSurfaceLineForSoilProfile2D(soilProfile2D, positionToSoilProfile2D); // When-Then Assert.That(SoilProfile2DSurfaceLineHelper.IsSurfaceLineInsideSoilProfile2D(surfaceLine, soilProfile2D), Is.EqualTo(result)); } [Test, TestCaseSource(nameof(SurfaceLinesTestCases))] public void GivenSoilProfile2DWhenCombiningWithSurfaceLineThenCorrectNewSoilProfile2DIsCreated(TestCaseSurfaceLine testCaseSurfaceLine) { // Given SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithThreeLayers(); var defaultSoil = new Soil { Name = "dikemat" }; SoilProfile2D newSoilProfile2D = SoilProfile2DSurfaceLineHelper.CombineSurfaceLineWithSoilProfile2D( testCaseSurfaceLine.SurfaceLine.Geometry, soilProfile2D, defaultSoil); Assert.That(newSoilProfile2D, Is.Not.Null); Assert.That(newSoilProfile2D.Surfaces, Has.Count.EqualTo(testCaseSurfaceLine.SurfaceCount)); } [Test] [TestCase(0, true)] // Surface line is above the bottom of the soil profile [TestCase(-10, true)] // Surface line is on and above the bottom of the soil profile [TestCase(-12, false)] // Surface line is partly below the bottom of the soil profile [TestCase(-20, false)] // Surface line is below the bottom of the soil profile public void GivenSoilProfile2DWhenCallingIsSurfaceLineAboveBottomSoilProfile2DThenCorrectResponseIsReturned(double offset, bool response) { SurfaceLine2 surfaceLine = FactoryForSurfaceLines.CreateSurfaceLineDike(offset); SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithThreeLayers(); Assert.That(SoilProfile2DSurfaceLineHelper.IsSurfaceLineAboveBottomSoilProfile2D(surfaceLine, soilProfile2D), Is.EqualTo(response)); } /// /// Test case class for GivenSoilProfile2DWhenCombiningWithSurfaceLineThenCorrectNewSoilProfile2DIsCreated() /// public class TestCaseSurfaceLine { public SurfaceLine2 SurfaceLine { get; init; } public int SurfaceCount { get; init; } public int TestNumber { 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; } public int TestNumber { get; init; } } private static SurfaceLine2 CreateSurfaceLineForSoilProfile2D(SoilProfile2D soilProfile2D, PositionToSoilProfile2D positionToSoilProfile2D) { Point2D geometryPoint = soilProfile2D.Geometry.SurfaceLine.CalcPoints.First(); var leftPoint = new Point2D(geometryPoint.X, geometryPoint.Z); geometryPoint = soilProfile2D.Geometry.SurfaceLine.CalcPoints.Last(); var rightPoint = new Point2D(geometryPoint.X, geometryPoint.Z); var middlePoint = new Point2D((leftPoint.X + rightPoint.X) / 2, (leftPoint.Z + rightPoint.Z) / 2); switch (positionToSoilProfile2D) { case PositionToSoilProfile2D.LeftOfSoilProfile: leftPoint.X -= 1; break; case PositionToSoilProfile2D.RightOfSoilProfile: rightPoint.X += 1; break; case PositionToSoilProfile2D.OnSoilProfile: break; case PositionToSoilProfile2D.InsideOfSoilProfile: leftPoint.X += 1; rightPoint.X -= 1; break; } SurfaceLine2 surfaceLine = FactoryForSoilProfiles.CreateSurfaceLine(new[] { leftPoint, middlePoint, rightPoint }); surfaceLine.CharacteristicPoints.Add(new CharacteristicPoint(surfaceLine.CharacteristicPoints, leftPoint)); surfaceLine.CharacteristicPoints.Annotate(0, CharacteristicPointType.SurfaceLevelOutside); surfaceLine.CharacteristicPoints.Add(new CharacteristicPoint(surfaceLine.CharacteristicPoints, rightPoint)); surfaceLine.CharacteristicPoints.Annotate(1, CharacteristicPointType.SurfaceLevelInside); return surfaceLine; } private static void CheckSoilProfileContainsSoilLayer(SoilProfile2D soilProfile2D, SoilLayer2D expectedSoilLayer) { if (expectedSoilLayer == null) { return; } int indexLayer = -1; // Find a point within the expected soil layer double[] xMin = expectedSoilLayer.GeometrySurface.OuterLoop.CalcPoints.Select(p => p.X).OrderBy(x => x).Distinct().ToArray(); double[] zMin = expectedSoilLayer.GeometrySurface.OuterLoop.CalcPoints.Select(p => p.Z).OrderBy(z => z).Distinct().ToArray(); var gravityPoint = new Point2D { X = xMin[0] + 2, Z = zMin[0] + 0.2 }; for (var i = 0; i < soilProfile2D.Surfaces.Count; i++) { bool find = soilProfile2D.Surfaces[i].GeometrySurface.OuterLoop.IsPointInLoopArea(gravityPoint); if (find) { indexLayer = i; break; } } Assert.That(indexLayer, Is.GreaterThan(-1), "The soil layer was not found "); Assert.Multiple(() => { Assert.That(soilProfile2D.Surfaces[indexLayer].SoilName, Is.EqualTo(expectedSoilLayer.SoilName)); Assert.That(soilProfile2D.Geometry.Surfaces[indexLayer].OuterLoop.CalcPoints, Has.Count.EqualTo(expectedSoilLayer.GeometrySurface.OuterLoop.CalcPoints.Count)); Assert.That(soilProfile2D.Geometry.Surfaces[indexLayer].OuterLoop.CurveList, Has.Count.EqualTo(expectedSoilLayer.GeometrySurface.OuterLoop.CurveList.Count)); Assert.That(soilProfile2D.Surfaces[indexLayer].GeometrySurface.OuterLoop.CalcPoints, Has.Count.EqualTo(expectedSoilLayer.GeometrySurface.OuterLoop.CalcPoints.Count)); Assert.That(soilProfile2D.Surfaces[indexLayer].GeometrySurface.OuterLoop.CurveList, Has.Count.EqualTo(expectedSoilLayer.GeometrySurface.OuterLoop.CurveList.Count)); }); foreach (GeometryCurve curve in expectedSoilLayer.GeometrySurface.OuterLoop.CurveList) { Assert.That(IsCurvePresentInSoilLayer(soilProfile2D.Surfaces[indexLayer], curve), Is.True); } foreach (Point2D point in expectedSoilLayer.GeometrySurface.OuterLoop.CalcPoints) { Assert.That(IsPointPresentInSoilLayer(soilProfile2D.Surfaces[indexLayer], point), Is.True); } } private static bool IsPointPresentInSoilLayer(SoilLayer2D soilLayer, Point2D point) { return soilLayer.GeometrySurface.OuterLoop.CalcPoints.Any(p => p.X.IsNearEqual(point.X) && p.Z.IsNearEqual(point.Z)); } private static bool IsCurvePresentInSoilLayer(SoilLayer2D soilLayer, GeometryCurve curve) { return soilLayer.GeometrySurface.OuterLoop.CurveList.Any(c => (c.HeadPoint.X.IsNearEqual(curve.HeadPoint.X) && c.HeadPoint.Z.IsNearEqual(curve.HeadPoint.Z) && c.EndPoint.X.IsNearEqual(curve.EndPoint.X) && c.EndPoint.Z.IsNearEqual(curve.EndPoint.Z)) || (c.EndPoint.X.IsNearEqual(curve.HeadPoint.X) && c.EndPoint.Z.IsNearEqual(curve.HeadPoint.Z) && c.HeadPoint.X.IsNearEqual(curve.EndPoint.X) && c.HeadPoint.Z.IsNearEqual(curve.EndPoint.Z))); } [TestCase (0.0, 0, true)] [TestCase (0.0, 3, false)] [TestCase (1.0, 0, false)] [Test] public void TestIsLayerAboveOriginalSurfaceLine(double surfaceZ, int layer, bool expectedLayerAbove) { // Given SurfaceLine2 surfaceLine = FactoryForSurfaceLines.CreateHorizontalSurfaceLine(surfaceZ, -50.0, 60.0); SoilProfile2D soilProfile = FactoryForSoilProfiles.CreateSoilProfile2DWithSixSurfacesFormingTwoLayers(); soilProfile.Geometry.RegenerateGeometry(); // When bool result = SoilProfile2DSurfaceLineHelper.IsLayerAboveOriginalSurfaceLine(soilProfile.Surfaces[layer], surfaceLine.Geometry); // Then Assert.That(result, Is.EqualTo(expectedLayerAbove)); } [Test] public void GivenSoilProfile2DWithInnerLoopsWhenCombiningWithSurfaceLineThenCorrectNewSoilProfile2DIsCreated() { // Given SurfaceLine2 surfaceLine = FactoryForSoilProfiles.CreateSurfaceLine(new[] { new Point2D(-50, -5), new Point2D(-20, -5), new Point2D(-5, 15), new Point2D(10, 15), new Point2D(30, 5), new Point2D(50, 5) }); SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithThreeLayersOfWhichTwoAreInnerLoops(); var defaultSoil = new Soil { Name = "dikemat" }; // When SoilProfile2D newSoilProfile2D = SoilProfile2DSurfaceLineHelper.CombineSurfaceLineWithSoilProfile2D( surfaceLine.Geometry, soilProfile2D, defaultSoil); //Then Assert.That(newSoilProfile2D, Is.Not.Null); Assert.Multiple(() => { Assert.That(newSoilProfile2D.Surfaces, Has.Count.EqualTo(4)); Assert.That(newSoilProfile2D.Geometry.Surfaces, Has.Count.EqualTo(4)); Assert.That(newSoilProfile2D.Geometry.Points, Has.Count.EqualTo(19)); Assert.That(newSoilProfile2D.Geometry.Curves, Has.Count.EqualTo(21)); Assert.That(newSoilProfile2D.Geometry.InnerLoopsCount, Is.EqualTo(1)); }); } [Test, TestCaseSource(nameof(ZigZagSurfaceLinesTestCases))] public void GivenComplexShiftedSoilProfile2D_WhenCombiningWithZigZagSurfaceLine_ThenCorrectNewSoilProfile2DIsCreated(TestCaseZigZagSurfaceLine testCaseSurfaceLine) { // Given SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithSixSurfacesFormingTwoLayers(); var defaultSoil = new Soil { Name = "Filling material" }; // When SoilProfile2D newSoilProfile2D = SoilProfile2DSurfaceLineHelper.CombineSurfaceLineWithSoilProfile2D( testCaseSurfaceLine.GivenZigZagSurfaceLine.Geometry, soilProfile2D, defaultSoil); // 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); } // New surface line is checked only for test case 6 if (testCaseSurfaceLine.TestNumber == 6) { Assert.That(newSoilProfile2D, Is.Not.Null); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints, Has.Count.EqualTo(8)); Assert.Multiple(() => { Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[0].X, Is.EqualTo(10)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[0].Z, Is.EqualTo(10)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[1].X, Is.EqualTo(30)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[1].Z, Is.EqualTo(12)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[2].X, Is.EqualTo(50)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[2].Z, Is.EqualTo(10)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[3].X, Is.EqualTo(60)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[3].Z, Is.EqualTo(9)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[4].X, Is.EqualTo(70)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[4].Z, Is.EqualTo(8)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[5].X, Is.EqualTo(90)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[5].Z, Is.EqualTo(10)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[6].X, Is.EqualTo(110)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[6].Z, Is.EqualTo(12)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[7].X, Is.EqualTo(130)); Assert.That(newSoilProfile2D.Geometry.SurfaceLine.CalcPoints[7].Z, Is.EqualTo(10)); }); } } private static IEnumerable ZigZagSurfaceLinesTestCases { get { SoilProfile2D newSoilProfile2D = new SoilProfile2D(); var soil1 = new Soil("Soil1"); var soil2 = new Soil("Soil2"); var soil3 = new Soil("Soil3"); var soil4 = new Soil("Soil4"); var soil5 = new Soil("Soil5"); var soil6 = new Soil("Soil6"); var soilFilling = new Soil("Filling material"); yield return new TestCaseData( new TestCaseZigZagSurfaceLine { TestNumber = 1, 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.CreateQuadrilateralSoilLayer2D(new Point2D(-50, 10), new Point2D(-30, 12), new Point2D(-10, 10), new Point2D(-20, 10), newSoilProfile2D, soilFilling), ExpectedFilling2 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(30, 10), new Point2D(50, 12), new Point2D(70, 10), new Point2D(60, 10), newSoilProfile2D, soilFilling), ExpectedExtendedSurface1 = null, ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, 60, 70, newSoilProfile2D, soil3), ExpectedExtendedSurface4 = null, ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 70, newSoilProfile2D, soil6), ExpectedSurface1 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, -50, -20, newSoilProfile2D, soil1), ExpectedSurface2 = FactoryForSoilProfiles.CreateHexagonSoilLayer2D(new Point2D(-20, 10), new Point2D(-10, 10), new Point2D(0, 9), new Point2D(0, 0),new Point2D(-10, 0), new Point2D(-20, 0), newSoilProfile2D, soil2), ExpectedSurface3 = FactoryForSoilProfiles.CreateHeptagonSoilLayer2D(new Point2D(0, 9), new Point2D(10, 8), new Point2D(30, 10), new Point2D(60, 10), new Point2D(60, 0), new Point2D(35, 0), new Point2D(0, 0), newSoilProfile2D, soil3), ExpectedSurface4 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-50, 0), new Point2D(-20, 0), new Point2D(-10, 0), new Point2D(-10, -15), new Point2D(-50, -15), newSoilProfile2D, soil4), ExpectedSurface5 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(0, 0), new Point2D(35, 0), new Point2D(35, -15), new Point2D(-10, -15), newSoilProfile2D, soil5), ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 60, newSoilProfile2D, soil6) }).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), 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([ ..new[] { 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(60, 10), new Point2D(0, 10), new Point2D(-20, 10), new Point2D(-50, 10) } ], soilFilling, newSoilProfile2D), ExpectedFilling2 = null, ExpectedExtendedSurface1 = null, ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, 60, 70, newSoilProfile2D, soil3), ExpectedExtendedSurface4 = null, ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 70, newSoilProfile2D, soil6), ExpectedSurface1 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, -50, -20, newSoilProfile2D, soil1), ExpectedSurface2 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-20, 10), new Point2D(0, 10), new Point2D(0, 0), new Point2D(-10, 0), new Point2D(-20, 0), newSoilProfile2D, soil2), ExpectedSurface3 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(0, 10), new Point2D(60, 10), new Point2D(60, 0), new Point2D(35, 0), new Point2D(0, 0), newSoilProfile2D, soil3), ExpectedSurface4 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-50, 0), new Point2D(-20, 0), new Point2D(-10, 0), new Point2D(-10, -15), new Point2D(-50, -15), newSoilProfile2D, soil4), ExpectedSurface5 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(0, 0), new Point2D(35, 0), new Point2D(35, -15), new Point2D(-10, -15), newSoilProfile2D, soil5), ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 60, newSoilProfile2D, soil6) }).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), ExpectedSurfaceCount = 8, // 2 extra surfaces created on the left side (between Z=60 and 70) ExpectedFilling1 = null, ExpectedFilling2 = null, ExpectedExtendedSurface1 = null, ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(60, 6), new Point2D(70, 5), new Point2D(70, 0), new Point2D(60, 0), newSoilProfile2D, soil3), ExpectedExtendedSurface4= null, ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 70, newSoilProfile2D, soil6), ExpectedSurface1 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-50, 5), new Point2D(-30, 7), new Point2D(-20, 6), new Point2D(-20, 0), new Point2D(-50, 0), newSoilProfile2D, soil1), ExpectedSurface2 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-20, 6), new Point2D(0, 4), new Point2D(0, 0), new Point2D(-10, 0),new Point2D(-20, 0), newSoilProfile2D, soil2), ExpectedSurface3 = FactoryForSoilProfiles.CreateHeptagonSoilLayer2D(new Point2D(0, 4), new Point2D(10, 3), new Point2D(50, 7), new Point2D(60, 6), new Point2D(60, 0), new Point2D(35, 0), new Point2D(0, 0), newSoilProfile2D, soil3), ExpectedSurface4 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-50, 0), new Point2D(-20, 0), new Point2D(-10, 0), new Point2D(-10, -15), new Point2D(-50, -15), newSoilProfile2D, soil4), ExpectedSurface5 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(0, 0), new Point2D(35, 0), new Point2D(35, -15), new Point2D(-10, -15), newSoilProfile2D, soil5), ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 60, newSoilProfile2D, soil6) }).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), 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), newSoilProfile2D, soil3), ExpectedExtendedSurface4 = null, ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 70, newSoilProfile2D, soil6), ExpectedSurface1 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(-50, 0), new Point2D(-30, 2), new Point2D(-20, 1), new Point2D(-20, 0), newSoilProfile2D, soil1), ExpectedSurface2 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(-20, 1), new Point2D(-10, 0), new Point2D(-20, 0), newSoilProfile2D, soil2), ExpectedSurface3 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(30, 0), new Point2D(50, 2), new Point2D(60, 1), new Point2D(60, 0), new Point2D(35, 0), newSoilProfile2D, soil3), ExpectedSurface4 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-50, 0), new Point2D(-20, 0), new Point2D(-10, 0), new Point2D(-10, -15), new Point2D(-50, -15), newSoilProfile2D, 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), newSoilProfile2D, soil5), ExpectedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 35, 60, newSoilProfile2D, soil6) }).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), 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), newSoilProfile2D, soilFilling), ExpectedFilling2 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(new Point2D(40, 10), new Point2D(60, 12), new Point2D(80, 10), new Point2D(60, 10), newSoilProfile2D, soilFilling), ExpectedExtendedSurface1 = null, ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, 60, 80, newSoilProfile2D, soil3), ExpectedExtendedSurface4 = null, ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 80, newSoilProfile2D, soil6), ExpectedSurface1 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, -40, -20, newSoilProfile2D, soil1), ExpectedSurface2 = null, // not null but not tested ExpectedSurface3 = null, // not null but not tested ExpectedSurface4 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-40, 0), new Point2D(-20, 0), new Point2D(-10, 0), new Point2D(-10, -15), new Point2D(-40, -15), newSoilProfile2D, soil4), ExpectedSurface5 = null, // not null but not tested ExpectedSurface6 = null // not null but not tested }).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), ExpectedSurfaceCount = 7, // Only few surfaces are tested ExpectedFilling1 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(10, 10), new Point2D(30, 12), new Point2D(50, 10), newSoilProfile2D, soilFilling), ExpectedFilling2 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(90, 10), new Point2D(110, 12), new Point2D(130, 10), newSoilProfile2D, soilFilling), ExpectedExtendedSurface1 = null, ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateHexagonSoilLayer2D(new Point2D(60, 9), new Point2D(70, 8), new Point2D(90, 10), new Point2D(130, 10), new Point2D(130, 0), new Point2D(60, 0), newSoilProfile2D, soil3), ExpectedExtendedSurface4 = null, ExpectedExtendedSurface6 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 60, 130, newSoilProfile2D, soil6), ExpectedSurface1 = null, ExpectedSurface2 = null, ExpectedSurface3 = FactoryForSoilProfiles.CreateHexagonSoilLayer2D(new Point2D(10, 10), new Point2D(50, 10), new Point2D(60, 9), new Point2D(60, 0), new Point2D(35, 0), new Point2D(10, 0), newSoilProfile2D, soil3), ExpectedSurface4 = null, ExpectedSurface5 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, 10, 35, newSoilProfile2D, soil5), ExpectedSurface6 = null // not null but not tested }).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), 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), newSoilProfile2D, soilFilling), ExpectedFilling2 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(20, 10), new Point2D(40, 12), new Point2D(60, 10), newSoilProfile2D, soilFilling), ExpectedExtendedSurface1 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, -60, -50, newSoilProfile2D, soil1), ExpectedExtendedSurface3 = null, ExpectedExtendedSurface4 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -60, -50, newSoilProfile2D, soil4), 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, newSoilProfile2D, soil6) }).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), ExpectedSurfaceCount = 9, // Only few surfaces are tested ExpectedFilling1 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(-110, 10), new Point2D(-90, 12), new Point2D(-70, 10), newSoilProfile2D, soilFilling), ExpectedFilling2 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-30, 10), new Point2D(-10, 12), new Point2D(10, 10), new Point2D(0, 10), new Point2D(-20, 10), newSoilProfile2D, soilFilling), ExpectedExtendedSurface1 = FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-110, 10), new Point2D(-70, 10), new Point2D(-50, 8), new Point2D(-50, 0), new Point2D(-110, 0), newSoilProfile2D, soil1), ExpectedExtendedSurface3 = null, ExpectedExtendedSurface4 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(0, -15, -110, -50, newSoilProfile2D, soil4), 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.CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(0, 0), new Point2D(10, 0), new Point2D(10, -15), new Point2D(-10, -15), newSoilProfile2D, soil5), ExpectedSurface6 = null }).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), 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, -7), new Point2D(150, -3), new Point2D(170, -5), new Point2D(170, -15), new Point2D(60, -15), newSoilProfile2D, soil6), 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), newSoilProfile2D, soil6) }).SetName("Test 9: Surface line starts inside surface 6 (right bottom) of the soil profile"); } } }