Index: dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs
===================================================================
diff -u -r452 -r478
--- dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 452)
+++ dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 478)
@@ -20,28 +20,64 @@
// All rights reserved.
using Deltares.DamEngine.Data.General;
-//using Deltares.DamEngine.Io.XmlInput;
-//using Deltares.DamEngine.Io.XmlOutput;
+using Deltares.DamEngine.Io.XmlInput;
using Input = Deltares.DamEngine.Io.XmlInput.Input;
namespace Deltares.DamEngine.Interface
{
public class FillXmlInputFromDam
{
+ ///
+ /// Creates the input.
+ ///
+ /// The dam project data.
+ ///
public static Input CreateInput(DamProjectData damProjectData)
{
Input input = new Input();
input.DamProjectType = ConversionHelper.ConvertToInputDamProjectType(damProjectData.DamProjectType);
- int locationCount = damProjectData.Dike.Locations.Count;
+ Dike dike = damProjectData.Dike;
+ TransferLocations(dike, input);
+ TransferSurfaceLines(dike, input);
+ return input;
+ }
+
+ 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.Points = new SurfaceLinePoint[surfaceLine.CharacteristicPoints.Count];
+ // This is not completely correct. The geometry points should also be transferred
+ 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 Io.XmlInput.Location[locationCount];
for (int i = 0; i < locationCount; i++)
{
- var location = damProjectData.Dike.Locations[i];
+ var location = dike.Locations[i];
input.Locations[i] = new Io.XmlInput.Location();
- var waternetOptions = new Io.XmlInput.LocationWaternetOptions();
+ var waternetOptions = new LocationWaternetOptions();
waternetOptions.PhreaticLineCreationMethod = ConversionHelper.ConvertToInputPhreaticLineCreationMethod(location.ModelParametersForPLLines.PLLineCreationMethod);
- waternetOptions.IntrusionVerticalWaterPressure = ConversionHelper.ConvertToInputIntrusionVerticalWaterPressure(location.IntrusionVerticalWaterPressure?? IntrusionVerticalWaterPressureType.Standard);
+ waternetOptions.IntrusionVerticalWaterPressure = ConversionHelper.ConvertToInputIntrusionVerticalWaterPressure(location.IntrusionVerticalWaterPressure ?? IntrusionVerticalWaterPressureType.Standard);
waternetOptions.PolderLevel = location.PolderLevel;
waternetOptions.DampingFactorPL3 = location.ModelParametersForPLLines.DampingFactorPL4;
waternetOptions.DampingFactorPL4 = location.ModelParametersForPLLines.DampingFactorPL3;
@@ -53,7 +89,7 @@
waternetOptions.DryPl1BelowCrestMiddleSpecified = location.PlLineOffsetDryBelowDikeCrestMiddle.HasValue;
waternetOptions.DryPl1BelowCrestMiddle = location.PlLineOffsetDryBelowDikeCrestMiddle ?? 0.0;
waternetOptions.DryPl1FactorBelowShoulderCrestSpecified = location.UsePlLineOffsetDryFactorBelowShoulderCrest ?? false;
- waternetOptions.DryPl1FactorBelowShoulderCrest = location.PlLineOffsetDryFactorBelowShoulderCrest??0.0;
+ waternetOptions.DryPl1FactorBelowShoulderCrest = location.PlLineOffsetDryFactorBelowShoulderCrest ?? 0.0;
waternetOptions.HeadPl2Specified = location.HeadPl2.HasValue;
waternetOptions.HeadPl2 = location.HeadPl2 ?? 0.0;
waternetOptions.HeadPl3Specified = location.HeadPl3.HasValue;
@@ -67,7 +103,6 @@
waternetOptions.Pl1BelowToeDikePolderside = location.PlLineOffsetBelowDikeToeAtPolder;
input.Locations[i].WaternetOptions = waternetOptions;
}
- return input;
}
}
}