Beispiel #1
0
        public void IsStructureIntersectionWithReferenceLineInSection_StructureDoesNotIntersectReferenceLine_ReturnsFalse()
        {
            // Setup
            var structure     = new TestStructure(new Point2D(0.0, 0.0));
            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(10.0, 0.0),
                new Point2D(20.0, 0.0)
            });

            var calculation = new TestStructuresCalculationScenario
            {
                InputParameters =
                {
                    Structure = structure
                }
            };

            IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(referenceLine.Points);

            // Call
            bool intersects = calculation.IsStructureIntersectionWithReferenceLineInSection(lineSegments);

            // Assert
            Assert.IsFalse(intersects);
        }
Beispiel #2
0
        public void IsDikeProfileIntersectionWithReferenceLineInSection_DikeProfileDoesNotIntersectReferenceLine_ReturnsFalse()
        {
            // Setup
            DikeProfile dikeProfile   = DikeProfileTestFactory.CreateDikeProfile(new Point2D(0.0, 0.0));
            var         referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(10.0, 0.0),
                new Point2D(20.0, 0.0)
            });

            var calculation = new GrassCoverErosionInwardsCalculationScenario
            {
                InputParameters =
                {
                    DikeProfile = dikeProfile
                }
            };

            IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(referenceLine.Points);

            // Call
            bool intersects = calculation.IsDikeProfileIntersectionWithReferenceLineInSection(lineSegments);

            // Assert
            Assert.IsFalse(intersects);
        }
        private static ReferenceLineIntersectionResult GetReferenceLineIntersections(ReferenceLine referenceLine, SurfaceLine surfaceLine)
        {
            IEnumerable <Segment2D> surfaceLineSegments   = Math2D.ConvertPointsToLineSegments(surfaceLine.Points.Select(p => new Point2D(p.X, p.Y))).ToArray();
            IEnumerable <Segment2D> referenceLineSegments = Math2D.ConvertPointsToLineSegments(referenceLine.Points).ToArray();

            return(GetReferenceLineIntersectionsResult(surfaceLineSegments, referenceLineSegments));
        }
Beispiel #4
0
        public void IsSurfaceLineIntersectionWithReferenceLineInSection_WithoutReferenceLineIntersectionWorldPoint_ThrowsArgumentNullException()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 5.0, 0.0),
                new Point3D(0.0, 0.0, 1.0),
                new Point3D(0.0, -5.0, 0.0)
            });
            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(0.0, 0.0),
                new Point2D(10.0, 0.0)
            });

            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    SurfaceLine = surfaceLine
                }
            };

            IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(referenceLine.Points);

            // Call
            TestDelegate call = () => calculation.IsSurfaceLineIntersectionWithReferenceLineInSection(lineSegments);

            // Assert
            Assert.Throws <ArgumentNullException>(call);
        }
        private static bool DoesSoilModelGeometryIntersectWithSurfaceLineGeometry(PipingStochasticSoilModel stochasticSoilModel,
                                                                                  Segment2D[] surfaceLineSegments)
        {
            IEnumerable <Segment2D> soilProfileGeometrySegments = Math2D.ConvertPointsToLineSegments(stochasticSoilModel.Geometry);

            return(soilProfileGeometrySegments.Any(s => DoesSegmentIntersectWithSegmentArray(s, surfaceLineSegments)));
        }
        protected override IEnumerable <GrassCoverErosionInwardsScenarioRow> GetScenarioRows(FailureMechanismSection failureMechanismSection)
        {
            IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(failureMechanismSection.Points);
            IEnumerable <GrassCoverErosionInwardsCalculationScenario> calculations = CalculationGroup.GetCalculations().OfType <GrassCoverErosionInwardsCalculationScenario>()
                                                                                     .Where(cs => cs.IsDikeProfileIntersectionWithReferenceLineInSection(lineSegments));

            return(calculations.Select(c => new GrassCoverErosionInwardsScenarioRow(c)).ToList());
        }
        protected override IEnumerable <StabilityPointStructuresScenarioRow> GetScenarioRows(FailureMechanismSection failureMechanismSection)
        {
            IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(failureMechanismSection.Points);
            IEnumerable <StructuresCalculationScenario <StabilityPointStructuresInput> > calculations = CalculationGroup.GetCalculations()
                                                                                                        .OfType <StructuresCalculationScenario <StabilityPointStructuresInput> >()
                                                                                                        .Where(cs => cs.IsStructureIntersectionWithReferenceLineInSection(lineSegments));

            return(calculations.Select(c => new StabilityPointStructuresScenarioRow(c)).ToList());
        }
