コード例 #1
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);
        }
コード例 #2
0
        public void Constructor_CalculationWithoutStochasticSoilProfile_ChartDataSetWithDefaultSoilProfileChartDataName()
        {
            // Setup
            MacroStabilityInwardsSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();

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

            // Call
            using (new MacroStabilityInwardsCalculatorFactoryConfig())
                using (var control = new MacroStabilityInwardsOutputChartControl(calculation,
                                                                                 new GeneralMacroStabilityInwardsInput(),
                                                                                 AssessmentSectionTestHelper.GetTestAssessmentLevel))
                {
                    // Assert
                    IChartControl       chartControl = GetChartControl(control);
                    ChartDataCollection chartData    = chartControl.Data;
                    MacroStabilityInwardsViewChartDataAssert.AssertSoilProfileChartData(calculation.InputParameters.SoilProfileUnderSurfaceLine,
                                                                                        "Ondergrondschematisatie",
                                                                                        false,
                                                                                        chartData.Collection.ElementAt(soilProfileIndex));

                    Assert.AreEqual(calculation.Name, chartControl.ChartTitle);
                }
        }
コード例 #3
0
        private static MacroStabilityInwardsSurfaceLine GetSurfaceLine(Point3D[] points)
        {
            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Surface line name");

            surfaceLine.SetGeometry(points);
            return(surfaceLine);
        }
コード例 #4
0
        public void GenerateCalculationItemsStructure_Always_CreateCalculationsWithSurfaceLineNameSoilProfileNameGeneralInputAndSemiProbabilisticInput()
        {
            // Setup
            var soilProfile1 = new MacroStabilityInwardsSoilProfile1D("Profile 1", -10.0, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(-5.0),
                new MacroStabilityInwardsSoilLayer1D(-2.0),
                new MacroStabilityInwardsSoilLayer1D(1.0)
            });
            var soilProfile2 = new MacroStabilityInwardsSoilProfile1D("Profile 2", -8.0, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(-4.0),
                new MacroStabilityInwardsSoilLayer1D(0.0),
                new MacroStabilityInwardsSoilLayer1D(4.0)
            });

            var soilModel = new MacroStabilityInwardsStochasticSoilModel("A", new[]
            {
                new Point2D(1.0, 0.0),
                new Point2D(5.0, 0.0)
            }, new[]
            {
                new MacroStabilityInwardsStochasticSoilProfile(0.3, soilProfile1),
                new MacroStabilityInwardsStochasticSoilProfile(0.7, soilProfile2)
            });

            MacroStabilityInwardsStochasticSoilModel[] availableSoilModels =
            {
                soilModel
            };

            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Surface Line");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(3.0, 5.0, 0.0),
                new Point3D(3.0, 0.0, 1.0),
                new Point3D(3.0, -5.0, 0.0)
            });

            MacroStabilityInwardsSurfaceLine[] surfaceLines =
            {
                surfaceLine
            };

            // Call
            IEnumerable <ICalculationBase> result = MacroStabilityInwardsCalculationConfigurationHelper.GenerateCalculationItemsStructure(
                surfaceLines,
                availableSoilModels).ToArray();

            // Assert
            var group = result.First(sl => sl.Name == surfaceLine.Name) as CalculationGroup;

            Assert.NotNull(group);
            var calculationInput1 = (MacroStabilityInwardsCalculationScenario)group.Children[0];
            var calculationInput2 = (MacroStabilityInwardsCalculationScenario)group.Children[1];

            Assert.AreEqual($"{surfaceLine.Name} {soilProfile1.Name}", calculationInput1.Name);
            Assert.AreEqual($"{surfaceLine.Name} {soilProfile2.Name}", calculationInput2.Name);
        }
