Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/Deltares.Dam.StixFileReader.csproj
===================================================================
diff -u -r4803 -r6159
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/Deltares.Dam.StixFileReader.csproj (.../Deltares.Dam.StixFileReader.csproj) (revision 4803)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/Deltares.Dam.StixFileReader.csproj (.../Deltares.Dam.StixFileReader.csproj) (revision 6159)
@@ -15,6 +15,9 @@
..\..\..\lib\DSL-Geo\Deltares.Geotechnics.dll
+
+ ..\..\..\lib\DSL-Core\Deltares.Mathematics.dll
+
..\..\..\lib\DSL-Core\Deltares.Standard.dll
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/PersistableDataModelFactory.cs
===================================================================
diff -u -r6112 -r6159
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/PersistableDataModelFactory.cs (.../PersistableDataModelFactory.cs) (revision 6112)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/PersistableDataModelFactory.cs (.../PersistableDataModelFactory.cs) (revision 6159)
@@ -415,4 +415,159 @@
}
};
}
+
+ ///
+ /// |-----------------------------------------------------------------|
+ /// | |
+ /// | bottom of layer 2 |
+ /// | |---------------------| |
+ /// | | | |
+ /// | layer 2 | | |
+ /// | | | |
+ /// | | layer 3 | |
+ /// | | | |
+ /// | | | |
+ /// | | | |
+ /// |-----------------|---------------------|-------------------------|
+ /// | layer 1 |
+ /// |-----------------------------------------------------------------|
+ ///
+ ///
+ /// Factory for creating a simple containing a layer
+ /// for which all the points are also in another surrounding layer,
+ /// but it is not an inner loop.
+ ///
+ ///
+ public static PersistableDataModel CreateSimpleDataModelWithLayerThatIsNotAnInnerLoop()
+ {
+ return new PersistableDataModel
+ {
+ Scenarios = new List
+ {
+ new()
+ {
+ Stages = new List
+ {
+ new()
+ {
+ GeometryId = "15",
+ SoilLayersId = "20"
+ }
+ }
+ }
+ },
+ Geometry = new List
+ {
+ new()
+ {
+ Id = "15",
+ Layers = new List
+ {
+ new()
+ {
+ Id = "16",
+ Points = new List
+ {
+ new(10, -6),
+ new(10, -5),
+ new(60, -5),
+ new(60, -6)
+ }
+ },
+ new()
+ {
+ Id = "17",
+ Points = new List
+ {
+ new(10, -5),
+ new(10, 5),
+ new(60, 5),
+ new(60, -5),
+ new(30, -5),
+ new(30, 4),
+ new(20, 4),
+ new(20, -5)
+ }
+ },
+ new()
+ {
+ Id = "18",
+ Points = new List
+ {
+ new(20, -5),
+ new(20, 4),
+ new(30, 4),
+ new(30, -5)
+ }
+ },
+ }
+ }
+ },
+ SoilLayers = new List
+ {
+ new()
+ {
+ Id = "20",
+ SoilLayers = new List
+ {
+ new()
+ {
+ LayerId = "16",
+ SoilId = "12"
+ },
+ new()
+ {
+ LayerId = "17",
+ SoilId = "13"
+ },
+ new()
+ {
+ LayerId = "18",
+ SoilId = "7"
+ }
+ }
+ }
+ },
+ Soils = new PersistableSoilCollection
+ {
+ Soils = new List
+ {
+ new()
+ {
+ Id = "7"
+ },
+ new()
+ {
+ Id = "12"
+ },
+ new()
+ {
+ Id = "13"
+ }
+ }
+ },
+ SoilVisualizations = new PersistableSoilVisualizationCollection
+ {
+ SoilVisualizations = new List
+ {
+ new()
+ {
+ SoilId = "7",
+ Color = ColorTranslator.FromHtml("#80657F22")
+ },
+ new()
+ {
+ SoilId = "12",
+ Color = ColorTranslator.FromHtml("#80FFCC00")
+ },
+ new()
+ {
+ SoilId = "13",
+ Color = ColorTranslator.FromHtml("#80BB8800")
+ }
+ }
+ }
+ };
+ }
+
}
\ No newline at end of file
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/SoilProfile2DDataModel.cs
===================================================================
diff -u -r6112 -r6159
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/SoilProfile2DDataModel.cs (.../SoilProfile2DDataModel.cs) (revision 6112)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/SoilProfile2DDataModel.cs (.../SoilProfile2DDataModel.cs) (revision 6159)
@@ -26,6 +26,7 @@
using Components.Persistence.Stability.Version2.Data;
using Deltares.Geometry;
using Deltares.Geotechnics.Soils;
+using Deltares.Mathematics;
namespace Deltares.Dam.StixFileReader;
@@ -230,10 +231,12 @@
continue;
}
GeometryLoop loop2 = soilProfile.Surfaces[index2].GeometrySurface.OuterLoop;
- bool allPointsInLoop2AreInLoop1 = loop2.Points.All(loop1.IsPointInLoopArea);
- if (allPointsInLoop2AreInLoop1)
+ if (loop2.Points.All(loop1.IsPointInLoopArea))
{
- layerConnections.Add(new LayerConnection(index2, index1, loop1.Area()));
+ if (CentroidOfLoop2IsInLoop1(loop2, loop1))
+ {
+ layerConnections.Add(new LayerConnection(index2, index1, loop1.Area()));
+ }
}
}
}
@@ -255,4 +258,13 @@
}
}
}
+
+ private static bool CentroidOfLoop2IsInLoop1(GeometryLoop loop2, GeometryLoop loop1)
+ {
+ List loop2Points = loop2.GetLocalPoint2DList();
+ Point2D centroidOfLoop2Point2D = Routines2D.DeterminePolygonCentroid(loop2Points);
+ var centroidOfLoop2 = new GeometryPoint(centroidOfLoop2Point2D.X, 0, centroidOfLoop2Point2D.Y);
+ bool centroidOfLoop2IsInLoop1 = loop1.IsPointInLoopArea(centroidOfLoop2);
+ return centroidOfLoop2IsInLoop1;
+ }
}
\ No newline at end of file
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/SoilProfile2DDataModelTest.cs
===================================================================
diff -u -r6112 -r6159
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/SoilProfile2DDataModelTest.cs (.../SoilProfile2DDataModelTest.cs) (revision 6112)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/SoilProfile2DDataModelTest.cs (.../SoilProfile2DDataModelTest.cs) (revision 6159)
@@ -210,4 +210,19 @@
Assert.That(soilProfile2D.Geometry.Surfaces.ElementAt(1).InnerLoops.ElementAt(0).CurveList, Has.Count.EqualTo(4));
});
}
+
+ [Test]
+ public void WhenCreateDataModelWithLayerThatIsNotAnInnerLoop_ThenSoilProfile2DIsAsExpected()
+ {
+ const double shift = 0;
+ PersistableDataModel dataModel = PersistableDataModelFactory.CreateSimpleDataModelWithLayerThatIsNotAnInnerLoop();
+ SoilProfile2D soilProfile2D = new SoilProfile2DDataModel().Create(dataModel, 0);
+
+ Assert.That(soilProfile2D.Geometry.Surfaces, Has.Count.EqualTo(3));
+ Assert.Multiple(() =>
+ {
+ Assert.That(soilProfile2D.Geometry.Surfaces.ElementAt(1).OuterLoop.CurveList, Has.Count.EqualTo(8));
+ Assert.That(soilProfile2D.Geometry.Surfaces.ElementAt(1).InnerLoops, Has.Count.EqualTo(0));
+ });
+ }
}
\ No newline at end of file