Beispiel #8
0
        protected override IEnumerable <MacroStabilityInwardsScenarioRow> GetScenarioRows(FailureMechanismSection failureMechanismSection)
        {
            IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(failureMechanismSection.Points);
            IEnumerable <MacroStabilityInwardsCalculationScenario> calculations = CalculationGroup
                                                                                  .GetCalculations()
                                                                                  .OfType <MacroStabilityInwardsCalculationScenario>()
                                                                                  .Where(pc => pc.IsSurfaceLineIntersectionWithReferenceLineInSection(lineSegments));

            return(calculations.Select(pc => new MacroStabilityInwardsScenarioRow(pc, FailureMechanism, failureMechanismSection)).ToList());
        }
Beispiel #9
0
        /// <summary>
        /// Creates a new instance of <see cref="SectionSegments"/>.
        /// </summary>
        /// <param name="section">The <see cref="FailureMechanismSection"/> whose <see cref="FailureMechanismSection.Points"/>
        /// this class represents as a collection of <see cref="Segment2D"/> objects.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="section"/> is <c>null</c>.</exception>
        public SectionSegments(FailureMechanismSection section)
        {
            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }

            Section  = section;
            segments = Math2D.ConvertPointsToLineSegments(section.Points);
        }
Beispiel #10
0
        private static IEnumerable <Point2D> GetSurfaceLineWithInterpolations(MacroStabilityInwardsInput inputParameters,
                                                                              IEnumerable <double> uniqueXs)
        {
            Segment2D[] surfaceLineSegments = Math2D.ConvertPointsToLineSegments(inputParameters.SurfaceLine.LocalGeometry).ToArray();

            foreach (double x in uniqueXs)
            {
                double y = surfaceLineSegments.Interpolate(x);
                yield return(new Point2D(x, y));
            }
        }
Beispiel #11
0
        protected override void PerformCalculation()
        {
            calculation.ClearOutput();

            FailureMechanismSection section = failureMechanism.Sections.Single(
                s => calculation.IsSurfaceLineIntersectionWithReferenceLineInSection(
                    Math2D.ConvertPointsToLineSegments(s.Points)));

            service.Calculate(calculation, failureMechanism.GeneralInput,
                              HydraulicBoundaryCalculationSettingsFactory.CreateSettings(assessmentSection.HydraulicBoundaryDatabase),
                              section.Length);
        }
        public void Run_ValidCalculation_InputPropertiesCorrectlySentToService()
        {
            // Setup
            var mocks = new MockRepository();
            var profileSpecificCalculator = new TestPipingCalculator();
            var sectionSpecificCalculator = new TestPipingCalculator();
            var calculatorFactory         = mocks.StrictMock <IHydraRingCalculatorFactory>();

            calculatorFactory.Expect(cf => cf.CreatePipingCalculator(null))
            .IgnoreArguments()
            .Return(profileSpecificCalculator)
            .Repeat.Once();
            calculatorFactory.Expect(cf => cf.CreatePipingCalculator(null))
            .IgnoreArguments()
            .Return(sectionSpecificCalculator)
            .Repeat.Once();
            mocks.ReplayAll();

            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);

            DataImportHelper.ImportHydraulicBoundaryDatabase(assessmentSection, validFilePath);

            TestPipingFailureMechanism failureMechanism = TestPipingFailureMechanism.GetFailureMechanismWithSurfaceLinesAndStochasticSoilModels();
            var calculation = ProbabilisticPipingCalculationTestFactory.CreateCalculationWithValidInput <TestProbabilisticPipingCalculation>(
                assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001));

            calculation.InputParameters.HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001);

            CalculatableActivity activity = PipingCalculationActivityFactory.CreateProbabilisticPipingCalculationActivity(
                calculation, failureMechanism, assessmentSection);

            using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
            {
                // Call
                activity.Run();

                // Assert
                PipingCalculationInput[] profileSpecificInputs = profileSpecificCalculator.ReceivedInputs.ToArray();
                PipingCalculationInput[] sectionSpecificInputs = sectionSpecificCalculator.ReceivedInputs.ToArray();

                Assert.AreEqual(1, profileSpecificInputs.Length);
                Assert.AreEqual(1, sectionSpecificInputs.Length);

                double sectionLength = failureMechanism.Sections.Single(
                    s => calculation.IsSurfaceLineIntersectionWithReferenceLineInSection(
                        Math2D.ConvertPointsToLineSegments(s.Points))).Length;

                AssertCalculatorInput(failureMechanism.GeneralInput, calculation.InputParameters, 0, profileSpecificInputs[0]);
                AssertCalculatorInput(failureMechanism.GeneralInput, calculation.InputParameters, sectionLength, sectionSpecificInputs[0]);
            }

            mocks.VerifyAll();
        }