コード例 #5
0
        /// <summary>
        /// Read the <see cref="SurfaceLineEntity"/> and use the information to construct
        /// a <see cref="MacroStabilityInwardsSurfaceLine"/>.
        /// </summary>
        /// <param name="entity">The <see cref="SurfaceLineEntity"/> to create
        /// <see cref="MacroStabilityInwardsSurfaceLine"/> for.</param>
        /// <param name="collector">The object keeping track of read operations.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsSurfaceLine"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <see cref="SurfaceLineEntity.PointsXml"/>
        /// of <paramref name="entity"/> is empty.</exception>
        /// <exception cref="InvalidEnumArgumentException">Thrown when the <paramref name="entity"/>
        /// contains an invalid type of characteristic point.</exception>
        /// <exception cref="NotSupportedException">Thrown when the <paramref name="entity"/> contains a
        /// characteristic point that is not supported.</exception>
        public static MacroStabilityInwardsSurfaceLine ReadAsMacroStabilityInwardsSurfaceLine(
            this SurfaceLineEntity entity,
            ReadConversionCollector collector)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

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

            if (collector.ContainsMacroStabilityInwardsSurfaceLine(entity))
            {
                return(collector.GetMacroStabilityInwardsSurfaceLine(entity));
            }

            var surfaceLine = new MacroStabilityInwardsSurfaceLine(entity.Name)
            {
                ReferenceLineIntersectionWorldPoint = GetReferenceLineIntersectionWorldPoint(entity)
            };

            surfaceLine.SetGeometry(ReadGeometryPoints(entity.PointsXml));
            entity.ReadCharacteristicPoints(surfaceLine);

            collector.Read(entity, surfaceLine);

            return(surfaceLine);
        }
コード例 #6
0
        /// <summary>
        /// Creates a <see cref="SurfaceLineEntity"/> based on the information of the <see cref="MacroStabilityInwardsSurfaceLine"/>.
        /// </summary>
        /// <param name="surfaceLine">The surface line to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="SurfaceLineEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        internal static SurfaceLineEntity Create(this MacroStabilityInwardsSurfaceLine surfaceLine,
                                                 PersistenceRegistry registry,
                                                 int order)
        {
            if (surfaceLine == null)
            {
                throw new ArgumentNullException(nameof(surfaceLine));
            }

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

            if (registry.Contains(surfaceLine))
            {
                return(registry.Get(surfaceLine));
            }

            var entity = new SurfaceLineEntity
            {
                Name = surfaceLine.Name.DeepClone(),
                ReferenceLineIntersectionX = surfaceLine.ReferenceLineIntersectionWorldPoint?.X.ToNaNAsNull(),
                ReferenceLineIntersectionY = surfaceLine.ReferenceLineIntersectionWorldPoint?.Y.ToNaNAsNull(),
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(surfaceLine.Points),
                Order     = order
            };

            CreateCharacteristicPointEntities(surfaceLine, entity);

            registry.Register(entity, surfaceLine);

            return(entity);
        }
        public void SoilProfile1DCreate_ValidSoilProfile1D_ReturnsEmptyPreconsolidationStresses()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 4.0),
                new Point3D(4, 0, 0.0),
                new Point3D(8, 0, 4.0)
            });

            var layer   = new MacroStabilityInwardsSoilLayer1D(1);
            var profile = new MacroStabilityInwardsSoilProfile1D("name", 0, new[]
            {
                layer
            });

            // Call
            MacroStabilityInwardsSoilProfileUnderSurfaceLine profileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(
                profile, surfaceLine);

            // Assert
            CollectionAssert.IsEmpty(profileUnderSurfaceLine.PreconsolidationStresses);
        }
コード例 #8
0
        public void Clone_AllPropertiesSet_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Surface line");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 0),
                new Point3D(1, 1, 1)
            });

            MacroStabilityInwardsStochasticSoilModel   stochasticSoilModel   = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel();
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = stochasticSoilModel.StochasticSoilProfiles.First();

            // Precondition
            Assert.IsNotNull(stochasticSoilProfile);

            var original = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties());

            MacroStabilityInwardsTestDataGenerator.SetRandomMacroStabilityInwardsInput(original);

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, MacroStabilityInwardsCloneAssert.AreClones);
        }
