Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs
===================================================================
diff -u -r7049 -r7057
--- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 7049)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 7057)
@@ -128,7 +128,7 @@
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([
+ ExpectedFilling1 = FactoryForSoilProfiles.CreatePolygonSoilLayer2D([
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,
@@ -501,7 +501,7 @@
7 => FactoryForSoilProfiles.CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(0, 0), new Point2D(35, 0), new Point2D(35, -15), new Point2D(-10, -15), newSoilProfile2D, soil5),
_ => null
};
- SoilLayer2D expectedSurfaceFilling = FactoryForSoilProfiles.CreatePolygoneSoilLayer2D([
+ SoilLayer2D expectedSurfaceFilling = FactoryForSoilProfiles.CreatePolygonSoilLayer2D([
new Point2D(-50, 11), surfaceLine.CharacteristicPoints[1].Point, surfaceLine.CharacteristicPoints[2].Point, surfaceLine.CharacteristicPoints[3].Point, new Point2D(xEndSurfaceLine, 11), new Point2D(xEndSurfaceLine, 10), new Point2D(0, 10), new Point2D(-20, 10), new Point2D(-50, 10)
], defaultSoil, newSoilProfile2D);
CheckSoilProfileContainsSoilLayer(newSoilProfile2D, expectedSurface1);
@@ -520,6 +520,57 @@
}
///
+ /// This test reflects the problem found in MWDAM-3279 when creating a new soil profile with a surface line very close to the
+ /// original surface line from the soil profile.
+ ///
+ [Test]
+ [TestCase(1, 2, 2)]
+ [TestCase(0.1, 0.2, 2)]
+ [TestCase(0.01, 0.02, 2)]
+ [TestCase(0.007, 0.008, 1)]
+ [TestCase(0.001, 0.002, 1)]
+ public void GivenSoilProfile2DWithSteepOrShallowSlopeInTwoPartsAndSurfaceLineCrossingTheSlope_WhenCombiningWithSurfaceLine_ThenExpectedNewSoilProfile2DCreated(double widthLowestSlope, double widthHighestSlope,int expectedLayerCount)
+ {
+ // Given
+ SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithSteepOrShallowSlopeInTwoParts(widthLowestSlope, widthHighestSlope);
+ var defaultSoil = new Soil("Filling material");
+ GeometryPointString originalSurfaceLine = soilProfile2D.Geometry.SurfaceLine;
+ var surfaceLine = new SurfaceLine2();
+ surfaceLine.Geometry.Points.Add(originalSurfaceLine.Points[0]);
+ surfaceLine.Geometry.Points.Add(originalSurfaceLine.Points[1]);
+ surfaceLine.Geometry.Points.Add(originalSurfaceLine.Points[3]);
+ surfaceLine.Geometry.Points.Add(originalSurfaceLine.Points[4]);
+
+ // When
+ SoilProfile2D newSoilProfile2D = SoilProfile2DSurfaceLineHelper.CombineSurfaceLineWithSoilProfile2D(
+ surfaceLine.Geometry, soilProfile2D, defaultSoil);
+
+ // Then
+ Assert.That(newSoilProfile2D, Is.Not.Null);
+ Assert.That(newSoilProfile2D.Surfaces, Has.Count.EqualTo(expectedLayerCount));
+ var lineNewSurfaceLine = new Line(surfaceLine.Geometry.Points[1], surfaceLine.Geometry.Points[2]);
+ var lineSurfaceSeparation = new Line(new Point2D(widthLowestSlope, -4.15), new Point2D(10, -4.15));
+ var intersectionPoint = new Point2D();
+ Assert.That(LineHelper.DetermineStrictIntersectionPoint(lineNewSurfaceLine, lineSurfaceSeparation, ref intersectionPoint), Is.True);
+
+ if (expectedLayerCount == 2)
+ {
+ var soil1 = new Soil("Surface 1");
+ var soil2 = new Soil("Surface 2");
+ SoilLayer2D expectedSurface1 = FactoryForSoilProfiles.CreatePolygonSoilLayer2D([intersectionPoint, new Point2D(widthLowestSlope + widthHighestSlope, -4.05), new Point2D(10, -4.05), new Point2D(10, -4.15)], soil1, null);
+ SoilLayer2D expectedSurface2 = FactoryForSoilProfiles.CreatePolygonSoilLayer2D([new Point2D(-10, -4.25), new Point2D(0, -4.25), intersectionPoint, new Point2D(10, -4.15), new Point2D(10, -5), new Point2D(-10, -5)], soil2, null);
+ CheckSoilProfileContainsSoilLayer(newSoilProfile2D, expectedSurface1);
+ CheckSoilProfileContainsSoilLayer(newSoilProfile2D, expectedSurface2);
+ }
+
+ if (expectedLayerCount == 1)
+ {
+ // When the surface line is too close to the original surface line, the top surface is not generated.
+ CheckSoilProfileContainsSoilLayer(newSoilProfile2D, soilProfile2D.Surfaces[1]);
+ }
+ }
+
+ ///
/// Test case class for GivenSoilProfile2DWhenCombiningWithSurfaceLineThenCorrectNewSoilProfile2DIsCreated()
///
public class TestCaseSurfaceLine