// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using System.Collections.Generic; using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Data.Exceptions; using Ringtoets.Integration.Data; using Ringtoets.Integration.Data.Assembly; using Ringtoets.Integration.IO.Assembly; namespace Ringtoets.Integration.IO.Factories { /// /// Factory to create instances of /// with assembly results. /// public static class ExportableAssessmentSectionFactory { /// /// Creates an with assembly results /// based on . /// /// The to create /// an for. /// An with assembly results. /// Thrown when /// is null. /// Thrown when no reference line is set for . /// Thrown when assembly results cannot be created for . public static ExportableAssessmentSection CreateExportableAssessmentSection(AssessmentSection assessmentSection) { if (assessmentSection == null) { throw new ArgumentNullException(nameof(assessmentSection)); } if (assessmentSection.ReferenceLine == null) { throw new ArgumentException("reference line of assessment section cannot be null."); } return new ExportableAssessmentSection(assessmentSection.Name, assessmentSection.Id, assessmentSection.ReferenceLine.Points, CreateExportableAssessmentSectionAssemblyResult(assessmentSection), CreateExportableFailureMechanismAssemblyResultWithProbability(assessmentSection), CreateExportableFailureMechanismAssemblyResultWithoutProbability(assessmentSection), CreateExportableFailureMechanismsWithProbability(assessmentSection), CreateExportableFailureMechanismsWithoutProbability(assessmentSection), CreateExportableCombinedSectionAssemblyCollection(assessmentSection)); } /// /// Creates an with the assembly result /// based on . /// /// The assessment section to create an for. /// An with assembly result. /// Thrown when assembly result cannot be created for . private static ExportableAssessmentSectionAssemblyResult CreateExportableAssessmentSectionAssemblyResult(AssessmentSection assessmentSection) { return new ExportableAssessmentSectionAssemblyResult(ExportableAssemblyMethod.WBI2C1, AssessmentSectionAssemblyFactory.AssembleAssessmentSection(assessmentSection, false)); } /// /// Creates an with the assembly result /// based on . /// /// The assessment section to create an for. /// An with assembly result. /// Thrown when assembly result cannot be created for . private static ExportableFailureMechanismAssemblyResultWithProbability CreateExportableFailureMechanismAssemblyResultWithProbability(AssessmentSection assessmentSection) { FailureMechanismAssembly assemblyResult = AssessmentSectionAssemblyFactory.AssembleFailureMechanismsWithProbability(assessmentSection, false); return new ExportableFailureMechanismAssemblyResultWithProbability(ExportableAssemblyMethod.WBI2B1, assemblyResult.Group, assemblyResult.Probability); } /// /// Creates an with the assembly result /// based on . /// /// The assessment section to create an for. /// An with assembly result. /// Thrown when assembly result cannot be created for . private static ExportableFailureMechanismAssemblyResult CreateExportableFailureMechanismAssemblyResultWithoutProbability(AssessmentSection assessmentSection) { return new ExportableFailureMechanismAssemblyResult(ExportableAssemblyMethod.WBI2A1, AssessmentSectionAssemblyFactory.AssembleFailureMechanismsWithoutProbability(assessmentSection, true)); } /// /// Creates a collection of /// for failure mechanisms with an assembly result with a probability based on . /// /// The assessment section to create a collection of /// with probability for. /// A collection of based on failure /// mechanisms with assembly results with a probability. /// Thrown when assembly results cannot be created for . private static IEnumerable> CreateExportableFailureMechanismsWithProbability(AssessmentSection assessmentSection) { return new[] { ExportablePipingFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.Piping, assessmentSection), ExportableMacroStabilityInwardsFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.MacroStabilityInwards, assessmentSection), ExportableGrassCoverErosionInwardsFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.GrassCoverErosionInwards, assessmentSection), ExportableHeightStructuresFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.HeightStructures, assessmentSection), ExportableClosingStructuresFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.ClosingStructures, assessmentSection), ExportableStabilityPointStructuresFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.StabilityPointStructures, assessmentSection) }; } /// /// Creates a collection of /// for failure mechanisms with an assembly result without a probability based on . /// /// The assessment section to create a collection of /// with probability for. /// A collection of based on failure /// mechanisms with assembly results without a probability. /// Thrown when assembly results cannot be created for . private static IEnumerable> CreateExportableFailureMechanismsWithoutProbability(AssessmentSection assessmentSection) { return new[] { ExportableStabilityStoneCoverFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.StabilityStoneCover), ExportableWaveImpactAsphaltCoverFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.WaveImpactAsphaltCover), ExportableGrassCoverErosionOutwardsFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.GrassCoverErosionOutwards), ExportableDuneErosionFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.DuneErosion), ExportableMacroStabilityOutwardsFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.MacroStabilityOutwards, assessmentSection), ExportableMicrostabilityFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.Microstability), ExportableGrassCoverSlipOffOutwardsFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.GrassCoverSlipOffOutwards), ExportableGrassCoverSlipOffInwardsFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.GrassCoverSlipOffInwards), ExportablePipingStructureFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.PipingStructure), ExportableWaterPressureAsphaltCoverFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.WaterPressureAsphaltCover), ExportableStrengthStabilityLengthwiseConstructionFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.StrengthStabilityLengthwiseConstruction), ExportableTechnicalInnovationFailureMechanismFactory.CreateExportableFailureMechanism(assessmentSection.TechnicalInnovation) }; } /// /// Creates a collection of based on . /// /// The assessment section to create a collection of for. /// A . /// Thrown when assembly results cannot be created for . private static IEnumerable CreateExportableCombinedSectionAssemblyCollection(AssessmentSection assessmentSection) { IEnumerable assemblyResults = AssessmentSectionAssemblyFactory.AssembleCombinedPerFailureMechanismSection(assessmentSection, false); return ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection(assemblyResults, assessmentSection.ReferenceLine); } } }