コード例 #9
0
        /// <summary>
        /// Creates a new <see cref="MacroStabilityInwardsSoilProfileUnderSurfaceLine"/>.
        /// </summary>
        /// <param name="soilProfile">The soil profile containing layers under the <paramref name="surfaceLine"/>.</param>
        /// <param name="surfaceLine">The surface line which determines the top of the <paramref name="soilProfile"/>.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsSoilProfileUnderSurfaceLine"/> containing geometries from the
        /// <paramref name="soilProfile"/> under the <paramref name="surfaceLine"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        /// <exception cref="NotSupportedException">Thrown when the given <paramref name="soilProfile"/> type
        /// is not supported.</exception>
        public static MacroStabilityInwardsSoilProfileUnderSurfaceLine Create(IMacroStabilityInwardsSoilProfile <IMacroStabilityInwardsSoilLayer> soilProfile,
                                                                              MacroStabilityInwardsSurfaceLine surfaceLine)
        {
            if (soilProfile == null)
            {
                throw new ArgumentNullException(nameof(soilProfile));
            }

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

            var profile1D = soilProfile as MacroStabilityInwardsSoilProfile1D;

            if (profile1D != null)
            {
                return(Create(profile1D, surfaceLine));
            }

            var profile2D = soilProfile as MacroStabilityInwardsSoilProfile2D;

            if (profile2D != null)
            {
                return(Create(profile2D));
            }

            throw new NotSupportedException($"{soilProfile.GetType().Name} is not supported. " +
                                            $"Supported types are: {nameof(MacroStabilityInwardsSoilProfile1D)} " +
                                            $"and {nameof(MacroStabilityInwardsSoilProfile2D)}.");
        }
        /// <summary>
        /// Makes a deep clone of the <paramref name="surfaceLine"/> and sets a
        /// new geometry, reference line intersection world reference point and
        /// characteristic points.
        /// </summary>
        /// <param name="surfaceLine">The <see cref="MacroStabilityInwardsSurfaceLine"/>
        /// which needs to be deep cloned and modified.</param>
        /// <returns>A deep clone of <paramref name="surfaceLine"/> with modified
        /// geometric and characteristic points.</returns>
        private static MacroStabilityInwardsSurfaceLine DeepCloneAndModifyPoints(MacroStabilityInwardsSurfaceLine surfaceLine)
        {
            var     random = new Random(21);
            Point2D newIntersectionPoint = null;

            if (surfaceLine.ReferenceLineIntersectionWorldPoint != null)
            {
                Point2D oldIntersectionPoint = surfaceLine.ReferenceLineIntersectionWorldPoint;
                newIntersectionPoint = new Point2D(oldIntersectionPoint.X + random.NextDouble(),
                                                   oldIntersectionPoint.Y + random.NextDouble());
            }

            var copiedLine = new MacroStabilityInwardsSurfaceLine(surfaceLine.Name)
            {
                ReferenceLineIntersectionWorldPoint = newIntersectionPoint
            };

            var newGeometry = new[]
            {
                new Point3D(6, 0, 10),
                new Point3D(7, 0, 11),
                new Point3D(8, 0, 12),
                new Point3D(9, 0, 13),
                new Point3D(10, 0, 14),
                new Point3D(11, 0, 15)
            };

            copiedLine.SetGeometry(newGeometry);
            return(copiedLine);
        }
コード例 #11
0
        private static UpliftVanCalculatorInput Create(UpliftVanSlipPlane slipPlane)
        {
            MacroStabilityInwardsSurfaceLine surfaceLine = CreateValidSurfaceLine();

            return(new UpliftVanCalculatorInput(new UpliftVanCalculatorInput.ConstructionProperties
            {
                AssessmentLevel = -1,
                SurfaceLine = surfaceLine,
                SoilProfile = CreateValidSoilProfile(),
                DrainageConstruction = new DrainageConstruction(),
                PhreaticLineOffsetsExtreme = new PhreaticLineOffsets(),
                PhreaticLineOffsetsDaily = new PhreaticLineOffsets(),
                SlipPlane = slipPlane,
                SlipPlaneConstraints = new UpliftVanSlipPlaneConstraints(1, 0.7),
                WaterLevelRiverAverage = -1,
                WaterLevelPolderExtreme = -1,
                WaterLevelPolderDaily = -1,
                MinimumLevelPhreaticLineAtDikeTopRiver = 0.1,
                MinimumLevelPhreaticLineAtDikeTopPolder = 0.2,
                LeakageLengthOutwardsPhreaticLine3 = 1.3,
                LeakageLengthInwardsPhreaticLine3 = 1.4,
                LeakageLengthOutwardsPhreaticLine4 = 1.5,
                LeakageLengthInwardsPhreaticLine4 = 1.6,
                PiezometricHeadPhreaticLine2Outwards = 0.3,
                PiezometricHeadPhreaticLine2Inwards = 0.4,
                PenetrationLengthExtreme = 0.5,
                PenetrationLengthDaily = 0.6,
                AdjustPhreaticLine3And4ForUplift = true,
                DikeSoilScenario = MacroStabilityInwardsDikeSoilScenario.ClayDikeOnClay,
                MoveGrid = false,
                MaximumSliceWidth = 1
            }));
        }
