public void Create_GlobalSurfaceLine_ProjectSurfaceLineIntoLZPlaneSpannedByFirstAndLastPoint()
        {
            // Setup
            const string name        = "Global coordinate surface line";
            var          surfaceLine = new PipingSurfaceLine(name);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(1.0, 1.0, 2.2),
                new Point3D(2.0, 3.0, 4.4), // Outlier from line specified by extrema
                new Point3D(3.0, 4.0, 7.7)
            });

            // Call
            Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine);

            // Assert
            double       length = Math.Sqrt(2 * 2 + 3 * 3);
            const double secondCoordinateFactor = (2.0 * 1.0 + 3.0 * 2.0) / (2.0 * 2.0 + 3.0 * 3.0);

            double[] expectedCoordinatesX =
            {
                0.0,
                secondCoordinateFactor *length,
                length
            };
            Assert.AreEqual(name, actual.Name);
            CollectionAssert.AreEqual(expectedCoordinatesX, actual.Points.Select(p => p.X).ToArray(), new DoubleWithToleranceComparer(1e-2));
            CollectionAssert.AreEqual(Enumerable.Repeat(0, surfaceLine.Points.Count()).ToArray(), actual.Points.Select(p => p.Y).ToArray());
            CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray());
            CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Count()), actual.Points.Select(p => p.Type));
        }
        public void Create_SurfaceLineWithOnlyOnePoint_CreatePipingSurfaceLineWithOnePoint()
        {
            // Setup
            const string name        = "Global coordinate surface line";
            var          surfaceLine = new PipingSurfaceLine(name);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(1.0, 1.0, 2.2)
            });

            // Call
            Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine);

            // Assert
            double[] expectedCoordinatesX =
            {
                0.0
            };
            Assert.AreEqual(name, actual.Name);
            CollectionAssert.AreEqual(expectedCoordinatesX, actual.Points.Select(p => p.X).ToArray());
            CollectionAssert.AreEqual(Enumerable.Repeat(0, surfaceLine.Points.Count()).ToArray(), actual.Points.Select(p => p.Y).ToArray());
            CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray());
            CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Count()), actual.Points.Select(p => p.Type));
        }
        public void Create_LocalSurfaceLineNotNormalized_TranslateAllPointsToMakeFirstCoordinateZeroX()
        {
            // Setup
            const string name        = "Local coordinate surface line";
            const double firstX      = 4.6;
            var          surfaceLine = new PipingSurfaceLine(name);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(firstX, 0.0, 1.1),
                new Point3D(7.8, 0.0, 3.3),
                new Point3D(9.9, 0.0, 5.5)
            });

            // Call
            Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine);

            // Assert
            double[] expectedCoordinatesX = surfaceLine.Points.Select(p => p.X - firstX).ToArray();
            Assert.AreEqual(name, actual.Name);
            CollectionAssert.AreEqual(expectedCoordinatesX, actual.Points.Select(p => p.X).ToArray(), new DoubleWithToleranceComparer(1e-2));
            CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Y).ToArray(), actual.Points.Select(p => p.Y).ToArray());
            CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray());
            CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Count()), actual.Points.Select(p => p.Type));
        }
        public void Create_SurfaceLineWithMultipleCharacteristicTypesForOnePoint_CreateSurfaceLineWithPointsForEachType()
        {
            // Setup
            const string name        = "Surface line without points";
            var          point       = new Point3D(1.0, 1.0, 2.2);
            var          surfaceLine = new PipingSurfaceLine(name);

            surfaceLine.SetGeometry(new[]
            {
                point
            });
            surfaceLine.SetDikeToeAtRiverAt(point);
            surfaceLine.SetDikeToeAtPolderAt(point);
            surfaceLine.SetDitchDikeSideAt(point);
            surfaceLine.SetBottomDitchPolderSideAt(point);
            surfaceLine.SetBottomDitchDikeSideAt(point);
            surfaceLine.SetDitchPolderSideAt(point);

            // Call
            Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine);

            // Assert
            Assert.AreEqual(name, actual.Name);
            Assert.AreEqual(5, actual.Points.Count);
            AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.DikeToeAtPolder);
            AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.DitchDikeSide);
            AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.BottomDitchPolderSide);
            AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.BottomDitchDikeSide);
            AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.DitchPolderSide);
        }
        public void Create_SurfaceLineWithoutPoints_CreateSurfaceLineWithoutPoints()
        {
            // Setup
            const string name        = "Surface line without points";
            var          surfaceLine = new PipingSurfaceLine(name);

            // Call
            Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine);

            // Assert
            Assert.AreEqual(name, actual.Name);
            CollectionAssert.IsEmpty(actual.Points);
        }
