Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs =================================================================== diff -u -r5404 -r5436 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs (.../PlLinesToWaternetConverter.cs) (revision 5404) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs (.../PlLinesToWaternetConverter.cs) (revision 5436) @@ -578,19 +578,21 @@ /// internal static void AvoidUpwardsVerticalLine(IList points) { - for (var i = 0; i < points.Count - 2; i++) + for (var i = 0; i < points.Count - 1; i++) { - if (Math.Abs(points[i].X - points[i + 1].X) < toleranceAlmostEqual && points[i].Z < points[i + 1].Z) + if (!(Math.Abs(points[i].X - points[i + 1].X) < toleranceAlmostEqual) || !(points[i].Z < points[i + 1].Z)) { - if (points[i + 1].X + 0.01 < points[i + 2].X) - { - points[i + 1].X += 0.01; - } - else - { - points[i + 1].X = points[i + 2].X - (points[i + 2].X - points[i + 1].X) / 2; - } + continue; } + + if (i == points.Count - 2 || (points[i + 1].X + 0.01 < points[i + 2].X)) + { + points[i + 1].X += 0.01; + } + else + { + points[i + 1].X = points[i + 2].X - (points[i + 2].X - points[i + 1].X) / 2; + } } } } \ No newline at end of file