Beispiel #13
0
        private FailureMechanismSection GetSection()
        {
            FailureMechanismSection[] sections = data.FailureMechanism
                                                 .Sections
                                                 .Where(section => data.PipingCalculation.IsSurfaceLineIntersectionWithReferenceLineInSection(
                                                            Math2D.ConvertPointsToLineSegments(section.Points)))
                                                 .ToArray();

            return(sections.Length == 1
                       ? sections[0]
                       : null);
        }
Beispiel #14
0
        /// <summary>
        /// Indicates whether a stochastic soil model intersects with a surface line.
        /// </summary>
        /// <param name="stochasticSoilModel">The stochastic soil model used to match a surface line.</param>
        /// <param name="surfaceLine">The surface line used to match a stochastic soil model.</param>
        /// <returns><c>true</c> when the <paramref name="stochasticSoilModel"/> intersects with the <paramref name="surfaceLine"/>;
        /// <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public static bool IntersectsWithSurfaceLineGeometry(this MacroStabilityInwardsStochasticSoilModel stochasticSoilModel,
                                                             MacroStabilityInwardsSurfaceLine surfaceLine)
        {
            if (stochasticSoilModel == null)
            {
                throw new ArgumentNullException(nameof(stochasticSoilModel));
            }

            if (surfaceLine == null)
            {
                throw new ArgumentNullException(nameof(surfaceLine));
            }

            Segment2D[] surfaceLineSegments = Math2D.ConvertPointsToLineSegments(surfaceLine.Points.Select(p => new Point2D(p.X, p.Y))).ToArray();
            return(DoesSoilModelGeometryIntersectWithSurfaceLineGeometry(stochasticSoilModel, surfaceLineSegments));
        }
        /// <summary>
        /// Indicates whether a stochastic soil model intersects with a surface line.
        /// </summary>
        /// <param name="stochasticSoilModel">The stochastic soil model used to match a surface line.</param>
        /// <param name="surfaceLine">The surface line used to match a stochastic soil model.</param>
        /// <returns><c>true</c> when the <paramref name="stochasticSoilModel"/> intersects with the <paramref name="surfaceLine"/>;
        /// <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public static bool IntersectsWithSurfaceLineGeometry(this PipingStochasticSoilModel stochasticSoilModel,
                                                             PipingSurfaceLine surfaceLine)
        {
            if (stochasticSoilModel == null)
            {
                throw new ArgumentNullException(nameof(stochasticSoilModel));
            }

            if (surfaceLine == null)
            {
                throw new ArgumentNullException(nameof(surfaceLine));
            }

            Segment2D[] surfaceLineSegments = Math2D.ConvertPointsToLineSegments(GetSurfaceLine2DGeometry(surfaceLine)).ToArray();
            return(DoesSoilModelGeometryIntersectWithSurfaceLineGeometry(stochasticSoilModel, surfaceLineSegments));
        }
