Index: DamClients/DamUI/trunk/src/Dam/Tests/WaterBoardImporterTests.cs =================================================================== diff -u -r3757 -r3796 --- DamClients/DamUI/trunk/src/Dam/Tests/WaterBoardImporterTests.cs (.../WaterBoardImporterTests.cs) (revision 3757) +++ DamClients/DamUI/trunk/src/Dam/Tests/WaterBoardImporterTests.cs (.../WaterBoardImporterTests.cs) (revision 3796) @@ -277,7 +277,7 @@ var dikeToeAtPolder = location.SurfaceLine2.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType .DikeToeAtPolder); - Assert.AreEqual(soilProfileProbability.SoilProfile.TopLevel, dikeToeAtPolder.Z, cTolerance); + Assert.AreEqual(soilProfileProbability.SoilProfile.Layers[1].TopLevel, dikeToeAtPolder.Z, cTolerance); } // Compare reference waterboard to converted waterboard @@ -293,18 +293,26 @@ s => s.SoilProfile.Name.Equals(string.Format("{0}-{1}-{2}", referenceSoilProfileProbability.SoilProfile.Name, location.Name, soilProbabilityIndex))); for (var layerIndex = 0; - layerIndex < soilProfileProbability.SoilProfile.LayerCount; - layerIndex++) - Assert.AreEqual(referenceSoilProfileProbability.SoilProfile.Layers[layerIndex].Height, - soilProfileProbability.SoilProfile.Layers[layerIndex].Height, cTolerance, - string.Format( - "Location {0} Segment {1} soilProfile {2} Layer {3} ({4}/{5}), Org ({6}/{7})", - location.Name, location.Segment.Name, soilProfileProbability.SoilProfile.Name, - soilProfileProbability.SoilProfile.Layers[layerIndex], - soilProfileProbability.SoilProfile.Layers[layerIndex].TopLevel, - soilProfileProbability.SoilProfile.Layers[layerIndex].BottomLevel, - referenceSoilProfileProbability.SoilProfile.Layers[layerIndex].TopLevel, - referenceSoilProfileProbability.SoilProfile.Layers[layerIndex].BottomLevel)); + layerIndex < soilProfileProbability.SoilProfile.LayerCount; + layerIndex++) + { + // As the moved profile has a new top layer, make sure to compare the proper layers + if (layerIndex > 0) + { + Assert.AreEqual( + referenceSoilProfileProbability.SoilProfile.Layers[layerIndex - 1].Height, + soilProfileProbability.SoilProfile.Layers[layerIndex].Height, cTolerance, + string.Format( + "Location {0} Segment {1} soilProfile {2} Layer {3} ({4}/{5}), Org ({6}/{7})", + location.Name, location.Segment.Name, soilProfileProbability.SoilProfile.Name, + soilProfileProbability.SoilProfile.Layers[layerIndex], + soilProfileProbability.SoilProfile.Layers[layerIndex].TopLevel, + soilProfileProbability.SoilProfile.Layers[layerIndex].BottomLevel, + referenceSoilProfileProbability.SoilProfile.Layers[layerIndex - 1].TopLevel, + referenceSoilProfileProbability.SoilProfile.Layers[layerIndex - 1] + .BottomLevel)); + } + } } } } Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs =================================================================== diff -u -r3526 -r3796 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs (.../FillXmlInputFromDamUi.cs) (revision 3526) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs (.../FillXmlInputFromDamUi.cs) (revision 3796) @@ -649,7 +649,7 @@ var layer = soilProfile1D.Layers[i]; var inputLayer = new SoilProfile1DLayer1D { - Name = layer.Id, + Name = "L" + i, SoilName = layer.Soil.Name, TopLevel = layer.TopLevel, IsAquifer = layer.IsAquifer, Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DataPlugins/DataPluginImporter.cs =================================================================== diff -u -r3526 -r3796 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DataPlugins/DataPluginImporter.cs (.../DataPluginImporter.cs) (revision 3526) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DataPlugins/DataPluginImporter.cs (.../DataPluginImporter.cs) (revision 3796) @@ -85,8 +85,7 @@ private readonly List importLogMessages = new List(); private List attributes; private DamProjectType damProjectType; - private bool csvDataAdded = false; - + private string damProjectFolder; /// @@ -1263,7 +1262,6 @@ importLogMessages.AddRange(combineImportedData.ErrorMessages); Debug.Assert(ReferenceEquals(waterBoard, combineImportedData.WaterBoard)); waterBoard = combineImportedData.WaterBoard; - csvDataAdded = true; } } Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/WaterBoardPostProcessRelativeProfiles.cs =================================================================== diff -u -r3757 -r3796 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/WaterBoardPostProcessRelativeProfiles.cs (.../WaterBoardPostProcessRelativeProfiles.cs) (revision 3757) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/WaterBoardPostProcessRelativeProfiles.cs (.../WaterBoardPostProcessRelativeProfiles.cs) (revision 3796) @@ -48,13 +48,17 @@ /// public static void CreateAbsoluteProfiles(WaterBoard waterBoard, CharacteristicPointType characteristicPointType) { + const double moveAccuracy = 1e-6; foreach (Dike dike in waterBoard.Dikes) { foreach (Location location in dike.Locations) { var orgSegment = location.Segment; if (orgSegment != null) { + var topSurfaceline = location.SurfaceLine2.CharacteristicPoints.Geometry.GetMaxZ(); + var characteristicGeometryPoint = location.SurfaceLine2.CharacteristicPoints.GetGeometryPoint(characteristicPointType); + bool errorFound = false; var newSegment = new Segment(); newSegment.Name = String.Format("Segment {0}-{1}", orgSegment.Name, location.Name); int soilProbabilityIndex = 0; @@ -63,7 +67,6 @@ soilProbabilityIndex++; try { - var characteristicGeometryPoint = location.SurfaceLine2.CharacteristicPoints.GetGeometryPoint(characteristicPointType); if (characteristicGeometryPoint == null) { throw new WaterBoardPostProcessRelativeProfilesException(String.Format("Characteristic point {0} is not defined", characteristicPointType)); @@ -95,21 +98,41 @@ { soilProfile1D.BottomLevel += deltaZ; } - + var profileTopLevel = soilProfile1D.TopLevel; + // If the top of the profile is moved below the top of the surface level, a gap appears which will be filled in later in the UI + // to the combined 2D. However, for Piping calculation the 1D profile itself needs to start at least at the top of the surface line + // too in order to perform a correct calculation. So extend the 1D profile here too! + if (Math.Abs(deltaZ) > moveAccuracy && profileTopLevel < topSurfaceline) + { + var newTopLayer = new SoilLayer1D + { + SoilProfile = soilProfile1D, + MaintainLayerOrder = true, + TopLevel = topSurfaceline, + IsAquifer = false, + Soil = dike.SoilList.GetSoilByName(location.DikeEmbankmentMaterial) + }; + soilProfile1D.Layers.Insert(0, newTopLayer); + } + // Add new SoilGeometryProbability to new segment and assign new segment to location newSegment.SoilProfileProbabilities.Add(newSoilGeometryProbability); - location.Segment = newSegment; - waterBoard.Segments.Add(newSegment); // Add new soil profile to existing list. dike.SoilProfiles.Add(soilProfile1D); } catch (Exception e) { + errorFound = true; LogManager.Messages.Add(new LogMessage(LogMessageType.Error, location, String.Format("Error in location '{0}' applying relative height for soilprofile '{1}': {2} ", location.Name, orgSoilGeometryProbability.SoilGeometryName, e.Message))); } } + if (!errorFound) + { + location.Segment = newSegment; + waterBoard.Segments.Add(newSegment); + } } } } Index: DamClients/DamUI/trunk/src/Dam/Tests/DamEngineIo/FillXmlInputFromDamUiTests.cs =================================================================== diff -u -r3664 -r3796 --- DamClients/DamUI/trunk/src/Dam/Tests/DamEngineIo/FillXmlInputFromDamUiTests.cs (.../FillXmlInputFromDamUiTests.cs) (revision 3664) +++ DamClients/DamUI/trunk/src/Dam/Tests/DamEngineIo/FillXmlInputFromDamUiTests.cs (.../FillXmlInputFromDamUiTests.cs) (revision 3796) @@ -1017,7 +1017,7 @@ { var layer = new SoilLayer1D { - Id = "Layer" + (j + 1).ToString(), + Id = "L" + j, Soil = dike.SoilList.Soils[j], TopLevel = 1 * -j }; Index: DamClients/DamUI/trunk/src/Dam/Tests/WaterBoardPostProcessRelativeProfilesTest.cs =================================================================== diff -u -r3708 -r3796 --- DamClients/DamUI/trunk/src/Dam/Tests/WaterBoardPostProcessRelativeProfilesTest.cs (.../WaterBoardPostProcessRelativeProfilesTest.cs) (revision 3708) +++ DamClients/DamUI/trunk/src/Dam/Tests/WaterBoardPostProcessRelativeProfilesTest.cs (.../WaterBoardPostProcessRelativeProfilesTest.cs) (revision 3796) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Linq; using Deltares.Dam.Data; using Deltares.Geotechnics.GeotechnicalGeometry; @@ -90,9 +91,20 @@ private static void AssertSoilProfile1D(double offset, SoilProfile1D soilProfile1D) { - Assert.AreEqual(1.0 + offset, soilProfile1D.TopLevel, CTolerance); - Assert.AreEqual(-1.0 + offset, soilProfile1D.Layers[1].TopLevel, CTolerance); - Assert.AreEqual(-10.0 + offset, soilProfile1D.BottomLevel, CTolerance); + // If there is no move, than there is no added layer + if (Math.Abs(offset) < CTolerance) + { + Assert.AreEqual(1.0 + offset, soilProfile1D.TopLevel, CTolerance); + Assert.AreEqual(-1.0 + offset, soilProfile1D.Layers[1].TopLevel, CTolerance); + Assert.AreEqual(-10.0 + offset, soilProfile1D.BottomLevel, CTolerance); + } + else + { + // If there is a move, than there is one added (top) layer + Assert.AreEqual(2.0 + offset, soilProfile1D.TopLevel, CTolerance); + Assert.AreEqual(-1.0 + offset, soilProfile1D.Layers[2].TopLevel, CTolerance); + Assert.AreEqual(-10.0 + offset, soilProfile1D.BottomLevel, CTolerance); + } } [Test]