using System; using System.Collections.Generic; using Deltares.DamEngine.Io.XmlInput; using Deltares.Geometry; using Deltares.Geotechnics.GeotechnicalGeometry; using Deltares.Geotechnics.Soils; using Deltares.Geotechnics.SurfaceLines; using Soil = Deltares.Geotechnics.Soils.Soil; using SurfaceLine = Deltares.DamEngine.Io.XmlInput.SurfaceLine; namespace Deltares.Dam.Data.DamEngineIo { /// /// Create DAM UI project from XML Input object /// public class FillDamUiFromXmlInput { /// /// Creates the dam project data. /// /// The input. /// public static DamProjectData CreateDamProjectData(Input input) { var damProjectData = new DamProjectData(); damProjectData.DamProjectType = ConversionHelper.ConvertToDamProjectType(input.DamProjectType); damProjectData.WaterBoard = new WaterBoard(); damProjectData.WaterBoard.Dikes = new List(); damProjectData.WaterBoard.Dikes.Add(new Dike()); Dike dike = damProjectData.WaterBoard.Dikes[0]; TransferLocations(input, dike); TransferSurfaceLines(input, dike); TransferSoils(input, dike); return damProjectData; } private static void TransferSoils(Input input, Dike dike) { dike.SoilList = new SoilList(); var soils = dike.SoilList.Soils; for (int i = 0; i < input.Soils.Length; i++) { var soil = new Soil(); var inputSoil = input.Soils[i]; soil.Name = inputSoil.Name; soil.BeddingAngle = inputSoil.BeddingAngleSpecified ? inputSoil.BeddingAngle : Double.NaN; soil.DiameterD70 = inputSoil.DiameterD70Specified ? inputSoil.DiameterD70 : Double.NaN; soil.DiameterD90 = inputSoil.DiameterD90Specified ? inputSoil.DiameterD90 : Double.NaN; soil.PermeabKx = inputSoil.PermeabKxSpecified ? inputSoil.PermeabKx : Double.NaN; soil.WhitesConstant = inputSoil.WhitesConstantSpecified ? inputSoil.WhitesConstant : Double.NaN; soils.Add(soil); } } private static void TransferSurfaceLines(Input input, Dike dike) { for (int i = 0; i < input.SurfaceLines.Length; i++) { var surfaceLine = new SurfaceLine2(); var inputSurfaceLine = input.SurfaceLines[i]; surfaceLine.CharacteristicPoints.Geometry = surfaceLine.Geometry; AddPointsToSurfaceLine(inputSurfaceLine, surfaceLine); dike.SurfaceLines2.Add(surfaceLine); } } private static void AddPointsToSurfaceLine(SurfaceLine inputSurfaceLine, SurfaceLine2 surfaceLine) { surfaceLine.Geometry = new LocalizedGeometryPointString(); for (int j = 0; j < inputSurfaceLine.Points.Length; j++) { var inputPoint = inputSurfaceLine.Points[j]; var geometryPoint = new GeometryPoint() { X = inputPoint.X, Y = 0.0, Z = inputPoint.Z }; surfaceLine.AddCharacteristicPoint(geometryPoint, ConversionHelper.ConvertToDamPointType(inputPoint.PointType)); } } private static void TransferLocations(Input input, Dike dike) { for (int i = 0; i < input.Locations.Length; i++) { var location = new Location(); var inputLocation = input.Locations[i]; var waternetOptions = inputLocation.WaternetOptions; location.PLLineCreationMethod = ConversionHelper.ConvertToPhreaticLineCreationMethod(waternetOptions.PhreaticLineCreationMethod); location.IntrusionVerticalWaterPressure = ConversionHelper.ConvertToIntrusionVerticalWaterPressure(waternetOptions.IntrusionVerticalWaterPressure); location.PolderLevel = waternetOptions.PolderLevel; location.DampingFactorPL4 = waternetOptions.DampingFactorPL3; location.DampingFactorPL3 = waternetOptions.DampingFactorPL4; location.PenetrationLength = waternetOptions.PenetrationLength; location.PlLineOffsetBelowDikeCrestMiddle = (waternetOptions.Pl1BelowCrestMiddleSpecified ? (double?) waternetOptions.Pl1BelowCrestMiddle : null); location.UsePlLineOffsetFactorBelowShoulderCrest = waternetOptions.Pl1FactorBelowShoulderCrestSpecified; location.PlLineOffsetFactorBelowShoulderCrest = waternetOptions.Pl1FactorBelowShoulderCrest; location.PlLineOffsetDryBelowDikeCrestMiddle = (waternetOptions.DryPl1BelowCrestMiddleSpecified ? (double?) waternetOptions.DryPl1BelowCrestMiddle : null); location.UsePlLineOffsetDryFactorBelowShoulderCrest = waternetOptions.DryPl1FactorBelowShoulderCrestSpecified; location.PlLineOffsetDryFactorBelowShoulderCrest = waternetOptions.DryPl1FactorBelowShoulderCrest; location.HeadPL2 = (waternetOptions.HeadPl2Specified ? (double?) waternetOptions.HeadPl2 : null); location.HeadPl3 = (waternetOptions.HeadPl3Specified ? (double?) waternetOptions.HeadPl3 : null); location.HeadPl4 = (waternetOptions.HeadPl4Specified ? (double?) waternetOptions.HeadPl4 : null); location.SlopeDampingPiezometricHeightPolderSide = waternetOptions.SlopeDampingFactor; location.PlLineOffsetBelowDikeTopAtRiver = waternetOptions.Pl1BelowCrestRiverside; location.PlLineOffsetBelowDikeTopAtPolder = waternetOptions.Pl1BelowCrestPolderside; location.PlLineOffsetBelowShoulderBaseInside = waternetOptions.Pl1BelowShoulderCrestPolderside; location.PlLineOffsetBelowDikeToeAtPolder = waternetOptions.Pl1BelowToeDikePolderside; dike.Locations.Add(location); } } } }