Beispiel #16
0
        public void IsSurfaceLineIntersectionWithReferenceLineInSection_SurfaceLineDoesNotIntersectReferenceline_ReturnsFalse()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty)
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(0.0, 0.0)
            };

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 5.0, 0.0),
                new Point3D(0.0, 0.0, 1.0),
                new Point3D(0.0, -5.0, 0.0)
            });
            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(10.0, 0.0),
                new Point2D(20.0, 0.0)
            });

            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    SurfaceLine = surfaceLine
                }
            };

            IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(referenceLine.Points);

            // Call
            bool intersects = calculation.IsSurfaceLineIntersectionWithReferenceLineInSection(lineSegments);

            // Assert
            Assert.IsFalse(intersects);
        }
Beispiel #17
0
        public void IsSurfaceLineIntersectionWithReferenceLineInSection_SurfaceLineIntersectsReferenceLine_ReturnsTrue()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty)
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(0.0, 0.0)
            };

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 5.0, 0.0),
                new Point3D(0.0, 0.0, 1.0),
                new Point3D(0.0, -5.0, 0.0)
            });
            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(0.0, 0.0),
                new Point2D(10.0, 0.0)
            });

            var calculation = new TestPipingCalculation
            {
                InputParameters =
                {
                    SurfaceLine = surfaceLine
                }
            };

            IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(referenceLine.Points);

            // Call
            bool intersects = calculation.IsSurfaceLineIntersectionWithReferenceLineInSection(lineSegments);

            // Assert
            Assert.IsTrue(intersects);
        }
        /// <summary>
        /// Gets a collection of the relevant <typeparamref name="T"/>.
        /// </summary>
        /// <param name="sectionResult">The section result to get the relevant scenarios for.</param>
        /// <param name="calculationScenarios">The calculation scenarios to get the relevant scenarios from.</param>
        /// <param name="intersectionFunc">The function to determine whether a scenario is belonging to the given <paramref name="sectionResult"/>.</param>
        /// <typeparam name="T">The type of the calculation scenarios.</typeparam>
        /// <returns>A collection of relevant calculation scenarios.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static IEnumerable <T> GetRelevantCalculationScenarios <T>(this FailureMechanismSectionResult sectionResult,
                                                                          IEnumerable <ICalculationScenario> calculationScenarios,
                                                                          Func <T, IEnumerable <Segment2D>, bool> intersectionFunc)
            where T : ICalculationScenario
        {
            if (sectionResult == null)
            {
                throw new ArgumentNullException(nameof(sectionResult));
            }

            if (calculationScenarios == null)
            {
                throw new ArgumentNullException(nameof(calculationScenarios));
            }

            if (intersectionFunc == null)
            {
                throw new ArgumentNullException(nameof(intersectionFunc));
            }

            IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(sectionResult.Section.Points);

            return(calculationScenarios.OfType <T>().Where(scenario => scenario.IsRelevant && intersectionFunc(scenario, lineSegments)));
        }
        private static IEnumerable <string> ValidateCalculationInMultipleSections(ProbabilisticPipingCalculation calculation, PipingFailureMechanism failureMechanism)
        {
            int numberOfSections = failureMechanism
                                   .Sections
                                   .Count(section => calculation.IsSurfaceLineIntersectionWithReferenceLineInSection(Math2D.ConvertPointsToLineSegments(section.Points)));

            if (numberOfSections > 1)
            {
                yield return(Resources.ProbabilisticPipingCalculationService_ValidateCalculationInMultipleSections_Cannot_determine_section_for_calculation);
            }
        }
