Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfile2D.cs
===================================================================
diff -u -r5251 -r5252
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfile2D.cs (.../SoilProfile2D.cs) (revision 5251)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfile2D.cs (.../SoilProfile2D.cs) (revision 5252)
@@ -71,6 +71,8 @@
///
/// Gets the soil profile 1D at the given X.
+ /// If the given X coincides with a vertical layer separation and both profiles at left and at right of the separation
+ /// are different, then the X is shifted by 1 mm to the right
///
/// The x.
/// Soil Profile 1D
@@ -94,14 +96,12 @@
{
x = Geometry.Left + diff;
}
-
- // If the X coincides with a vertical layer separation and both profiles at left and at right of the separation are different,
- // then the X is shifted by 1 mm to the right.
+
bool isXShiftedToRight;
double xRelevant = x;
do
{
- isXShiftedToRight = HasLayerAVerticalPartAtGivenX(xRelevant) && !AreSoilProfilesIdentical(xRelevant - diff / 2, xRelevant + diff / 2);
+ isXShiftedToRight = AreLayersWithVerticalPartPresentAtGivenX(xRelevant) && !AreSoilProfilesIdentical(xRelevant - diff / 2, xRelevant + diff / 2);
if (isXShiftedToRight)
{
xRelevant += diff;
@@ -156,7 +156,7 @@
public static SoilLayer2D GetOriginalLayerFromOldSurfaces(GeometrySurface geometrySurface,
IEnumerable oldSurfaces)
{
- return GetOriginalLayerFromOldSurfaces(geometrySurface, oldSurfaces, 0.0);
+ return GetOriginalLayerFromOldSurfaces(geometrySurface, oldSurfaces, 0.0);
}
///
@@ -169,29 +169,29 @@
private static SoilLayer2D GetOriginalLayerFromOldSurfaces(GeometrySurface geometrySurface, IEnumerable oldSurfaces,
double shift)
{
- Point2D point = new Point2D(0.0, 0.0);
- bool isPointInOuterLoopAndOldSurface = false;
- point = IsPointInOuterLoopAndOldSurface(geometrySurface, oldSurfaces, shift, point, ref isPointInOuterLoopAndOldSurface);
+ Point2D point = new Point2D(0.0, 0.0);
+ bool isPointInOuterLoopAndOldSurface = false;
+ point = IsPointInOuterLoopAndOldSurface(geometrySurface, oldSurfaces, shift, point, ref isPointInOuterLoopAndOldSurface);
- if (!isPointInOuterLoopAndOldSurface)
- {
- isPointInOuterLoopAndOldSurface = IsPointInOldSurfaceJustBelowTopOfNewGeometryWithinItsLimits(geometrySurface,
- oldSurfaces, shift, point, isPointInOuterLoopAndOldSurface);
- }
- if (isPointInOuterLoopAndOldSurface)
- {
- point.X -= shift;
- if (IsPointInPreviousOuterLoopOfOldSurface(oldSurfaces, point, out SoilLayer2D soilLayer2D))
+ if (!isPointInOuterLoopAndOldSurface)
{
- return soilLayer2D;
+ isPointInOuterLoopAndOldSurface = IsPointInOldSurfaceJustBelowTopOfNewGeometryWithinItsLimits(geometrySurface,
+ oldSurfaces, shift, point, isPointInOuterLoopAndOldSurface);
}
-
- if (IsPointInOuterLoopOfOldSurface(oldSurfaces, point, out SoilLayer2D originalLayerFromOldSurfaces1))
+ if (isPointInOuterLoopAndOldSurface)
{
- return originalLayerFromOldSurfaces1;
+ point.X -= shift;
+ if (IsPointInPreviousOuterLoopOfOldSurface(oldSurfaces, point, out SoilLayer2D soilLayer2D))
+ {
+ return soilLayer2D;
+ }
+
+ if (IsPointInOuterLoopOfOldSurface(oldSurfaces, point, out SoilLayer2D originalLayerFromOldSurfaces1))
+ {
+ return originalLayerFromOldSurfaces1;
+ }
}
- }
- return null;
+ return null;
}
private static bool IsPointInOuterLoopOfOldSurface(IEnumerable oldSurfaces, Point2D point,
@@ -202,7 +202,7 @@
{
GeometryLoop outerLoop = oldSurface.GeometrySurface.OuterLoop;
if (outerLoop != null && outerLoop.CurveList.Count > 2 && Routines2D.CheckIfPointIsInPolygon(outerLoop, point.X,
- point.Z) == PointInPolygon.InsidePolygon)
+ point.Z) == PointInPolygon.InsidePolygon)
{
bool isPointInOuterLoopOfOldSurface = true;
foreach (GeometryLoop innerLoop in oldSurface.GeometrySurface.InnerLoops)
@@ -249,7 +249,7 @@
}
private static bool IsPointInOldSurfaceJustBelowTopOfNewGeometryWithinItsLimits(GeometrySurface geometrySurface,
- IEnumerable oldSurfaces, double shift, Point2D point, bool isPointInOuterLoopAndOldSurface)
+ IEnumerable oldSurfaces, double shift, Point2D point, bool isPointInOuterLoopAndOldSurface)
{
GeometryPointString topGeometrySurface = geometrySurface.DetermineTopGeometrySurface();
topGeometrySurface.SortPointsByXAscending();
@@ -365,7 +365,7 @@
foreach (GeometryLoop innerLoop in innerLoops)
{
if (Routines2D.CheckIfPointIsInPolygon(innerLoop, point.X, point.Z) == PointInPolygon.InsidePolygon)
- return false;
+ return false;
}
}
return isPointInSurface;
@@ -400,21 +400,11 @@
return soilProfile;
}
- private bool HasLayerAVerticalPartAtGivenX(double xCoordinate)
+ private bool AreLayersWithVerticalPartPresentAtGivenX(double xCoordinate)
{
- foreach (SoilLayer2D surface in Surfaces)
- {
- foreach (GeometryCurve curve in surface.GeometrySurface.OuterLoop.CurveList)
- {
- if (curve.HeadPoint.X.IsNearEqual(xCoordinate, toleranceAlmostEqual) &&
- curve.EndPoint.X.IsNearEqual(xCoordinate, toleranceAlmostEqual))
- {
- return true;
- }
- }
- }
-
- return false;
+ return Surfaces.Any(surface => surface.GeometrySurface.OuterLoop.CurveList.Any
+ (curve => curve.HeadPoint.X.IsNearEqual(xCoordinate, toleranceAlmostEqual) &&
+ curve.EndPoint.X.IsNearEqual(xCoordinate, toleranceAlmostEqual)));
}
private bool AreSoilProfilesIdentical(double x1, double x2)