Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs =================================================================== diff -u -r5102 -r5104 --- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs (.../FactoryForSoilProfiles.cs) (revision 5102) +++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs (.../FactoryForSoilProfiles.cs) (revision 5104) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using System.Linq; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; @@ -1095,10 +1096,10 @@ }; SoilLayer2D soilLayer1 = CreateRectangularSoilLayer2D(10, 0, -50, -20, "Surface 1", soilProfile2D); - SoilLayer2D soilLayer2 = CreateRectangularSoilLayer2D(10, 0, -20, 0, "Surface 2", soilProfile2D); - SoilLayer2D soilLayer3 = CreateRectangularSoilLayer2D(10, 0, 0, 60, "Surface 3", soilProfile2D); - SoilLayer2D soilLayer4 = CreateRectangularSoilLayer2D(0, -15, -50, -10, "Surface 4", soilProfile2D); - SoilLayer2D soilLayer5 = CreateRectangularSoilLayer2D(0, -15, -10, 35, "Surface 5", soilProfile2D); + SoilLayer2D soilLayer2 = CreatePentagonSoilLayer2D(new Point2D(-20, 10), new Point2D(0, 10), new Point2D(0, 0), new Point2D(-10, 0), new Point2D(-20, 0), "Surface 2", soilProfile2D); + SoilLayer2D soilLayer3 = CreatePentagonSoilLayer2D(new Point2D(0, 10), new Point2D(60, 10), new Point2D(60, 0), new Point2D(35, 0), new Point2D(0, 0), "Surface 3", soilProfile2D); + SoilLayer2D soilLayer4 = CreatePentagonSoilLayer2D(new Point2D(-50, 0), new Point2D(-20, 0), new Point2D(-10, 0), new Point2D(-10, -15), new Point2D(-50, -15), "Surface 4", soilProfile2D); + SoilLayer2D soilLayer5 = CreatePentagonSoilLayer2D(new Point2D(-10, 0), new Point2D(0, 0), new Point2D(35, 0), new Point2D(35, -15), new Point2D(-10, -15), "Surface 5", soilProfile2D); SoilLayer2D soilLayer6 = CreateRectangularSoilLayer2D(0, -15, 35, 60, "Surface 6", soilProfile2D); soilProfile2D.Surfaces.Add(soilLayer1); @@ -1143,14 +1144,14 @@ if (soilProfile2D != null) { - soilProfile2D.Geometry.Points.Add(topLeftPoint); - soilProfile2D.Geometry.Points.Add(topRightPoint); - soilProfile2D.Geometry.Points.Add(bottomRightPoint); - soilProfile2D.Geometry.Points.Add(bottomLeftPoint); - soilProfile2D.Geometry.Curves.Add(curve1); - soilProfile2D.Geometry.Curves.Add(curve2); - soilProfile2D.Geometry.Curves.Add(curve3); - soilProfile2D.Geometry.Curves.Add(curve4); + AddPointIfNotYetPresentInGeometry(soilProfile2D, topLeftPoint); + AddPointIfNotYetPresentInGeometry(soilProfile2D, topRightPoint); + AddPointIfNotYetPresentInGeometry(soilProfile2D, bottomRightPoint); + AddPointIfNotYetPresentInGeometry(soilProfile2D, bottomLeftPoint); + AddCurvefNotYetPresentInGeometry(soilProfile2D, curve1); + AddCurvefNotYetPresentInGeometry(soilProfile2D, curve2); + AddCurvefNotYetPresentInGeometry(soilProfile2D, curve3); + AddCurvefNotYetPresentInGeometry(soilProfile2D, curve4); } return new SoilLayer2D @@ -1214,8 +1215,29 @@ }; } - public static SoilLayer2D CreatePentagonSoilLayer2D(Point2D point1, Point2D point2, Point2D point3, Point2D point4, Point2D point5, string soilName) + public static SoilLayer2D CreatePentagonSoilLayer2D(Point2D point1, Point2D point2, Point2D point3, Point2D point4, Point2D point5, string soilName, SoilProfile2D soilProfile2D = null) { + var curve1 = new GeometryCurve(point1, point2); + var curve2 = new GeometryCurve(point2, point3); + var curve3 = new GeometryCurve(point3, point4); + var curve4 = new GeometryCurve(point4, point5); + var curve5 = new GeometryCurve(point5, point1); + + if (soilProfile2D != null) + { + AddPointIfNotYetPresentInGeometry(soilProfile2D, point1); + AddPointIfNotYetPresentInGeometry(soilProfile2D, point2); + AddPointIfNotYetPresentInGeometry(soilProfile2D, point3); + AddPointIfNotYetPresentInGeometry(soilProfile2D, point4); + AddPointIfNotYetPresentInGeometry(soilProfile2D, point5); + + AddCurvefNotYetPresentInGeometry(soilProfile2D, curve1); + AddCurvefNotYetPresentInGeometry(soilProfile2D, curve2); + AddCurvefNotYetPresentInGeometry(soilProfile2D, curve3); + AddCurvefNotYetPresentInGeometry(soilProfile2D, curve4); + AddCurvefNotYetPresentInGeometry(soilProfile2D, curve5); + } + return new SoilLayer2D { GeometrySurface = new GeometrySurface @@ -1224,11 +1246,11 @@ { CurveList = { - new GeometryCurve(point1, point2), - new GeometryCurve(point2, point3), - new GeometryCurve(point3, point4), - new GeometryCurve(point4, point5), - new GeometryCurve(point5, point1) + curve1, + curve2, + curve3, + curve4, + curve5 } } }, @@ -1282,4 +1304,23 @@ SoilName = soilName }; } + + private static void AddPointIfNotYetPresentInGeometry(SoilProfile2D soilProfile, Point2D point) + { + if (!soilProfile.Geometry.Points.Any(p => p.X.IsNearEqual(point.X) && p.Z.IsNearEqual(point.Z))) + { + soilProfile.Geometry.Points.Add(point); + } + } + + private static void AddCurvefNotYetPresentInGeometry(SoilProfile2D soilProfile, GeometryCurve curve) + { + if (!soilProfile.Geometry.Curves.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)))) + { + soilProfile.Geometry.Curves.Add(curve); + } + } } \ No newline at end of file