Index: Ringtoets/Common/src/Ringtoets.Common.IO/SurfaceLines/SurfaceLineExtensions.cs =================================================================== diff -u -rfc91936524e52aeab541d4e72d15c5ff7832fee5 -r024957c81d6192c2cf8e6026fccc131c1fe81b19 --- Ringtoets/Common/src/Ringtoets.Common.IO/SurfaceLines/SurfaceLineExtensions.cs (.../SurfaceLineExtensions.cs) (revision fc91936524e52aeab541d4e72d15c5ff7832fee5) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SurfaceLines/SurfaceLineExtensions.cs (.../SurfaceLineExtensions.cs) (revision 024957c81d6192c2cf8e6026fccc131c1fe81b19) @@ -100,12 +100,13 @@ if (result.IntersectionType == Intersection2DType.Intersects) { - if (intersectionPoint != null) + Point2D resultIntersectionPoint = result.IntersectionPoints[0]; + if (intersectionPoint != null && !intersectionPoint.Equals(resultIntersectionPoint)) { // Early exit as multiple intersections is a return result: return ReferenceLineIntersectionResult.CreateMultipleIntersectionsOrOverlapResult(); } - intersectionPoint = result.IntersectionPoints[0]; + intersectionPoint = resultIntersectionPoint; } if (result.IntersectionType == Intersection2DType.Overlaps) Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SurfaceLines/SurfaceLineExtensionsTest.cs =================================================================== diff -u -rfc91936524e52aeab541d4e72d15c5ff7832fee5 -r024957c81d6192c2cf8e6026fccc131c1fe81b19 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SurfaceLines/SurfaceLineExtensionsTest.cs (.../SurfaceLineExtensionsTest.cs) (revision fc91936524e52aeab541d4e72d15c5ff7832fee5) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SurfaceLines/SurfaceLineExtensionsTest.cs (.../SurfaceLineExtensionsTest.cs) (revision 024957c81d6192c2cf8e6026fccc131c1fe81b19) @@ -83,6 +83,36 @@ } [Test] + public void CheckReferenceLineInterSections_SurfaceLineThroughReferenceLinePoint_ReturnIntersectionPoint() + { + // Setup + var referenceLine = new ReferenceLine(); + + const string surfaceLineName = "somewhere"; + var surfaceLine = new SurfaceLine + { + Name = surfaceLineName + }; + surfaceLine.SetGeometry(new[] + { + new Point3D(3.0, 4.0, 2.1), + new Point3D(3.0, 5.0, 2.1) + }); + referenceLine.SetGeometry(new[] + { + new Point2D(2.0, 4.5), + new Point2D(3.0, 4.5), + new Point2D(4.0, 4.5) + }); + + // Call + Point2D result = surfaceLine.GetSingleReferenceLineInterSection(referenceLine); + + // Assert + Assert.AreEqual(new Point2D(3.0, 4.5), result); + } + + [Test] public void CheckReferenceLineInterSections_SurfaceLineNotOnReferenceLine_ThrowSurfaceLineTransformerException() { // Setup @@ -113,7 +143,7 @@ } [Test] - public void CheckReferenceLineInterSections_SurfaceLineIntersectsReferenceLineMultipleTimes_ThrowSurfaceLineTransformerException() + public void CheckReferenceLineInterSections_SurfaceLineIntersectsReferenceLineMultipleTimesInSamePoint_ReturnsIntersectionPoint() { // Setup var referenceLine = new ReferenceLine(); @@ -126,7 +156,8 @@ surfaceLine.SetGeometry(new[] { new Point3D(1.0, 5.0, 2.1), - new Point3D(1.0, 3.0, 2.1) + new Point3D(1.0, 3.0, 2.1), + new Point3D(1.0, 5.0, 2.1) }); referenceLine.SetGeometry(new[] { @@ -136,6 +167,36 @@ }); // Call + Point2D result = surfaceLine.GetSingleReferenceLineInterSection(referenceLine); + + // Assert + Assert.AreEqual(new Point2D(1.0, 4.0), result); + } + + [Test] + public void CheckReferenceLineInterSections_SurfaceLineIntersectsReferenceLineMultipleTimesInDifferentPoints_ThrowSurfaceLineTransformerException() + { + // Setup + var referenceLine = new ReferenceLine(); + + const string surfaceLineName = "somewhere"; + var surfaceLine = new SurfaceLine + { + Name = surfaceLineName + }; + surfaceLine.SetGeometry(new[] + { + new Point3D(1.0, 5.0, 2.1), + new Point3D(1.0, 3.0, 2.1) + }); + referenceLine.SetGeometry(new[] + { + new Point2D(0.0, 5.0), + new Point2D(2.0, 4.0), + new Point2D(0.0, 3.0) + }); + + // Call TestDelegate test = () => surfaceLine.GetSingleReferenceLineInterSection(referenceLine); // Assert Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Importers/MacrostabilityInwardsSurfaceLineTransformerTest.cs =================================================================== diff -u -rfc91936524e52aeab541d4e72d15c5ff7832fee5 -r024957c81d6192c2cf8e6026fccc131c1fe81b19 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Importers/MacrostabilityInwardsSurfaceLineTransformerTest.cs (.../MacrostabilityInwardsSurfaceLineTransformerTest.cs) (revision fc91936524e52aeab541d4e72d15c5ff7832fee5) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Importers/MacrostabilityInwardsSurfaceLineTransformerTest.cs (.../MacrostabilityInwardsSurfaceLineTransformerTest.cs) (revision 024957c81d6192c2cf8e6026fccc131c1fe81b19) @@ -175,9 +175,9 @@ }); referenceLine.SetGeometry(new[] { - new Point2D(0.0, 4.0), + new Point2D(0.0, 5.0), new Point2D(2.0, 4.0), - new Point2D(0.0, 4.0) + new Point2D(0.0, 3.0) }); // Call Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingSurfaceLineTransformerTest.cs =================================================================== diff -u -rfc91936524e52aeab541d4e72d15c5ff7832fee5 -r024957c81d6192c2cf8e6026fccc131c1fe81b19 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingSurfaceLineTransformerTest.cs (.../PipingSurfaceLineTransformerTest.cs) (revision fc91936524e52aeab541d4e72d15c5ff7832fee5) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingSurfaceLineTransformerTest.cs (.../PipingSurfaceLineTransformerTest.cs) (revision 024957c81d6192c2cf8e6026fccc131c1fe81b19) @@ -134,9 +134,9 @@ }); referenceLine.SetGeometry(new[] { - new Point2D(0.0, 4.0), + new Point2D(0.0, 5.0), new Point2D(2.0, 4.0), - new Point2D(0.0, 4.0) + new Point2D(0.0, 3.0) }); // Call