Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfileHelper.cs
===================================================================
diff -u -r4000 -r4052
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfileHelper.cs (.../SoilProfileHelper.cs) (revision 4000)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfileHelper.cs (.../SoilProfileHelper.cs) (revision 4052)
@@ -19,74 +19,73 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-namespace Deltares.DamEngine.Data.Geotechnics
+namespace Deltares.DamEngine.Data.Geotechnics;
+
+///
+/// Helper class for Soil profile
+///
+public class SoilProfileHelper
{
///
- /// Helper class for Soil profile
+ /// Determines for surface line corrected1 d profile at x.
///
- public class SoilProfileHelper
+ /// The original soil profile1 d.
+ /// The surface line.
+ /// The x coordinate.
+ /// The dike embankment material.
+ ///
+ public static SoilProfile1D DetermineForSurfaceLineCorrected1DProfileAtX(SoilProfile1D originalSoilProfile1D,
+ SurfaceLine2 surfaceLine, double xCoordinate, Soil dikeEmbankmentMaterial)
{
- ///
- /// Determines for surface line corrected1 d profile at x.
- ///
- /// The original soil profile1 d.
- /// The surface line.
- /// The x coordinate.
- /// The dike embankment material.
- ///
- public static SoilProfile1D DetermineForSurfaceLineCorrected1DProfileAtX(SoilProfile1D originalSoilProfile1D,
- SurfaceLine2 surfaceLine, double xCoordinate, Soil dikeEmbankmentMaterial)
+ var soilProfile = new SoilProfile1D();
+ soilProfile.Assign(originalSoilProfile1D);
+ double top = surfaceLine.Geometry.GetZatX(xCoordinate);
+ if (soilProfile.TopLevel < top)
{
- var soilProfile = new SoilProfile1D();
- soilProfile.Assign(originalSoilProfile1D);
- double top = surfaceLine.Geometry.GetZatX(xCoordinate);
- if (soilProfile.TopLevel < top)
+ var topLayer = new SoilLayer1D
{
- var topLayer = new SoilLayer1D
- {
- TopLevel = top,
- Soil = dikeEmbankmentMaterial,
- SoilProfile = soilProfile,
- BottomLevel = soilProfile.TopLevel
- };
- soilProfile.Layers.Insert(0, topLayer);
- }
- // Todo #Bka: I believe this code should be here to ensure you do not take soil above surface line into account.
- // Todo However, it causes a series of errors in the tests which I do not get. Have to look at that together with Tom
- // else if (soilProfile.TopLevel > top)
- // {
- // var bottom = RemoveLayersAboveTop(originalSoilProfile1D.LayerCount, soilProfile, top);
- // var topLayer = new SoilLayer1D
- // {
- // TopLevel = top,
- // Soil = originalSoilProfile1D.Layers[bottom].Soil,
- // SoilProfile = soilProfile,
- // IsAquifer = originalSoilProfile1D.Layers[bottom].IsAquifer,
- // BottomLevel = originalSoilProfile1D.Layers[bottom].BottomLevel
- // };
- // soilProfile.Layers.Insert(0, topLayer);
- // }
-
- soilProfile.BottomLevel = originalSoilProfile1D.BottomLevel;
- return soilProfile;
+ TopLevel = top,
+ Soil = dikeEmbankmentMaterial,
+ SoilProfile = soilProfile,
+ BottomLevel = soilProfile.TopLevel
+ };
+ soilProfile.Layers.Insert(0, topLayer);
}
+ // Todo #Bka: I believe this code should be here to ensure you do not take soil above surface line into account.
+ // Todo However, it causes a series of errors in the tests which I do not get. Have to look at that together with Tom
+ // else if (soilProfile.TopLevel > top)
+ // {
+ // var bottom = RemoveLayersAboveTop(originalSoilProfile1D.LayerCount, soilProfile, top);
+ // var topLayer = new SoilLayer1D
+ // {
+ // TopLevel = top,
+ // Soil = originalSoilProfile1D.Layers[bottom].Soil,
+ // SoilProfile = soilProfile,
+ // IsAquifer = originalSoilProfile1D.Layers[bottom].IsAquifer,
+ // BottomLevel = originalSoilProfile1D.Layers[bottom].BottomLevel
+ // };
+ // soilProfile.Layers.Insert(0, topLayer);
+ // }
- private static int RemoveLayersAboveTop(int layerCount, SoilProfile1D soilProfile, double top)
+ soilProfile.BottomLevel = originalSoilProfile1D.BottomLevel;
+ return soilProfile;
+ }
+
+ private static int RemoveLayersAboveTop(int layerCount, SoilProfile1D soilProfile, double top)
+ {
+ int index = layerCount;
+ for (int i = layerCount - 1; i >= 0; i--)
{
- int index = layerCount;
- for (int i = layerCount - 1; i >= 0; i--)
+ if (soilProfile.Layers[i].TopLevel > top)
{
- if (soilProfile.Layers[i].TopLevel > top)
+ soilProfile.Layers.RemoveAt(i);
+ if (index == layerCount)
{
- soilProfile.Layers.RemoveAt(i);
- if (index == layerCount)
- {
- index = i;
- }
+ index = i;
}
}
-
- return index; //soilProfile.Layers[0].TopLevel;
}
+
+ return index; //soilProfile.Layers[0].TopLevel;
}
}
\ No newline at end of file