Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Helpers/ExportableFailureMechanismSectionHelper.cs =================================================================== diff -u -r6cf42b92f47cb984c4a2f08936b74b9aba7a4d38 -r548b7cecd2ac4a239dd218c1e675a2c6f2bf4a6d --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Helpers/ExportableFailureMechanismSectionHelper.cs (.../ExportableFailureMechanismSectionHelper.cs) (revision 6cf42b92f47cb984c4a2f08936b74b9aba7a4d38) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Helpers/ExportableFailureMechanismSectionHelper.cs (.../ExportableFailureMechanismSectionHelper.cs) (revision 548b7cecd2ac4a239dd218c1e675a2c6f2bf4a6d) @@ -104,7 +104,7 @@ point }); - sectionLengthOnReferenceLine = sectionLengthOnReferenceLine + pointsLength; + sectionLengthOnReferenceLine += pointsLength; if (sectionLength > sectionLengthOnReferenceLine) { @@ -118,7 +118,8 @@ } else if (sectionLength < sectionLengthOnReferenceLine) { - sectionPoints.Add(InterpolatePoint(lastPoint, point, sectionLengthOnReferenceLine - sectionLength)); + double distance = pointsLength - (sectionLengthOnReferenceLine - sectionLength); + sectionPoints.Add(InterpolatePoint(lastPoint, point, distance)); break; } } @@ -147,7 +148,7 @@ referenceLinePoints[i] }); - totalLength = totalLength + pointsLength; + totalLength += pointsLength; if (Math.Abs(totalLength - sectionStart) < 1e-6) { @@ -157,7 +158,8 @@ if (totalLength > sectionStart) { - startPoint = InterpolatePoint(referenceLinePoints[i - 1], referenceLinePoints[i], sectionStart - (totalLength - pointsLength)); + double distance = sectionStart - (totalLength - pointsLength); + startPoint = InterpolatePoint(referenceLinePoints[i - 1], referenceLinePoints[i], distance); index = i - 1; break; } Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Helpers/ExportableFailureMechanismSectionHelperTest.cs =================================================================== diff -u -rc6abf7f3537baaba6e7a6108d115a0c27fd7f4a0 -r548b7cecd2ac4a239dd218c1e675a2c6f2bf4a6d --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Helpers/ExportableFailureMechanismSectionHelperTest.cs (.../ExportableFailureMechanismSectionHelperTest.cs) (revision c6abf7f3537baaba6e7a6108d115a0c27fd7f4a0) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Helpers/ExportableFailureMechanismSectionHelperTest.cs (.../ExportableFailureMechanismSectionHelperTest.cs) (revision 548b7cecd2ac4a239dd218c1e675a2c6f2bf4a6d) @@ -157,16 +157,42 @@ } [Test] - public void GetFailureMechanismSectionGeometry_SectionStartAndEndBetweenTwoReferenceLinePoint_ReturnExpectedPoints() + public void GetFailureMechanismSectionGeometry_SectionStartAndEndBetweenSameTwoReferenceLinePoint_ReturnExpectedPoints() { // Setup - const int sectionStart = 10; - const int sectionEnd = 30; + const int sectionStart = 2; + const int sectionEnd = 4; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new [] { new Point2D(0, 0), new Point2D(5, 0), + new Point2D(15, 0) + }); + + // Call + IEnumerable sectionPoints = ExportableFailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(referenceLine, sectionStart, sectionEnd); + + // Assert + CollectionAssert.AreEqual(new[] + { + new Point2D(sectionStart, 0), + new Point2D(sectionEnd, 0) + }, sectionPoints); + } + + [Test] + public void GetFailureMechanismSectionGeometry_SectionStartAndEndBetweenDifferentTwoReferenceLinePoint_ReturnExpectedPoints() + { + // Setup + var random = new Random(21); + int sectionStart = random.Next(5, 15); + int sectionEnd = random.Next(25, 35); + var referenceLine = new ReferenceLine(); + referenceLine.SetGeometry(new [] + { + new Point2D(0, 0), + new Point2D(5, 0), new Point2D(15, 0), new Point2D(25, 0), new Point2D(35, 0)