Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs =================================================================== diff -u -r7068 -r7069 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs (.../MacroStabilityCommonHelper.cs) (revision 7068) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs (.../MacroStabilityCommonHelper.cs) (revision 7069) @@ -575,12 +575,23 @@ for (var i = 0; i < surfaceLine.Geometry.Points.Count; i++) { Point2D surfaceLinePoint = surfaceLine.Geometry.Points[i]; - SoilProfile1D geometry1D = soilProfile2D.GetSoilProfile1D(surfaceLinePoint.X); + // For the first and last points, shift X with 1 mm to get the correct soil profile 1D. + double xRelevant = surfaceLinePoint.X; + double zRelevant = surfaceLinePoint.Z; + if (i == 0) + { + xRelevant = surfaceLinePoint.X + 0.001; + zRelevant = surfaceLine.Geometry.GetZatX(xRelevant); + } + if (i == surfaceLine.Geometry.Points.Count - 1) + { + xRelevant = surfaceLinePoint.X - 0.001; + zRelevant = surfaceLine.Geometry.GetZatX(xRelevant); + } + SoilProfile1D geometry1D = soilProfile2D.GetSoilProfile1D(xRelevant); bool profileContainsHole = geometry1D.Layers.Any(layer => layer.Soil == null); // Check if the top layer is generated correctly. - // Do not check the first and last points because the 1D profile is not exactly at the X position. - bool topLayerNotGenerated = i > 0 && i < surfaceLine.Geometry.Points.Count - 1 && - Math.Abs(geometry1D.TopLevel - surfaceLinePoint.Z) > 2 * GeometryConstants.Accuracy; + bool topLayerNotGenerated = Math.Abs(geometry1D.TopLevel - zRelevant) > 2 * GeometryConstants.Accuracy; if (profileContainsHole || topLayerNotGenerated) {