public void CreateSoilLayerAreas_SurfaceLineEndsBelowLayerTopButAboveBottom_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 3.0),
                new Point3D(1, 0, 2.0),
                new Point3D(2, 0, 2.0)
            });
            const double bottom      = 1.5;
            const double top         = 2.5;
            var          soilLayer   = new PipingSoilLayer(top);
            var          soilProfile = new PipingSoilProfile("name", bottom, new[]
            {
                soilLayer
            }, SoilProfileType.SoilProfile1D);

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();

            // Assert
            Assert.AreEqual(1, areas.Count());
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(0.5, top),
                new Point2D(1, 2.0),
                new Point2D(2, 2.0),
                new Point2D(2, bottom),
                new Point2D(0, bottom),
                new Point2D(0, top)
            }, areas.ElementAt(0));
        }
Ejemplo n.º 2
0
        private void SetSoilProfileChartData()
        {
            PipingSoilProfile soilProfile = data.InputParameters.StochasticSoilProfile?.SoilProfile;

            // If necessary, regenerate all soil layer chart data
            if (!ReferenceEquals(currentSoilProfile, soilProfile))
            {
                currentSoilProfile = soilProfile;

                soilProfileChartData.Clear();
                soilLayerChartDataLookup.Clear();
                GetSoilLayers().Select(PipingChartDataFactory.CreateSoilLayerChartData)
                .ForEachElementDo(sl =>
                {
                    soilProfileChartData.Insert(0, sl);
                    soilLayerChartDataLookup.Add(sl);
                });

                PipingChartDataFactory.UpdateSoilProfileChartDataName(soilProfileChartData, currentSoilProfile);
            }

            // Update the areas of all soil layer chart data
            IEnumerable <PipingSoilLayer> soilLayers = GetSoilLayers();

            for (var i = 0; i < soilLayers.Count(); i++)
            {
                ChartMultipleAreaData soilLayerData = soilLayerChartDataLookup[i];

                soilLayerData.Areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayers.ElementAt(i), currentSoilProfile, data.InputParameters.SurfaceLine);
            }
        }
        public void CreateSoilLayerAreas_SurfaceLineOnTopOrAboveSoilLayer_ReturnsSoilLayerPointsAsRectangle()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 4),
                new Point3D(0, 0, 3.2),
                new Point3D(2, 0, 4)
            });
            var soilLayer   = new PipingSoilLayer(3.2);
            var soilProfile = new PipingSoilProfile("name", 2.0, new[]
            {
                soilLayer
            }, SoilProfileType.SoilProfile1D);

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();

            // Assert
            Assert.AreEqual(1, areas.Count());
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(0, 3.2),
                new Point2D(2, 3.2),
                new Point2D(2, 2),
                new Point2D(0, 2)
            }, areas.ElementAt(0));
        }
        public void CreateSoilLayerAreas_SoilProfileNull_ReturnsEmptyAreasCollection()
        {
            // Setup
            var soilLayer = new PipingSoilLayer(3.2);
            PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, null, surfaceLine);

            // Assert
            CollectionAssert.IsEmpty(areas);
        }
        public void CreateSoilLayerAreas_SurfaceLineNull_ReturnsEmptyAreasCollection()
        {
            // Setup
            var soilLayer   = new PipingSoilLayer(3.2);
            var soilProfile = new PipingSoilProfile("name", 2.0, new[]
            {
                soilLayer
            }, SoilProfileType.SoilProfile1D);

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, null);

            // Assert
            CollectionAssert.IsEmpty(areas);
        }
        public void CreateSoilLayerAreas_SurfaceLineZigZagsThroughSoilLayer_ReturnsSoilLayerPointsSplitInMultipleAreas()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 4.0),
                new Point3D(4, 0, 0.0),
                new Point3D(8, 0, 4.0)
            });
            const int bottom      = 1;
            const int top         = 3;
            var       soilLayer   = new PipingSoilLayer(top);
            var       soilProfile = new PipingSoilProfile("name", bottom, new[]
            {
                soilLayer
            }, SoilProfileType.SoilProfile1D);

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();

            // Assert
            Assert.AreEqual(2, areas.Count());
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(1, top),
                new Point2D(3, bottom),
                new Point2D(0, bottom),
                new Point2D(0, top)
            }, areas.ElementAt(0));
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(5, bottom),
                new Point2D(7, top),
                new Point2D(8, top),
                new Point2D(8, bottom)
            }, areas.ElementAt(1));
        }
        public void CreateSoilLayerAreas_SurfaceLineBelowSoilLayer_ReturnsEmptyAreasCollection()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 2.0),
                new Point3D(2, 0, 2.0)
            });
            var soilLayer   = new PipingSoilLayer(3.2);
            var soilProfile = new PipingSoilProfile("name", 2.0, new[]
            {
                soilLayer
            }, SoilProfileType.SoilProfile1D);

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine);

            // Assert
            CollectionAssert.IsEmpty(areas);
        }