Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Geometry2DImporter/SoilProfile2DImporter.cs =================================================================== diff -u -r5875 -r5884 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Geometry2DImporter/SoilProfile2DImporter.cs (.../SoilProfile2DImporter.cs) (revision 5875) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Geometry2DImporter/SoilProfile2DImporter.cs (.../SoilProfile2DImporter.cs) (revision 5884) @@ -27,6 +27,8 @@ using Deltares.DamEngine.Data.Geometry; using Deltares.Geotechnics.Soils; using Deltares.Standard.Language; +using GeometryPoint = Deltares.Geometry.GeometryPoint; +using GeometryPointString = Deltares.Geometry.GeometryPointString; namespace Deltares.Dam.Data.Geometry2DImporter; @@ -132,15 +134,21 @@ private static void ResetSoilsForSurfaces(List originalSurfaces, SoilProfile2D readSoilProfile, double xSoilGeometry2DOrigin) { - if (originalSurfaces != null) + if (originalSurfaces == null) { - for (int i = 0; i < readSoilProfile.Surfaces.Count; i++) + return; + } + + for (var i = 0; i < readSoilProfile.Surfaces.Count; i++) + { + GeometryPointString topCurves = readSoilProfile.Surfaces[i].GeometrySurface.DetermineTopGeometrySurface(); + GeometryPoint point = topCurves.Points[1]; + Soil soil = FindSoilInOldSurfaces(originalSurfaces, point, xSoilGeometry2DOrigin); + if (soil == null) { - var topCurves = readSoilProfile.Surfaces[i].GeometrySurface.DetermineTopGeometrySurface(); - var point = topCurves.Points[1]; - var soil = FindSoilInOldSurfaces(originalSurfaces, point, xSoilGeometry2DOrigin); - readSoilProfile.Surfaces[i].Soil = soil; + throw new InvalidOperationException("Soil should always be found!"); } + readSoilProfile.Surfaces[i].Soil = soil; } } @@ -165,11 +173,7 @@ { return null; } - var backupSoils = new List(); - foreach (var surface in profile2D.Surfaces) - { - backupSoils.Add(surface.Soil); - } + var oldSurfaces = new List(); oldSurfaces.AddRange((IEnumerable) profile2D.Surfaces);