Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs
===================================================================
diff -u -r4000 -r4052
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs (.../GeometryData.cs) (revision 4000)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs (.../GeometryData.cs) (revision 4052)
@@ -25,868 +25,867 @@
using Deltares.DamEngine.Data.Standard.Language;
using Deltares.DamEngine.Data.Standard.Validation;
-namespace Deltares.DamEngine.Data.Geometry
+namespace Deltares.DamEngine.Data.Geometry;
+
+///
+/// Class containing the geometry data
+///
+///
+public class GeometryData : GeometryObject
{
+ private readonly GeometryPointString surfaceLine = new GeometryPointString();
+ private GeometryGenerator geometryGenerator;
+ private bool isRegeneratingGeometry;
+
+ private bool updatingSurfaceLine;
+
///
- /// Class containing the geometry data
+ /// Initializes a new instance of the class.
///
- ///
- public class GeometryData : GeometryObject
+ public GeometryData()
{
- private readonly GeometryPointString surfaceLine = new GeometryPointString();
- private GeometryGenerator geometryGenerator;
- private bool isRegeneratingGeometry;
+ geometryGenerator = null;
+ }
- private bool updatingSurfaceLine;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public GeometryData()
+ ///
+ /// Ordered list of all geometry points at the surface
+ ///
+ public virtual GeometryPointString SurfaceLine
+ {
+ get
{
- geometryGenerator = null;
- }
-
- ///
- /// Ordered list of all geometry points at the surface
- ///
- public virtual GeometryPointString SurfaceLine
- {
- get
+ if (surfaceLine.CalcPoints.Count == 0 && Points.Count > 0)
{
- if (surfaceLine.CalcPoints.Count == 0 && Points.Count > 0)
- {
- UpdateSurfaceLine();
- }
-
- return surfaceLine;
+ UpdateSurfaceLine();
}
+
+ return surfaceLine;
}
+ }
- ///
- /// Checks geometry for loose curves and AutoRegeneration
- ///
- ///
- [Validate]
- public ValidationResult[] ValidateGeometry()
+ ///
+ /// Checks geometry for loose curves and AutoRegeneration
+ ///
+ ///
+ [Validate]
+ public ValidationResult[] ValidateGeometry()
+ {
+ var validationList = new List();
{
- var validationList = new List();
+ foreach (Point2D point in Points)
{
- foreach (Point2D point in Points)
+ foreach (Point2D point1 in Points)
{
- foreach (Point2D point1 in Points)
+ if (point != point1)
{
- if (point != point1)
+ var isValidated = false;
+ foreach (ValidationResult validatedItem in validationList)
{
- var isValidated = false;
- foreach (ValidationResult validatedItem in validationList)
+ if (validatedItem.Subject == point)
{
- if (validatedItem.Subject == point)
- {
- isValidated = true;
- }
+ isValidated = true;
}
+ }
- if (!isValidated)
+ if (!isValidated)
+ {
+ if (Math.Abs(point.X - point1.X) < GeometryConstants.Accuracy &&
+ Math.Abs(point.Z - point1.Z) < GeometryConstants.Accuracy)
{
- if (Math.Abs(point.X - point1.X) < GeometryConstants.Accuracy &&
- Math.Abs(point.Z - point1.Z) < GeometryConstants.Accuracy)
- {
- validationList.Add(new ValidationResult(ValidationResultType.Error,
- point + " and " +
- point1 + " values are same.",
- point1));
- }
+ validationList.Add(new ValidationResult(ValidationResultType.Error,
+ point + " and " +
+ point1 + " values are same.",
+ point1));
}
}
}
}
}
- if (Surfaces.Count < 1)
- {
- validationList.Add(new ValidationResult(ValidationResultType.Error, "No soil surface available.",
- this));
- }
-
- return validationList.ToArray();
}
-
- ///
- /// Deletes the point and the curves it belongs too.
- ///
- /// The point.
- public void DeletePointWithCurves(Point2D point)
+ if (Surfaces.Count < 1)
{
- var curvesToDelete = new List();
- foreach (GeometryCurve curve in Curves)
- {
- if (curve.ContainsPoint(point))
- {
- curvesToDelete.Add(curve);
- }
- }
-
- foreach (GeometryCurve curveToDelete in curvesToDelete)
- {
- Curves.Remove(curveToDelete);
- }
-
- Points.Remove(point);
+ validationList.Add(new ValidationResult(ValidationResultType.Error, "No soil surface available.",
+ this));
}
- ///
- /// Synchronizes the loops.
- ///
- public void SynchronizeLoops()
+ return validationList.ToArray();
+ }
+
+ ///
+ /// Deletes the point and the curves it belongs too.
+ ///
+ /// The point.
+ public void DeletePointWithCurves(Point2D point)
+ {
+ var curvesToDelete = new List();
+ foreach (GeometryCurve curve in Curves)
{
- DeleteAllLoops();
- foreach (GeometrySurface surface in Surfaces)
+ if (curve.ContainsPoint(point))
{
- // #Bka: 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);
- }
+ curvesToDelete.Add(curve);
}
}
- ///
- /// Returns a that represents this instance.
- ///
- ///
- /// A that represents this instance.
- ///
- public override string ToString()
+ foreach (GeometryCurve curveToDelete in curvesToDelete)
{
- return LocalizationManager.GetTranslatedText(this, "GeometryData");
+ Curves.Remove(curveToDelete);
}
- ///
- /// Removes the boundary curves from the given list of curves.
- /// The boundaries themselves are determined from the given geometry
- ///
- /// The curves.
- /// The geometry (as string).
- private static void RemoveBoundaryCurves(List curves, GeometryPointString geometry)
+ Points.Remove(point);
+ }
+
+ ///
+ /// Synchronizes the loops.
+ ///
+ public void SynchronizeLoops()
+ {
+ DeleteAllLoops();
+ foreach (GeometrySurface surface in Surfaces)
{
- double minX = geometry.GetMinX();
- double maxX = geometry.GetMaxX();
- double minZ = geometry.GetMinZ();
- foreach (GeometryCurve curve in curves.ToArray())
+ // #Bka: 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())
{
- if (IsBoundaryCurve(curve, minX, maxX, minZ))
- {
- curves.Remove(curve);
- }
+ Loops.Add(surface.OuterLoop);
}
}
+ }
- ///
- /// get all geometrypoints from all geometrycurves
- ///
- ///
- ///
- private static GeometryPointString GetAllPointsFromCurveList(List curveList)
+ ///
+ /// Returns a that represents this instance.
+ ///
+ ///
+ /// A that represents this instance.
+ ///
+ public override string ToString()
+ {
+ return LocalizationManager.GetTranslatedText(this, "GeometryData");
+ }
+
+ ///
+ /// Removes the boundary curves from the given list of curves.
+ /// The boundaries themselves are determined from the given geometry
+ ///
+ /// The curves.
+ /// The geometry (as string).
+ private static void RemoveBoundaryCurves(List curves, GeometryPointString geometry)
+ {
+ double minX = geometry.GetMinX();
+ double maxX = geometry.GetMaxX();
+ double minZ = geometry.GetMinZ();
+ foreach (GeometryCurve curve in curves.ToArray())
{
- var result = new GeometryPointString();
- foreach (GeometryCurve curve in curveList)
+ if (IsBoundaryCurve(curve, minX, maxX, minZ))
{
- result.CalcPoints.Add(curve.EndPoint);
- result.CalcPoints.Add(curve.HeadPoint);
+ curves.Remove(curve);
}
+ }
+ }
- return result;
+ ///
+ /// get all geometrypoints from all geometrycurves
+ ///
+ ///
+ ///
+ private static GeometryPointString GetAllPointsFromCurveList(List curveList)
+ {
+ var result = new GeometryPointString();
+ foreach (GeometryCurve curve in curveList)
+ {
+ result.CalcPoints.Add(curve.EndPoint);
+ result.CalcPoints.Add(curve.HeadPoint);
}
- ///
- /// Gets next connected top curve in list of curves
- ///
- ///
- ///
- ///
- ///
- private GeometryCurve GetNextTopCurve(GeometryCurve curve, List boundaryCurves,
- List excludedCurves)
+ return result;
+ }
+
+ ///
+ /// Gets next connected top curve in list of curves
+ ///
+ ///
+ ///
+ ///
+ ///
+ private 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)
{
- // 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;
- }
+ return null;
+ }
- foreach (GeometryCurve geometryCurve in boundaryCurves)
+ foreach (GeometryCurve geometryCurve in boundaryCurves)
+ {
+ if (geometryCurve != curve && !excludedCurves.Contains(geometryCurve))
{
- if (geometryCurve != curve && !excludedCurves.Contains(geometryCurve))
+ if (AreConnected(curve, geometryCurve))
{
- if (AreConnected(curve, geometryCurve))
- {
- return geometryCurve;
- }
+ return geometryCurve;
}
}
-
- return null;
}
- ///
- /// create a copy of the curves
- ///
- ///
- ///
- private List GetCurvesCopy(List bCurves)
+ return null;
+ }
+
+ ///
+ /// create a copy of the curves
+ ///
+ ///
+ ///
+ private List GetCurvesCopy(List bCurves)
+ {
+ var outerloopCurvesCopy = new List(bCurves);
+ return outerloopCurvesCopy;
+ }
+
+ ///
+ /// Create a surface line from points in curves
+ /// Precondition is that the curves start at the left boundary and are connected left to right
+ /// (not neccesarily neat head-end)
+ ///
+ ///
+ ///
+ private void CreateSurfaceLinePointString(List curves)
+ {
+ surfaceLine.CalcPoints.Clear();
+
+ if (curves.Count == 0)
{
- var outerloopCurvesCopy = new List(bCurves);
- return outerloopCurvesCopy;
+ return;
}
- ///
- /// Create a surface line from points in curves
- /// Precondition is that the curves start at the left boundary and are connected left to right
- /// (not neccesarily neat head-end)
- ///
- ///
- ///
- private void CreateSurfaceLinePointString(List curves)
+ var reversed = false;
+ // The headpoint of the first curve must be on the left boundary otherwise the
+ // surface line will be in the wrong order. So make sure.
+ if (!(Math.Abs(curves[0].HeadPoint.X - Left) < GeometryConstants.Accuracy))
{
- surfaceLine.CalcPoints.Clear();
+ curves[0].Reverse();
+ reversed = true;
+ }
- if (curves.Count == 0)
+ foreach (GeometryCurve curve in curves)
+ {
+ if (!surfaceLine.CalcPoints.Contains(curve.HeadPoint))
{
- return;
+ surfaceLine.CalcPoints.Add(curve.HeadPoint);
}
- var reversed = false;
- // The headpoint of the first curve must be on the left boundary otherwise the
- // surface line will be in the wrong order. So make sure.
- if (!(Math.Abs(curves[0].HeadPoint.X - Left) < GeometryConstants.Accuracy))
+ if (!surfaceLine.CalcPoints.Contains(curve.EndPoint))
{
- curves[0].Reverse();
- reversed = true;
+ surfaceLine.CalcPoints.Add(curve.EndPoint);
}
+ }
- foreach (GeometryCurve curve in curves)
- {
- if (!surfaceLine.CalcPoints.Contains(curve.HeadPoint))
- {
- surfaceLine.CalcPoints.Add(curve.HeadPoint);
- }
-
- if (!surfaceLine.CalcPoints.Contains(curve.EndPoint))
- {
- surfaceLine.CalcPoints.Add(curve.EndPoint);
- }
- }
-
- if (reversed)
- {
- curves[0].Reverse();
- }
+ if (reversed)
+ {
+ curves[0].Reverse();
}
+ }
- ///
- /// get curves of the top side of the outerloop, vertical curves are omitted
- ///
- ///
- ///
- private List GetTopCurves(List curves)
+ ///
+ /// get curves of the top side of the outerloop, vertical curves are omitted
+ ///
+ ///
+ ///
+ private List GetTopCurves(List curves)
+ {
+ GeometryCurve topCurve;
+ // Remove all curves on the geometry boundary
+ if (GetLeftPoints().Count > 0 && GetRightPoints().Count > 0)
{
- GeometryCurve topCurve;
- // Remove all curves on the geometry boundary
- if (GetLeftPoints().Count > 0 && GetRightPoints().Count > 0)
+ foreach (GeometryCurve curve in curves.ToArray())
{
- foreach (GeometryCurve curve in curves.ToArray())
+ if (IsBoundaryCurve(curve, Left, Right, Bottom))
{
- if (IsBoundaryCurve(curve, Left, Right, Bottom))
- {
- curves.Remove(curve);
- }
+ curves.Remove(curve);
}
-
- // Make sure you start with topcurve = curve at the left top position
- topCurve = curves.Where(g => Math.Abs(g.HeadPoint.X - Left) < GeometryConstants.Accuracy ||
- Math.Abs(g.EndPoint.X - Left) < GeometryConstants.Accuracy)
- .OrderByDescending(c => c.HeadPoint.Z)
- .FirstOrDefault();
}
- else
- {
- GeometryPointString gString = GetAllPointsFromCurveList(curves);
- RemoveBoundaryCurves(curves, gString);
- double minX = gString.GetMinX();
- // Make sure you start with topcurve = curve at the left top position
- topCurve =
- curves.Where(g => Math.Abs(g.HeadPoint.X - minX) < GeometryConstants.Accuracy ||
- Math.Abs(g.EndPoint.X - minX) < GeometryConstants.Accuracy).OrderByDescending(c => c.HeadPoint.Z).FirstOrDefault();
- }
- var topCurvesLocal = new List();
- while (topCurve != null)
- {
- topCurvesLocal.Add(topCurve);
- topCurve = GetNextTopCurve(topCurve, curves, topCurvesLocal);
- }
-
- return topCurvesLocal;
+ // Make sure you start with topcurve = curve at the left top position
+ topCurve = curves.Where(g => Math.Abs(g.HeadPoint.X - Left) < GeometryConstants.Accuracy ||
+ Math.Abs(g.EndPoint.X - Left) < GeometryConstants.Accuracy)
+ .OrderByDescending(c => c.HeadPoint.Z)
+ .FirstOrDefault();
}
+ else
+ {
+ GeometryPointString gString = GetAllPointsFromCurveList(curves);
+ RemoveBoundaryCurves(curves, gString);
+ double minX = gString.GetMinX();
+ // Make sure you start with topcurve = curve at the left top position
+ topCurve =
+ curves.Where(g => Math.Abs(g.HeadPoint.X - minX) < GeometryConstants.Accuracy ||
+ Math.Abs(g.EndPoint.X - minX) < GeometryConstants.Accuracy).OrderByDescending(c => c.HeadPoint.Z).FirstOrDefault();
+ }
- ///
- /// Indicates whether a curve is on the boundary of the geometry
- ///
- ///
- ///
- ///
- ///
- ///
- private static bool IsBoundaryCurve(GeometryCurve curve, double minX, double maxX, double minZ)
+ var topCurvesLocal = new List();
+ while (topCurve != null)
{
- if (Math.Abs(curve.HeadPoint.X - minX) < GeometryConstants.Accuracy && Math.Abs(curve.EndPoint.X - minX) < GeometryConstants.Accuracy)
- {
- return true;
- }
+ topCurvesLocal.Add(topCurve);
+ topCurve = GetNextTopCurve(topCurve, curves, topCurvesLocal);
+ }
- if (Math.Abs(curve.HeadPoint.X - maxX) < GeometryConstants.Accuracy && Math.Abs(curve.EndPoint.X - maxX) < GeometryConstants.Accuracy)
- {
- return true;
- }
+ return topCurvesLocal;
+ }
- if (Math.Abs(curve.HeadPoint.Z - minZ) < GeometryConstants.Accuracy && Math.Abs(curve.EndPoint.Z - minZ) < GeometryConstants.Accuracy)
- {
- return true;
- }
-
- return false;
+ ///
+ /// Indicates whether a curve is on the boundary of the geometry
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private static bool IsBoundaryCurve(GeometryCurve curve, double minX, double maxX, double minZ)
+ {
+ if (Math.Abs(curve.HeadPoint.X - minX) < GeometryConstants.Accuracy && Math.Abs(curve.EndPoint.X - minX) < GeometryConstants.Accuracy)
+ {
+ return true;
}
- private bool AreConnected(GeometryCurve curve1, GeometryCurve curve2)
+ if (Math.Abs(curve.HeadPoint.X - maxX) < GeometryConstants.Accuracy && Math.Abs(curve.EndPoint.X - maxX) < GeometryConstants.Accuracy)
{
- return (curve1.HeadPoint == curve2.HeadPoint || curve1.HeadPoint == curve2.EndPoint ||
- curve1.EndPoint == curve2.HeadPoint || curve1.EndPoint == curve2.EndPoint);
+ return true;
}
- ///
- /// Updates the line at the top of the geometry
- ///
- private void UpdateSurfaceLine()
+ if (Math.Abs(curve.HeadPoint.Z - minZ) < GeometryConstants.Accuracy && Math.Abs(curve.EndPoint.Z - minZ) < GeometryConstants.Accuracy)
{
- if (updatingSurfaceLine)
- {
- return;
- }
+ return true;
+ }
- updatingSurfaceLine = true;
+ return false;
+ }
- List bCurves = GetBoundaryCurves();
- if (bCurves.Count == 0)
- {
- surfaceLine.CalcPoints.Clear();
- }
+ private bool AreConnected(GeometryCurve curve1, GeometryCurve curve2)
+ {
+ return (curve1.HeadPoint == curve2.HeadPoint || curve1.HeadPoint == curve2.EndPoint ||
+ curve1.EndPoint == curve2.HeadPoint || curve1.EndPoint == curve2.EndPoint);
+ }
- List curvesCopy = GetCurvesCopy(bCurves);
- List curves = GetTopCurves(curvesCopy);
- CreateSurfaceLinePointString(curves);
+ ///
+ /// Updates the line at the top of the geometry
+ ///
+ private void UpdateSurfaceLine()
+ {
+ if (updatingSurfaceLine)
+ {
+ return;
+ }
- updatingSurfaceLine = false;
- surfaceLine.SyncPoints();
+ updatingSurfaceLine = true;
+
+ List bCurves = GetBoundaryCurves();
+ if (bCurves.Count == 0)
+ {
+ surfaceLine.CalcPoints.Clear();
}
- #region properties
+ List curvesCopy = GetCurvesCopy(bCurves);
+ List curves = GetTopCurves(curvesCopy);
+ CreateSurfaceLinePointString(curves);
- ///
- /// Gets the points.
- ///
- ///
- /// The points.
- ///
- [Validate]
- public List Points { get; } = new List();
+ updatingSurfaceLine = false;
+ surfaceLine.SyncPoints();
+ }
- ///
- /// Gets the newly effected points.
- ///
- ///
- /// The newly effected points.
- ///
- public List NewlyEffectedPoints { get; } = new List();
+ #region properties
- ///
- /// gets the Curve data list.
- ///
- ///
- /// The curves.
- ///
- public List Curves { get; } = new List();
+ ///
+ /// Gets the points.
+ ///
+ ///
+ /// The points.
+ ///
+ [Validate]
+ public List Points { get; } = new List();
- ///
- /// Gets the newly effected curves.
- ///
- ///
- /// The newly effected curves.
- ///
- public List NewlyEffectedCurves { get; } = new List();
+ ///
+ /// Gets the newly effected points.
+ ///
+ ///
+ /// The newly effected points.
+ ///
+ public List NewlyEffectedPoints { get; } = new List();
- ///
- /// gets the Loop data list.
- ///
- ///
- /// The loops.
- ///
- public List Loops { get; } = new List();
+ ///
+ /// gets the Curve data list.
+ ///
+ ///
+ /// The curves.
+ ///
+ public List Curves { get; } = new List();
- ///
- /// gets the Surface data list.
- ///
- public List Surfaces { get; } = new List();
+ ///
+ /// Gets the newly effected curves.
+ ///
+ ///
+ /// The newly effected curves.
+ ///
+ public List NewlyEffectedCurves { get; } = new List();
- public void RegenerateGeometry()
- {
- if (isRegeneratingGeometry)
- {
- return;
- }
+ ///
+ /// gets the Loop data list.
+ ///
+ ///
+ /// The loops.
+ ///
+ public List Loops { get; } = new List();
- isRegeneratingGeometry = true;
- if (geometryGenerator == null)
- {
- geometryGenerator = new GeometryGenerator(this);
- }
+ ///
+ /// gets the Surface data list.
+ ///
+ public List Surfaces { get; } = new List();
- lock (this)
- {
- SynchronizeLoops();
- RemoveDoublesFromNewlyEffectedPointsAndCurves();
- Curves.Clear();
- Points.Clear();
- Points.AddRange(NewlyEffectedPoints);
- Curves.AddRange(NewlyEffectedCurves);
+ public void RegenerateGeometry()
+ {
+ if (isRegeneratingGeometry)
+ {
+ return;
+ }
- geometryGenerator.GenerateGeometry();
- NewlyEffectedPoints.Clear();
- NewlyEffectedCurves.Clear();
- UpdateSurfaceLine();
+ isRegeneratingGeometry = true;
+ if (geometryGenerator == null)
+ {
+ geometryGenerator = new GeometryGenerator(this);
+ }
- SynchronizeLoops();
- }
+ lock (this)
+ {
+ SynchronizeLoops();
+ RemoveDoublesFromNewlyEffectedPointsAndCurves();
+ Curves.Clear();
+ Points.Clear();
+ Points.AddRange(NewlyEffectedPoints);
+ Curves.AddRange(NewlyEffectedCurves);
- isRegeneratingGeometry = false;
+ geometryGenerator.GenerateGeometry();
+ NewlyEffectedPoints.Clear();
+ NewlyEffectedCurves.Clear();
+ UpdateSurfaceLine();
+
+ SynchronizeLoops();
}
- ///
- /// Gets the minimum geometry points x.
- ///
- ///
- /// The minimum geometry points x.
- ///
- public double MinGeometryPointsX
+ isRegeneratingGeometry = false;
+ }
+
+ ///
+ /// Gets the minimum geometry points x.
+ ///
+ ///
+ /// The minimum geometry points x.
+ ///
+ public double MinGeometryPointsX
+ {
+ get
{
- get
+ return Points.Select(geometryPoint => geometryPoint.X).Concat(new[]
{
- return Points.Select(geometryPoint => geometryPoint.X).Concat(new[]
- {
- double.MaxValue
- }).Min();
- }
+ double.MaxValue
+ }).Min();
}
+ }
- ///
- /// Gets the minimum geometry points z.
- ///
- ///
- /// The minimum geometry points z.
- ///
- public double MinGeometryPointsZ
+ ///
+ /// Gets the minimum geometry points z.
+ ///
+ ///
+ /// The minimum geometry points z.
+ ///
+ public double MinGeometryPointsZ
+ {
+ get
{
- get
+ return Points.Select(geometryPoint => geometryPoint.Z).Concat(new[]
{
- return Points.Select(geometryPoint => geometryPoint.Z).Concat(new[]
- {
- double.MaxValue
- }).Min();
- }
+ double.MaxValue
+ }).Min();
}
+ }
- ///
- /// Gets the maximum geometry points x.
- ///
- ///
- /// The maximum geometry points x.
- ///
- public double MaxGeometryPointsX
+ ///
+ /// Gets the maximum geometry points x.
+ ///
+ ///
+ /// The maximum geometry points x.
+ ///
+ public double MaxGeometryPointsX
+ {
+ get
{
- get
+ return Points.Select(geometryPoint => geometryPoint.X).Concat(new[]
{
- return Points.Select(geometryPoint => geometryPoint.X).Concat(new[]
- {
- double.MinValue
- }).Max();
- }
+ double.MinValue
+ }).Max();
}
+ }
- ///
- /// Gets the maximum geometry points z.
- ///
- ///
- /// The maximum geometry points z.
- ///
- public double MaxGeometryPointsZ
+ ///
+ /// Gets the maximum geometry points z.
+ ///
+ ///
+ /// The maximum geometry points z.
+ ///
+ public double MaxGeometryPointsZ
+ {
+ get
{
- get
+ return Points.Select(geometryPoint => geometryPoint.Z).Concat(new[]
{
- return Points.Select(geometryPoint => geometryPoint.Z).Concat(new[]
- {
- double.MinValue
- }).Max();
- }
+ double.MinValue
+ }).Max();
}
+ }
- ///
- /// Gets or sets the left.
- ///
- ///
- /// The left.
- ///
- public double Left { get; set; } = GeometryConstants.DefaultLeftLimitGeometry;
+ ///
+ /// Gets or sets the left.
+ ///
+ ///
+ /// The left.
+ ///
+ public double Left { get; set; } = GeometryConstants.DefaultLeftLimitGeometry;
- ///
- /// Gets or sets the right.
- ///
- ///
- /// The right.
- ///
- public double Right { get; set; } = GeometryConstants.DefaultRightLimitGeometry;
+ ///
+ /// Gets or sets the right.
+ ///
+ ///
+ /// The right.
+ ///
+ public double Right { get; set; } = GeometryConstants.DefaultRightLimitGeometry;
- ///
- /// Gets or sets the bottom.
- ///
- ///
- /// The bottom.
- ///
- public double Bottom { get; set; } = GeometryConstants.DefaultBottomLimitGeometry;
+ ///
+ /// Gets or sets the bottom.
+ ///
+ ///
+ /// The bottom.
+ ///
+ public double Bottom { get; set; } = GeometryConstants.DefaultBottomLimitGeometry;
- ///
- /// Removes the doubles from newly effected points and curves.
- ///
- public void RemoveDoublesFromNewlyEffectedPointsAndCurves()
+ ///
+ /// Removes the doubles from newly effected points and curves.
+ ///
+ public void RemoveDoublesFromNewlyEffectedPointsAndCurves()
+ {
+ var pdel = new List();
+ Point2D[] par = NewlyEffectedPoints.ToArray();
+ for (var i = 0; i < par.Length; i++)
{
- var pdel = new List();
- Point2D[] par = NewlyEffectedPoints.ToArray();
- for (var i = 0; i < par.Length; i++)
+ for (int j = i; j < par.Length; j++)
{
- for (int j = i; j < par.Length; j++)
+ if (i != j && par[i].LocationEquals(par[j]))
{
- if (i != j && par[i].LocationEquals(par[j]))
+ if (!pdel.Contains(par[j]))
{
- if (!pdel.Contains(par[j]))
- {
- pdel.Add(par[j]);
- }
+ pdel.Add(par[j]);
}
}
}
+ }
- foreach (Point2D point in pdel)
- {
- NewlyEffectedPoints.Remove(point);
- }
+ foreach (Point2D point in pdel)
+ {
+ NewlyEffectedPoints.Remove(point);
+ }
- var cdel = new List();
- GeometryCurve[] car = NewlyEffectedCurves.ToArray();
- // First remove all "illegal" newlyeffected curves
- for (var i = 0; i < car.Length; i++)
+ var cdel = new List();
+ GeometryCurve[] car = NewlyEffectedCurves.ToArray();
+ // First remove all "illegal" newlyeffected curves
+ for (var i = 0; i < car.Length; i++)
+ {
+ if (car[i].HeadPoint == null || car[i].EndPoint == null || car[i].HeadPoint.LocationEquals(car[i].EndPoint))
{
- if (car[i].HeadPoint == null || car[i].EndPoint == null || car[i].HeadPoint.LocationEquals(car[i].EndPoint))
- {
- cdel.Add(car[i]);
- }
+ cdel.Add(car[i]);
}
+ }
- foreach (GeometryCurve curve in cdel)
- {
- NewlyEffectedCurves.Remove(curve);
- }
+ foreach (GeometryCurve curve in cdel)
+ {
+ NewlyEffectedCurves.Remove(curve);
+ }
- // then remove all real doubles
- GeometryCurve[] car2 = NewlyEffectedCurves.ToArray();
- cdel.Clear();
- for (var i = 0; i < car2.Length; i++)
+ // then remove all real doubles
+ GeometryCurve[] car2 = NewlyEffectedCurves.ToArray();
+ cdel.Clear();
+ for (var i = 0; i < car2.Length; i++)
+ {
+ for (int j = i; j < car2.Length; j++)
{
- for (int j = i; j < car2.Length; j++)
+ if (i != j && car2[i].LocationEquals(car2[j]))
{
- if (i != j && car2[i].LocationEquals(car2[j]))
+ if (!cdel.Contains(car2[j]))
{
- if (!cdel.Contains(car2[j]))
- {
- cdel.Add(car2[j]);
- }
+ cdel.Add(car2[j]);
}
}
}
-
- foreach (GeometryCurve curve in cdel)
- {
- NewlyEffectedCurves.Remove(curve);
- }
}
- ///
- /// Gets all points on the Left boundary.
- ///
- ///
- private List GetLeftPoints()
+ foreach (GeometryCurve curve in cdel)
{
- List geometryPoints = Points.Where(gp => Math.Abs(gp.X - Left) < GeometryConstants.Accuracy).ToList();
- return geometryPoints;
+ NewlyEffectedCurves.Remove(curve);
}
+ }
- ///
- /// Gets all points on the Right boundary.
- ///
- ///
- private List GetRightPoints()
- {
- List geometryPoints = Points.Where(point => Math.Abs(point.X - Right) < GeometryConstants.Accuracy).ToList();
- return geometryPoints;
- }
+ ///
+ /// Gets all points on the Left boundary.
+ ///
+ ///
+ private List GetLeftPoints()
+ {
+ List geometryPoints = Points.Where(gp => Math.Abs(gp.X - Left) < GeometryConstants.Accuracy).ToList();
+ return geometryPoints;
+ }
- ///
- /// Gets the geometry bounds.
- ///
- ///
- public override GeometryBounds GetGeometryBounds()
+ ///
+ /// Gets all points on the Right boundary.
+ ///
+ ///
+ private List GetRightPoints()
+ {
+ List geometryPoints = Points.Where(point => Math.Abs(point.X - Right) < GeometryConstants.Accuracy).ToList();
+ return geometryPoints;
+ }
+
+ ///
+ /// Gets the geometry bounds.
+ ///
+ ///
+ public override GeometryBounds GetGeometryBounds()
+ {
+ return new GeometryBounds(Left, Right, Bottom,
+ Bottom + Math.Min(Right - Left, 20));
+ }
+
+ #endregion
+
+ #region Functions
+
+ #region create functions
+
+ ///
+ /// Adjust the Geometry Bottom, Left and Right properties to the currently contained surfaces
+ ///
+ public void Rebox()
+ {
+ var xMin = double.MaxValue;
+ var xMax = double.MinValue;
+ var zMin = double.MaxValue;
+ var zMax = double.MinValue;
+
+ foreach (Point2D point in Points)
{
- return new GeometryBounds(Left, Right, Bottom,
- Bottom + Math.Min(Right - Left, 20));
+ xMin = Math.Min(point.X, xMin);
+ xMax = Math.Max(point.X, xMax);
+ zMin = Math.Min(point.Z, zMin);
+ zMax = Math.Max(point.Z, zMax);
}
- #endregion
+ Bottom = zMin;
+ Left = xMin;
+ Right = xMax;
+ }
- #region Functions
+ #endregion
- #region create functions
+ #region remove functions
- ///
- /// Adjust the Geometry Bottom, Left and Right properties to the currently contained surfaces
- ///
- public void Rebox()
- {
- var xMin = double.MaxValue;
- var xMax = double.MinValue;
- var zMin = double.MaxValue;
- var zMax = double.MinValue;
+ ///
+ /// Clears this instance.
+ ///
+ public void Clear()
+ {
+ Points.Clear();
+ Curves.Clear();
+ Surfaces.Clear();
+ NewlyEffectedPoints.Clear();
+ NewlyEffectedCurves.Clear();
+ }
- foreach (Point2D point in Points)
- {
- xMin = Math.Min(point.X, xMin);
- xMax = Math.Max(point.X, xMax);
- zMin = Math.Min(point.Z, zMin);
- zMax = Math.Max(point.Z, zMax);
- }
+ ///
+ /// deletes all the Loop from IGeometryLoop.
+ ///
+ private void DeleteAllLoops()
+ {
+ Loops.Clear();
+ }
- Bottom = zMin;
- Left = xMin;
- Right = xMax;
- }
+ #endregion
- #endregion
+ #region other functions
- #region remove functions
+ #region calculation function
- ///
- /// Clears this instance.
- ///
- public void Clear()
+ ///
+ /// CheckIfIntersectStricktly
+ /// Determines if two lines intersect each other stricktly (so no extrapolated points).
+ ///
+ /// Line 1 GeometryPoint 1
+ /// Line 1 GeometryPoint 2
+ /// Line 2 GeometryPoint 1
+ /// Line 2 GeometryPoint 2
+ /// Intersection coordinates
+ /// True if lines intersect each other
+ private static bool CheckIfIntersectStricktly(Point2D beginPoint1, Point2D endPoint1,
+ Point2D beginPoint2, Point2D endPoint2,
+ ref Point2D intersect)
+ {
+ Point2D ip;
+ LineIntersection res = Routines2D.DetermineIf2DLinesIntersectStrickly(beginPoint1, endPoint1,
+ beginPoint2, endPoint2, out ip);
+ if (ip != null)
{
- Points.Clear();
- Curves.Clear();
- Surfaces.Clear();
- NewlyEffectedPoints.Clear();
- NewlyEffectedCurves.Clear();
+ intersect = ip;
}
- ///
- /// deletes all the Loop from IGeometryLoop.
- ///
- private void DeleteAllLoops()
+ return res == LineIntersection.Intersects;
+ }
+
+ ///
+ /// CheckIfIntersect
+ /// Determines if two lines intersect each other stricktly (so no extrapolated points).
+ ///
+ /// Line 1 GeometryPoint 1
+ /// Line 1 GeometryPoint 2
+ /// Line 2 GeometryPoint 1
+ /// Line 2 GeometryPoint 2
+ /// Intersection coordinates
+ /// True if lines intersect each other
+ public static bool CheckIfIntersect(double[] aL1P1, double[] aL1P2, double[] aL2P1, double[] aL2P2,
+ ref double[] aIntersect)
+ {
+ var p1 = new Point2D(aL1P1[0], aL1P1[1]);
+ var p2 = new Point2D(aL1P2[0], aL1P2[1]);
+ var p3 = new Point2D(aL2P1[0], aL2P1[1]);
+ var p4 = new Point2D(aL2P2[0], aL2P2[1]);
+ var ip = new Point2D();
+ bool res = CheckIfIntersectStricktly(p1, p2, p3, p4, ref ip);
+ if (res)
{
- Loops.Clear();
+ aIntersect[0] = ip.X;
+ aIntersect[1] = ip.Z;
}
- #endregion
+ return res;
+ }
- #region other functions
-
- #region calculation function
-
- ///
- /// CheckIfIntersectStricktly
- /// Determines if two lines intersect each other stricktly (so no extrapolated points).
- ///
- /// Line 1 GeometryPoint 1
- /// Line 1 GeometryPoint 2
- /// Line 2 GeometryPoint 1
- /// Line 2 GeometryPoint 2
- /// Intersection coordinates
- /// True if lines intersect each other
- private static bool CheckIfIntersectStricktly(Point2D beginPoint1, Point2D endPoint1,
- Point2D beginPoint2, Point2D endPoint2,
- ref Point2D intersect)
+ ///
+ /// Gets the height of the surface(s) intersected at the given x.
+ ///
+ /// The x.
+ ///
+ public double GetSurfaceHeight(double x)
+ {
+ double surfaceHeight = -Double.MaxValue;
+ double[] intersectionPoints = IntersectLayers(x, -9999);
+ for (var i = 0; i < intersectionPoints.Length; i++)
{
- Point2D ip;
- LineIntersection res = Routines2D.DetermineIf2DLinesIntersectStrickly(beginPoint1, endPoint1,
- beginPoint2, endPoint2, out ip);
- if (ip != null)
+ if (intersectionPoints[i] > surfaceHeight)
{
- intersect = ip;
+ surfaceHeight = intersectionPoints[i];
}
-
- return res == LineIntersection.Intersects;
}
- ///
- /// CheckIfIntersect
- /// Determines if two lines intersect each other stricktly (so no extrapolated points).
- ///
- /// Line 1 GeometryPoint 1
- /// Line 1 GeometryPoint 2
- /// Line 2 GeometryPoint 1
- /// Line 2 GeometryPoint 2
- /// Intersection coordinates
- /// True if lines intersect each other
- public static bool CheckIfIntersect(double[] aL1P1, double[] aL1P2, double[] aL2P1, double[] aL2P2,
- ref double[] aIntersect)
- {
- var p1 = new Point2D(aL1P1[0], aL1P1[1]);
- var p2 = new Point2D(aL1P2[0], aL1P2[1]);
- var p3 = new Point2D(aL2P1[0], aL2P1[1]);
- var p4 = new Point2D(aL2P2[0], aL2P2[1]);
- var ip = new Point2D();
- bool res = CheckIfIntersectStricktly(p1, p2, p3, p4, ref ip);
- if (res)
- {
- aIntersect[0] = ip.X;
- aIntersect[1] = ip.Z;
- }
+ return surfaceHeight;
+ }
- return res;
+ ///
+ /// All the Intersection of layers in respect with a given vertical are detemined here.
+ ///
+ /// Startingpoint of the Vertical (X)
+ /// Startingpoint of the Vertical (Y)
+ /// List of Z intersection coordinates
+ private double[] IntersectLayers(double aXCoord, double aZCoord)
+ {
+ if (Surfaces == null)
+ {
+ throw new Exception("Empty Surfaces in IntersectLayers");
}
- ///
- /// Gets the height of the surface(s) intersected at the given x.
- ///
- /// The x.
- ///
- public double GetSurfaceHeight(double x)
+ var beginPoint2 = new Point2D
{
- double surfaceHeight = -Double.MaxValue;
- double[] intersectionPoints = IntersectLayers(x, -9999);
- for (var i = 0; i < intersectionPoints.Length; i++)
- {
- if (intersectionPoints[i] > surfaceHeight)
- {
- surfaceHeight = intersectionPoints[i];
- }
- }
+ X = aXCoord,
+ Z = aZCoord
+ };
- return surfaceHeight;
- }
-
- ///
- /// All the Intersection of layers in respect with a given vertical are detemined here.
- ///
- /// Startingpoint of the Vertical (X)
- /// Startingpoint of the Vertical (Y)
- /// List of Z intersection coordinates
- private double[] IntersectLayers(double aXCoord, double aZCoord)
+ var endPoint2 = new Point2D
{
- if (Surfaces == null)
- {
- throw new Exception("Empty Surfaces in IntersectLayers");
- }
+ X = aXCoord,
+ Z = 99999
+ };
- var beginPoint2 = new Point2D
- {
- X = aXCoord,
- Z = aZCoord
- };
+ var referencePoint = new Point2D();
- var endPoint2 = new Point2D
- {
- X = aXCoord,
- Z = 99999
- };
+ var intersections = new List();
- var referencePoint = new Point2D();
-
- var intersections = new List();
-
- for (var surfaceIndexLocal = 0; surfaceIndexLocal < Surfaces.Count; surfaceIndexLocal++)
+ for (var surfaceIndexLocal = 0; surfaceIndexLocal < Surfaces.Count; surfaceIndexLocal++)
+ {
+ List outerLoopCurveList = Surfaces[surfaceIndexLocal].OuterLoop.CurveList;
+ for (var curveIndexLocal = 0; curveIndexLocal < outerLoopCurveList.Count; curveIndexLocal++)
{
- List outerLoopCurveList = Surfaces[surfaceIndexLocal].OuterLoop.CurveList;
- for (var curveIndexLocal = 0; curveIndexLocal < outerLoopCurveList.Count; curveIndexLocal++)
- {
- //Check for each curve if it intersects with x coordinate
- Point2D beginPoint1 = outerLoopCurveList[curveIndexLocal].GetHeadPoint(CurveDirection.Forward);
- Point2D endPoint1 = outerLoopCurveList[curveIndexLocal].GetEndPoint(CurveDirection.Forward);
+ //Check for each curve if it intersects with x coordinate
+ Point2D beginPoint1 = outerLoopCurveList[curveIndexLocal].GetHeadPoint(CurveDirection.Forward);
+ Point2D endPoint1 = outerLoopCurveList[curveIndexLocal].GetEndPoint(CurveDirection.Forward);
- if (Math.Max(beginPoint1.X, endPoint1.X) >= aXCoord &&
- Math.Min(beginPoint1.X, endPoint1.X) <= aXCoord)
+ if (Math.Max(beginPoint1.X, endPoint1.X) >= aXCoord &&
+ Math.Min(beginPoint1.X, endPoint1.X) <= aXCoord)
+ {
+ if (CheckIfIntersectStricktly(beginPoint1, endPoint1, beginPoint2, endPoint2,
+ ref referencePoint))
{
- if (CheckIfIntersectStricktly(beginPoint1, endPoint1, beginPoint2, endPoint2,
- ref referencePoint))
+ if (referencePoint.Z > aZCoord && !intersections.Contains(referencePoint.Z))
{
- if (referencePoint.Z > aZCoord && !intersections.Contains(referencePoint.Z))
- {
- intersections.Add(referencePoint.Z);
- }
+ intersections.Add(referencePoint.Z);
}
}
}
}
+ }
- return intersections.ToArray();
+ return intersections.ToArray();
+ }
+
+ ///
+ /// Returns a list of boundary curves. These are curves which are used in only one surface so they have to be on a boundary (inner or outer)
+ ///
+ ///
+ private List GetBoundaryCurves()
+ {
+ var curves = new List();
+ var loops = new List();
+ foreach (GeometrySurface surface in Surfaces)
+ {
+ loops.Add(surface.OuterLoop);
+ // Todo Ask Rob/Tom: when a real "doughnut" type surface (so hole in the center) is permitted, adding the innerloops here will
+ // result in a wrong list of curves (because it will include the inner loop curves defining the hole) for its actual purpose:
+ // the determination of the surfaceline. When there is always a surface defined within the "dougnut" (so no real hole),
+ // this code will work and the innerloop must even be added to prevent finding internal boundaries. So this depends on the specs!
+ loops.AddRange(surface.InnerLoops);
}
- ///
- /// Returns a list of boundary curves. These are curves which are used in only one surface so they have to be on a boundary (inner or outer)
- ///
- ///
- private List GetBoundaryCurves()
+ foreach (GeometryLoop loop in loops)
{
- var curves = new List();
- var loops = new List();
- foreach (GeometrySurface surface in Surfaces)
+ foreach (GeometryCurve curve in loop.CurveList)
{
- loops.Add(surface.OuterLoop);
- // Todo Ask Rob/Tom: when a real "doughnut" type surface (so hole in the center) is permitted, adding the innerloops here will
- // result in a wrong list of curves (because it will include the inner loop curves defining the hole) for its actual purpose:
- // the determination of the surfaceline. When there is always a surface defined within the "dougnut" (so no real hole),
- // this code will work and the innerloop must even be added to prevent finding internal boundaries. So this depends on the specs!
- loops.AddRange(surface.InnerLoops);
- }
-
- foreach (GeometryLoop loop in loops)
- {
- foreach (GeometryCurve curve in loop.CurveList)
+ if (curves.Contains(curve))
{
- if (curves.Contains(curve))
- {
- // Second appearance, remove
- curves.Remove(curve);
- }
- else
- {
- curves.Add(curve);
- }
+ // Second appearance, remove
+ curves.Remove(curve);
}
+ else
+ {
+ curves.Add(curve);
+ }
}
-
- return curves;
}
- #endregion
+ return curves;
+ }
- #endregion
+ #endregion
- #endregion
- }
+ #endregion
+
+ #endregion
}
\ No newline at end of file