Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryGenerator.cs
===================================================================
diff -u -r5564 -r5618
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryGenerator.cs (.../GeometryGenerator.cs) (revision 5564)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryGenerator.cs (.../GeometryGenerator.cs) (revision 5618)
@@ -167,7 +167,11 @@
{
var newSurface = new GeometrySurface();
newSurface.SetOuterLoop(loop);
- geometryData.Surfaces.Add(newSurface);
+ if (!geometryData.HasSurfaceWithSameOuterLoop(newSurface.OuterLoop))
+ {
+ geometryData.Surfaces.Add(newSurface);
+ }
+
return newSurface;
}
@@ -355,10 +359,6 @@
if (geometryData.NewlyEffectedPoints.Contains(point))
{
geometryData.NewlyEffectedPoints.Remove(point);
- if (!geometryData.NewlyEffectedPoints.Contains(doublePoints[point]))
- {
- geometryData.NewlyEffectedPoints.Add(doublePoints[point]); //#Bka why should this be needed? point is already in geometry
- }
}
}
}
@@ -572,9 +572,9 @@
// find the surface that is most repeated in the loop's in curves
newSurface = GetReassignmentSurfaceFromCurves(loop);
- // an existing surface has been found
+ // an existing surface (in geometryLoopDirections) has been found
if (newSurface != null)
- {
+ {
newSurface = CreateSurface(loop);
}
else // no existing surface found from its comprising curves... create aValue1 brand new surface!
@@ -858,7 +858,7 @@
newSurface.RemoveAllInnerLoops();
for (var index = 0; index < surfaceCount; index++)
{
- if (newSurface == geometryData.Surfaces[index])
+ if (newSurface.Equals(geometryData.Surfaces[index]))
{
continue;
}
@@ -902,7 +902,8 @@
}
//Add New Loop as inner loop to the existing Surface
- if ((innerPointCount == newPointCount) || ((innerPointCount > 0) && (newPointCount == (innerPointCount + isOnPointCount))))
+ //#BKA: Temp code to be tested as replacement: if ((innerPointCount == newPointCount) || ((innerPointCount > 0) && (newPointCount == (innerPointCount + isOnPointCount))))
+ if (innerPointCount == newPointCount)
{
geometryData.Surfaces[index].AddInnerLoop(newLoop);
}
@@ -991,7 +992,7 @@
Point2D geometryCurve1EndPoint = geometryCurve1.EndPoint;
Point2D geometryCurve2HeadPoint = geometryCurve2.HeadPoint;
Point2D geometryCurve2EndPoint = geometryCurve2.EndPoint;
- if (!geometryCurve1.LocationEquals(geometryCurve2) && // geometryCurve1 != geometryCurve2 &&
+ if (!geometryCurve1.LocationEquals(geometryCurve2) &&
!RegenerateParallelCurves(geometryCurve2, geometryCurve1, ref isCurveInserted) &&
Routines2D.DetermineIf2DLinesIntersectStrickly(geometryCurve1HeadPoint, geometryCurve1EndPoint, geometryCurve2HeadPoint, geometryCurve2EndPoint, out Point2D intersectionPoint) ==
LineIntersection.Intersects)
Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryLoop.cs
===================================================================
diff -u -r5527 -r5618
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryLoop.cs (.../GeometryLoop.cs) (revision 5527)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryLoop.cs (.../GeometryLoop.cs) (revision 5618)
@@ -236,7 +236,7 @@
private bool AddEitherHeadOrEndPointOfCurveToCalcPoints(int index)
{
- // Compare by reference (is faster then by value)
+ // Compare by reference (is faster than by value)
if (CurveList[index].HeadPoint == calcPoints[calcPoints.Count - 1])
{
calcPoints.Add(CurveList[index].EndPoint);
@@ -264,6 +264,24 @@
}
///
+ /// Determines if all curves in the loop are equal (by reference) to the curves of the given geometry loop.
+ ///
+ ///
+ /// true when there are curves and they are equal, else false
+ public bool HasSameCurvesByReference(GeometryLoop geometryLoop)
+ {
+ foreach (GeometryCurve geometryCurve in CurveList)
+ {
+ if (!geometryLoop.CurveList.Contains(geometryCurve))
+ {
+ return false;
+ }
+ }
+
+ return CurveList.Count > 2 && CurveList.Count == geometryLoop.CurveList.Count;
+ }
+
+ ///
/// Helper class NotEnoughUniquePointsException
///
public class NotEnoughUniquePointsException : InvalidOperationException