Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/LineHelper.cs
===================================================================
diff -u -r4905 -r5936
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/LineHelper.cs (.../LineHelper.cs) (revision 4905)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/LineHelper.cs (.../LineHelper.cs) (revision 5936)
@@ -28,7 +28,7 @@
///
/// Helper class for Line objects
///
-public class LineHelper
+public static class LineHelper
{
///
/// Calculate intersection between two lines (strict interpolation)
@@ -37,7 +37,7 @@
///
///
///
- public bool GetStrictIntersectionPoint(Line line1, Line line2, ref GeometryPoint intersectPoint)
+ public static bool GetStrictIntersectionPoint(Line line1, Line line2, ref GeometryPoint intersectPoint)
{
var point1 = new Point2D(line1.BeginPoint.X, line1.BeginPoint.Z);
var point2 = new Point2D(line1.EndPoint.X, line1.EndPoint.Z);
@@ -55,109 +55,21 @@
return res == LineIntersection.Intersects;
}
-
- ///
- /// This method uses constant extrapolation from the start point to the negative X direction and
- /// from the end point to the positive X direction. Then the method tries to find intersection
- /// points with the circle on that line.
- ///
- /// Circle's middle point X value
- /// Circle's middle point Z value
- /// Circle's radius
- /// Point collection which defines a line. Extrapolation is performed at the start and end points.
- /// Intersections of this line extrapolated to the negative and positive X with the circle.
- public List ExtendedSurfaceIntersectionPointsWithCircle(double xMid, double zMid, double radius, IList pointss)
+
+ public static GeometryPoint GetIntersectionPointWithExtrapolation(GeometryPoint p1, GeometryPoint p2, GeometryPoint p3, GeometryPoint p4)
{
- List points = pointss.Where(p => !double.IsNaN(p.X)).ToList();
- if (points.Count >= 2)
- {
- double requiredMinSurfacePointX = xMid - radius;
- double requiredMaxSurfacePointX = xMid + radius;
- if (requiredMinSurfacePointX < points[0].X)
- {
- points.Insert(0, new Point2D
- {
- X = requiredMinSurfacePointX,
- Z = points[0].Z
- });
- }
-
- if (requiredMaxSurfacePointX > points[points.Count - 1].X)
- {
- points.Insert(points.Count, new Point2D
- {
- X = requiredMaxSurfacePointX,
- Z = points[points.Count - 1].Z
- });
- }
- }
-
- return IntersectionPointsWithCircle(xMid, zMid, radius, points);
- }
-
- ///
- /// Intersections the points with circle.
- ///
- /// The x mid.
- /// The z mid.
- /// The radius.
- /// The points.
- ///
- public List IntersectionPointsWithCircle(double xMid, double zMid, double radius, IList points)
- {
- var result = new List();
- if (points.Count >= 2)
- {
- for (var pointIndex = 0; pointIndex < points.Count - 1; pointIndex++)
- {
- Point2D start = points[pointIndex];
- Point2D end = points[pointIndex + 1];
- bool outOfReach = ((Math.Max(start.X, end.X) < xMid - radius) ||
- (Math.Min(start.X, end.X) > xMid + radius) ||
- (Math.Max(start.Z, end.Z) < zMid - radius) ||
- (Math.Min(start.Z, end.Z) > zMid + radius));
- if (!outOfReach)
- {
- var line = new Line
- {
- BeginPoint = start,
- EndPoint = end
- };
- result.AddRange(Intersect_Circle_line(xMid, zMid, radius, line));
- }
- }
- }
-
- return result;
- }
-
- public GeometryPoint GetIntersectionPointWithExtrapolation(GeometryPoint p1, GeometryPoint p2, GeometryPoint p3, GeometryPoint p4)
- {
return IntersectionPointWithExtrapolation(p1, p2, p3, p4);
}
///
- /// Intersects the circle line.
- ///
- /// The xm.
- /// The ym.
- /// The r.
- /// The line.
- ///
- private List Intersect_Circle_line(double xm, double ym, double r, Line line)
- {
- return Routines2D.IntersectCircleline(xm, ym, r, line.BeginPoint.X, line.EndPoint.X, line.BeginPoint.Z, line.EndPoint.Z);
- }
-
- ///
/// Determines the intersection point of two lines, allowing the intersection point being extrapolated.
///
///
///
///
///
/// Intersection point or null (parallel lines)
- private GeometryPoint IntersectionPointWithExtrapolation(GeometryPoint p1, GeometryPoint p2, GeometryPoint p3, GeometryPoint p4)
+ private static GeometryPoint IntersectionPointWithExtrapolation(GeometryPoint p1, GeometryPoint p2, GeometryPoint p3, GeometryPoint p4)
{
GeometryPoint intersectPoint = null;