コード例 #12
0
        private void UpdateInputChartData()
        {
            MacroStabilityInwardsInput       input       = data.InputParameters;
            MacroStabilityInwardsSurfaceLine surfaceLine = input.SurfaceLine;
            IMacroStabilityInwardsSoilProfile <IMacroStabilityInwardsSoilLayer> soilProfile = input.StochasticSoilProfile?.SoilProfile;

            if (!ReferenceEquals(currentSoilProfile, soilProfile) || !ReferenceEquals(currentSurfaceLine, surfaceLine))
            {
                currentSoilProfile = soilProfile;
                currentSurfaceLine = surfaceLine;

                SetSoilProfileChartData();
            }

            SetWaternetExtremeChartData(DerivedMacroStabilityInwardsInput.GetWaternetExtreme(input, generalInput, GetEffectiveAssessmentLevel()));
            SetWaternetDailyChartData(DerivedMacroStabilityInwardsInput.GetWaternetDaily(input, generalInput));

            if (data.Output != null)
            {
                SetSurfaceLineChartData(surfaceLine);
                SetSoilLayerAreas();
                SetWaternetDatas(surfaceLine);
            }
            else
            {
                SetSurfaceLineChartData(null);
                SetEmptySoilLayerAreas();
                SetEmptyWaternets();
            }

            soilProfileChartData.Collection.ForEachElementDo(sp => sp.NotifyObservers());
            waternetZonesDailyChartData.Collection.ForEachElementDo(cd => cd.NotifyObservers());
            waternetZonesExtremeChartData.Collection.ForEachElementDo(cd => cd.NotifyObservers());
        }
コード例 #13
0
        public void ReadAsMacroStabilityInwardsSurfaceLine_SurfaceLineEntityWithPointsAndAllCharacteristicPointsSetToSamePoint_ReturnsExpectedSurfaceLine()
        {
            // Setup
            var collector = new ReadConversionCollector();
            var random    = new Random(31);

            Point3D[] points =
            {
                CreatePoint3D(random),
                CreatePoint3D(random)
            };

            var entity = new SurfaceLineEntity
            {
                Name = "Better name.",
                ReferenceLineIntersectionX = random.NextDouble(),
                ReferenceLineIntersectionY = random.NextDouble(),
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(points),
                MacroStabilityInwardsCharacteristicPointEntities =
                {
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.SurfaceLevelOutside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DikeToeAtRiver),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DikeTopAtPolder),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DikeTopAtRiver),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.ShoulderBaseInside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.ShoulderTopInside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DikeToeAtPolder),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DitchDikeSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.BottomDitchDikeSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.BottomDitchPolderSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DitchPolderSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.SurfaceLevelInside)
                }
            };

            // Call
            MacroStabilityInwardsSurfaceLine surfaceLine = entity.ReadAsMacroStabilityInwardsSurfaceLine(collector);

            // Assert
            Assert.AreEqual(entity.Name, surfaceLine.Name);
            Assert.AreEqual(entity.ReferenceLineIntersectionX, surfaceLine.ReferenceLineIntersectionWorldPoint.X);
            Assert.AreEqual(entity.ReferenceLineIntersectionY, surfaceLine.ReferenceLineIntersectionWorldPoint.Y);

            Point3D[] geometry = surfaceLine.Points.ToArray();
            Assert.AreEqual(2, geometry.Length);
            Point3D geometryPoint = geometry[0];

            Assert.AreSame(geometryPoint, surfaceLine.SurfaceLevelOutside);
            Assert.AreSame(geometryPoint, surfaceLine.DikeToeAtRiver);
            Assert.AreSame(geometryPoint, surfaceLine.DikeTopAtPolder);
            Assert.AreSame(geometryPoint, surfaceLine.DikeTopAtRiver);
            Assert.AreSame(geometryPoint, surfaceLine.ShoulderBaseInside);
            Assert.AreSame(geometryPoint, surfaceLine.ShoulderTopInside);
            Assert.AreSame(geometryPoint, surfaceLine.DikeToeAtPolder);
            Assert.AreSame(geometryPoint, surfaceLine.DitchDikeSide);
            Assert.AreSame(geometryPoint, surfaceLine.BottomDitchDikeSide);
            Assert.AreSame(geometryPoint, surfaceLine.BottomDitchPolderSide);
            Assert.AreSame(geometryPoint, surfaceLine.DitchPolderSide);
            Assert.AreSame(geometryPoint, surfaceLine.SurfaceLevelInside);
        }
