Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs
===================================================================
diff -u -r6245 -r6404
--- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 6245)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 6404)
@@ -1,4 +1,4 @@
-// Copyright (C) Stichting Deltares 2024. All rights reserved.
+// Copyright (C) Stichting Deltares 2025. All rights reserved.
//
// This file is part of the Dam Engine.
//
@@ -81,304 +81,17 @@
new Point2D(5, 9),
new Point2D(10, 11)
}),
- SurfaceCount = 5,
+ 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.Points.First();
- var leftPoint = new Point2D(geometryPoint.X, geometryPoint.Z);
- geometryPoint = soilProfile2D.Geometry.SurfaceLine.Points.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.Points.Select(p => p.X).OrderBy(x => x).Distinct().ToArray();
- double[] zMin = expectedSoilLayer.GeometrySurface.OuterLoop.Points.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.Points, Has.Count.EqualTo(expectedSoilLayer.GeometrySurface.OuterLoop.Points.Count));
- Assert.That(soilProfile2D.Geometry.Surfaces[indexLayer].OuterLoop.CurveList, Has.Count.EqualTo(expectedSoilLayer.GeometrySurface.OuterLoop.CurveList.Count));
- Assert.That(soilProfile2D.Surfaces[indexLayer].GeometrySurface.OuterLoop.Points, Has.Count.EqualTo(expectedSoilLayer.GeometrySurface.OuterLoop.Points.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.Points)
- {
- Assert.That(IsPointPresentInSoilLayer(soilProfile2D.Surfaces[indexLayer], point), Is.True);
- }
- }
-
- private static bool IsPointPresentInSoilLayer(SoilLayer2D soilLayer, Point2D point)
- {
- return soilLayer.GeometrySurface.OuterLoop.Points.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.Points, Has.Count.EqualTo(8));
- Assert.Multiple(() =>
- {
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[0].X, Is.EqualTo(10));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[0].Z, Is.EqualTo(10));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[1].X, Is.EqualTo(30));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[1].Z, Is.EqualTo(12));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[2].X, Is.EqualTo(50));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[2].Z, Is.EqualTo(10));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[3].X, Is.EqualTo(60));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[3].Z, Is.EqualTo(9));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[4].X, Is.EqualTo(70));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[4].Z, Is.EqualTo(8));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[5].X, Is.EqualTo(90));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[5].Z, Is.EqualTo(10));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[6].X, Is.EqualTo(110));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[6].Z, Is.EqualTo(12));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[7].X, Is.EqualTo(130));
- Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[7].Z, Is.EqualTo(10));
- });
- }
- }
-
-
private static IEnumerable ZigZagSurfaceLinesTestCases
{
get
{
- SoilProfile2D newSoilProfile2D = new SoilProfile2D();
+ var newSoilProfile2D = new SoilProfile2D();
var soil1 = new Soil("Soil1");
var soil2 = new Soil("Soil2");
var soil3 = new Soil("Soil3");
@@ -391,7 +104,7 @@
{
TestNumber = 1,
GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, 10),
- ExpectedSurfaceCount = 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),
@@ -400,21 +113,20 @@
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),
+ 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()
+ new TestCaseZigZagSurfaceLine
{
TestNumber = 2,
GivenZigZagSurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineInZigZag(-50, 13),
- ExpectedSurfaceCount = 9,
+ 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[]
@@ -433,7 +145,7 @@
], soilFilling, newSoilProfile2D),
ExpectedFilling2 = null,
ExpectedExtendedSurface1 = null,
- ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(10, 0, 60, 70, newSoilProfile2D, soil3),
+ 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),
@@ -444,29 +156,29 @@
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,
+ 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,
+ 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),
+ 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
{
@@ -477,18 +189,18 @@
ExpectedFilling1 = null,
ExpectedFilling2 = null,
ExpectedExtendedSurface1 = null,
- ExpectedExtendedSurface3 = FactoryForSoilProfiles.CreateTriangularSoilLayer2D(new Point2D(60, 1), new Point2D(70, 0), new Point2D(60, 0), newSoilProfile2D, soil3),
+ 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),
+ 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
{
@@ -510,7 +222,7 @@
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
{
@@ -524,15 +236,15 @@
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,
+ 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,
+ 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
{
@@ -554,7 +266,7 @@
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
{
@@ -573,10 +285,10 @@
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
+ 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
{
@@ -591,13 +303,298 @@
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,
+ 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");
-
}
}
+ [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));
+ }
+
+ [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.Points, Has.Count.EqualTo(8));
+ Assert.Multiple(() =>
+ {
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[0].X, Is.EqualTo(10));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[0].Z, Is.EqualTo(10));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[1].X, Is.EqualTo(30));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[1].Z, Is.EqualTo(12));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[2].X, Is.EqualTo(50));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[2].Z, Is.EqualTo(10));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[3].X, Is.EqualTo(60));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[3].Z, Is.EqualTo(9));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[4].X, Is.EqualTo(70));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[4].Z, Is.EqualTo(8));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[5].X, Is.EqualTo(90));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[5].Z, Is.EqualTo(10));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[6].X, Is.EqualTo(110));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[6].Z, Is.EqualTo(12));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[7].X, Is.EqualTo(130));
+ Assert.That(newSoilProfile2D.Geometry.SurfaceLine.Points[7].Z, Is.EqualTo(10));
+ });
+ }
+ }
+
+ ///
+ /// 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.Points.First();
+ var leftPoint = new Point2D(geometryPoint.X, geometryPoint.Z);
+ geometryPoint = soilProfile2D.Geometry.SurfaceLine.Points.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.Points.Select(p => p.X).OrderBy(x => x).Distinct().ToArray();
+ double[] zMin = expectedSoilLayer.GeometrySurface.OuterLoop.Points.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.Points, Has.Count.EqualTo(expectedSoilLayer.GeometrySurface.OuterLoop.Points.Count));
+ Assert.That(soilProfile2D.Geometry.Surfaces[indexLayer].OuterLoop.CurveList, Has.Count.EqualTo(expectedSoilLayer.GeometrySurface.OuterLoop.CurveList.Count));
+ Assert.That(soilProfile2D.Surfaces[indexLayer].GeometrySurface.OuterLoop.Points, Has.Count.EqualTo(expectedSoilLayer.GeometrySurface.OuterLoop.Points.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.Points)
+ {
+ Assert.That(IsPointPresentInSoilLayer(soilProfile2D.Surfaces[indexLayer], point), Is.True);
+ }
+ }
+
+ private static bool IsPointPresentInSoilLayer(SoilLayer2D soilLayer, Point2D point)
+ {
+ return soilLayer.GeometrySurface.OuterLoop.Points.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)));
+ }
}
\ No newline at end of file