Beispiel #20
0
        private static IEnumerable <Point2D> ClipWaternetZoneToSurfaceLine(IEnumerable <Point2D> surfaceLineLocalGeometry, IEnumerable <Point2D> waternetZoneAsPolygon)
        {
            double leftX  = Math.Max(waternetZoneAsPolygon.Min(p => p.X), surfaceLineLocalGeometry.Select(p => p.X).Min());
            double rightX = Math.Min(waternetZoneAsPolygon.Max(p => p.X), surfaceLineLocalGeometry.Select(p => p.X).Max());

            Segment2D[] surfaceLineSegments  = Math2D.ConvertPointsToLineSegments(surfaceLineLocalGeometry).ToArray();
            Segment2D[] waternetZoneSegments = Math2D.ConvertPointsToLineSegments(waternetZoneAsPolygon).ToArray();

            var intersectionPoints = new List <Point2D>();

            foreach (Segment2D surfaceLineSegment in surfaceLineSegments)
            {
                foreach (Segment2D waternetZoneSegment in waternetZoneSegments)
                {
                    Segment2DIntersectSegment2DResult intersectionPointResult = Math2D.GetIntersectionBetweenSegments(surfaceLineSegment, waternetZoneSegment);

                    if (intersectionPointResult.IntersectionType == Intersection2DType.Intersects)
                    {
                        intersectionPoints.Add(intersectionPointResult.IntersectionPoints.First());
                    }
                }
            }

            IEnumerable <double> allXCoordinates = waternetZoneAsPolygon.Select(p => p.X)
                                                   .Concat(surfaceLineLocalGeometry.Select(p => p.X))
                                                   .Concat(intersectionPoints.Select(p => p.X))
                                                   .Where(x => x >= leftX && x <= rightX)
                                                   .OrderBy(d => d)
                                                   .Distinct();

            var topLine    = new List <Point2D>();
            var bottomLine = new List <Point2D>();

            foreach (double xCoordinate in allXCoordinates)
            {
                Point2D surfaceLineIntersection = Math2D.SegmentsIntersectionWithVerticalLine(surfaceLineSegments, xCoordinate).First();
                IEnumerable <Point2D> waternetZoneIntersection = Math2D.SegmentsIntersectionWithVerticalLine(waternetZoneSegments, xCoordinate).Distinct().ToArray();

                if (waternetZoneIntersection.Any())
                {
                    double waternetZoneTop    = waternetZoneIntersection.Max(p => p.Y);
                    double waternetZoneBottom = waternetZoneIntersection.Min(p => p.Y);

                    double waternetBottomDelta = waternetZoneBottom - surfaceLineIntersection.Y;
                    double waternetTopDelta    = waternetZoneTop - surfaceLineIntersection.Y;

                    if ((Math.Abs(waternetBottomDelta) < tolerance || waternetBottomDelta > 0) && !intersectionPoints.Any(c => c.X.Equals(xCoordinate)))
                    {
                        continue;
                    }

                    IEnumerable <Point2D> waternetZonePoints = waternetZoneIntersection.OrderBy(p => p.Y);

                    if (Math.Abs(waternetTopDelta) < tolerance || waternetTopDelta < 0)
                    {
                        bottomLine.Add(waternetZonePoints.First());
                        topLine.Add(waternetZonePoints.Last());
                    }
                    else if (waternetTopDelta > 0 && waternetBottomDelta < -1.0 * tolerance)
                    {
                        bottomLine.Add(waternetZonePoints.First());
                        topLine.Add(surfaceLineIntersection);
                    }
                    else if (Math.Abs(waternetBottomDelta) < tolerance && waternetTopDelta > 0)
                    {
                        bottomLine.Add(surfaceLineIntersection);
                        topLine.Add(surfaceLineIntersection);
                    }
                }
            }

            var area = new List <Point2D>();

            if (AreaIsNotFlatLine(topLine, bottomLine))
            {
                area.AddRange(topLine);

                List <Point2D> sortedBottomLine = bottomLine.OrderByDescending(p => p.X).ToList();
                if (sortedBottomLine.First().Equals(topLine.Last()))
                {
                    sortedBottomLine.Remove(sortedBottomLine.First());
                }

                area.AddRange(sortedBottomLine);
                if (topLine.Any() && !area.Last().Equals(topLine.First()))
                {
                    area.Add(topLine.First());
                }
            }

            return(area.Count > 2 ? area : Enumerable.Empty <Point2D>());
        }