コード例 #14
0
        public void UpdateSurfaceLinesWithImportedData_WithCurrentAndImportedDataAreDifferent_ReplacesCurrentWithImportedData()
        {
            // Setup
            var targetSurfaceLine = new MacroStabilityInwardsSurfaceLine("Name A");
            var failureMechanism  = new MacroStabilityInwardsFailureMechanism();

            failureMechanism.SurfaceLines.AddRange(new[]
            {
                targetSurfaceLine
            }, sourceFilePath);

            var readSurfaceLine = new MacroStabilityInwardsSurfaceLine("Name B");

            var strategy = new MacroStabilityInwardsSurfaceLineReplaceDataStrategy(failureMechanism);

            // Call
            IEnumerable <IObservable> affectedObjects = strategy.UpdateSurfaceLinesWithImportedData(new[]
            {
                readSurfaceLine
            }, sourceFilePath);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                failureMechanism.SurfaceLines
            }, affectedObjects);

            MacroStabilityInwardsSurfaceLine[] expectedSurfaceLines =
            {
                readSurfaceLine
            };
            CollectionAssert.AreEqual(expectedSurfaceLines, failureMechanism.SurfaceLines);
        }
コード例 #15
0
        public void SetCharacteristicPoints_MandatoryPointNotOnSurfaceLine_ThrowsImportedDataTransformException(
            CharacteristicPoints points,
            Action <CharacteristicPoints, Point3D> setPoint,
            string pointDescription)
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(points.Name);

            surfaceLine.SetGeometry(CharacteristicPointsToGeometry(points));

            var changedPoint = new Point3D(-1, -1, -1);

            setPoint(points, changedPoint);

            // Call
            TestDelegate test = () => surfaceLine.SetCharacteristicPoints(points);

            // Assert
            var    exception = Assert.Throws <ImportedDataTransformException>(test);
            string message   = $"Profielschematisatie '{points.Name}' kan niet gebruikt worden. " +
                               $"De geometrie bevat geen punt op locatie {changedPoint} om als \'{pointDescription}\' in te stellen. " +
                               "Dit karakteristieke punt is verplicht.";

            Assert.AreEqual(message, exception.Message);
        }
コード例 #16
0
        /// <summary>
        /// Creates a scenario for which the surface line on the input intersects with <paramref name="section"/> and
        /// the calculation has not been performed.
        /// </summary>
        /// <param name="section">The section for which an intersection will be created.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsCalculationScenario"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="section"/> is <c>null</c>.</exception>
        public static MacroStabilityInwardsCalculationScenario CreateNotCalculatedMacroStabilityInwardsCalculationScenario(FailureMechanismSection section)
        {
            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }

            var     surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);
            Point2D p           = section.Points.First();

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(p.X, p.Y, 0),
                new Point3D(p.X + 2, p.Y + 2, 0)
            });
            surfaceLine.ReferenceLineIntersectionWorldPoint = section.Points.First();

            var scenario = new MacroStabilityInwardsCalculationScenario
            {
                IsRelevant      = true,
                InputParameters =
                {
                    SurfaceLine = surfaceLine
                }
            };

            return(scenario);
        }
コード例 #17
0
 private static bool IsDitchPresent(MacroStabilityInwardsSurfaceLine surfaceLine)
 {
     return(surfaceLine.DitchDikeSide != null &&
            surfaceLine.DitchPolderSide != null &&
            surfaceLine.BottomDitchDikeSide != null &&
            surfaceLine.BottomDitchPolderSide != null);
 }
コード例 #18
0
        public void IntersectsWithSurfaceLineGeometry_SurfaceLineIntersectingSoilModel_ReturnTrue()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilModel soilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("A", new[]
            {
                new Point2D(1.0, 0.0),
                new Point2D(5.0, 0.0)
            });

            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(3.0, 5.0, 0.0),
                new Point3D(3.0, 0.0, 1.0),
                new Point3D(3.0, -5.0, 0.0)
            });

            // Call
            bool intersecting = soilModel.IntersectsWithSurfaceLineGeometry(surfaceLine);

            // Assert
            Assert.IsTrue(intersecting);
        }
        public void SoilProfile1DCreate_SurfaceLineEndsBelowLayerTopButAboveBottom_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(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 MacroStabilityInwardsSoilLayer1D(top);
            var          soilProfile = new MacroStabilityInwardsSoilProfile1D("name", bottom, new[]
            {
                soilLayer
            });

            // Call
            MacroStabilityInwardsSoilProfileUnderSurfaceLine areas = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine);

            // Assert
            Assert.AreEqual(1, areas.Layers.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.Layers.ElementAt(0).OuterRing.Points);
        }
