Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilSurfaceProfileTests.cs =================================================================== diff -u -r3236 -r3237 --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilSurfaceProfileTests.cs (.../SoilSurfaceProfileTests.cs) (revision 3236) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilSurfaceProfileTests.cs (.../SoilSurfaceProfileTests.cs) (revision 3237) @@ -24,6 +24,7 @@ using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Data.Standard; +using Deltares.DamEngine.TestHelpers; using Deltares.DamEngine.TestHelpers.Factories; using NUnit.Framework; @@ -58,6 +59,7 @@ } [Test] + [Category(Categories.WorkInProgress)] public void ConvertToSoilProfile2D_WithSurfaceLineFullyAboveSoilLayers_SetsCorrectSurfacesAndGeometry() { // Setup @@ -182,6 +184,76 @@ }, bottomSurface.CurveList); } + [Test] + [Category(Categories.WorkInProgress)] + public void ConvertToSoilProfile2D_WithSurfaceLinePartiallyEnvelopedByTopSoilLayer_SetsCorrectSurfacesAndGeometry() + { + // Setup + const string bottomLayerName = "BottomLayer"; + const string middleLayerName = "MiddleLayer"; + const string topLayerName = "TopLayer"; + + var profile = new SoilProfile1D + { + BottomLevel = -10 + }; + profile.Layers.Add(CreateSoilLayer(-5, bottomLayerName)); + profile.Layers.Add(CreateSoilLayer(0, middleLayerName)); + + SurfaceLine2 surfaceLine = CreateSurfaceLine(new[] + { + new GeometryPoint(0, -2.5), + new GeometryPoint(5, 2.5), + new GeometryPoint(10, -2.5) + }); + + var soilSurfaceProfile = new SoilSurfaceProfile + { + SoilProfile = profile, + SurfaceLine2 = surfaceLine, + DikeEmbankmentMaterial = new Soil + { + Name = topLayerName + } + }; + + // Call + soilSurfaceProfile.ConvertToSoilProfile2D(); + + // Assert + var soilLayer2Ds = soilSurfaceProfile.Surfaces; + Assert.That(soilLayer2Ds, Has.Count.EqualTo(3)); + + GeometryLoop topSurface = soilLayer2Ds.Single(l => string.Equals(l.Name, topLayerName)).GeometrySurface.OuterLoop; + AssertGeometry(new[] + { + new GeometryCurve(new Point2D(2.5, 0), new Point2D(5, 2.5)), + new GeometryCurve(new Point2D(5, 2.5), new Point2D(7.5, 0)), + new GeometryCurve(new Point2D(7.5, 0), new Point2D(2.5, 0)) + }, topSurface.CurveList); + + GeometryLoop middleSurface = soilLayer2Ds.Single(l => string.Equals(l.Name, middleLayerName)).GeometrySurface.OuterLoop; + AssertGeometry(new[] + { + new GeometryCurve(new Point2D(0, -5), new Point2D(0, -2.5)), + new GeometryCurve(new Point2D(0, -2.5), new Point2D(2.5, 0)), + new GeometryCurve(new Point2D(2.5, 0), new Point2D(7.5, 0)), + new GeometryCurve(new Point2D(7.5, 0), new Point2D(10, -2.5)), + new GeometryCurve(new Point2D(10, -2.5), new Point2D(10, -5)), + new GeometryCurve(new Point2D(10, -5), new Point2D(0, -5)), + new GeometryCurve(new Point2D(0, -5), new Point2D(0, -2.5)) + }, middleSurface.CurveList); + + GeometryLoop bottomSurface = soilLayer2Ds.Single(l => string.Equals(l.Name, bottomLayerName)).GeometrySurface.OuterLoop; + AssertGeometry(new[] + { + new GeometryCurve(new Point2D(0, -5), new Point2D(10, -5)), + new GeometryCurve(new Point2D(10, -5), new Point2D(10, -10)), + new GeometryCurve(new Point2D(10, -10), new Point2D(0, -10)), + new GeometryCurve(new Point2D(0, -10), new Point2D(0, -5)) + }, bottomSurface.CurveList); + } + private static void AssertGeometry(IEnumerable expectedCurves, IEnumerable actualCurves) { int nrOfExpectedCurves = expectedCurves.Count(); @@ -192,7 +264,7 @@ foreach (GeometryCurve expectedCurve in expectedCurves) { Assert.That(actualCurves.Any(c => c.LocationEquals(expectedCurve)), Is.True, - $"Expected curve ({expectedCurve.HeadPoint.X}, {expectedCurve.HeadPoint.Z}) --> ({expectedCurve.EndPoint.X}, {expectedCurve.EndPoint.Z}) not found." + + $"Expected curve ({expectedCurve.HeadPoint.X}, {expectedCurve.HeadPoint.Z}) --> ({expectedCurve.EndPoint.X}, {expectedCurve.EndPoint.Z}) not found. " + $"Actual curves {string.Join(", ", actualCurveString)}"); } }