Index: DamClients/DamUI/trunk/src/Dam/Tests/WaterBoardPostProcessRelativeProfilesTest.cs =================================================================== diff -u -r3527 -r3708 --- DamClients/DamUI/trunk/src/Dam/Tests/WaterBoardPostProcessRelativeProfilesTest.cs (.../WaterBoardPostProcessRelativeProfilesTest.cs) (revision 3527) +++ DamClients/DamUI/trunk/src/Dam/Tests/WaterBoardPostProcessRelativeProfilesTest.cs (.../WaterBoardPostProcessRelativeProfilesTest.cs) (revision 3708) @@ -19,8 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Linq; using Deltares.Dam.Data; -using Deltares.Geotechnics; using Deltares.Geotechnics.GeotechnicalGeometry; using Deltares.Geotechnics.Soils; using Deltares.Geotechnics.SurfaceLines; @@ -66,6 +66,7 @@ var dike = new Dike() {Name = "Dike"}; dike.Locations.Add(location); dike.SurfaceLines2.Add(simpleSurfaceLine); + dike.SoilProfiles.Add(soilProfile1D); var waterBoard = new WaterBoard(); waterBoard.Segments.Add(segment); @@ -78,13 +79,22 @@ using (WaterBoard waterBoard = CreateWaterBoard(offset)) { WaterBoardPostProcessRelativeProfiles.CreateAbsoluteProfiles(waterBoard, CharacteristicPointType.DikeToeAtPolder); - var soilProfile1D = waterBoard.Dikes[0].Locations[0].Segment.SoilProfileProbabilities[0].SoilProfile; - 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); + // Is location soil profile moved + var soilProfile1DLocation = waterBoard.Dikes[0].Locations[0].Segment.SoilProfileProbabilities[0].SoilProfile; + AssertSoilProfile1D(offset, soilProfile1DLocation); + // Is moved dike soil profile present in dike.SoilProfileList + var soilProfile1DDike = waterBoard.Dikes[0].SoilProfiles.FirstOrDefault(p => p.Name.Equals(soilProfile1DLocation.Name)); + AssertSoilProfile1D(offset, soilProfile1DDike); } } + 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); + } + [Test] public void CanPostProcessWaterBoardNoMove() { Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/WaterBoardPostProcessRelativeProfiles.cs =================================================================== diff -u -r3526 -r3708 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/WaterBoardPostProcessRelativeProfiles.cs (.../WaterBoardPostProcessRelativeProfiles.cs) (revision 3526) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/WaterBoardPostProcessRelativeProfiles.cs (.../WaterBoardPostProcessRelativeProfiles.cs) (revision 3708) @@ -40,10 +40,12 @@ /// Creates the absolute profiles based on the original profiles. /// The original profiles are considered to be relative to the specified characteristic point /// 1) Create a copy of the assigned segment for each location - /// 2) In the copy the toplevel of the soilprofile will be moved to the z-coordinate of the specified characteristic point + /// 2) Create a copy of the soil profile and assign it to the new segment + /// 3) In the copy of the soil profile the toplevel will be moved to the z-coordinate of the specified characteristic point + /// 4) Add the new soil profile to the dike.SoilProfileList /// /// The water board. - /// The characteristic point to which the soilprofile toplevel should be moved + /// public static void CreateAbsoluteProfiles(WaterBoard waterBoard, CharacteristicPointType characteristicPointType) { foreach (Dike dike in waterBoard.Dikes) @@ -55,8 +57,10 @@ { var newSegment = new Segment(); newSegment.Name = String.Format("Segment {0}", location.Name); + int soilProbabilityIndex = 0; foreach (SoilGeometryProbability orgSoilGeometryProbability in orgSegment.SoilProfileProbabilities) { + soilProbabilityIndex++; try { var characteristicGeometryPoint = location.SurfaceLine2.CharacteristicPoints.GetGeometryPoint(characteristicPointType); @@ -77,6 +81,7 @@ // Dependent if deltaZ is positive or negative, the bottomLevel should be adjusted before or after adjusting the layers // This is necessary, because the bottomlevel is adjusted automatically during adjustment of layers var soilProfile1D = newSoilGeometryProbability.SoilProfile; + soilProfile1D.Name = String.Format("{0}-{1}", location.Name, soilProbabilityIndex); double deltaZ = characteristicGeometryPoint.Z - soilProfile1D.TopLevel; if (deltaZ < 0) { @@ -95,6 +100,8 @@ newSegment.SoilProfileProbabilities.Add(newSoilGeometryProbability); location.Segment = newSegment; waterBoard.Segments.Add(newSegment); + // Add new soil profile existing list + dike.SoilProfiles.Add(soilProfile1D); } catch (Exception e) { @@ -106,7 +113,6 @@ } } } - } } }