Beispiel #21
0
 private static IEnumerable <Segment2D> GetLineSegments(IEnumerable <Point2D> linePoints)
 {
     return(Math2D.ConvertPointsToLineSegments(linePoints));
 }
Beispiel #22
0
        private static IEnumerable <IEnumerable <Point2D> > CreateZoneAreas(IEnumerable <Point2D> waternetLineGeometry, IEnumerable <Point2D> phreaticLineGeometry)
        {
            var areas = new List <IEnumerable <Point2D> >();

            Segment2D[] phreaticLineSegments = Math2D.ConvertPointsToLineSegments(phreaticLineGeometry).ToArray();
            Segment2D[] waternetLineSegments = Math2D.ConvertPointsToLineSegments(waternetLineGeometry).ToArray();

            var intersectionPoints = new List <Point2D>();

            foreach (Segment2D phreaticLineSegment in phreaticLineSegments)
            {
                foreach (Segment2D waternetLineSegment in waternetLineSegments)
                {
                    Segment2DIntersectSegment2DResult intersectionPointResult = Math2D.GetIntersectionBetweenSegments(phreaticLineSegment, waternetLineSegment);

                    if (intersectionPointResult.IntersectionType == Intersection2DType.Intersects)
                    {
                        intersectionPoints.Add(intersectionPointResult.IntersectionPoints.First());
                    }
                }
            }

            IEnumerable <double> allXCoordinates = phreaticLineGeometry.Select(p => p.X)
                                                   .Concat(waternetLineGeometry.Select(p => p.X))
                                                   .Concat(intersectionPoints.Select(p => p.X))
                                                   .OrderBy(d => d)
                                                   .Distinct();

            var waternetLineArea = new List <Point2D>();
            var phreaticLineArea = new List <Point2D>();
            var areaPoints       = new List <Point2D>();

            foreach (double xCoordinate in allXCoordinates)
            {
                IEnumerable <Point2D> phreaticLineIntersections = Math2D.SegmentsIntersectionWithVerticalLine(phreaticLineSegments, xCoordinate);
                IEnumerable <Point2D> waternetLineIntersections = Math2D.SegmentsIntersectionWithVerticalLine(waternetLineSegments, xCoordinate);

                if (!phreaticLineIntersections.Any() || !waternetLineIntersections.Any())
                {
                    continue;
                }

                Point2D phreaticLineIntersection = phreaticLineIntersections.First();
                Point2D waternetLineIntersection = waternetLineIntersections.First();

                waternetLineArea.Add(new Point2D(xCoordinate, waternetLineIntersection.Y));
                phreaticLineArea.Add(new Point2D(xCoordinate, phreaticLineIntersection.Y));

                if (intersectionPoints.Any(p => Math.Abs(p.X - xCoordinate) < tolerance))
                {
                    areaPoints.AddRange(phreaticLineArea);
                    areaPoints.AddRange(waternetLineArea.OrderByDescending(p => p.X));
                    areaPoints.Add(phreaticLineArea.First());

                    areas.Add(areaPoints.ToArray());

                    waternetLineArea.Clear();
                    phreaticLineArea.Clear();
                    areaPoints.Clear();

                    waternetLineArea.Add(new Point2D(xCoordinate, waternetLineIntersection.Y));
                    phreaticLineArea.Add(new Point2D(xCoordinate, phreaticLineIntersection.Y));
                }
            }

            areaPoints.AddRange(phreaticLineArea);
            areaPoints.AddRange(waternetLineArea.OrderByDescending(p => p.X));
            areaPoints.Add(phreaticLineArea.First());

            areas.Add(areaPoints.ToArray());

            return(areas);
        }