Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs =================================================================== diff -u -r6283 -r6284 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs (.../FillXmlInputFromDamUi.cs) (revision 6283) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs (.../FillXmlInputFromDamUi.cs) (revision 6284) @@ -82,6 +82,14 @@ input.Locations = new DamEngine.Io.XmlInput.Location[filteredJobs.Count]; TransferLocations(filteredLocations, input.Locations); + // Process segments + IList usedSegments = DetermineUsedSegments(filteredLocations); + if (usedSegments != null) + { + input.Segments = new DamEngine.Io.XmlInput.Segment[usedSegments.Count]; + TransferSegments(usedSegments, input.Segments); + } + // Process surface lines List usedSurfaceLines = DetermineUsedSurfaceLines(filteredLocations); input.SurfaceLines = new SurfaceLine[usedSurfaceLines.Count]; @@ -91,26 +99,17 @@ input.Soils = new DamEngine.Io.XmlInput.Soil[dike.SoilList.Soils.Count]; TransferSoils(dike.SoilList.Soils, input.Soils); - // Process soilprofiles - // Fill 1D profiles in case of DamClassicStability - if (dike.SoilProfiles != null) + // Process soil profiles 1D + if (dike.SoilProfiles != null && dike.SoilProfiles.Count > 0) { - int profilesCount = dike.SoilProfiles.Count; - input.SoilProfiles1D = new DamEngine.Io.XmlInput.SoilProfile1D[profilesCount]; - TransferSoilProfiles1D(dike.SoilProfiles, input.SoilProfiles1D); + List usedSoilProfiles = DetermineUsedSoilProfiles1D(usedSegments); + input.SoilProfiles1D = new DamEngine.Io.XmlInput.SoilProfile1D[usedSoilProfiles.Count]; + TransferSoilProfiles1D(usedSoilProfiles, input.SoilProfiles1D); } input.SoilProfiles2D = soilProfiles2DToSerialize.ToArray(); TransferTrafficLoadDegreeOfConsolidation(dike.TrafficLoadDegreeOfConsolidations, input); - - // Process segments - IList usedSegments = DetermineUsedSegments(filteredLocations); - if (usedSegments != null) - { - input.Segments = new DamEngine.Io.XmlInput.Segment[usedSegments.Count]; - TransferSegments(usedSegments, input.Segments); - } if (damProjectData.InputTimeSerieCollection != null) { @@ -156,6 +155,24 @@ return usedSurfaceLines; } + private static List DetermineUsedSoilProfiles1D(IList segments) + { + var usedSoilProfiles1D = new List(); + foreach (Segment segment in segments) + { + foreach (SoilGeometryProbability soilProfileProbability in segment.SoilProfileProbabilities) + { + if (!usedSoilProfiles1D.Any(usp => usp.Name.Equals(soilProfileProbability.SoilProfile.Name) + && soilProfileProbability.SoilProfileType == SoilProfileType.SoilProfile1D)) + { + usedSoilProfiles1D.Add(soilProfileProbability.SoilProfile); + } + } + } + + return usedSoilProfiles1D; + } + private static void TransferSensorData(SensorData sensorData, InputSensorData inputSensorData) { // Transfer sensor groups