Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismSectionResultDetailedAssessmentExtensions.cs =================================================================== diff -u -r739752c5cc7ed800dacf74e12221c227183ddc6f -rd8d1d5d4a3eabd84c2d6e07eedb75fa200c2d54e --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismSectionResultDetailedAssessmentExtensions.cs (.../MacroStabilityInwardsFailureMechanismSectionResultDetailedAssessmentExtensions.cs) (revision 739752c5cc7ed800dacf74e12221c227183ddc6f) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismSectionResultDetailedAssessmentExtensions.cs (.../MacroStabilityInwardsFailureMechanismSectionResultDetailedAssessmentExtensions.cs) (revision d8d1d5d4a3eabd84c2d6e07eedb75fa200c2d54e) @@ -98,52 +98,90 @@ } /// - /// Gets the contribution of all relevant together. + /// Gets the total contribution of all relevant calculation scenarios. /// - /// The result to get the result for. - /// All calculations in the failure mechanism. - public static RoundedDouble GetTotalContribution(this MacroStabilityInwardsFailureMechanismSectionResult macroStabilityInwardsFailureMechanismSectionResult, - IEnumerable calculations) + /// The section result to get the total contribution for. + /// The calculation scenarios to get the total contribution for. + /// The total contribution of all relevant calculation scenarios. + /// Thrown when any parameter is null. + public static RoundedDouble GetTotalContribution(this MacroStabilityInwardsFailureMechanismSectionResult sectionResult, + IEnumerable calculationScenarios) { - return (RoundedDouble) macroStabilityInwardsFailureMechanismSectionResult - .GetCalculationScenarios(calculations) + if (sectionResult == null) + { + throw new ArgumentNullException(nameof(sectionResult)); + } + + if (calculationScenarios == null) + { + throw new ArgumentNullException(nameof(calculationScenarios)); + } + + return (RoundedDouble) sectionResult + .GetCalculationScenarios(calculationScenarios) .Aggregate(0, (current, calculationScenario) => current + calculationScenario.Contribution); } /// - /// Gets a list of the relevant . + /// Gets a collection of the relevant . /// - /// The result to get the result for. - /// All calculations in the failure mechanism. - public static IEnumerable GetCalculationScenarios(this MacroStabilityInwardsFailureMechanismSectionResult macroStabilityInwardsFailureMechanismSectionResult, - IEnumerable calculations) + /// The section result to get the relevant scenarios for. + /// The calculation scenarios to get the relevant scenarios from. + /// A collection of relevant calculation scenarios. + /// Thrown when any parameter is null. + public static IEnumerable GetCalculationScenarios( + this MacroStabilityInwardsFailureMechanismSectionResult sectionResult, + IEnumerable calculationScenarios) { - IEnumerable lineSegments = Math2D.ConvertLinePointsToLineSegments(macroStabilityInwardsFailureMechanismSectionResult.Section.Points); + if (sectionResult == null) + { + throw new ArgumentNullException(nameof(sectionResult)); + } - return calculations + if (calculationScenarios == null) + { + throw new ArgumentNullException(nameof(calculationScenarios)); + } + + IEnumerable lineSegments = Math2D.ConvertLinePointsToLineSegments(sectionResult.Section.Points); + + return calculationScenarios .Where(pc => pc.IsRelevant && pc.IsSurfaceLineIntersectionWithReferenceLineInSection(lineSegments)); } /// /// Gets the status of the section result depending on the relevant calculation scenarios. /// - /// The result to get the result for. - /// All calculations in the failure mechanism. + /// The section result to get the calculation status for. + /// The calculation scenarios to get the calculation status for. + /// The calculation scenario status for the section result. + /// Thrown when any parameter is null. /// Thrown when any of the relevant calculations - /// in has an invalid . - /// Thrown when any of the relevant scenarios has an unsupported value of . + /// in has an invalid . + /// Thrown when any of the relevant scenarios has an unsupported + /// value of . public static CalculationScenarioStatus GetCalculationScenarioStatus( - this MacroStabilityInwardsFailureMechanismSectionResult macroStabilityInwardsFailureMechanismSectionResult, - IEnumerable calculations) + this MacroStabilityInwardsFailureMechanismSectionResult sectionResult, + IEnumerable calculationScenarios) { + if (sectionResult == null) + { + throw new ArgumentNullException(nameof(sectionResult)); + } + + if (calculationScenarios == null) + { + throw new ArgumentNullException(nameof(calculationScenarios)); + } + var failed = false; var notCalculated = false; - foreach (MacroStabilityInwardsCalculationScenario calculationScenario in macroStabilityInwardsFailureMechanismSectionResult.GetCalculationScenarios(calculations).Where(cs => cs.IsRelevant)) + foreach (MacroStabilityInwardsCalculationScenario calculationScenario in sectionResult.GetCalculationScenarios(calculationScenarios).Where(cs => cs.IsRelevant)) { CalculationScenarioStatus calculationScenarioStatus = calculationScenario.Status; if (!Enum.IsDefined(typeof(CalculationScenarioStatus), calculationScenarioStatus)) { - throw new InvalidEnumArgumentException(nameof(macroStabilityInwardsFailureMechanismSectionResult), + throw new InvalidEnumArgumentException(nameof(sectionResult), (int) calculationScenarioStatus, typeof(CalculationScenarioStatus)); }