Esempio n. 1
0
        /// <summary>
        /// Sets the geometry of the foreshore profile.
        /// </summary>
        /// <param name="points">The points corresponding to the geometry of
        /// the foreshore profile.</param>
        /// <exception cref="ArgumentException">Thrown when an element in
        /// <paramref name="points"/> is <c>null</c>.</exception>
        private void SetGeometry(IEnumerable <Point2D> points)
        {
            if (points.Any(p => p == null))
            {
                throw new ArgumentException(Resources.ForeshoreProfile_SetGeometry_A_point_in_the_collection_is_null);
            }

            Geometry = new RoundedPoint2DCollection(2, points.Select(p => new Point2D(p)).ToArray());
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MechanismSurfaceLineBase"/> class.
        /// </summary>
        /// <param name="name">The name of the surface line.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="name"/> is <c>null</c>.</exception>
        protected MechanismSurfaceLineBase(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            Name          = name;
            Points        = new Point3D[0];
            LocalGeometry = new RoundedPoint2DCollection(numberOfDecimalPlaces, new Point2D[0]);
        }
Esempio n. 3
0
        private static void AssertForeshoreChartData(ForeshoreProfile foreshoreProfile, ChartData chartData)
        {
            Assert.IsInstanceOf <ChartLineData>(chartData);
            var foreshoreChartData = (ChartLineData)chartData;

            RoundedPoint2DCollection foreshoreGeometry = foreshoreProfile.Geometry;
            string expectedName = $"{foreshoreProfile.Name} - Voorlandprofiel";

            Assert.AreEqual(expectedName, chartData.Name);
            CollectionAssert.AreEqual(foreshoreGeometry, foreshoreChartData.Points);
        }
Esempio n. 4
0
        public void EntryPointL_Always_SameNumberOfDecimalsAsSurfaceLineLocalGeometry()
        {
            // Setup
            PipingSurfaceLine surfaceLine = CreateSurfaceLine();
            var pipingInput = new TestPipingInput();

            // Call
            RoundedPoint2DCollection localGeometry = surfaceLine.LocalGeometry;

            // Assert
            Assert.AreEqual(localGeometry.NumberOfDecimalPlaces, pipingInput.EntryPointL.NumberOfDecimalPlaces);
        }
Esempio n. 5
0
        /// <summary>
        /// Create points of the Waternet zone in 2D space based on the provide <paramref name="waternetLine"/>.
        /// </summary>
        /// <param name="waternetLine">The Waternet line to create the zone for.</param>
        /// <param name="surfaceLine">The <see cref="MacroStabilityInwardsSurfaceLine"/> that may intersect with
        /// the <see cref="MacroStabilityInwardsWaternetLine.PhreaticLine"/> and by doing that restricts the
        /// drawn height of it.</param>
        /// <returns>A collection of points in 2D space or an empty collection when:
        /// <list type="bullet">
        /// <item><paramref name="waternetLine"/> is <c>null</c>;</item>
        /// <item><paramref name="surfaceLine"/> is <c>null</c>;</item>
        /// <item>The geometry of the <see cref="MacroStabilityInwardsWaternetLine"/> is <c>empty</c>;</item>
        /// <item>The geometry of the <see cref="MacroStabilityInwardsWaternetLine.PhreaticLine"/> is <c>empty</c>.</item>
        /// </list>
        /// </returns>
        public static IEnumerable <IEnumerable <Point2D> > CreateWaternetZonePoints(MacroStabilityInwardsWaternetLine waternetLine,
                                                                                    MacroStabilityInwardsSurfaceLine surfaceLine)
        {
            if (waternetLine == null || surfaceLine == null ||
                !waternetLine.Geometry.Any() || !waternetLine.PhreaticLine.Geometry.Any())
            {
                return(new Point2D[0][]);
            }

            IEnumerable <Point2D> surfaceLineLocalGeometry = surfaceLine.LocalGeometry.ToArray();
            IEnumerable <Point2D> phreaticLineGeometry     = new RoundedPoint2DCollection(2, waternetLine.PhreaticLine.Geometry).ToArray();
            IEnumerable <Point2D> waternetLineGeometry     = new RoundedPoint2DCollection(2, waternetLine.Geometry).ToArray();

            return(IsSurfaceLineAboveWaternetZone(surfaceLineLocalGeometry, waternetLineGeometry, phreaticLineGeometry)
                       ? CreateZoneAreas(waternetLineGeometry, phreaticLineGeometry)
                       : GetWaternetZoneWithSurfaceLineIntersection(surfaceLineLocalGeometry, waternetLineGeometry, phreaticLineGeometry).ToArray());
        }
Esempio n. 6
0
        private static void AssertWaterLevelsChartData(RoundedPoint2DCollection foreshorePoints,
                                                       IEnumerable <RoundedDouble> waterLevels,
                                                       ChartData chartData)
        {
            Assert.IsInstanceOf <ChartMultipleLineData>(chartData);
            var chartLineData = (ChartMultipleLineData)chartData;

            List <Point2D[]> expectedGeometry = waterLevels.Select(waterLevel => new[]
            {
                new Point2D(foreshorePoints.First().X, waterLevel),
                new Point2D(GetPointX(waterLevel, foreshorePoints.Last()), waterLevel)
            }).ToList();

            CollectionAssert.AreEqual(expectedGeometry, chartLineData.Lines);

            Assert.AreEqual("Waterstanden in berekening", chartLineData.Name);
        }
Esempio n. 7
0
        private static void AssertChartData(RoundedPoint2DCollection foreshorePoints,
                                            double value,
                                            ChartData chartData,
                                            string chartDataName)
        {
            Assert.IsInstanceOf <ChartLineData>(chartData);
            var chartLineData = (ChartLineData)chartData;

            var expectedGeometry = new[]
            {
                new Point2D(foreshorePoints.First().X, value),
                new Point2D(GetPointX(value, foreshorePoints.Last()), value)
            };

            CollectionAssert.AreEqual(expectedGeometry, chartLineData.Points);

            Assert.AreEqual(chartDataName, chartLineData.Name);
        }
        public void ParameteredConstructor_ExpectedValues()
        {
            // Setup
            const int             numberOfDecimals = 2;
            IEnumerable <Point2D> points           = CreatePointData();

            // Call
            var collection = new RoundedPoint2DCollection(numberOfDecimals, points);

            // Assert
            Assert.IsInstanceOf <IEnumerable <Point2D> >(collection);
            Assert.AreEqual(numberOfDecimals, collection.NumberOfDecimalPlaces);
            IEnumerable <Point2D> expectedPoints = new[]
            {
                new Point2D(2.35, 3.85),
                new Point2D(4.63, 2.10),
                new Point2D(6.74, 1.59)
            };

            CollectionAssert.AreEqual(expectedPoints, collection);
        }
Esempio n. 9
0
        /// <summary>
        /// Sets the geometry of the surface line.
        /// </summary>
        /// <param name="points">The collection of points defining the surface line geometry.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="points"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when any element of <paramref name="points"/> is <c>null</c>.</exception>
        public void SetGeometry(IEnumerable <Point3D> points)
        {
            if (points == null)
            {
                throw new ArgumentNullException(nameof(points), Resources.MechanismSurfaceLineBase_Collection_of_points_for_geometry_is_null);
            }

            if (points.Any(p => p == null))
            {
                throw new ArgumentException(Resources.MechanismSurfaceLineBase_A_point_in_the_collection_was_null);
            }

            Points = points.Select(p => new Point3D(p)).ToArray();

            if (Points.Any())
            {
                StartingWorldPoint = Points.First();
                EndingWorldPoint   = Points.Last();
            }

            LocalGeometry = new RoundedPoint2DCollection(numberOfDecimalPlaces, Points.ProjectToLZ());
        }
        public void GetEnumerator_Always_ReturnsRoundedPoints()
        {
            // Setup
            const int             numberOfDecimals = 2;
            IEnumerable <Point2D> points           = CreatePointData();

            // Call
            var collection = new RoundedPoint2DCollection(numberOfDecimals, points);

            // Assert
            Point2D[] expectedPoints =
            {
                new Point2D(2.35, 3.85),
                new Point2D(4.63, 2.10),
                new Point2D(6.74, 1.59)
            };
            var index = 0;

            foreach (Point2D roundedPoint in collection)
            {
                Assert.AreEqual(expectedPoints[index], roundedPoint);
                index++;
            }
        }
Esempio n. 11
0
 /// <summary>
 /// Gets the accuracy for a <see cref="RoundedPoint2DCollection"/>.
 /// </summary>
 public static double GetAccuracy(this RoundedPoint2DCollection collection)
 {
     return(0.5 * Math.Pow(10.0, -collection.NumberOfDecimalPlaces));
 }
Esempio n. 12
0
 /// <summary>
 /// Creates a new instance of <see cref="Ring"/>.
 /// </summary>
 /// <param name="points">The points that form the ring.</param>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="points"/> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Thrown when <paramref name="points"/> contains less than 2 unique points.</exception>
 /// <remarks>While a ring is defined to be closed line, it's not required
 /// that the given <paramref name="points"/>' first point and last point
 /// are equal.</remarks>
 public Ring(IEnumerable <Point2D> points)
 {
     ValidateAndTrimPoints(points);
     Points = new RoundedPoint2DCollection(2, points);
 }