Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs =================================================================== diff -u -r3260 -r3261 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs (.../SoilSurfaceProfile.cs) (revision 3260) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs (.../SoilSurfaceProfile.cs) (revision 3261) @@ -142,7 +142,8 @@ } /// - /// Updates the layers. + /// Function to create and update the , + /// based on a 1D profile and a surface line. /// private void Create2DGeometryBasedOn1DProfileAndSurfaceLine() { @@ -152,11 +153,10 @@ var layerData = CreateLayerData(filteredSoilLayers, surfaceLine2, xCoordinatesToTraverse); BuildGeometryModel(Geometry, layerData, originalSoilProfile1D, surfaceLine2); - BuildSoilLayer2D(Surfaces, layerData, Geometry); + AssignSoilLayer2DProperties(Surfaces, layerData, Geometry); } - - private void BuildGeometryModel(GeometryData geometryData, + private static void BuildGeometryModel(GeometryData geometryData, IEnumerable layers, SoilProfile1D profile, SurfaceLine2 surfaceLine) @@ -177,7 +177,7 @@ geometryData.Clear(); geometryData.Left = minX; geometryData.Right = maxX; - geometryData.Bottom = Math.Min(profile.BottomLevel, surfaceLine2.Geometry.GetMinZ() - 1); + geometryData.Bottom = Math.Min(profile.BottomLevel, surfaceLine.Geometry.GetMinZ() - 1); var pointsToBeAdded = layers.SelectMany(l => l.Points); var curvesToBeAdded = layers.SelectMany(l => l.Curves); @@ -186,21 +186,23 @@ geometryData.RegenerateGeometry(); } - private void BuildSoilLayer2D(ICollection soilLayer2Ds, + private static void AssignSoilLayer2DProperties(ICollection surfaces, IEnumerable layers, GeometryData geometryData) { - soilLayer2Ds.Clear(); + surfaces.Clear(); foreach (GeometrySurface surface in geometryData.Surfaces) { GeometryBounds bounds = surface.GetGeometryBounds(); double z = (bounds.Top + bounds.Bottom) * 0.5; + // Get the corresponding layer data. This assumption only holds + // because each z coordinate contains ONE single layer definition. LayerData layerData = layers.FirstOrDefault(l => l.IsZLocatedInLayer(z)); if (layerData != null) { - Surfaces.Add(new SoilLayer2D + surfaces.Add(new SoilLayer2D { GeometrySurface = surface, IsAquifer = layerData.IsAquifer, @@ -322,6 +324,12 @@ return layerData; } + /// + /// 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. + /// A based on the input arguments. private static LayerData CreateSurfaceLineWideSoilLayer(SoilLayer1D soilLayer, IEnumerable xCoordinates) { // A single square definition does not suffice for the area definition. The @@ -336,6 +344,14 @@ return new LayerData(pointsToConvert, curves, soilLayer.Soil, soilLayer.IsAquifer, soilLayer.WaterpressureInterpolationModel); } + /// + /// Creates a 2D soil layer with points at based on its input arguments. + /// + /// The to create the 2D soil layer for. + /// The surface line to create the 2D soil layer with. + /// The collection of x coordinates to define the 2D soil layer for. + /// A collection of based on the input arguments. + /// The collection only contains with non-empty coordinates. private static IEnumerable CreateSoilLayerWithSurfaceLineIntersection(SoilLayer1D soilLayer, SurfaceLine2 surfaceLine, IEnumerable xCoordinates) { @@ -374,7 +390,7 @@ // Determine if a new area should be started. This should only happen when: if (previousZCoordinate > layerBottomLevel // The area already started above or at the soil layer bottom - && zCoordinateSurfaceLine < previousZCoordinate // The surface line has a decreasing trend wrt the previous z coordinate + && zCoordinateSurfaceLine < previousZCoordinate // The surface line has a decreasing trend w.r.t. the previous z coordinate && zCoordinateSurfaceLine <= layerBottomLevel) // The surface line crossed the bottom of the layer { enclosedAreas.Add(currentArea);