Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs =================================================================== diff -u -r6285 -r6287 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs (.../FillXmlInputFromDamUi.cs) (revision 6285) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs (.../FillXmlInputFromDamUi.cs) (revision 6287) @@ -95,20 +95,22 @@ input.SurfaceLines = new SurfaceLine[usedSurfaceLines.Count]; TransferSurfaceLines(usedSurfaceLines, input.SurfaceLines); - // Process soils - input.Soils = new DamEngine.Io.XmlInput.Soil[dike.SoilList.Soils.Count]; - TransferSoils(dike.SoilList.Soils, input.Soils); - // Process soil profiles 1D + List usedSoilProfiles1D = null; if (dike.SoilProfiles != null && dike.SoilProfiles.Count > 0) { - List usedSoilProfiles = DetermineUsedSoilProfiles1D(usedSegments); - input.SoilProfiles1D = new DamEngine.Io.XmlInput.SoilProfile1D[usedSoilProfiles.Count]; - TransferSoilProfiles1D(usedSoilProfiles, input.SoilProfiles1D); + usedSoilProfiles1D = DetermineUsedSoilProfiles1D(usedSegments); + input.SoilProfiles1D = new DamEngine.Io.XmlInput.SoilProfile1D[usedSoilProfiles1D.Count]; + TransferSoilProfiles1D(usedSoilProfiles1D, input.SoilProfiles1D); } input.SoilProfiles2D = soilProfiles2DToSerialize.ToArray(); + // Process soils + List usedSoils = DetermineUsedSoils(dike.SoilList.Soils, usedSoilProfiles1D, soilProfiles2DToSerialize); + input.Soils = new DamEngine.Io.XmlInput.Soil[dike.SoilList.Soils.Count]; + TransferSoils(usedSoils, input.Soils); + TransferTrafficLoadDegreeOfConsolidation(dike.TrafficLoadDegreeOfConsolidations, input); if (damProjectData.InputTimeSerieCollection != null) @@ -171,7 +173,48 @@ return usedSoilProfiles1D; } + + private static List DetermineUsedSoils(List allSoils, List soilProfile1Ds, List soilProfile2Ds) + { + List usedSoils = DetermineUsedSoilsFromSoilProfiles1D(soilProfile1Ds); + if (soilProfile2Ds != null && soilProfile2Ds.Count > 0) + { + foreach (SoilProfile2D soilProfile2D in soilProfile2Ds) + { + foreach (SoilProfile2DLayer2D layer2D in soilProfile2D.Layers2D) + { + if (!usedSoils.Any(usedSoil => string.Equals(usedSoil.Name, layer2D.SoilName, StringComparison.OrdinalIgnoreCase))) + { + usedSoils.Add(allSoils.First(soil => string.Equals(soil.Name, layer2D.SoilName, StringComparison.OrdinalIgnoreCase))); + } + } + } + } + + return usedSoils; + } + + private static List DetermineUsedSoilsFromSoilProfiles1D(List soilProfile1Ds) + { + var usedSoils = new List(); + if (soilProfile1Ds != null) + { + foreach (SoilProfile1D soilProfile1D in soilProfile1Ds) + { + foreach (Soil soil in soilProfile1D.Soils) + { + if (!usedSoils.Any(usp => string.Equals(usp.Name, soil.Name, StringComparison.OrdinalIgnoreCase))) + { + usedSoils.Add(soil); + } + } + } + } + + return usedSoils; + } + private static void TransferSensorData(SensorData sensorData, InputSensorData inputSensorData) { // Transfer sensor groups