Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs =================================================================== diff -u -r3259 -r3260 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs (.../SoilSurfaceProfile.cs) (revision 3259) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs (.../SoilSurfaceProfile.cs) (revision 3260) @@ -332,19 +332,7 @@ var pointsToConvert = xCoordinates.Select(xCoordinate => new Point2D(xCoordinate, layerTopLevel)).ToList(); pointsToConvert.AddRange(xCoordinates.Reverse().Select(xCoordinate => new Point2D(xCoordinate, layerBottomLevel)).ToArray()); - Point2D startPoint = pointsToConvert[0]; - var curves = new List(); - for (int i = 1; i < pointsToConvert.Count; i++) - { - Point2D endPoint = pointsToConvert[i]; - curves.Add(new GeometryCurve(startPoint, endPoint)); - startPoint = endPoint; - } - - // Close the geometry by connecting the first and last points with each other. - // The loop is now closed in a clock wise fashion - curves.Add(new GeometryCurve(pointsToConvert.Last(), pointsToConvert.First())); - + var curves = GenerateClosedLoopCurves(pointsToConvert); return new LayerData(pointsToConvert, curves, soilLayer.Soil, soilLayer.IsAquifer, soilLayer.WaterpressureInterpolationModel); } @@ -433,6 +421,17 @@ } } + var curves = GenerateClosedLoopCurves(pointsToConvert); + return new LayerData(pointsToConvert, curves, soilLayer.Soil, soilLayer.IsAquifer, soilLayer.WaterpressureInterpolationModel); + } + + /// + /// Generates curves that define a clockwise closed loop based on a collection of points. + /// + /// The collection points to generate a curve collection for. + /// A collection of . + private static IEnumerable GenerateClosedLoopCurves(List pointsToConvert) + { Point2D startPoint = pointsToConvert[0]; var curves = new List(); for (int i = 1; i < pointsToConvert.Count; i++) @@ -445,8 +444,7 @@ // Close the geometry by connecting the first and last points with each other // This closes the outer loop in a clockwise definition. curves.Add(new GeometryCurve(pointsToConvert.Last(), pointsToConvert.First())); - - return new LayerData(pointsToConvert, curves, soilLayer.Soil, soilLayer.IsAquifer, soilLayer.WaterpressureInterpolationModel); + return curves; } ///