コード例 #20
0
        /// <summary>
        /// Tries to set the relevant characteristic points from the <paramref name="characteristicPoints"/>
        /// on the <paramref name="surfaceLine"/>.
        /// </summary>
        /// <param name="surfaceLine">The surface line to set the characteristic points for.</param>
        /// <param name="characteristicPoints">The characteristic points to set, if the collection is valid.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="surfaceLine"/> is <c>null</c>.</exception>
        /// <exception cref="ImportedDataTransformException">Thrown when a mandatory characteristic point is not
        /// present or not on the given <paramref name="surfaceLine"/>.</exception>
        public static void SetCharacteristicPoints(this MacroStabilityInwardsSurfaceLine surfaceLine, CharacteristicPoints characteristicPoints)
        {
            if (surfaceLine == null)
            {
                throw new ArgumentNullException(nameof(surfaceLine));
            }

            if (characteristicPoints == null)
            {
                throw new ImportedDataTransformException($"Karakteristieke punten definitie voor profielschematisatie '{surfaceLine.Name}' is verplicht.");
            }

            surfaceLine.TrySetSurfaceLevelOutside(characteristicPoints.SurfaceLevelOutside);
            surfaceLine.TrySetDikeToeAtRiver(characteristicPoints.DikeToeAtRiver);
            surfaceLine.TrySetDikeTopAtPolder(characteristicPoints.DikeTopAtPolder);
            surfaceLine.TrySetDikeTopAtRiver(characteristicPoints.DikeTopAtRiver);
            surfaceLine.TrySetDikeToeAtPolder(characteristicPoints.DikeToeAtPolder);
            surfaceLine.TrySetSurfaceLevelInside(characteristicPoints.SurfaceLevelInside);

            surfaceLine.TrySetShoulderBaseInside(characteristicPoints.ShoulderBaseInside);
            surfaceLine.TrySetShoulderTopInside(characteristicPoints.ShoulderTopInside);
            surfaceLine.TrySetDitchDikeSide(characteristicPoints.DitchDikeSide);
            surfaceLine.TrySetBottomDitchDikeSide(characteristicPoints.BottomDitchDikeSide);
            surfaceLine.TrySetBottomDitchPolderSide(characteristicPoints.BottomDitchPolderSide);
            surfaceLine.TrySetDitchPolderSide(characteristicPoints.DitchPolderSide);
        }
        public void SoilProfile1DCreate_SurfaceLineOnTopOrAboveSoilLayer_ReturnsSoilLayerPointsAsRectangle()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);

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

            // Call
            MacroStabilityInwardsSoilProfileUnderSurfaceLine areas = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine);

            // Assert
            Assert.AreEqual(1, areas.Layers.Count());
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(2, 3.2),
                new Point2D(2, 2),
                new Point2D(0, 2),
                new Point2D(0, 3.2)
            }, areas.Layers.ElementAt(0).OuterRing.Points);
        }
コード例 #22
0
        public void Validate_SurfaceLineNotNear2DProfile_ReturnsError(MacroStabilityInwardsSoilProfile2D soilProfile)
        {
            // Setup

            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Test");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0.0, 10),
                new Point3D(1, 0.0, 20),
                new Point3D(2, 0.0, 10)
            });

            input.StochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.0,
                                                                                         soilProfile);
            input.SurfaceLine = surfaceLine;

            // Call
            IEnumerable <string> messages = MacroStabilityInwardsInputValidator.Validate(input,
                                                                                         AssessmentSectionTestHelper.GetTestAssessmentLevel()).ToArray();

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                "De profielschematisatie moet op de ondergrondschematisatie liggen."
            }, messages);
        }
