Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs =================================================================== diff -u -r3257 -r3258 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs (.../SoilSurfaceProfile.cs) (revision 3257) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilSurfaceProfile.cs (.../SoilSurfaceProfile.cs) (revision 3258) @@ -142,217 +142,6 @@ } /// - /// Make sure that the top layer of the 1D profile is above the surface line by adding extra layer if needed using the dike material when needed. - /// - private void EnsureAvailabilityOfMaterialForNew2DGeometry() - { - if (soilProfile != null && surfaceLine2.Geometry != null) - { - double topSurfaceLine = surfaceLine2.Geometry.GetMaxZ(); - if (!double.IsNaN(topSurfaceLine) && (soilProfile.Layers.Count == 0 || soilProfile.TopLevel < topSurfaceLine)) - { - double newTopLevel = topSurfaceLine + 0.5; - - if (soilProfile.Layers.Count > 0 && soilProfile.Layers[0].Soil == DikeEmbankmentMaterial) - { - SoilLayer1D dikeMaterialLayer = soilProfile.Layers[0]; - dikeMaterialLayer.TopLevel = newTopLevel; - } - else - { - // Add toplayer of dikematerial - var newLayer = new SoilLayer1D - { - TopLevel = newTopLevel, - Soil = DikeEmbankmentMaterial, - }; - - // special handling for dummy soil profiles - if (soilProfile.Layers.Count == 0 && DikeEmbankmentMaterial == null) - { - soilProfile.BottomLevel = surfaceLine2.Geometry.GetMinZ() - 1; - } - - soilProfile.Layers.Insert(0, newLayer); - soilProfile.EnsureLastLayerHasHeight(); - } - } - } - } - - /// - /// Adds the layer geometry. - /// - /// The data. - /// The layer. - /// The minimum x. - /// The maximum x. - private static void Add2DLayerToGeometry(GeometryData data, SoilLayer1D layer, double minX, double maxX) - { - var top = layer.TopLevel; - var bottom = layer.BottomLevel; - - if (Math.Abs(layer.BottomLevel - layer.SoilProfile.BottomLevel) < GeometryConstants.Accuracy) - { - bottom = data.Bottom; - } - - var bottomLeft = new Point2D(minX, bottom); - var bottomRight = new Point2D(maxX,bottom); - var topLeft = new Point2D(minX, top); - var topRight = new Point2D(maxX, top); - - data.Points.Add(bottomLeft); - data.Points.Add(bottomRight); - data.Points.Add(topLeft); - data.Points.Add(topRight); - - data.Curves.Add(new GeometryCurve(bottomLeft, bottomRight)); - data.Curves.Add(new GeometryCurve(bottomRight, topRight)); - data.Curves.Add(new GeometryCurve(topRight, topLeft)); - data.Curves.Add(new GeometryCurve(topLeft, bottomLeft)); - } - - private GeometryPointString GetClonedSurfaceLineWithIntersections() - { - var locsurfaceline = surfaceLine2.Geometry.Clone(); - var intersectionPoints = new List(); - var bounds = surfaceLine2.Geometry.GetGeometryBounds(); - double minX = bounds.Left; - double maxX = bounds.Right; - foreach (var locGeometryCurve in originalSoilProfile1D.Layers) - { - var line = new Line - { - BeginPoint = new Point2D(minX - 5, locGeometryCurve.TopLevel), - EndPoint = new Point2D(maxX + 5, locGeometryCurve.TopLevel) - }; - foreach (var point2D in locsurfaceline.IntersectionPointsXzWithLineXz(line)) - { - intersectionPoints.Add(new GeometryPoint(point2D.X, point2D.Z)); - } - } - locsurfaceline.Points.AddRange(intersectionPoints); - locsurfaceline.SortPointsByXAscending(); - locsurfaceline.RemoveNonAscendingPointsOnSurfaceLine(); - return locsurfaceline; - } - - private GeometryPointString AddSurfaceLineToGeometry(GeometryData data) - { - var locSurfaceLine = GetClonedSurfaceLineWithIntersections(); - locSurfaceLine.SyncCalcPoints(); - var currentPoint = locSurfaceLine.CalcPoints[0]; - data.Points.Add(currentPoint); - for (int i = 1; i < locSurfaceLine.CalcPoints.Count; ++i) - { - var previousPoint = currentPoint; - currentPoint = locSurfaceLine.CalcPoints[i]; - - data.Points.Add(currentPoint); - data.Curves.Add(new GeometryCurve(previousPoint, currentPoint)); - } - - return locSurfaceLine; - } - - private void BuildGeometryModel() - { - if (surfaceLine2.Geometry == null - || soilProfile == null - || soilProfile.Layers.Count == 0 - || surfaceLine2.Geometry.GetMaxZ() < soilProfile.BottomLevel - || surfaceLine2.Geometry.Points.Count < 2) - { - return; - } - - var bounds = surfaceLine2.Geometry.GetGeometryBounds(); - double minX = bounds.Left; - double maxX = bounds.Right; - - Geometry.Clear(); - Geometry.Left = minX; - Geometry.Right = maxX; - Geometry.Bottom = Math.Min(soilProfile.BottomLevel, surfaceLine2.Geometry.GetMinZ() - 1); - - // add 1D profile layers as 2D layers (points and curves) to geometry - soilProfile.Layers.Sort(); - foreach (var layer in soilProfile.Layers) - { - Add2DLayerToGeometry(Geometry, layer, minX, maxX); - } - - // add surface line as points and curves to geometry, return the geometry of the surface line with the intersection points - var localSurfaceLineGeometry = AddSurfaceLineToGeometry(Geometry); - - // Remove all points and curve above the surface line - RemoveGeometryDataAboveSurfaceLine(localSurfaceLineGeometry); - - // Add curves from start and end of surface line to top layer. - Geometry.Curves.Add(new GeometryCurve(Geometry.Points[0], localSurfaceLineGeometry.CalcPoints[0])); - Geometry.Curves.Add(new GeometryCurve(Geometry.Points[1], localSurfaceLineGeometry.CalcPoints.Last())); - - // Now regenerate surfaces based on added points and curves - Geometry.NewlyEffectedPoints.AddRange(Geometry.Points); - Geometry.NewlyEffectedCurves.AddRange(Geometry.Curves); - Geometry.RegenerateGeometry(); - } - - private void RebuildSurfaces(GeometryData locGeometry) - { - Surfaces.Clear(); - if (locGeometry == null || surfaceLine2.Geometry == null) - { - return; - } - foreach (var geometrySurface in locGeometry.Surfaces) - { - var bounds = geometrySurface.GetGeometryBounds(); - var z = (bounds.Top + bounds.Bottom) * 0.5; - - var soilLayer = soilProfile.GetLayerAt(z); - - if (soilLayer != null) - { - Surfaces.Add(new SoilLayer2D - { - GeometrySurface = geometrySurface, - IsAquifer = soilLayer.IsAquifer, - WaterpressureInterpolationModel = soilLayer.WaterpressureInterpolationModel, - Soil = soilLayer.Soil - }); - } - } - } - - /// - /// Removes the geometry data above surface line. - /// - /// The surface line. - private void RemoveGeometryDataAboveSurfaceLine(GeometryPointString surfaceLine) - { - // remove all points and attached curves that are above the surfaceline. - if (surfaceLine != null && Geometry.Curves.Count > 1) - { - var pointsToDelete = new List(); - foreach (var point in Geometry.Points.ToArray()) - { - // See if point is above surface line and if so remove it with its belonging curves - if (surfaceLine.GetZatX(point.X) < point.Z - GeometryConstants.Accuracy) - { - pointsToDelete.Add(point); - } - } - // finally remove points with their belonging curves - foreach (var pointToDelete in pointsToDelete) - { - Geometry.DeletePointWithCurves(pointToDelete); - } - } - } - - /// /// Gets the collection of to convert based on the input arguments. /// /// The to retrieve the layers for. @@ -662,15 +451,6 @@ BuildGeometryModel(Geometry, layerData, originalSoilProfile1D, surfaceLine2); BuildSoilLayer2D(Surfaces, layerData, Geometry); - -// if (originalSoilProfile1D != null) -// { -// soilProfile = (SoilProfile1D)originalSoilProfile1D.Clone(); -// -// EnsureAvailabilityOfMaterialForNew2DGeometry(); -// BuildGeometryModel(); -// RebuildSurfaces(Geometry); -// } }