Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Factories/MacroStabilityInwardsChartDataPointsFactory.cs =================================================================== diff -u -r09667b4737dfec082af4a6190f79996062eb6654 -r2bdf4a594b0ca27cce7b6485103c1011291a50d5 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Factories/MacroStabilityInwardsChartDataPointsFactory.cs (.../MacroStabilityInwardsChartDataPointsFactory.cs) (revision 09667b4737dfec082af4a6190f79996062eb6654) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Factories/MacroStabilityInwardsChartDataPointsFactory.cs (.../MacroStabilityInwardsChartDataPointsFactory.cs) (revision 2bdf4a594b0ca27cce7b6485103c1011291a50d5) @@ -402,8 +402,9 @@ /// Create the tangent lines based on the provided /// and . /// - /// The tangent line Y-coordinates. - /// The surface line that determines the boundaries of the tangent line. + /// The tangent line Z-coordinates. + /// The surface line that determines the horizontal boundaries + /// of the tangent lines. /// A collection of arrays of points in 2D space or an empty collection when /// or is null. public static IEnumerable CreateTangentLines(IEnumerable tangentLines, @@ -422,6 +423,54 @@ } /// + /// Create tangent lines based on the provided amount and + /// range between and + /// within the boundaries of the . + /// + /// The grid determination type. + /// The tangent line determination type. + /// The bottom boundary for the tangent lines. + /// The top boundary for the tangent lines. + /// The amount of tangent lines to display. + /// The surface line that determines the horizontal boundaries + /// of the tangent lines. + /// A collection of arrays of points in 2D space or an empty collection when: + /// + /// is ; + /// is ; + /// is null; + /// is or infinity; + /// is or infinity. + /// + public static IEnumerable CreateInputTangentLines(MacroStabilityInwardsGridDeterminationType gridDeterminationType, + MacroStabilityInwardsTangentLineDeterminationType tangentLineDeterminationType, + double tangentLineBottom, + double tangentLineTop, + int tangentLineNumber, + MacroStabilityInwardsSurfaceLine surfaceLine) + { + if (gridDeterminationType == MacroStabilityInwardsGridDeterminationType.Automatic + || tangentLineDeterminationType == MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated + || double.IsNaN(tangentLineBottom) + || double.IsInfinity(tangentLineBottom) + || double.IsNaN(tangentLineTop) + || double.IsInfinity(tangentLineTop)) + { + return Enumerable.Empty(); + } + + var tangentLines = new List(); + for (var i = 0; i < tangentLineNumber; i++) + { + double diff = tangentLineBottom - tangentLineTop; + double scale = diff / Math.Max(1, tangentLineNumber - 1); + tangentLines.Add(tangentLineTop + (i * scale)); + } + + return CreateTangentLines(tangentLines, surfaceLine); + } + + /// /// Create lines of the slices based on the provided . /// /// The slices to create the areas for. Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs =================================================================== diff -u -ra371ae048cf582e8a9cad8436a21c2b9b18dc793 -r2bdf4a594b0ca27cce7b6485103c1011291a50d5 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs (.../MacroStabilityInwardsInputView.cs) (revision a371ae048cf582e8a9cad8436a21c2b9b18dc793) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs (.../MacroStabilityInwardsInputView.cs) (revision 2bdf4a594b0ca27cce7b6485103c1011291a50d5) @@ -62,6 +62,7 @@ private readonly ChartPointData surfaceLevelOutsideChartData; private readonly ChartPointData leftGridChartData; private readonly ChartPointData rightGridChartData; + private readonly ChartMultipleLineData tangentLinesData; private readonly List soilLayerChartDataLookup; private IMacroStabilityInwardsSoilProfile currentSoilProfile; @@ -97,6 +98,7 @@ dikeToeAtRiverChartData = RingtoetsChartDataFactory.CreateDikeToeAtRiverChartData(); dikeTopAtRiverChartData = MacroStabilityInwardsChartDataFactory.CreateDikeTopAtRiverChartData(); surfaceLevelOutsideChartData = MacroStabilityInwardsChartDataFactory.CreateSurfaceLevelOutsideChartData(); + tangentLinesData = MacroStabilityInwardsChartDataFactory.CreateTangentLinesChartData(); leftGridChartData = MacroStabilityInwardsChartDataFactory.CreateLeftGridChartData(); rightGridChartData = MacroStabilityInwardsChartDataFactory.CreateRightGridChartData(); waternetZonesExtremeChartData = MacroStabilityInwardsChartDataFactory.CreateWaternetZonesExtremeChartDataCollection(); @@ -116,6 +118,7 @@ chartDataCollection.Add(dikeToeAtRiverChartData); chartDataCollection.Add(dikeTopAtRiverChartData); chartDataCollection.Add(surfaceLevelOutsideChartData); + chartDataCollection.Add(tangentLinesData); chartDataCollection.Add(leftGridChartData); chartDataCollection.Add(rightGridChartData); chartDataCollection.Add(waternetZonesExtremeChartData); @@ -216,6 +219,13 @@ leftGridChartData.Points = MacroStabilityInwardsChartDataPointsFactory.CreateGridPoints(leftGrid, gridDeterminationType); rightGridChartData.Points = MacroStabilityInwardsChartDataPointsFactory.CreateGridPoints(rightGrid, gridDeterminationType); + + tangentLinesData.Lines = MacroStabilityInwardsChartDataPointsFactory.CreateInputTangentLines(data.InputParameters.GridDeterminationType, + data.InputParameters.TangentLineDeterminationType, + data.InputParameters.TangentLineZBottom, + data.InputParameters.TangentLineZTop, + data.InputParameters.TangentLineNumber, + data.InputParameters.SurfaceLine); } private void SetWaternetExtremeChartData(MacroStabilityInwardsWaternet waternet, MacroStabilityInwardsSurfaceLine surfaceLine) Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Factories/MacroStabilityInwardsChartDataPointsFactoryTest.cs =================================================================== diff -u -r09667b4737dfec082af4a6190f79996062eb6654 -r2bdf4a594b0ca27cce7b6485103c1011291a50d5 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Factories/MacroStabilityInwardsChartDataPointsFactoryTest.cs (.../MacroStabilityInwardsChartDataPointsFactoryTest.cs) (revision 09667b4737dfec082af4a6190f79996062eb6654) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Factories/MacroStabilityInwardsChartDataPointsFactoryTest.cs (.../MacroStabilityInwardsChartDataPointsFactoryTest.cs) (revision 2bdf4a594b0ca27cce7b6485103c1011291a50d5) @@ -1456,24 +1456,24 @@ public void CreateTangentLines_TangentLinesNull_ReturnsEmptyCollection() { // Call - IEnumerable areas = MacroStabilityInwardsChartDataPointsFactory.CreateTangentLines(null, new MacroStabilityInwardsSurfaceLine("line")); + IEnumerable lines = MacroStabilityInwardsChartDataPointsFactory.CreateTangentLines(null, new MacroStabilityInwardsSurfaceLine("line")); // Assert - CollectionAssert.IsEmpty(areas); + CollectionAssert.IsEmpty(lines); } [Test] public void CreateTangentLines_SurfaceLineNull_ReturnsEmptyCollection() { // Call - IEnumerable areas = MacroStabilityInwardsChartDataPointsFactory.CreateTangentLines(Enumerable.Empty(), null); + IEnumerable lines = MacroStabilityInwardsChartDataPointsFactory.CreateTangentLines(Enumerable.Empty(), null); // Assert - CollectionAssert.IsEmpty(areas); + CollectionAssert.IsEmpty(lines); } [Test] - public void CreateTangentLines_WithSlices_ReturnsLines() + public void CreateTangentLines_WithSurfaceLineAndTangentLines_ReturnsLines() { // Setup var surfaceLine = new MacroStabilityInwardsSurfaceLine("line"); @@ -1506,6 +1506,137 @@ }, lines); } + [Test] + public void CreateInputTangentLines_SurfaceLineNull_ReturnsEmptyCollection() + { + // Call + IEnumerable lines = MacroStabilityInwardsChartDataPointsFactory.CreateInputTangentLines( + MacroStabilityInwardsGridDeterminationType.Manual, + MacroStabilityInwardsTangentLineDeterminationType.Specified, + 0.0, + 10.0, + 3, + null); + + // Assert + CollectionAssert.IsEmpty(lines); + } + + [Test] + [TestCase(double.NaN, 10.0)] + [TestCase(10.0, double.NaN)] + [TestCase(double.NegativeInfinity, 10.0)] + [TestCase(double.PositiveInfinity, 10.0)] + [TestCase(0.0, double.NegativeInfinity)] + [TestCase(0.0, double.PositiveInfinity)] + public void CreateInputTangentLines_BoundariesInvalid_ReturnsEmptyCollection(double bottom, double top) + { + // Call + IEnumerable lines = MacroStabilityInwardsChartDataPointsFactory.CreateInputTangentLines( + MacroStabilityInwardsGridDeterminationType.Manual, + MacroStabilityInwardsTangentLineDeterminationType.Specified, + bottom, + top, + 3, + null); + + // Assert + CollectionAssert.IsEmpty(lines); + } + + [Test] + [TestCase(MacroStabilityInwardsGridDeterminationType.Automatic, MacroStabilityInwardsTangentLineDeterminationType.Specified)] + [TestCase(MacroStabilityInwardsGridDeterminationType.Manual, MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated)] + [TestCase(MacroStabilityInwardsGridDeterminationType.Automatic, MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated)] + public void CreateInputTangentLines_DeterminationTypeAutomatic_ReturnsEmptyCollection( + MacroStabilityInwardsGridDeterminationType gridDeterminationType, + MacroStabilityInwardsTangentLineDeterminationType tangentLineDeterminationType) + { + // Call + IEnumerable lines = MacroStabilityInwardsChartDataPointsFactory.CreateInputTangentLines( + gridDeterminationType, + tangentLineDeterminationType, + 10.0, + 30.0, + 3, + null); + + // Assert + CollectionAssert.IsEmpty(lines); + } + + [Test] + public void CreateInputTangentLines_SingleTangentLine_ReturnsExpectedLine() + { + // Setup + var surfaceLine = new MacroStabilityInwardsSurfaceLine("line"); + surfaceLine.SetGeometry(new[] + { + new Point3D(-5, 2, 2), + new Point3D(10, 2, 2) + }); + + // Call + IEnumerable lines = MacroStabilityInwardsChartDataPointsFactory.CreateInputTangentLines( + MacroStabilityInwardsGridDeterminationType.Manual, + MacroStabilityInwardsTangentLineDeterminationType.Specified, + 10.0, + 20.0, + 1, + surfaceLine); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0.0, 20.0), + new Point2D(15.0, 20.0) + } + }, lines); + } + + [Test] + public void CreateInputTangentLines_MultipleTangentLines_ReturnsExpectedLines() + { + // Setup + var surfaceLine = new MacroStabilityInwardsSurfaceLine("line"); + surfaceLine.SetGeometry(new[] + { + new Point3D(-5, 2, 2), + new Point3D(10, 2, 2) + }); + + // Call + IEnumerable lines = MacroStabilityInwardsChartDataPointsFactory.CreateInputTangentLines( + MacroStabilityInwardsGridDeterminationType.Manual, + MacroStabilityInwardsTangentLineDeterminationType.Specified, + 10.0, + 20.0, + 3, + surfaceLine); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0.0, 20.0), + new Point2D(15.0, 20.0) + }, + new[] + { + new Point2D(0, 15.0), + new Point2D(15.0, 15.0) + }, + new[] + { + new Point2D(0, 10.0), + new Point2D(15.0, 10.0) + } + }, lines); + } + private static MacroStabilityInwardsWaternetLine CreateWaternetLine(IEnumerable waternetLineGeometry, IEnumerable phreaticLineGeometry) { Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsInputViewTest.cs =================================================================== diff -u -ra371ae048cf582e8a9cad8436a21c2b9b18dc793 -r2bdf4a594b0ca27cce7b6485103c1011291a50d5 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsInputViewTest.cs (.../MacroStabilityInwardsInputViewTest.cs) (revision a371ae048cf582e8a9cad8436a21c2b9b18dc793) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsInputViewTest.cs (.../MacroStabilityInwardsInputViewTest.cs) (revision 2bdf4a594b0ca27cce7b6485103c1011291a50d5) @@ -57,11 +57,12 @@ private const int dikeToeAtRiverIndex = 11; private const int dikeTopAtRiverIndex = 12; private const int surfaceLevelOutsideIndex = 13; - private const int leftGridIndex = 14; - private const int rightGridIndex = 15; - private const int waternetZonesExtremeIndex = 16; - private const int waternetZonesDailyIndex = 17; - private const int nrOfChartData = 18; + private const int tangentLinesIndex = 14; + private const int leftGridIndex = 15; + private const int rightGridIndex = 16; + private const int waternetZonesExtremeIndex = 17; + private const int waternetZonesDailyIndex = 18; + private const int nrOfChartData = 19; [Test] public void DefaultConstructor_DefaultValues() @@ -541,6 +542,7 @@ const int updatedDikeToeAtRiverIndex = dikeToeAtRiverIndex - 1; const int updatedDikeTopAtRiverIndex = dikeTopAtRiverIndex - 1; const int updatedSurfaceLevelOutsideIndex = surfaceLevelOutsideIndex - 1; + const int updatedTangentLinesIndex = tangentLinesIndex - 1; const int updatedLeftGridIndex = leftGridIndex - 1; const int updatedRightGridIndex = rightGridIndex - 1; const int updatedWaternetZonesExtremeIndex = waternetZonesExtremeIndex - 1; @@ -575,6 +577,7 @@ var dikeToeAtRiverData = (ChartPointData) chartDataList[updatedDikeToeAtRiverIndex]; var dikeTopAtRiverData = (ChartPointData) chartDataList[updatedDikeTopAtRiverIndex]; var surfaceLevelOutsideData = (ChartPointData) chartDataList[updatedSurfaceLevelOutsideIndex]; + var tangentLinesData = (ChartMultipleLineData) chartDataList[updatedTangentLinesIndex]; var leftGridData = (ChartPointData) chartDataList[updatedLeftGridIndex]; var rightGridData = (ChartPointData) chartDataList[updatedRightGridIndex]; var waternetZonesExtremeData = (ChartDataCollection) chartDataList[updatedWaternetZonesExtremeIndex]; @@ -594,6 +597,7 @@ Assert.AreEqual("Teen dijk buitenwaarts", dikeToeAtRiverData.Name); Assert.AreEqual("Kruin buitentalud", dikeTopAtRiverData.Name); Assert.AreEqual("Maaiveld buitenwaarts", surfaceLevelOutsideData.Name); + Assert.AreEqual("Tangentlijnen", tangentLinesData.Name); Assert.AreEqual("Linker grid", leftGridData.Name); Assert.AreEqual("Rechter grid", rightGridData.Name); Assert.AreEqual("Zones extreem", waternetZonesExtremeData.Name); @@ -622,6 +626,7 @@ var actualDikeToeAtRiverData = (ChartPointData) chartDataList[updatedDikeToeAtRiverIndex]; var actualDikeTopAtRiverData = (ChartPointData) chartDataList[updatedDikeTopAtRiverIndex]; var actualSurfaceLevelOutsideData = (ChartPointData) chartDataList[updatedSurfaceLevelOutsideIndex]; + var actualTangentLinesData = (ChartMultipleLineData) chartDataList[updatedTangentLinesIndex]; var actualLeftGridData = (ChartPointData) chartDataList[updatedLeftGridIndex]; var actualRightGridData = (ChartPointData) chartDataList[updatedRightGridIndex]; var actualWaternetZonesExtremeData = (ChartDataCollection) chartDataList[updatedWaternetZonesExtremeIndex]; @@ -641,6 +646,7 @@ Assert.AreEqual("Teen dijk buitenwaarts", actualDikeToeAtRiverData.Name); Assert.AreEqual("Kruin buitentalud", actualDikeTopAtRiverData.Name); Assert.AreEqual("Maaiveld buitenwaarts", actualSurfaceLevelOutsideData.Name); + Assert.AreEqual("Tangentlijnen", actualTangentLinesData.Name); Assert.AreEqual("Linker grid", actualLeftGridData.Name); Assert.AreEqual("Rechter grid", actualRightGridData.Name); Assert.AreEqual("Zones extreem", actualWaternetZonesExtremeData.Name); @@ -810,6 +816,62 @@ } [Test] + [TestCase(MacroStabilityInwardsGridDeterminationType.Manual, MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated)] + [TestCase(MacroStabilityInwardsGridDeterminationType.Automatic, MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated)] + [TestCase(MacroStabilityInwardsGridDeterminationType.Automatic, MacroStabilityInwardsTangentLineDeterminationType.Specified)] + public void GivenViewWithSpecifiedTangentLines_WhenTangentLineOrGridDeterminationTypeSetToManual_ThenNoTangentLines( + MacroStabilityInwardsGridDeterminationType gridDeterminationType, + MacroStabilityInwardsTangentLineDeterminationType tangentLineDeterminationType) + { + // Given + var calculation = new MacroStabilityInwardsCalculationScenario + { + InputParameters = + { + SurfaceLine = GetSurfaceLineWithGeometry(), + GridDeterminationType = MacroStabilityInwardsGridDeterminationType.Manual, + TangentLineDeterminationType = MacroStabilityInwardsTangentLineDeterminationType.Specified, + TangentLineZTop = new RoundedDouble(2, 10.0), + TangentLineZBottom = new RoundedDouble(2, 5.0), + TangentLineNumber = 2 + } + }; + MacroStabilityInwardsInput input = calculation.InputParameters; + + using (var view = new MacroStabilityInwardsInputView + { + Data = calculation + }) + { + // Precondition + ChartDataCollection chartData = view.Chart.Data; + List chartDataList = chartData.Collection.ToList(); + var tangentLinesData = (ChartMultipleLineData) chartDataList[tangentLinesIndex]; + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0.0, 10.0), + new Point2D(1.58, 10.0) + }, + new[] + { + new Point2D(0.0, 5.0), + new Point2D(1.58, 5.0) + } + }, tangentLinesData.Lines); + + // When + input.GridDeterminationType = gridDeterminationType; + input.TangentLineDeterminationType = tangentLineDeterminationType; + input.NotifyObservers(); + + // Then + CollectionAssert.IsEmpty(tangentLinesData.Lines); + } + } + + [Test] public void GivenMacroStabilityInputViewWithSoilProfileSeries_WhenSurfaceLineSetToNull_ThenCollectionOfEmptyChartDataSetForSoilProfiles() { // Given Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.TestUtil/MacroStabilityInwardsInputViewChartDataAssert.cs =================================================================== diff -u -ra371ae048cf582e8a9cad8436a21c2b9b18dc793 -r2bdf4a594b0ca27cce7b6485103c1011291a50d5 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.TestUtil/MacroStabilityInwardsInputViewChartDataAssert.cs (.../MacroStabilityInwardsInputViewChartDataAssert.cs) (revision a371ae048cf582e8a9cad8436a21c2b9b18dc793) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.TestUtil/MacroStabilityInwardsInputViewChartDataAssert.cs (.../MacroStabilityInwardsInputViewChartDataAssert.cs) (revision 2bdf4a594b0ca27cce7b6485103c1011291a50d5) @@ -47,11 +47,12 @@ private const int dikeToeAtRiverIndex = 11; private const int dikeTopAtRiverIndex = 12; private const int surfaceLevelOutsideIndex = 13; - private const int leftGridIndex = 14; - private const int rightGridIndex = 15; - private const int waternetZonesExtremeIndex = 16; - private const int waternetZonesDailyIndex = 17; - private const int nrOfChartData = 18; + private const int tangentLinesIndex = 14; + private const int leftGridIndex = 15; + private const int rightGridIndex = 16; + private const int waternetZonesExtremeIndex = 17; + private const int waternetZonesDailyIndex = 18; + private const int nrOfChartData = 19; /// /// Asserts whether corresponds to . @@ -124,6 +125,7 @@ var dikeToeAtRiverData = (ChartPointData) chartDataArray[dikeToeAtRiverIndex]; var dikeTopAtRiverData = (ChartPointData) chartDataArray[dikeTopAtRiverIndex]; var surfaceLevelOutsideData = (ChartPointData) chartDataArray[surfaceLevelOutsideIndex]; + var tangentLinesData = (ChartMultipleLineData) chartDataArray[tangentLinesIndex]; var leftGridOutsideData = (ChartPointData) chartDataArray[leftGridIndex]; var rightGridOutsideData = (ChartPointData) chartDataArray[rightGridIndex]; var waternetZonesExtremeData = (ChartDataCollection) chartDataArray[waternetZonesExtremeIndex]; @@ -143,6 +145,7 @@ CollectionAssert.IsEmpty(dikeToeAtRiverData.Points); CollectionAssert.IsEmpty(dikeTopAtRiverData.Points); CollectionAssert.IsEmpty(surfaceLevelOutsideData.Points); + CollectionAssert.IsEmpty(tangentLinesData.Lines); CollectionAssert.IsEmpty(leftGridOutsideData.Points); CollectionAssert.IsEmpty(rightGridOutsideData.Points); CollectionAssert.IsEmpty(waternetZonesExtremeData.Collection); @@ -162,6 +165,7 @@ Assert.AreEqual("Teen dijk buitenwaarts", dikeToeAtRiverData.Name); Assert.AreEqual("Kruin buitentalud", dikeTopAtRiverData.Name); Assert.AreEqual("Maaiveld buitenwaarts", surfaceLevelOutsideData.Name); + Assert.AreEqual("Tangentlijnen", tangentLinesData.Name); Assert.AreEqual("Linker grid", leftGridOutsideData.Name); Assert.AreEqual("Rechter grid", rightGridOutsideData.Name); Assert.AreEqual("Zones extreem", waternetZonesExtremeData.Name);