using System; using Deltares.DamEngine.Io.XmlInput; using Deltares.Geotechnics.Soils; namespace Deltares.Dam.Data.DamEngineIo { /// /// Create XML Input object from DAM UI project /// public class FillXmlInputFromDamUi { /// /// Creates the input. /// /// The dam project data. /// public static Input CreateInput(DamProjectData damProjectData) { Input input = new Input(); input.DamProjectType = ConversionHelper.ConvertToInputDamProjectType(damProjectData.DamProjectType); Dike dike = damProjectData.WaterBoard.Dikes[0]; TransferLocations(dike, input); TransferSurfaceLines(dike, input); TransferSoils(dike, input); return input; } private static void TransferSoils(Dike dike, Input input) { var soils = dike.SoilList.Soils; input.Soils = new DamEngine.Io.XmlInput.Soil[soils.Count]; for (int i = 0; i < soils.Count; i++) { var soil = dike.SoilList.Soils[i]; var inputSoil = new DamEngine.Io.XmlInput.Soil(); inputSoil.Name = soil.Name; inputSoil.BeddingAngleSpecified = !Double.IsNaN(soil.BeddingAngle); inputSoil.BeddingAngle = soil.BeddingAngle; inputSoil.DiameterD70Specified = !Double.IsNaN(soil.DiameterD70); inputSoil.DiameterD70 = soil.DiameterD70; inputSoil.DiameterD90Specified = !Double.IsNaN(soil.DiameterD70); inputSoil.DiameterD90 = soil.DiameterD90; inputSoil.PermeabKxSpecified = !Double.IsNaN(soil.DiameterD90); inputSoil.PermeabKx = soil.PermeabKx; inputSoil.WhitesConstantSpecified = !Double.IsNaN(soil.WhitesConstant); inputSoil.WhitesConstant = soil.WhitesConstant; input.Soils[i] = inputSoil; } } private static void TransferSurfaceLines(Dike dike, Input input) { input.SurfaceLines = new SurfaceLine[dike.SurfaceLines2.Count]; for (int i = 0; i < dike.SurfaceLines2.Count; i++) { var surfaceLine = dike.SurfaceLines2[i]; var inputSurfaceLine = new SurfaceLine(); inputSurfaceLine.Name = surfaceLine.Name; inputSurfaceLine.Points = new SurfaceLinePoint[surfaceLine.CharacteristicPoints.Count]; for (int j = 0; j < surfaceLine.CharacteristicPoints.Count; j++) { var characteristicPoint = surfaceLine.CharacteristicPoints[j]; var inputPoint = new SurfaceLinePoint() { PointType = ConversionHelper.ConvertToInputPointType(characteristicPoint.CharacteristicPointType), X = characteristicPoint.X, Z = characteristicPoint.Z }; inputSurfaceLine.Points[j] = inputPoint; } input.SurfaceLines[i] = inputSurfaceLine; } } private static void TransferLocations(Dike dike, Input input) { int locationCount = dike.Locations.Count; input.Locations = new DamEngine.Io.XmlInput.Location[locationCount]; for (int i = 0; i < locationCount; i++) { var location = dike.Locations[i]; var inputLocation = new DamEngine.Io.XmlInput.Location(); inputLocation.SurfaceLineName = location.SurfaceLine2.Name; var waternetOptions = new LocationWaternetOptions(); waternetOptions.PhreaticLineCreationMethod = ConversionHelper.ConvertToInputPhreaticLineCreationMethod(location.PLLineCreationMethod); waternetOptions.IntrusionVerticalWaterPressure = ConversionHelper.ConvertToInputIntrusionVerticalWaterPressure(location.IntrusionVerticalWaterPressure ?? IntrusionVerticalWaterPressureType.Standard); waternetOptions.PolderLevel = location.PolderLevel; waternetOptions.DampingFactorPL3 = location.DampingFactorPL4; waternetOptions.DampingFactorPL4 = location.DampingFactorPL3; waternetOptions.PenetrationLength = location.PenetrationLength; waternetOptions.Pl1BelowCrestMiddleSpecified = location.PlLineOffsetBelowDikeCrestMiddle.HasValue; waternetOptions.Pl1BelowCrestMiddle = location.PlLineOffsetBelowDikeCrestMiddle ?? 0.0; waternetOptions.Pl1FactorBelowShoulderCrestSpecified = location.UsePlLineOffsetFactorBelowShoulderCrest ?? false; waternetOptions.Pl1FactorBelowShoulderCrest = location.PlLineOffsetFactorBelowShoulderCrest ?? 0.0; waternetOptions.DryPl1BelowCrestMiddleSpecified = location.PlLineOffsetDryBelowDikeCrestMiddle.HasValue; waternetOptions.DryPl1BelowCrestMiddle = location.PlLineOffsetDryBelowDikeCrestMiddle ?? 0.0; waternetOptions.DryPl1FactorBelowShoulderCrestSpecified = location.UsePlLineOffsetDryFactorBelowShoulderCrest ?? false; waternetOptions.DryPl1FactorBelowShoulderCrest = location.PlLineOffsetDryFactorBelowShoulderCrest ?? 0.0; waternetOptions.HeadPl2Specified = location.HeadPL2.HasValue; waternetOptions.HeadPl2 = location.HeadPL2 ?? 0.0; waternetOptions.HeadPl3Specified = location.HeadPl3.HasValue; waternetOptions.HeadPl3 = location.HeadPl3 ?? 0.0; waternetOptions.HeadPl4Specified = location.HeadPl4.HasValue; waternetOptions.HeadPl4 = location.HeadPl4 ?? 0.0; waternetOptions.SlopeDampingFactor = location.SlopeDampingPiezometricHeightPolderSide; waternetOptions.Pl1BelowCrestRiverside = location.PlLineOffsetBelowDikeTopAtRiver; waternetOptions.Pl1BelowCrestPolderside = location.PlLineOffsetBelowDikeTopAtPolder; waternetOptions.Pl1BelowShoulderCrestPolderside = location.PlLineOffsetBelowShoulderBaseInside; waternetOptions.Pl1BelowToeDikePolderside = location.PlLineOffsetBelowDikeToeAtPolder; inputLocation.WaternetOptions = waternetOptions; input.Locations[i] = inputLocation; } } } }