Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs =================================================================== diff -u -r6276 -r6404 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs (.../GeometryData.cs) (revision 6276) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs (.../GeometryData.cs) (revision 6404) @@ -1,4 +1,4 @@ -// Copyright (C) Stichting Deltares 2024. All rights reserved. +// Copyright (C) Stichting Deltares 2025. All rights reserved. // // This file is part of the Dam Engine. // @@ -171,23 +171,6 @@ } /// - /// Synchronizes the loops. - /// - private void SynchronizeLoops() - { - DeleteAllLoops(); - foreach (GeometrySurface surface in Surfaces) - { - // As real donuts (or holes in geom) are not allowed, there can be no innerloop that - // is NOT an outerloop for another surface. So no need to sync innerloops. - if (surface.OuterLoop != null && surface.OuterLoop.IsLoop()) - { - Loops.Add(surface.OuterLoop); - } - } - } - - /// /// Finds the point at location. /// /// Point location to be found. @@ -243,6 +226,7 @@ { NewlyEffectedPoints.Add(newPoint); } + return newPoint; } @@ -264,7 +248,7 @@ } Remove(point); - + foreach (GeometryCurve aCurve in source) { DeleteCurve(aCurve, true); @@ -298,6 +282,7 @@ geometryGenerator.SetIsUsed(curve1, CurveDirection.Forward, false); geometryGenerator.SetIsUsed(curve1, CurveDirection.Reverse, false); } + curve1.HeadPoint = point1; curve1.EndPoint = point2; AddDataItemToProperList(curve1); @@ -333,6 +318,57 @@ return clonedGeometryData; } + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + return LocalizationManager.GetTranslatedText(this, "GeometryData"); + } + + /// + /// Gets next connected top curve in list of curves + /// + /// + /// + /// + /// Curve + protected internal GeometryCurve GetNextTopCurve(GeometryCurve curve, List boundaryCurves, + List excludedCurves) + { + // if current curve ends on right limit then that must have been the last one so stop the search + if (Math.Abs(curve.HeadPoint.X - Right) < GeometryConstants.Accuracy || Math.Abs(curve.EndPoint.X - Right) < GeometryConstants.Accuracy) + { + return null; + } + + IEnumerable includedCurves = boundaryCurves.Where(geometryCurve => geometryCurve != curve && !excludedCurves.Contains(geometryCurve)); + IEnumerable connectedCurves = includedCurves.Where(geometryCurve => AreConnected(curve, geometryCurve)); + IEnumerable connectedCurvesOnRightSide = connectedCurves.Where(geometryCurve => IsCurveOnLeftSideOfOtherCurve(curve, geometryCurve)); + GeometryCurve topConnectedCurve = connectedCurvesOnRightSide.MaxBy(c => c.HeadPoint.Z + c.EndPoint.Z); + return topConnectedCurve; + } + + /// + /// Synchronizes the loops. + /// + private void SynchronizeLoops() + { + DeleteAllLoops(); + foreach (GeometrySurface surface in Surfaces) + { + // As real donuts (or holes in geom) are not allowed, there can be no innerloop that + // is NOT an outerloop for another surface. So no need to sync innerloops. + if (surface.OuterLoop != null && surface.OuterLoop.IsLoop()) + { + Loops.Add(surface.OuterLoop); + } + } + } + private void CloneSurfaces(GeometryData clonedGeometryData) { foreach (GeometrySurface surface in Surfaces) @@ -348,6 +384,7 @@ ReplacePointsForLoop(clonedGeometryData, innerLoop); ReplaceCurvesForLoop(clonedGeometryData, innerLoop); } + clonedGeometryData.Loops.AddRange(innerLoops); GeometrySurface clonedSurface = surface.Clone(); clonedSurface.OuterLoop = clonedLoop; @@ -358,21 +395,21 @@ private static void ReplacePointsForLoop(GeometryData clonedGeometryData, GeometryLoop clonedLoop) { - for (int i = 0; i < clonedLoop.Points.Count; i++) + for (var i = 0; i < clonedLoop.Points.Count; i++) { clonedLoop.Points[i] = clonedGeometryData.GetPointAtLocation(clonedLoop.Points[i]); } } - + private static void ReplaceCurvesForLoop(GeometryData clonedGeometryData, GeometryLoop clonedLoop) { - for (int i = 0; i < clonedLoop.CurveList.Count; i++) + for (var i = 0; i < clonedLoop.CurveList.Count; i++) { clonedLoop.CurveList[i].HeadPoint = clonedGeometryData.GetPointAtLocation(clonedLoop.CurveList[i].HeadPoint); clonedLoop.CurveList[i].EndPoint = clonedGeometryData.GetPointAtLocation(clonedLoop.CurveList[i].EndPoint); } } - + private void CloneNewlyEffectedCurves(GeometryData clonedGeometryData) { foreach (GeometryCurve curve in NewlyEffectedCurves) @@ -406,40 +443,6 @@ } /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - return LocalizationManager.GetTranslatedText(this, "GeometryData"); - } - - /// - /// Gets next connected top curve in list of curves - /// - /// - /// - /// - /// Curve - protected internal GeometryCurve GetNextTopCurve(GeometryCurve curve, List boundaryCurves, - List excludedCurves) - { - // if current curve ends on right limit then that must have been the last one so stop the search - if (Math.Abs(curve.HeadPoint.X - Right) < GeometryConstants.Accuracy || Math.Abs(curve.EndPoint.X - Right) < GeometryConstants.Accuracy) - { - return null; - } - - IEnumerable includedCurves = boundaryCurves.Where(geometryCurve => geometryCurve != curve && !excludedCurves.Contains(geometryCurve)); - IEnumerable connectedCurves = includedCurves.Where(geometryCurve => AreConnected(curve, geometryCurve)); - IEnumerable connectedCurvesOnRightSide = connectedCurves.Where(geometryCurve => IsCurveOnLeftSideOfOtherCurve(curve, geometryCurve)); - GeometryCurve topConnectedCurve = connectedCurvesOnRightSide.MaxBy(c => c.HeadPoint.Z + c.EndPoint.Z); - return topConnectedCurve; - } - - /// /// Removes the boundary curves from the given list of curves. /// The boundaries themselves are determined from the given geometry /// @@ -630,7 +633,7 @@ private Point2D AddRequestedPointAsNewPointWhenNeeded(Point2D requestedPoint, out bool isExistingPoint) { isExistingPoint = false; - + // try to find the requested point in Points Point2D newPoint = GetPointAtLocation(requestedPoint); @@ -650,14 +653,14 @@ isExistingPoint = true; } } - + if (newPoint == null) { newPoint = new Point2D(requestedPoint.X, requestedPoint.Z); AddDataItemToProperList(newPoint); return newPoint; } - + return newPoint; } @@ -933,11 +936,11 @@ { return Curves.Any(c => c.LocationEquals(curve)); } - + private void RemoveDoublesFromNewlyEffectedCurves() { RemoveIllegalDoublesFromNewlyEffectedCurves(); - + RemoveRealDoublesFromNewlyEffectedCurves(); } @@ -965,7 +968,7 @@ private void RemoveIllegalDoublesFromNewlyEffectedCurves() { var curvesToDelete = new List(); - + GeometryCurve[] curvesAsArray = NewlyEffectedCurves.ToArray(); for (var i = 0; i < curvesAsArray.Length; i++) { @@ -990,8 +993,8 @@ { for (int j = i; j < pointsAsArray.Length; j++) { - if (i != j && - (pointsAsArray[i].LocationEquals(pointsAsArray[j]) || + if (i != j && + (pointsAsArray[i].LocationEquals(pointsAsArray[j]) || Routines2D.Compute2DDistance(pointsAsArray[i].X, pointsAsArray[i].Z, pointsAsArray[j].X, pointsAsArray[j].Z) < minDist) && !pointsToDelete.Contains(pointsAsArray[j])) { @@ -1177,7 +1180,7 @@ #endregion #region other functions - + /// /// Determines if there is already a surface with the same outer loop. /// @@ -1186,16 +1189,16 @@ public bool HasSurfaceWithSameOuterLoop(GeometryLoop outerLoop) { foreach (GeometrySurface geometrySurface in Surfaces) - { + { if (geometrySurface.OuterLoop.HasSameCurves(outerLoop)) { return true; - } + } } return false; } - + /// /// Finds a Surface based on its outerloop /// @@ -1204,16 +1207,16 @@ public GeometrySurface FindSurfaceByItsOuterLoop(GeometryLoop outerLoop) { foreach (GeometrySurface geometrySurface in Surfaces) - { + { if (geometrySurface.OuterLoop.HasSameCurves(outerLoop)) { return geometrySurface; - } + } } return null; } - + /// /// ///