コード例 #23
0
        public void GivenViewWithSurfaceLineData_WhenSurfaceLineUpdatedAndNotified_ThenMapDataUpdated()
        {
            // Given
            var surfaceLine      = new MacroStabilityInwardsSurfaceLine(string.Empty);
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            failureMechanism.SurfaceLines.AddRange(new[]
            {
                surfaceLine
            }, "path");

            MacroStabilityInwardsFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());

            IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

            var mocks = new MockRepository();

            IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
            observers[surfaceLinesIndex].Expect(obs => obs.UpdateObserver());
            mocks.ReplayAll();

            // When
            surfaceLine.SetGeometry(new[]
            {
                new Point3D(7, 8, 9),
                new Point3D(10, 11, 12)
            });
            surfaceLine.NotifyObservers();

            // Then
            var surfaceLineMapData = (MapLineData)map.Data.Collection.ElementAt(surfaceLinesIndex);

            AssertSurfaceLinesMapData(failureMechanism.SurfaceLines, surfaceLineMapData);
            mocks.VerifyAll();
        }
コード例 #24
0
        /// <summary>
        /// Creates a new <see cref="WaternetCalculatorInput"/>.
        /// </summary>
        /// <returns>The created <see cref="WaternetCalculatorInput"/>.</returns>
        public static WaternetCalculatorInput CreateCompleteCalculatorInput()
        {
            var random = new Random(21);

            MacroStabilityInwardsSurfaceLine surfaceLine = CreateValidSurfaceLine();

            return(new WaternetCalculatorInput(new WaternetCalculatorInput.ConstructionProperties
            {
                AssessmentLevel = random.NextDouble(),
                SurfaceLine = surfaceLine,
                SoilProfile = CreateValidSoilProfile(surfaceLine),
                DrainageConstruction = new DrainageConstruction(),
                PhreaticLineOffsets = new PhreaticLineOffsets(),
                WaterLevelRiverAverage = random.Next(),
                WaterLevelPolder = random.Next(),
                MinimumLevelPhreaticLineAtDikeTopRiver = random.Next(),
                MinimumLevelPhreaticLineAtDikeTopPolder = random.Next(),
                LeakageLengthOutwardsPhreaticLine3 = random.Next(),
                LeakageLengthInwardsPhreaticLine3 = random.Next(),
                LeakageLengthOutwardsPhreaticLine4 = random.Next(),
                LeakageLengthInwardsPhreaticLine4 = random.Next(),
                PiezometricHeadPhreaticLine2Outwards = random.Next(),
                PiezometricHeadPhreaticLine2Inwards = random.Next(),
                PenetrationLength = random.Next(),
                AdjustPhreaticLine3And4ForUplift = random.NextBoolean(),
                DikeSoilScenario = random.NextEnumValue <MacroStabilityInwardsDikeSoilScenario>()
            }));
        }
コード例 #25
0
        private static IEnumerable <string> ValidateZoneBoundaries(MacroStabilityInwardsInput inputParameters)
        {
            if (!inputParameters.CreateZones ||
                inputParameters.ZoningBoundariesDeterminationType == MacroStabilityInwardsZoningBoundariesDeterminationType.Automatic)
            {
                yield break;
            }

            RoundedDouble zoneBoundaryLeft  = inputParameters.ZoneBoundaryLeft;
            RoundedDouble zoneBoundaryRight = inputParameters.ZoneBoundaryRight;

            if (zoneBoundaryLeft > zoneBoundaryRight)
            {
                yield return(Resources.MacroStabilityInwardsInputValidator_ValidateZoneBoundaries_ZoneBoundaries_BoundaryLeft_should_be_smaller_than_or_equal_to_BoundaryRight);
            }

            MacroStabilityInwardsSurfaceLine surfaceLine = inputParameters.SurfaceLine;

            if (!surfaceLine.ValidateInRange(zoneBoundaryLeft) || !surfaceLine.ValidateInRange(zoneBoundaryRight))
            {
                var validityRange = new Range <double>(surfaceLine.LocalGeometry.First().X, surfaceLine.LocalGeometry.Last().X);
                yield return(string.Format(Resources.MacroStabilityInwardsInputValidator_ValidateZoneBoundaries_ZoneBoundaries_must_be_in_Range_0,
                                           validityRange.ToString(FormattableConstants.ShowAtLeastOneDecimal, CultureInfo.CurrentCulture)));
            }
        }
