Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs =================================================================== diff -u -r3268 -r3269 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs (.../SoilSurfaceProfile.cs) (revision 3268) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs (.../SoilSurfaceProfile.cs) (revision 3269) @@ -151,9 +151,10 @@ var localSurfaceLinePoints = GetLocalSurfaceLinePoints(filteredSoilLayers, surfaceLine2); var layerData = CreateLayerData(filteredSoilLayers, localSurfaceLinePoints); + var filteredLayerData = FilterLayerDataWithClosedLoops(layerData); - BuildGeometryModel(Geometry, layerData, originalSoilProfile1D, surfaceLine2, localSurfaceLinePoints); - AssignSoilLayer2DProperties(Surfaces, layerData, Geometry); + BuildGeometryModel(Geometry, filteredLayerData, originalSoilProfile1D, surfaceLine2, localSurfaceLinePoints); + AssignSoilLayer2DProperties(Surfaces, filteredLayerData, Geometry); } private static void BuildGeometryModel(GeometryData geometryData, @@ -333,12 +334,22 @@ return layerData; } + + /// + /// Filters layer data that consist of closed loops. + /// + /// The collection of to filter. + /// A collection of that define a closed loop. + private static IEnumerable FilterLayerDataWithClosedLoops(IEnumerable layerData) + { + return layerData.Where(l => l.Curves.Count() > 2); + } /// /// Creates a 2D soil layer with points at . /// /// The to create the 2D soil layer for. - /// The collection of x coordinates to define the 2D soil layer for. + /// The collection of that defines the surface line. /// A based on the input arguments. private static LayerData CreateSurfaceLineWideSoilLayer(SoilLayer1D soilLayer, IEnumerable surfaceLinePoints) { @@ -358,9 +369,8 @@ /// Creates a 2D soil layer with points at based on its input arguments. /// /// The to create the 2D soil layer for. - /// The collection of x coordinates to define the 2D soil layer for. + /// The collection of that defines the surface line. /// A collection of based on the input arguments. - /// The collection only contains with non-empty coordinates. private static IEnumerable CreateSoilLayerWithSurfaceLineIntersection(SoilLayer1D soilLayer, IEnumerable surfaceLinePoints) { // Surface cannot be determined if there are not at least 2 coordinates @@ -383,9 +393,9 @@ { Point2D currentPoint = pointsArray[i]; double xCoordinate = currentPoint.X; - - double nextSurfaceLineZCoordinate = pointsArray[j].Z; double zCoordinateSurfaceLine = currentPoint.Z; + double nextSurfaceLineZCoordinate = pointsArray[j].Z; + double currentZCoordinate = zCoordinateSurfaceLine; if (zCoordinateSurfaceLine > layerTopLevel) { @@ -442,7 +452,7 @@ var pointsToConvert = new List(area.Coordinates); // Determine the additional points need to be added to close the area - // The area ends at the top right point. Go clockwise to close the area if necessary by adding + // The area ends at the top right point. Go clockwise to close the area by adding // points corresponding to the layer bottom level. var pointsToTraverse = area.Coordinates.Reverse(); foreach (Point2D point in pointsToTraverse) @@ -463,7 +473,7 @@ /// /// The collection points to generate a curve collection for. /// A collection of . - private static IEnumerable GenerateCurves(List pointsToConvert) + private static IEnumerable GenerateCurves(IReadOnlyList pointsToConvert) { Point2D startPoint = pointsToConvert[0]; var curves = new List(); @@ -482,7 +492,7 @@ /// /// The collection points to generate a curve collection for. /// A collection of . - private static IEnumerable GenerateClosedLoopCurves(List pointsToConvert) + private static IEnumerable GenerateClosedLoopCurves(IReadOnlyList pointsToConvert) { var curves = GenerateCurves(pointsToConvert).ToList();