예제 #1
0
        public void GetFailureMechanismSectionGeometry_SectionStartAndEndExactlyOnReferenceLinePoints_ReturnExpectedPoints()
        {
            // Setup
            const int sectionStart = 10;
            const int sectionEnd   = 30;
            var       points       = new[]
            {
                new Point2D(0, 0),
                new Point2D(sectionStart, 0),
                new Point2D(20, 0),
                new Point2D(sectionEnd, 0)
            };

            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(points);

            // Call
            IEnumerable <Point2D> sectionPoints = FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(referenceLine, sectionStart, sectionEnd);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(sectionStart, 0),
                new Point2D(20, 0),
                new Point2D(sectionEnd, 0)
            }, sectionPoints);
        }
예제 #2
0
        public void GetFailureMechanismSectionGeometry_SectionStartAndEndBetweenDifferentTwoReferenceLinePoints_ReturnExpectedPoints()
        {
            // Setup
            var random        = new Random(21);
            int sectionStart  = random.Next(5, 15);
            int sectionEnd    = random.Next(25, 35);
            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(0, 0),
                new Point2D(5, 0),
                new Point2D(15, 0),
                new Point2D(25, 0),
                new Point2D(35, 0)
            });

            // Call
            IEnumerable <Point2D> sectionPoints = FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(referenceLine, sectionStart, sectionEnd);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(sectionStart, 0),
                new Point2D(15, 0),
                new Point2D(25, 0),
                new Point2D(sectionEnd, 0)
            }, sectionPoints);
        }
        /// <summary>
        /// Creates features for the combined failure mechanism section assembly.
        /// </summary>
        /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to create the features for.</param>
        /// <returns>A collection of <see cref="MapFeature"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="assessmentSection"/>
        /// is <c>null</c>.</exception>
        public static IEnumerable<MapFeature> CreateCombinedFailureMechanismSectionAssemblyFeatures(AssessmentSection assessmentSection)
        {
            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            IEnumerable<CombinedFailureMechanismSectionAssemblyResult> assemblyResults;
            try
            {
                assemblyResults = AssessmentSectionAssemblyFactory.AssembleCombinedPerFailureMechanismSection(assessmentSection);
            }
            catch (AssemblyException)
            {
                return Array.Empty<MapFeature>();
            }

            var mapFeatures = new List<MapFeature>();
            foreach (CombinedFailureMechanismSectionAssemblyResult assemblyResult in assemblyResults)
            {
                IEnumerable<Point2D> geometry = FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
                    assessmentSection.ReferenceLine, assemblyResult.SectionStart, assemblyResult.SectionEnd);
                MapFeature mapFeature = RiskeerMapDataFeaturesFactory.CreateSingleLineMapFeature(geometry);

                mapFeature.MetaData[RiskeerCommonFormsResources.AssemblyGroup_DisplayName] =
                    EnumDisplayNameHelper.GetDisplayName(assemblyResult.TotalResult);

                mapFeatures.Add(mapFeature);
            }

            return mapFeatures;
        }
예제 #4
0
        /// <summary>
        /// Creates a collection of <see cref="ExportableCombinedSectionAssembly"/>
        /// based on <paramref name="combinedSectionAssemblyResults"/>.
        /// </summary>
        /// <param name="combinedSectionAssemblyResults">A collection of combined section results to
        /// create a collection of <see cref="ExportableCombinedSectionAssembly"/> for.</param>
        /// <param name="assessmentSection">The <see cref="AssessmentSection"/> the section results belong to.</param>
        /// <returns>A collection of <see cref="ExportableCombinedSectionAssembly"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static IEnumerable <ExportableCombinedSectionAssembly> CreateExportableCombinedSectionAssemblyCollection(
            IEnumerable <CombinedFailureMechanismSectionAssemblyResult> combinedSectionAssemblyResults,
            AssessmentSection assessmentSection)
        {
            if (combinedSectionAssemblyResults == null)
            {
                throw new ArgumentNullException(nameof(combinedSectionAssemblyResults));
            }

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

            var sectionResults = new List <ExportableCombinedSectionAssembly>();

            foreach (CombinedFailureMechanismSectionAssemblyResult assemblyResult in combinedSectionAssemblyResults)
            {
                var exportableSection = new ExportableCombinedFailureMechanismSection(
                    FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
                        assessmentSection.ReferenceLine, assemblyResult.SectionStart, assemblyResult.SectionEnd),
                    assemblyResult.SectionStart,
                    assemblyResult.SectionEnd,
                    ExportableAssemblyMethodFactory.Create(assemblyResult.CommonSectionAssemblyMethod));

                var exportableSectionResult = new ExportableCombinedSectionAssembly(
                    exportableSection, new ExportableFailureMechanismSectionAssemblyResult(
                        exportableSection, assemblyResult.TotalResult, ExportableAssemblyMethodFactory.Create(assemblyResult.CombinedSectionResultAssemblyMethod)),
                    CreateFailureMechanismCombinedSectionAssemblyResults(assemblyResult, assessmentSection));

                sectionResults.Add(exportableSectionResult);
            }

            return(sectionResults);
        }
예제 #5
0
        public void GetFailureMechanismSectionGeometry_ReferenceLineNull_ThrowsArgumentNullException()
        {
            // Call
            TestDelegate call = () => FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(null, 0, 0);

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

            Assert.AreEqual("referenceLine", exception.ParamName);
        }
예제 #6
0
        private static void AssertEqualPointCollections(ReferenceLine referenceLine,
                                                        CombinedFailureMechanismSectionAssemblyResult sectionAssemblyResult,
                                                        MapGeometry geometry)
        {
            IEnumerable <Point2D> expectedGeometry = FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
                referenceLine,
                sectionAssemblyResult.SectionStart,
                sectionAssemblyResult.SectionEnd).ToArray();

            CollectionAssert.IsNotEmpty(expectedGeometry);

            CollectionAssert.AreEqual(expectedGeometry, geometry.PointCollections.Single());
        }
예제 #7
0
        private static void AssertExportableCombinedFailureMechanismSection(CombinedFailureMechanismSectionAssemblyResult expectedSection,
                                                                            ExportableCombinedFailureMechanismSection actualSection,
                                                                            ReferenceLine referenceLine)
        {
            IEnumerable <Point2D> expectedGeometry = FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
                referenceLine,
                actualSection.StartDistance,
                actualSection.EndDistance).ToArray();

            CollectionAssert.IsNotEmpty(expectedGeometry);

            Assert.AreEqual(expectedSection.SectionStart, actualSection.StartDistance);
            Assert.AreEqual(expectedSection.SectionEnd, actualSection.EndDistance);
            CollectionAssert.AreEqual(expectedGeometry, actualSection.Geometry);
            Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedSection.CommonSectionAssemblyMethod), actualSection.AssemblyMethod);
        }
예제 #8
0
        public void GetFailureMechanismSectionGeometry_SectionStartAndEndBetweenSameTwoReferenceLinePoints_ReturnExpectedPoints()
        {
            // Setup
            const int sectionStart  = 2;
            const int sectionEnd    = 4;
            var       referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(0, 0),
                new Point2D(5, 0),
                new Point2D(15, 0)
            });

            // Call
            IEnumerable <Point2D> sectionPoints = FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(referenceLine, sectionStart, sectionEnd);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(sectionStart, 0),
                new Point2D(sectionEnd, 0)
            }, sectionPoints);
        }