Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryPointString.cs =================================================================== diff -u -r5992 -r6087 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryPointString.cs (.../GeometryPointString.cs) (revision 5992) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryPointString.cs (.../GeometryPointString.cs) (revision 6087) @@ -83,15 +83,13 @@ /// /// The calculate points as protected field (to be able to prevent recursive calls to CalcPoints) /// - protected readonly List calcPoints = new List(); + protected List calcPoints = new List(); - private readonly List points = new List(); - /// - /// Gets the at the specified index. + /// Gets the at the specified index. /// /// - /// The . + /// The . /// /// The index. /// When less @@ -105,7 +103,7 @@ } /// - /// The calculate points (to be used in calcualtion instead of Points for better performance) + /// The calculate points (to be used in calculation instead of Points for better performance) /// public virtual List CalcPoints { @@ -116,20 +114,6 @@ } /// - /// List of points that describe the physical surface line or surface. - /// - /// - /// The points. - /// - public virtual IList Points - { - get - { - return points; - } - } - - /// /// Gets the count of the points. /// /// @@ -151,13 +135,11 @@ { var clone = new GeometryPointString(); this.CloneProperties(clone); // excludes the points ! - clone.Points.Clear(); - foreach (GeometryPoint point in Points) + clone.CalcPoints.Clear(); + foreach (Point2D point in CalcPoints) { - clone.Points.Add(new GeometryPoint(point)); + clone.CalcPoints.Add(new Point2D(point.X, point.Z)); } - - clone.SyncCalcPoints(); return clone; } @@ -166,7 +148,7 @@ /// public void RoundPointsCoordinates(double accuracy) { - foreach (GeometryPoint point in Points) + foreach (Point2D point in CalcPoints) { point.X = RoundValue(point.X, accuracy); point.Z = RoundValue(point.Z, accuracy); @@ -405,19 +387,6 @@ } /// - /// Gets the GeometryPoint at the specified coordinates. - /// - /// The x. - /// The z. - /// - public GeometryPoint DetermineGeometryPointAt(double x, double z) - { - return Points.FirstOrDefault( - point => point.X.AlmostEquals(x, GeometryPoint.Precision) && - point.Z.AlmostEquals(z, GeometryPoint.Precision)); - } - - /// /// Returns ALL intersection points that are found for a line costructed at level z, /// including the double ones as the number of points can be relevant! /// @@ -474,13 +443,12 @@ public virtual void SortPointsByXAscending() { calcPoints.Sort(); - points.Sort(); } /// /// Removes all double points at a location, if consecutive /// - public void CondensePoints() + private void CondensePoints() { for (int i = calcPoints.Count - 1; i > 0; i--) { @@ -514,46 +482,12 @@ } /// - /// Synchronizes the calculation points based on the Points. - /// - public void SyncCalcPoints() - { - calcPoints.Clear(); - foreach (GeometryPoint geometryPoint in Points) - { - var p2D = new Point2D - { - X = geometryPoint.X, - Z = geometryPoint.Z - }; - calcPoints.Add(p2D); - } - } - - /// - /// Synchronizes the points based on the CalcPoints. - /// - public void SyncPoints() - { - points.Clear(); - foreach (Point2D p2D in calcPoints) - { - var geometryPoint = new GeometryPoint - { - X = p2D.X, - Z = p2D.Z - }; - points.Add(geometryPoint); - } - } - - /// /// Finds all intersections in the XZ-plane the given list. /// /// The list. /// /// - public List IntersectionXzPointsWithGeometryPointList(IList list) + private List IntersectionXzPointsWithGeometryPointList(IList list) { return IntersectWithPointsListCore(list, false); } @@ -566,7 +500,7 @@ /// public RelativeXzPosition GetPosition(GeometryLoop geometryLoop, ExtraPolationMode extraPolationMode = ExtraPolationMode.Beyond) { - foreach (GeometryPoint point in geometryLoop.Points.Concat(DetermineLoopSegmentMiddlePoints(geometryLoop))) + foreach (Point2D point in geometryLoop.CalcPoints.Concat(DetermineLoopSegmentMiddlePoints(geometryLoop))) { RelativeXzPosition position = PositionXzOfPointRelatedToExtrapolatedLine(point, extraPolationMode); if (position == RelativeXzPosition.BeyondGeometricLine) @@ -589,22 +523,11 @@ /// public override GeometryBounds GetGeometryBounds() { - if (!Points.Any()) + GeometryBounds bounds = CalcPoints[0].GetGeometryBounds(); + for (var i = 1; i < CalcPoints.Count; i++) { - // Sync with calcPoints - SyncPoints(); - // if still no points, then return null - if (!Points.Any()) - { - return null; - } - } + Point2D point = CalcPoints[i]; - GeometryBounds bounds = Points[0].GetGeometryBounds(); - for (var i = 1; i < Points.Count; i++) - { - GeometryPoint point = Points[i]; - bounds.Left = Math.Min(bounds.Left, point.X); bounds.Right = Math.Max(bounds.Right, point.X); bounds.Top = Math.Max(bounds.Top, point.Z); @@ -628,28 +551,28 @@ return intersectionPointsWithLine; } - private RelativeXzPosition PositionXzOfPointRelatedToExtrapolatedLine(GeometryPoint point, + private RelativeXzPosition PositionXzOfPointRelatedToExtrapolatedLine(Point2D point, ExtraPolationMode extraPolationMode = ExtraPolationMode.Beyond) { return IsPointConsideredBeyondLine(point, extraPolationMode) ? RelativeXzPosition.BeyondGeometricLine : DeterminePositionWithRespectToExtrapolatedLine(point, extraPolationMode); } - private bool IsPointConsideredBeyondLine(GeometryPoint point, ExtraPolationMode extraPolationMode) + private bool IsPointConsideredBeyondLine(Point2D point, ExtraPolationMode extraPolationMode) { - if (Points.Count == 0) + if (CalcPoints.Count == 0) { return true; } return IsPointOutsideRangeX(point) && extraPolationMode == ExtraPolationMode.Beyond; } - private bool IsPointOutsideRangeX(GeometryPoint point) + private bool IsPointOutsideRangeX(Point2D point) { - return point.X < Points[0].X || point.X > Points[checked(Points.Count - 1)].X; + return point.X < CalcPoints[0].X || point.X > CalcPoints[checked(CalcPoints.Count - 1)].X; } - private RelativeXzPosition DeterminePositionWithRespectToExtrapolatedLine(GeometryPoint point, + private RelativeXzPosition DeterminePositionWithRespectToExtrapolatedLine(Point2D point, ExtraPolationMode extraPolationMode) { double xToEvaluate = DetermineXToEvaluate(point, extraPolationMode); @@ -662,55 +585,55 @@ return point.Z <= zAtX ? RelativeXzPosition.BelowGeometricLine : RelativeXzPosition.AboveGeometricLine; } - private double DetermineXToEvaluate(GeometryPoint point, ExtraPolationMode extraPolationMode) + private double DetermineXToEvaluate(Point2D point, ExtraPolationMode extraPolationMode) { double x = point.X; if (extraPolationMode == ExtraPolationMode.Horizontal) { - if (x < Points[0].X) + if (x < CalcPoints[0].X) { - x = Points[0].X; + x = CalcPoints[0].X; } - else if (x > Points[checked(Points.Count - 1)].X) + else if (x > CalcPoints[checked(CalcPoints.Count - 1)].X) { - x = Points[checked(Points.Count - 1)].X; + x = CalcPoints[checked(CalcPoints.Count - 1)].X; } } return x; } - private static IEnumerable DetermineLoopSegmentMiddlePoints(GeometryPointString geometryLoop) + private static IEnumerable DetermineLoopSegmentMiddlePoints(GeometryPointString geometryLoop) { - var loopSegmentMiddlePoints = new List(); + var loopSegmentMiddlePoints = new List(); var index = 0; - while (index < checked(geometryLoop.Points.Count - 1)) + while (index < checked(geometryLoop.CalcPoints.Count - 1)) { - AddLoopSegmentMiddlePoint(geometryLoop.Points[index], geometryLoop.Points[checked(index + 1)], loopSegmentMiddlePoints); + AddLoopSegmentMiddlePoint(geometryLoop.CalcPoints[index], geometryLoop.CalcPoints[checked(index + 1)], loopSegmentMiddlePoints); checked { ++index; } } - if (geometryLoop.Points.Count > 2) + if (geometryLoop.CalcPoints.Count > 2) { - int last = geometryLoop.Points.Count - 1; - AddLoopSegmentMiddlePoint(geometryLoop.Points[0], geometryLoop.Points[last], loopSegmentMiddlePoints); + int last = geometryLoop.CalcPoints.Count - 1; + AddLoopSegmentMiddlePoint(geometryLoop.CalcPoints[0], geometryLoop.CalcPoints[last], loopSegmentMiddlePoints); } return loopSegmentMiddlePoints; } - private static void AddLoopSegmentMiddlePoint(GeometryPoint point1, GeometryPoint point2, IList loopSegmentMiddlePoints) + private static void AddLoopSegmentMiddlePoint(Point2D point1, Point2D point2, IList loopSegmentMiddlePoints) { if (Math.Abs(point1.Z - point2.Z) < 0.001) { - loopSegmentMiddlePoints.Insert(0, new GeometryPoint((point1.X + point2.X) / 2.0, point1.Z)); + loopSegmentMiddlePoints.Insert(0, new Point2D((point1.X + point2.X) / 2.0, point1.Z)); } else { - loopSegmentMiddlePoints.Add(new GeometryPoint((point1.X + point2.X) / 2.0, (point1.Z + point2.Z) / 2.0)); + loopSegmentMiddlePoints.Add(new Point2D((point1.X + point2.X) / 2.0, (point1.Z + point2.Z) / 2.0)); } }