Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs =================================================================== diff -u -r4928 -r4962 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 4928) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 4962) @@ -102,8 +102,8 @@ model = MStabModelType.Bishop; } - macroStabilityCommonHelper.EnsureSoilProfile2DIsFilled(damKernelInput.SubSoilScenario, damKernelInput.Location.SurfaceLine, - damKernelInput.Location.GetDikeEmbankmentSoil()); + macroStabilityCommonHelper.CombineSoilProfileWithSurfaceLine(damKernelInput.SubSoilScenario, damKernelInput.Location.SurfaceLine, + damKernelInput.Location.GetDikeEmbankmentSoil()); // Check if the surface-line is within the SoilProfile2D boundaries (left/right) if (!SoilProfile2DSurfaceLineHelper.IsSurfaceLineInsideSoilProfile2D(damKernelInput.Location.SurfaceLine, damKernelInput.SubSoilScenario.SoilProfile2D)) { Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityOutwards/MacroStabilityOutwardsKernelWrapper.cs =================================================================== diff -u -r4928 -r4962 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityOutwards/MacroStabilityOutwardsKernelWrapper.cs (.../MacroStabilityOutwardsKernelWrapper.cs) (revision 4928) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityOutwards/MacroStabilityOutwardsKernelWrapper.cs (.../MacroStabilityOutwardsKernelWrapper.cs) (revision 4962) @@ -97,8 +97,8 @@ throw new NotImplementedException(); } - macroStabilityCommonHelper.EnsureSoilProfile2DIsFilled(damKernelInput.SubSoilScenario, damKernelInput.Location.SurfaceLine, - damKernelInput.Location.GetDikeEmbankmentSoil()); + macroStabilityCommonHelper.CombineSoilProfileWithSurfaceLine(damKernelInput.SubSoilScenario, damKernelInput.Location.SurfaceLine, + damKernelInput.Location.GetDikeEmbankmentSoil()); const bool useRiverLevelLow = true; //Determine pl Lines. Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs =================================================================== diff -u -r4898 -r4962 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs (.../MacroStabilityCommonHelper.cs) (revision 4898) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs (.../MacroStabilityCommonHelper.cs) (revision 4962) @@ -52,30 +52,25 @@ public class MacroStabilityCommonHelper { /// - /// Ensures the soil profile2d is filled. - /// In case the soil profile2d is not filled, it will be filled by combining the surfaceline wit the SoilProfile1D. + /// Combines the surfaceline with the SoilProfile1D or the SoilProfile2D. /// /// The sub soil scenario. - /// The surface line2. + /// The surfaceline. /// The dike embankment soil. - public void EnsureSoilProfile2DIsFilled(SoilGeometryProbability subSoilScenario, SurfaceLine2 surfaceLine2, Soil dikeEmbankmentSoil) + /// Thrown when subSoilScenario.SoilProfileType is ProfileTypeStiFile + /// + public void CombineSoilProfileWithSurfaceLine(SoilGeometryProbability subSoilScenario, SurfaceLine2 surfaceLine2, Soil dikeEmbankmentSoil) { - SoilProfile2D soilProfile2D = subSoilScenario.SoilProfile2D; - if (soilProfile2D == null) + switch (subSoilScenario.SoilProfileType) { - var soilSurfaceProfile = new SoilSurfaceProfile - { - SoilProfile = subSoilScenario.SoilProfile1D, - SurfaceLine2 = surfaceLine2, - Name = subSoilScenario.SoilProfile1D.Name, - DikeEmbankmentMaterial = dikeEmbankmentSoil - }; - // Convert the soilSurfaceProfile to a SoilProfile2D to be able to edit it properly. - SoilProfile2D soilProfile2DNew = soilSurfaceProfile.ConvertToSoilProfile2D(); - subSoilScenario.SoilProfile2D = soilProfile2DNew; - subSoilScenario.SoilProfile2DName = soilProfile2DNew.Name; - subSoilScenario.SoilProfileType = SoilProfileType.ProfileType2D; - subSoilScenario.SoilProfile1D = null; + case SoilProfileType.ProfileType1D: + CombineSoilProfile1DWithSurfaceLine(subSoilScenario, surfaceLine2, dikeEmbankmentSoil); + break; + case SoilProfileType.ProfileType2D: + CombineSoilProfile2DWithSurfaceLine(subSoilScenario, surfaceLine2, dikeEmbankmentSoil); + break; + default: + throw new NotImplementedException(); } } @@ -412,6 +407,54 @@ } /// + /// Combines the surfaceline with the SoilProfile2D. + /// + /// The sub soil scenario. + /// The surfaceline. + /// The dike embankment soil. + /// Thrown when no SoilProfile2D is defined + private void CombineSoilProfile2DWithSurfaceLine(SoilGeometryProbability subSoilScenario, SurfaceLine2 surfaceLine2, Soil dikeEmbankmentSoil) + { + if (subSoilScenario.SoilProfile2D == null) + { + throw new ArgumentNullException(nameof(subSoilScenario.SoilProfile1D), @"SoilProfile2D cannot be null."); + } + } + + /// + /// Combines the surfaceline with the SoilProfile1D. + /// + /// The sub soil scenario. + /// The surfaceline. + /// The dike embankment soil. + /// Thrown when no SoilProfile1D is defined + private void CombineSoilProfile1DWithSurfaceLine(SoilGeometryProbability subSoilScenario, SurfaceLine2 surfaceLine2, Soil dikeEmbankmentSoil) + { + if (subSoilScenario.SoilProfile1D == null) + { + throw new ArgumentNullException(nameof(subSoilScenario.SoilProfile1D), @"SoilProfile1D cannot be null."); + } + + SoilProfile2D soilProfile2D = subSoilScenario.SoilProfile2D; + if (soilProfile2D == null) + { + var soilSurfaceProfile = new SoilSurfaceProfile + { + SoilProfile = subSoilScenario.SoilProfile1D, + SurfaceLine2 = surfaceLine2, + Name = subSoilScenario.SoilProfile1D.Name, + DikeEmbankmentMaterial = dikeEmbankmentSoil + }; + // Convert the soilSurfaceProfile to a SoilProfile2D to be able to edit it properly. + SoilProfile2D soilProfile2DNew = soilSurfaceProfile.ConvertToSoilProfile2D(); + subSoilScenario.SoilProfile2D = soilProfile2DNew; + subSoilScenario.SoilProfile2DName = soilProfile2DNew.Name; + subSoilScenario.SoilProfileType = SoilProfileType.ProfileType2D; + subSoilScenario.SoilProfile1D = null; + } + } + + /// /// Determines the calculation filename. /// /// The filename prefix.