Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryLoop.cs
===================================================================
diff -u -r3893 -r4000
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryLoop.cs (.../GeometryLoop.cs) (revision 3893)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryLoop.cs (.../GeometryLoop.cs) (revision 4000)
@@ -30,20 +30,7 @@
///
public class GeometryLoop : GeometryPointString
{
- private readonly List curveList = new List();
-
///
- /// Gets the List of all Curves.
- ///
- public List CurveList
- {
- get
- {
- return curveList;
- }
- }
-
- ///
/// List of points that describe the physical surface line or surface.
///
/// This property is not serialized. If you want to add point definitions,
@@ -64,6 +51,11 @@
}
///
+ /// Gets the List of all Curves.
+ ///
+ public List CurveList { get; } = new List();
+
+ ///
/// Determines whether this instance is loop.
///
///
@@ -74,8 +66,8 @@
return false;
}
- GeometryCurve beginCurve = curveList[0];
- GeometryCurve endCurve = curveList[curveList.Count - 1];
+ GeometryCurve beginCurve = CurveList[0];
+ GeometryCurve endCurve = CurveList[CurveList.Count - 1];
if (beginCurve.HeadPoint == endCurve.HeadPoint ||
beginCurve.HeadPoint == endCurve.EndPoint ||
@@ -98,6 +90,7 @@
{
return false;
}
+
// Make sure points from curves are also exist as points
if (CalcPoints.Count > 0)
{
@@ -110,7 +103,7 @@
// Calculate area of polygon using Shoelace algorithm:
var sum = 0.0;
- for (int i = 1; i < points.Count; i++)
+ for (var i = 1; i < points.Count; i++)
{
sum += points[i - 1].X * points[i].Z - points[i - 1].Z * points[i].X;
}
@@ -126,16 +119,18 @@
/// Cannot determine if loop is clockwise if checked location forms a straight line with its neighboring vectors.
public bool IsClockWise()
{
- var polyGon = GetLocalPoint2DList();
- var isClockWise = Routines2D.IsClockWise(polyGon);
+ List polyGon = GetLocalPoint2DList();
+ Clockwise isClockWise = Routines2D.IsClockWise(polyGon);
if (isClockWise == Clockwise.NotEnoughUniquePoints)
{
throw new NotEnoughUniquePointsException();
}
+
if (isClockWise == Clockwise.PointsOnLine)
{
throw new InvalidOperationException("Cannot determine if loop is clockwise if checked location forms a straight line with its neighboring vectors.");
}
+
return isClockWise == Clockwise.IsClockwise;
}
@@ -168,37 +163,39 @@
{
return;
}
- for (int index = 0; index < curveList.Count; index++)
+
+ for (var index = 0; index < CurveList.Count; index++)
{
if (index == 0)
{
- calcPoints.Add(curveList[index].HeadPoint);
- calcPoints.Add(curveList[index].EndPoint);
+ calcPoints.Add(CurveList[index].HeadPoint);
+ calcPoints.Add(CurveList[index].EndPoint);
}
else
{
// TODO why not compare by value instead of reference
- if (curveList[index].HeadPoint == calcPoints[calcPoints.Count - 1])
+ if (CurveList[index].HeadPoint == calcPoints[calcPoints.Count - 1])
{
- calcPoints.Add(curveList[index].EndPoint);
+ calcPoints.Add(CurveList[index].EndPoint);
}
- else if (curveList[index].EndPoint == calcPoints[calcPoints.Count - 1])
+ else if (CurveList[index].EndPoint == calcPoints[calcPoints.Count - 1])
{
- calcPoints.Add(curveList[index].HeadPoint);
+ calcPoints.Add(CurveList[index].HeadPoint);
}
else
{
if (calcPoints.Count == 2)
{
calcPoints.Reverse();
}
- if (curveList[index].HeadPoint == calcPoints[calcPoints.Count - 1])
+
+ if (CurveList[index].HeadPoint == calcPoints[calcPoints.Count - 1])
{
- calcPoints.Add(curveList[index].EndPoint);
+ calcPoints.Add(CurveList[index].EndPoint);
}
- else if (curveList[index].EndPoint == calcPoints[calcPoints.Count - 1])
+ else if (CurveList[index].EndPoint == calcPoints[calcPoints.Count - 1])
{
- calcPoints.Add(curveList[index].HeadPoint);
+ calcPoints.Add(CurveList[index].HeadPoint);
}
}
}
@@ -222,7 +219,7 @@
/// Initializes a new instance of the class.
///
public NotEnoughUniquePointsException()
- : base("At least 3 unique points are required to determine if the loop is running clockwise.") { }
+ : base("At least 3 unique points are required to determine if the loop is running clockwise.") {}
}
}
}
\ No newline at end of file