// 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 Ringtoets.Common.IO.Exceptions; using Ringtoets.Common.IO.SoilProfile; using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.IO.SoilProfiles { /// /// Transforms generic into /// or . /// internal static class MacroStabilityInwardsSoilLayerTransformer { /// /// Transforms the generic into a /// . /// /// The soil layer to use in the transformation. /// A based on the given data. /// Thrown when is /// null. /// Thrown when transformation would not result /// in a valid transformed instance. public static MacroStabilityInwardsSoilLayer1D Transform(SoilLayer1D soilLayer) { if (soilLayer == null) { throw new ArgumentNullException(nameof(soilLayer)); } var layer = new MacroStabilityInwardsSoilLayer1D(soilLayer.Top) { Properties = { MaterialName = soilLayer.MaterialName, IsAquifer = soilLayer.IsAquifer, Color = soilLayer.Color, UsePop = soilLayer.UsePop, AbovePhreaticLevelMean = soilLayer.AbovePhreaticLevelMean, AbovePhreaticLevelDeviation = soilLayer.AbovePhreaticLevelDeviation, BelowPhreaticLevelMean = soilLayer.BelowPhreaticLevelMean, BelowPhreaticLevelDeviation = soilLayer.BelowPhreaticLevelDeviation, CohesionMean = soilLayer.CohesionMean, CohesionDeviation = soilLayer.CohesionDeviation, CohesionShift = soilLayer.CohesionShift, FrictionAngleMean = soilLayer.FrictionAngleMean, FrictionAngleDeviation = soilLayer.FrictionAngleDeviation, FrictionAngleShift = soilLayer.FrictionAngleShift, ShearStrengthRatioMean = soilLayer.ShearStrengthRatioMean, ShearStrengthRatioDeviation = soilLayer.ShearStrengthRatioDeviation, ShearStrengthRatioShift = soilLayer.ShearStrengthRatioShift, StrengthIncreaseExponentMean = soilLayer.StrengthIncreaseExponentMean, StrengthIncreaseExponentDeviation = soilLayer.StrengthIncreaseExponentDeviation, StrengthIncreaseExponentShift = soilLayer.StrengthIncreaseExponentShift, PopMean = soilLayer.PopMean, PopDeviation = soilLayer.PopDeviation, PopShift = soilLayer.PopShift } }; try { layer.Properties.ShearStrengthModel = TransformShearStrengthModel(soilLayer.ShearStrengthModel); } catch (NotSupportedException e) { throw new ImportedDataTransformException("Er ging iets mis met transformeren.", e); } return layer; } /// /// Transforms the to . /// /// The model to transform. /// A based on the given data. /// Thrown when /// has an invalid value. private static MacroStabilityInwardsShearStrengthModel TransformShearStrengthModel(ShearStrengthModel shearStrengthModel) { switch (shearStrengthModel) { case ShearStrengthModel.None: return MacroStabilityInwardsShearStrengthModel.None; case ShearStrengthModel.SuCalculated: return MacroStabilityInwardsShearStrengthModel.SuCalculated; case ShearStrengthModel.CPhi: return MacroStabilityInwardsShearStrengthModel.CPhi; case ShearStrengthModel.CPhiOrSuCalculated: return MacroStabilityInwardsShearStrengthModel.CPhiOrSuCalculated; default: throw new NotSupportedException(); } } } }