Index: dam engine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs =================================================================== diff -u -r557 -r563 --- dam engine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 557) +++ dam engine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 563) @@ -29,6 +29,7 @@ using Deltares.DamEngine.Io.XmlInput; using KellermanSoftware.CompareNetObjects; using NUnit.Framework; +using Segment = Deltares.DamEngine.Data.General.Segment; using Soil = Deltares.DamEngine.Data.Geotechnics.Soil; using SoilProfile1D = Deltares.DamEngine.Data.Geotechnics.SoilProfile1D; using SoilProfile2D = Deltares.DamEngine.Data.Geotechnics.SoilProfile2D; @@ -83,6 +84,7 @@ FillLocations(dike); FillSoilProfiles1D(dike); FillSoilProfiles2D(dike); + FillSegments(damProjectData); return damProjectData; } @@ -299,6 +301,30 @@ } } + private static void FillSegments(DamProjectData damProjectData) + { + var segmentCount = 2; + for (int i = 0; i < segmentCount; i++) + { + var segment = new Segment(); + segment.Name = "Segment " + i.ToString(); + var soilProfileProbability = new SoilGeometryProbability(); + if (i == 0) + { + soilProfileProbability.SegmentFailureMechanismType = FailureMechanismSystemType.StabilityInside; + soilProfileProbability.SoilGeometry2DName = "Profile2D " + (i + 1).ToString(); + } + else + { + soilProfileProbability.SegmentFailureMechanismType = FailureMechanismSystemType.Piping; + soilProfileProbability.SoilGeometry1DName = "Profile1D " + (i + 1).ToString(); + } + soilProfileProbability.Probability = 0.003 * (i + 1); + segment.SoilProfileProbabilities.Add(soilProfileProbability); + damProjectData.Segments.Add(segment); + } + } + private void CompareDamProjectData(DamProjectData actual, DamProjectData expected) { var compare = new CompareLogic { Config = { MaxDifferences = 100 } }; Index: dam engine/trunk/src/Deltares.DamEngine.Data/General/Segment.cs =================================================================== diff -u -r537 -r563 --- dam engine/trunk/src/Deltares.DamEngine.Data/General/Segment.cs (.../Segment.cs) (revision 537) +++ dam engine/trunk/src/Deltares.DamEngine.Data/General/Segment.cs (.../Segment.cs) (revision 563) @@ -110,7 +110,7 @@ { get { - if (SoilProfile != null) + if (SoilProfile != null || !string.IsNullOrEmpty(SoilGeometry1DName)) { return SoilGeometryType.SoilGeometry1D; } Index: dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs =================================================================== diff -u -r555 -r563 --- dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 555) +++ dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 563) @@ -27,6 +27,7 @@ using Deltares.DamEngine.Io.XmlInput; using Input = Deltares.DamEngine.Io.XmlInput.Input; using Location = Deltares.DamEngine.Data.General.Location; +using Segment = Deltares.DamEngine.Data.General.Segment; using Soil = Deltares.DamEngine.Io.XmlInput.Soil; using SoilProfile1D = Deltares.DamEngine.Data.Geotechnics.SoilProfile1D; using SoilProfile2D = Deltares.DamEngine.Data.Geotechnics.SoilProfile2D; @@ -64,6 +65,11 @@ input.SoilProfiles2D = new Io.XmlInput.SoilProfile2D[profilesCount]; TransferSoilProfiles2D(dike.SoilProfiles2D, input.SoilProfiles2D); } + if (damProjectData.Segments != null) + { + input.Segments = new Io.XmlInput.Segment[damProjectData.Segments.Count]; + TransferSegments(damProjectData.Segments, input.Segments); + } return input; } @@ -347,5 +353,47 @@ } } } + + private static void TransferSegments(IList segments, Io.XmlInput.Segment[] inputSegments) + { + for (int i = 0; i < segments.Count; i++) + { + var segment = segments[i]; + var inputSegment = new Io.XmlInput.Segment + { + Name = segment.Name + }; + AddSoilProfileProbabilities(segment, inputSegment); + inputSegments[i] = inputSegment; + } + } + + private static void AddSoilProfileProbabilities(Segment segment, Io.XmlInput.Segment inputSegment) + { + if (segment.SoilProfileProbabilities != null) + { + var probabilityCount = segment.SoilProfileProbabilities.Count; + inputSegment.SoilGeometryProbability = new SegmentSoilGeometryProbability[probabilityCount]; + for (int i = 0; i < probabilityCount; i++) + { + var soilGeometryProbability = segment.SoilProfileProbabilities[i]; + var inputSoilGeometryProbability = new SegmentSoilGeometryProbability(); + inputSoilGeometryProbability.Probability = soilGeometryProbability.Probability; + if (soilGeometryProbability.SegmentFailureMechanismType.HasValue) + { + //inputSoilGeometryProbability.SegmentFailureMechanismType = soilGeometryProbability.FailureMechanismSystemType; + } + if (soilGeometryProbability.SoilGeometryType == SoilGeometryType.SoilGeometry1D) + { + inputSoilGeometryProbability.SoilGeometryName = soilGeometryProbability.SoilGeometry1DName; + } + else + { + inputSoilGeometryProbability.SoilGeometryName = soilGeometryProbability.SoilGeometry2DName; + } + inputSegment.SoilGeometryProbability[i] = inputSoilGeometryProbability; + } + } + } } } Index: dam engine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs =================================================================== diff -u -r555 -r563 --- dam engine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs (.../FillDamFromXmlInput.cs) (revision 555) +++ dam engine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs (.../FillDamFromXmlInput.cs) (revision 563) @@ -61,7 +61,7 @@ TransferLocations(input.Locations, dike.Locations, dike.SurfaceLines2); TransferSoilProfiles1D(input.SoilProfiles1D, dike.SoilProfiles, dike.SoilList); TransferSoilProfiles2D(input.SoilProfiles2D, dike.SoilProfiles2D, dike.SoilList); - //TransferSegments(input.Segments, damProjectData.Segments); To be implemented at other side. + TransferSegments(input.Segments, damProjectData.Segments); PostProcess(input, damProjectData); return damProjectData; @@ -367,7 +367,8 @@ else { soilGeometryProbability.SoilGeometry2DName = inputSoilGeometryProbability.SoilGeometryName; - } + } + segment.SoilProfileProbabilities.Add(soilGeometryProbability); } }