Beispiel #6
0
        private static IEnumerable <PipingPoint> CreatePoints(RiskeerPipingSurfaceLine line)
        {
            Point2D[] projectedPoints = line.LocalGeometry.ToArray();
            var       pipingPoints    = new List <PipingPoint>();

            for (var i = 0; i < line.Points.Count(); i++)
            {
                IEnumerable <PipingPoint> newPoints = CreatePoint(line, projectedPoints, i);
                pipingPoints.AddRange(newPoints);
            }

            return(pipingPoints);
        }
Beispiel #7
0
        /// <summary>
        /// Creates a <see cref="PipingSurfaceLine"/> for the kernel given a <see cref="RiskeerPipingSurfaceLine"/>.
        /// </summary>
        /// <param name="line">The surface line configured in the application.</param>
        /// <returns>The surface line to be consumed by the kernel.</returns>
        public static PipingSurfaceLine Create(RiskeerPipingSurfaceLine line)
        {
            var surfaceLine = new PipingSurfaceLine
            {
                Name = line.Name
            };

            if (line.Points.Any())
            {
                surfaceLine.Points.AddRange(CreatePoints(line));
            }

            return(surfaceLine);
        }
        public void Create_SurfaceLineWithPolderDikeSide_CreateSurfaceLineWithDitchPolderSideSet()
        {
            // Setup
            const string name        = "Surface line without points";
            var          point       = new Point3D(1.0, 1.0, 2.2);
            var          surfaceLine = new PipingSurfaceLine(name);

            surfaceLine.SetGeometry(new[]
            {
                point
            });
            surfaceLine.SetDitchPolderSideAt(point);

            // Call
            Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine);

            // Assert
            Assert.AreEqual(name, actual.Name);
            Assert.AreEqual(1, actual.Points.Count);
            AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.DitchPolderSide);
        }
Beispiel #9
0
        private static IEnumerable <PipingPoint> CreatePoint(RiskeerPipingSurfaceLine line, IEnumerable <Point2D> projectedPoints, int index)
        {
            Point3D surfaceLinePoint = line.Points.ElementAt(index);
            Point2D projectedPoint   = projectedPoints.ElementAt(index);

            var pipingPoints = new List <PipingPoint>();

            if (ReferenceEquals(line.DitchPolderSide, surfaceLinePoint))
            {
                pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.DitchPolderSide));
            }

            if (ReferenceEquals(line.BottomDitchPolderSide, surfaceLinePoint))
            {
                pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.BottomDitchPolderSide));
            }

            if (ReferenceEquals(line.BottomDitchDikeSide, surfaceLinePoint))
            {
                pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.BottomDitchDikeSide));
            }

            if (ReferenceEquals(line.DitchDikeSide, surfaceLinePoint))
            {
                pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.DitchDikeSide));
            }

            if (ReferenceEquals(line.DikeToeAtPolder, surfaceLinePoint))
            {
                pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.DikeToeAtPolder));
            }

            if (!pipingPoints.Any())
            {
                pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.None));
            }

            return(pipingPoints);
        }
        public void Create_NormalizedLocalSurfaceLine_ReturnsSurfaceLineWithIdenticalPoints()
        {
            // Setup
            const string name        = "Local coordinate surface line";
            var          surfaceLine = new PipingSurfaceLine(name);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 1.1),
                new Point3D(2.2, 0.0, 3.3),
                new Point3D(4.4, 0.0, 5.5)
            });

            // Call
            Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine);

            // Assert
            Assert.AreEqual(name, actual.Name);
            CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.X).ToArray(), actual.Points.Select(p => p.X).ToArray());
            CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Y).ToArray(), actual.Points.Select(p => p.Y).ToArray());
            CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray());
            CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Count()), actual.Points.Select(p => p.Type));
        }