Example #1
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);
        }
Example #2
0
        /// <summary>
        /// Tries to assign the stochastic soil model.
        /// </summary>
        /// <param name="calculationConfiguration">The calculation read from the imported file.</param>
        /// <param name="calculation">The calculation to configure.</param>
        /// <returns><c>false</c> when
        /// <list type="bullet">
        /// <item>the <paramref name="calculationConfiguration"/> has a <see cref="MacroStabilityInwardsStochasticSoilModel"/>
        /// set which is not available in the failure mechanism.</item>
        /// <item>The <see cref="MacroStabilityInwardsStochasticSoilModel"/> does not intersect
        /// with the <see cref="MacroStabilityInwardsSurfaceLine"/>
        /// when this is set.</item>
        /// </list>
        /// <c>true</c> otherwise.</returns>
        private bool TrySetStochasticSoilModel(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
                                               MacroStabilityInwardsCalculationScenario calculation)
        {
            if (calculationConfiguration.StochasticSoilModelName == null)
            {
                return(true);
            }

            MacroStabilityInwardsStochasticSoilModel soilModel = failureMechanism.StochasticSoilModels
                                                                 .FirstOrDefault(ssm => ssm.Name == calculationConfiguration.StochasticSoilModelName);

            if (soilModel == null)
            {
                Log.LogCalculationConversionError(string.Format(
                                                      Resources.MacroStabilityInwardsCalculationConfigurationImporter_ReadStochasticSoilModel_Stochastische_soil_model_0_does_not_exist,
                                                      calculationConfiguration.StochasticSoilModelName),
                                                  calculation.Name);
                return(false);
            }

            if (calculation.InputParameters.SurfaceLine != null &&
                !soilModel.IntersectsWithSurfaceLineGeometry(calculation.InputParameters.SurfaceLine))
            {
                Log.LogCalculationConversionError(string.Format(
                                                      Resources.MacroStabilityInwardsCalculationConfigurationImporter_ReadStochasticSoilModel_Stochastische_soil_model_0_does_not_intersect_with_surfaceLine_1,
                                                      calculationConfiguration.StochasticSoilModelName,
                                                      calculationConfiguration.SurfaceLineName),
                                                  calculation.Name);
                return(false);
            }

            calculation.InputParameters.StochasticSoilModel = soilModel;
            return(true);
        }
Example #3
0
        public void IntersectsWithSurfaceLineGeometry_SurfaceLineNull_ThrowArgumentNullException()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilModel soilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("A", new[]
            {
                new Point2D(1.0, 0.0),
                new Point2D(5.0, 0.0)
            });

            // Call
            TestDelegate test = () => soilModel.IntersectsWithSurfaceLineGeometry(null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(test);

            Assert.AreEqual("surfaceLine", exception.ParamName);
        }