コード例 #26
0
        public void Create_GlobalSurfaceLine_ProjectSurfaceLineIntoLZPlaneSpannedByFirstAndLastPoint()
        {
            // Setup
            const string name        = "Global coordinate surface line";
            var          surfaceLine = new MacroStabilityInwardsSurfaceLine(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
            SurfaceLine actual = SurfaceLineCreator.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
            };

            CollectionAssert.AreEqual(expectedCoordinatesX, actual.CharacteristicPoints.Select(p => p.GeometryPoint.X), new DoubleWithToleranceComparer(1e-2));
            CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z), actual.CharacteristicPoints.Select(p => p.GeometryPoint.Z));
            Assert.IsTrue(actual.CharacteristicPoints.All(cp => cp.CharacteristicPointType == CharacteristicPointType.None));
        }
コード例 #27
0
        public void Constructor_CalculationWithoutOutputAndWithWaternet_ChartDataEmpty()
        {
            // Setup
            MacroStabilityInwardsSurfaceLine           surfaceLine           = GetSurfaceLineWithGeometry();
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D();

            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    SurfaceLine           = surfaceLine,
                    StochasticSoilProfile = stochasticSoilProfile
                }
            };

            // Call
            using (new MacroStabilityInwardsCalculatorFactoryConfig())
                using (var control = new MacroStabilityInwardsOutputChartControl(calculation,
                                                                                 new GeneralMacroStabilityInwardsInput(),
                                                                                 AssessmentSectionTestHelper.GetTestAssessmentLevel))
                {
                    // Assert
                    IChartControl       chartControl = GetChartControl(control);
                    ChartDataCollection chartData    = chartControl.Data;
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyChartDataWithEmptySoilLayerAndWithWaternetChartData(chartData);
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyOutputChartData(chartData);
                    Assert.AreEqual(calculation.Name, chartControl.ChartTitle);
                }
        }
        private MacroStabilityInwardsSurfaceLine CreateSurfaceLine(Random random)
        {
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(nameof(MacroStabilityInwardsSurfaceLine))
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble())
            };

            var geometryPoints = new Point3D[12];

            for (var i = 0; i < geometryPoints.Length; i++)
            {
                geometryPoints[i] = new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble());
            }

            surfaceLine.SetGeometry(geometryPoints);

            surfaceLine.SetDitchPolderSideAt(geometryPoints[1]);
            surfaceLine.SetBottomDitchPolderSideAt(geometryPoints[2]);
            surfaceLine.SetBottomDitchDikeSideAt(geometryPoints[3]);
            surfaceLine.SetDitchDikeSideAt(geometryPoints[4]);
            surfaceLine.SetDikeTopAtPolderAt(geometryPoints[5]);
            surfaceLine.SetDikeTopAtRiverAt(geometryPoints[6]);
            surfaceLine.SetShoulderBaseInsideAt(geometryPoints[7]);
            surfaceLine.SetShoulderTopInsideAt(geometryPoints[8]);
            surfaceLine.SetDikeToeAtRiverAt(geometryPoints[9]);
            surfaceLine.SetDikeToeAtPolderAt(geometryPoints[10]);
            surfaceLine.SetSurfaceLevelInsideAt(geometryPoints[11]);
            surfaceLine.SetSurfaceLevelOutsideAt(geometryPoints[0]);

            return(surfaceLine);
        }
コード例 #29
0
        /// <summary>
        /// Creates macro stability inwards input with an aquifer layer.
        /// </summary>
        /// <param name="thicknessAquiferLayer">The thickness of the aquifer layer.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsInput"/>.</returns>
        public static MacroStabilityInwardsInput CreateInputWithAquifer(double thicknessAquiferLayer = 1.0)
        {
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 0.0),
                new Point3D(1.0, 0, 0.0)
            });
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.0, new MacroStabilityInwardsSoilProfile1D(string.Empty, -thicknessAquiferLayer, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(0.0)
                {
                    Data =
                    {
                        IsAquifer = true
                    }
                }
            }));

            return(new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties())
            {
                SurfaceLine = surfaceLine,
                StochasticSoilProfile = stochasticSoilProfile
            });
        }
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var surfaceLine1      = new MacroStabilityInwardsSurfaceLine("Line A");
            var surfaceLine2      = new MacroStabilityInwardsSurfaceLine("Line B");

            var surfaceLines = new MacroStabilityInwardsSurfaceLineCollection();

            surfaceLines.AddRange(new[]
            {
                surfaceLine1,
                surfaceLine2
            }, "path");

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            var surfaceLinesContext = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            mocks.ReplayAll();

            // Call
            object[] objects = info.ChildNodeObjects(surfaceLinesContext);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                surfaceLine1,
                surfaceLine2
            }, objects);
        }