Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/LineHelper.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/LineHelper.cs (.../LineHelper.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/LineHelper.cs (.../LineHelper.cs) (revision 4248)
@@ -28,24 +28,27 @@
///
/// Helper class for Line objects
///
-public static class LineHelper
+public class LineHelper
{
+
+ private readonly Routines2D routines2D = new Routines2D();
+
///
/// Calculate intersection between two lines (strict interpolation)
///
///
///
///
///
- public static bool GetStrictIntersectionPoint(Line line1, Line line2, ref GeometryPoint intersectPoint)
+ public 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);
var point3 = new Point2D(line2.BeginPoint.X, line2.BeginPoint.Z);
var point4 = new Point2D(line2.EndPoint.X, line2.EndPoint.Z);
Point2D ip;
- LineIntersection res = Routines2D.DetermineIf2DLinesIntersectStrickly(point1, point2, point3,
+ LineIntersection res = routines2D.DetermineIf2DLinesIntersectStrickly(point1, point2, point3,
point4, out ip);
if (ip != null)
{
@@ -66,7 +69,7 @@
/// 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 static List ExtendedSurfaceIntersectionPointsWithCircle(double xMid, double zMid, double radius, IList pointss)
+ public List ExtendedSurfaceIntersectionPointsWithCircle(double xMid, double zMid, double radius, IList pointss)
{
List points = pointss.Where(p => !double.IsNaN(p.X)).ToList();
if (points.Count >= 2)
@@ -103,7 +106,7 @@
/// The radius.
/// The points.
///
- public static List IntersectionPointsWithCircle(double xMid, double zMid, double radius, IList points)
+ public List IntersectionPointsWithCircle(double xMid, double zMid, double radius, IList points)
{
var result = new List();
if (points.Count >= 2)
@@ -131,7 +134,7 @@
return result;
}
- public static GeometryPoint GetIntersectionPointWithExtrapolation(GeometryPoint p1, GeometryPoint p2, GeometryPoint p3, GeometryPoint p4)
+ public GeometryPoint GetIntersectionPointWithExtrapolation(GeometryPoint p1, GeometryPoint p2, GeometryPoint p3, GeometryPoint p4)
{
return IntersectionPointWithExtrapolation(p1, p2, p3, p4);
}
@@ -144,9 +147,9 @@
/// The r.
/// The line.
///
- private static List Intersect_Circle_line(double xm, double ym, double r, Line 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);
+ return routines2D.IntersectCircleline(xm, ym, r, line.BeginPoint.X, line.EndPoint.X, line.BeginPoint.Z, line.EndPoint.Z);
}
///
@@ -157,7 +160,7 @@
///
///
/// Intersection point or null (parallel lines)
- private static GeometryPoint IntersectionPointWithExtrapolation(GeometryPoint p1, GeometryPoint p2, GeometryPoint p3, GeometryPoint p4)
+ private GeometryPoint IntersectionPointWithExtrapolation(GeometryPoint p1, GeometryPoint p2, GeometryPoint p3, GeometryPoint p4)
{
GeometryPoint intersectPoint = null;
@@ -166,7 +169,7 @@
var point3 = new Point2D(p3.X, p3.Z);
var point4 = new Point2D(p4.X, p4.Z);
- Routines2D.DetermineIf2DLinesIntersectWithExtrapolation(point1, point2, point3, point4, out Point2D ip);
+ routines2D.DetermineIf2DLinesIntersectWithExtrapolation(point1, point2, point3, point4, out Point2D ip);
if (ip != null)
{
intersectPoint = new GeometryPoint(ip.X, ip.Z);
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/SurfaceLineHeightAdapter.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/SurfaceLineHeightAdapter.cs (.../SurfaceLineHeightAdapter.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/SurfaceLineHeightAdapter.cs (.../SurfaceLineHeightAdapter.cs) (revision 4248)
@@ -30,6 +30,8 @@
///
public class SurfaceLineHeightAdapter : SurfaceLineAdapter
{
+ private readonly LineHelper lineHelper = new LineHelper();
+
///
/// Initializes a new instance of the class.
///
@@ -69,7 +71,7 @@
X = pointAtTopRiver.X + 100,
Z = pointAtTopRiver.Z + 100 * Location.NewDikeSlopeOutside
};
- newPointAtTopRiver = LineHelper.GetIntersectionPointWithExtrapolation(pointAtTopRiver, newOutsideSlopePoint,
+ newPointAtTopRiver = lineHelper.GetIntersectionPointWithExtrapolation(pointAtTopRiver, newOutsideSlopePoint,
new GeometryPoint(pointAtTopRiver.X, newDikeHeight),
new GeometryPoint(pointAtTopPolder.X, newDikeHeight));
oldPointAtTopRiver = new GeometryPoint
@@ -80,7 +82,7 @@
}
else
{
- newPointAtTopRiver = LineHelper.GetIntersectionPointWithExtrapolation(startingPoint, pointAtTopRiver,
+ newPointAtTopRiver = lineHelper.GetIntersectionPointWithExtrapolation(startingPoint, pointAtTopRiver,
new GeometryPoint(pointAtTopRiver.X, newDikeHeight),
new GeometryPoint(pointAtTopPolder.X, newDikeHeight));
}
@@ -174,7 +176,7 @@
Z = newPointAtTopPolder.Z - 100 * slopeTangent
};
GeometryPoint dikeTopAtPolder = surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtPolder);
- GeometryPoint ip = LineHelper.GetIntersectionPointWithExtrapolation(newPointAtTopPolder, newPoint,
+ GeometryPoint ip = lineHelper.GetIntersectionPointWithExtrapolation(newPointAtTopPolder, newPoint,
surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver),
dikeTopAtPolder);
if (ip != null && ip.X <= dikeTopAtPolder.X)
Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryLoop.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryLoop.cs (.../GeometryLoop.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryLoop.cs (.../GeometryLoop.cs) (revision 4248)
@@ -30,6 +30,8 @@
///
public class GeometryLoop : GeometryPointString
{
+ private readonly Routines2D routines2D = new Routines2D();
+
///
/// List of points that describe the physical surface line or surface.
///
@@ -120,7 +122,7 @@
public bool IsClockWise()
{
List polyGon = GetLocalPoint2DList();
- Clockwise isClockWise = Routines2D.IsClockWise(polyGon);
+ Clockwise isClockWise = routines2D.IsClockWise(polyGon);
if (isClockWise == Clockwise.NotEnoughUniquePoints)
{
throw new NotEnoughUniquePointsException();
@@ -141,7 +143,7 @@
///
public bool IsPointInLoopArea(Point2D aPoint)
{
- return Routines2D.CheckIfPointIsInPolygon(this, aPoint.X, aPoint.Z) != PointInPolygon.OutsidePolygon;
+ return routines2D.CheckIfPointIsInPolygon(this, aPoint.X, aPoint.Z) != PointInPolygon.OutsidePolygon;
}
///
Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryGenerator.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryGenerator.cs (.../GeometryGenerator.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryGenerator.cs (.../GeometryGenerator.cs) (revision 4248)
@@ -40,7 +40,7 @@
// private readonly List intersectedCurveList = new List();
private readonly List newlyDetectedSurfaceList = new List();
-
+ private readonly Routines2D routines2D = new Routines2D();
///
/// Regenerates the geometry.
///
@@ -451,7 +451,7 @@
point4.X = attachedCurveList[index2].GetEndPoint().X;
point4.Z = attachedCurveList[index2].GetEndPoint().Z;
- double angle = Routines2D.FindAngle(point1, point2, point3, point4);
+ double angle = routines2D.FindAngle(point1, point2, point3, point4);
if (angle < minAngle)
{
@@ -848,7 +848,7 @@
// check if it is an inner loop
for (var innerIndex = 0; innerIndex < newPointCount; innerIndex++)
{
- PointInPolygon location = Routines2D.CheckIfPointIsInPolygon(loop, newPolygon[innerIndex].X, newPolygon[innerIndex].Z);
+ PointInPolygon location = routines2D.CheckIfPointIsInPolygon(loop, newPolygon[innerIndex].X, newPolygon[innerIndex].Z);
if (location == PointInPolygon.InsidePolygon)
{
@@ -863,7 +863,7 @@
// check if it has an inner loop
for (var innerIndex1 = 0; innerIndex1 < existingLoopPointCount; innerIndex1++)
{
- PointInPolygon location = Routines2D.CheckIfPointIsInPolygon(newLoop, polygon[innerIndex1].X, polygon[innerIndex1].Z);
+ PointInPolygon location = routines2D.CheckIfPointIsInPolygon(newLoop, polygon[innerIndex1].X, polygon[innerIndex1].Z);
if (location == PointInPolygon.InsidePolygon)
{
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 4248)
@@ -44,7 +44,7 @@
private double? waterLevelRiverLow;
private PlLine currentPl1Line; // is needed when calculating uplift reduction for PL3 and Pl4
-
+ private readonly LineHelper lineHelper = new LineHelper();
// Output
///
@@ -1509,7 +1509,7 @@
new Point2D(SurfaceLine.Geometry.Points[indexatDitchPolder].X, SurfaceLine.Geometry.Points[indexatDitchPolder].Z));
var intersectDitchPolderPhreatic = new GeometryPoint();
- if (LineHelper.GetStrictIntersectionPoint(lineDitchPolderSide, phreaticPolderPartialLine, ref intersectDitchPolderPhreatic))
+ if (lineHelper.GetStrictIntersectionPoint(lineDitchPolderSide, phreaticPolderPartialLine, ref intersectDitchPolderPhreatic))
{
phreaticLine.Points.Add(new PlLinePoint(intersectDitchPolderPhreatic.X, intersectDitchPolderPhreatic.Z));
}
@@ -1542,7 +1542,7 @@
new Point2D(SurfaceLine.Geometry.Points[surfacePointIndex + 1].X, SurfaceLine.Geometry.Points[surfacePointIndex + 1].Z));
var intersectDitchDikePhreatic = new GeometryPoint();
- if (LineHelper.GetStrictIntersectionPoint(lineDitchDikeSide, phreaticPolderPartialLine, ref intersectDitchDikePhreatic))
+ if (lineHelper.GetStrictIntersectionPoint(lineDitchDikeSide, phreaticPolderPartialLine, ref intersectDitchDikePhreatic))
{
phreaticLine.Points.Add(new PlLinePoint(intersectDitchDikePhreatic.X, intersectDitchDikePhreatic.Z));
}
@@ -1577,7 +1577,7 @@
SurfaceLine.Geometry.Points[surfacePointIndex - 1].Z), new Point2D(SurfaceLine.Geometry.Points[surfacePointIndex].X,
SurfaceLine.Geometry.Points[surfacePointIndex].Z));
var intersectPoint = new GeometryPoint();
- if (LineHelper.GetStrictIntersectionPoint(surfaceLineSegment, polderlevelLine, ref intersectPoint))
+ if (lineHelper.GetStrictIntersectionPoint(surfaceLineSegment, polderlevelLine, ref intersectPoint))
{
return new PlLinePoint(intersectPoint.X, intersectPoint.Z);
}
@@ -1620,7 +1620,7 @@
new Point2D(SurfaceLine.Geometry.Points[surfacePointIndex + 1].X, SurfaceLine.Geometry.Points[surfacePointIndex + 1].Z));
var intersectGeoPoint = new GeometryPoint();
var intersectPoint = new Point2D();
- if (LineHelper.GetStrictIntersectionPoint(phreaticLineSegment, surfaceLineSegment, ref intersectGeoPoint))
+ if (lineHelper.GetStrictIntersectionPoint(phreaticLineSegment, surfaceLineSegment, ref intersectGeoPoint))
{
intersectPoint.X = intersectGeoPoint.X;
intersectPoint.Z = intersectGeoPoint.Z;
Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2Extensions.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2Extensions.cs (.../SurfaceLine2Extensions.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2Extensions.cs (.../SurfaceLine2Extensions.cs) (revision 4248)
@@ -33,6 +33,8 @@
///
public static class SurfaceLine2Extensions
{
+ private static readonly LineHelper lineHelper = new LineHelper();
+
///
/// Returns all that require to be sorted on X
/// ascending.
@@ -470,7 +472,7 @@
GeometryPoint geometryPoint2 = line.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder);
GeometryPoint p2 = line.HasShoulderInside() ? line.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.ShoulderBaseInside) : geometryPoint2;
GeometryPoint geometryPoint3 = line.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.SurfaceLevelOutside);
- GeometryPoint withExtrapolation = LineHelper.GetIntersectionPointWithExtrapolation(geometryPoint1, p2, shoulderTopInside, new GeometryPoint(geometryPoint3.X, shoulderTopInside.Z));
+ GeometryPoint withExtrapolation = lineHelper.GetIntersectionPointWithExtrapolation(geometryPoint1, p2, shoulderTopInside, new GeometryPoint(geometryPoint3.X, shoulderTopInside.Z));
return shoulderTopInside.X - withExtrapolation.X;
}
Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryCurve.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryCurve.cs (.../GeometryCurve.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryCurve.cs (.../GeometryCurve.cs) (revision 4248)
@@ -49,7 +49,8 @@
{
private Point2D endPoint;
private Point2D headPoint;
-
+ private readonly Routines2D routines2D = new Routines2D();
+
///
/// Initializes a new instance of the class.
///
@@ -198,7 +199,7 @@
public bool ContainsPoint(Point2D point, double tolerance = GeometryConstants.Accuracy * 0.5)
{
return HeadPoint != null && EndPoint != null &&
- Routines2D.DoesPointExistInLine(HeadPoint, EndPoint, point, tolerance);
+ routines2D.DoesPointExistInLine(HeadPoint, EndPoint, point, tolerance);
}
///
Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/LayerDetector.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/LayerDetector.cs (.../LayerDetector.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/LayerDetector.cs (.../LayerDetector.cs) (revision 4248)
@@ -43,6 +43,7 @@
private readonly IList soilSurfaces;
private double verticalXCoordinate;
+ private readonly Routines2D routines2D = new Routines2D();
///
/// Initializes a new instance of the class.
@@ -154,7 +155,7 @@
var verticalEndPoint = new Point2D(verticalXCoordinate, minvalue);
Point2D intersectionPoint;
- LineIntersection intersectionResult = Routines2D.DetermineIf2DLinesIntersectStrickly(verticalHeadPoint,
+ LineIntersection intersectionResult = routines2D.DetermineIf2DLinesIntersectStrickly(verticalHeadPoint,
verticalEndPoint, aHeadpoint, aEndPoint, out intersectionPoint);
if (intersectionResult == LineIntersection.Intersects)
@@ -164,8 +165,8 @@
else if (intersectionResult == LineIntersection.NoIntersection || intersectionResult == LineIntersection.Parallel)
{
const double cEpsilon = 1.0e-3;
- if ((Routines2D.DoesPointExistInLine(verticalHeadPoint, verticalEndPoint,
- aHeadpoint, cEpsilon)) && (Routines2D.DoesPointExistInLine(verticalHeadPoint,
+ if ((routines2D.DoesPointExistInLine(verticalHeadPoint, verticalEndPoint,
+ aHeadpoint, cEpsilon)) && (routines2D.DoesPointExistInLine(verticalHeadPoint,
verticalEndPoint, aEndPoint, cEpsilon)))
{
AddPointToList(new LayerIntersectionPoint(aHeadpoint, aSurfaceRefKey));
@@ -234,7 +235,7 @@
};
// check where the mid point lies
- PointInPolygon polygonResult = Routines2D.CheckIfPointIsInPolygon(aPoint1.SurfaceRefKey.GeometrySurface.OuterLoop,
+ PointInPolygon polygonResult = routines2D.CheckIfPointIsInPolygon(aPoint1.SurfaceRefKey.GeometrySurface.OuterLoop,
midPoint.X, midPoint.Z);
Point2D startPoint = aPoint1.IntersectionPoint;
@@ -248,7 +249,7 @@
List innerLoopList = aPoint1.SurfaceRefKey.GeometrySurface.InnerLoops;
foreach (GeometryLoop innerLoop in innerLoopList)
{
- PointInPolygon innerPolygonResult = Routines2D.CheckIfPointIsInPolygon(innerLoop, midPoint.X, midPoint.Z);
+ PointInPolygon innerPolygonResult = routines2D.CheckIfPointIsInPolygon(innerLoop, midPoint.X, midPoint.Z);
if (innerPolygonResult != PointInPolygon.OutsidePolygon)
{
isPresentInInnerLoop = true;
Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs (.../GeometryData.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryData.cs (.../GeometryData.cs) (revision 4248)
@@ -38,7 +38,8 @@
private bool isRegeneratingGeometry;
private bool updatingSurfaceLine;
-
+ private readonly Routines2D routines2D = new Routines2D();
+
///
/// Initializes a new instance of the class.
///
@@ -727,12 +728,12 @@
/// Line 2 GeometryPoint 2
/// Intersection coordinates
/// True if lines intersect each other
- private static bool CheckIfIntersectStricktly(Point2D beginPoint1, Point2D endPoint1,
+ private bool CheckIfIntersectStricktly(Point2D beginPoint1, Point2D endPoint1,
Point2D beginPoint2, Point2D endPoint2,
ref Point2D intersect)
{
Point2D ip;
- LineIntersection res = Routines2D.DetermineIf2DLinesIntersectStrickly(beginPoint1, endPoint1,
+ LineIntersection res = routines2D.DetermineIf2DLinesIntersectStrickly(beginPoint1, endPoint1,
beginPoint2, endPoint2, out ip);
if (ip != null)
{
@@ -752,7 +753,7 @@
/// Line 2 GeometryPoint 2
/// Intersection coordinates
/// True if lines intersect each other
- public static bool CheckIfIntersect(double[] aL1P1, double[] aL1P2, double[] aL2P1, double[] aL2P2,
+ public bool CheckIfIntersect(double[] aL1P1, double[] aL1P2, double[] aL2P1, double[] aL2P2,
ref double[] aIntersect)
{
var p1 = new Point2D(aL1P1[0], aL1P1[1]);
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.resx
===================================================================
diff -u -r4000 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.resx (.../Resources.resx) (revision 4000)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.resx (.../Resources.resx) (revision 4248)
@@ -289,6 +289,6 @@
No segments with failure mechanism {0} present
- Location {0} Profile {1} Scenario {2} is not relevant (different calculator or no uplift at using stabilty UpliftVan).
+ Location {0} Profile {1} Scenario {2} is not relevant (different calculator or no uplift at using piping or stability UpliftVan).
\ No newline at end of file
Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/DebuggingTest.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/DebuggingTest.cs (.../DebuggingTest.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/DebuggingTest.cs (.../DebuggingTest.cs) (revision 4248)
@@ -26,6 +26,7 @@
using Deltares.DamEngine.Interface;
using Deltares.DamEngine.Io;
using Deltares.DamEngine.Io.XmlOutput;
+using Deltares.DamEngine.TestHelpers;
using NUnit.Framework;
namespace Deltares.DamEngine.IntegrationTests.IntegrationTests;
@@ -41,20 +42,26 @@
/// 2) Copy the file to src\Deltares.DamEngine.IntegrationTests\TestFiles\InputForDebugging.xml
/// 3) Run the test in Debugging mode
///
- [Test, Ignore("This test is only used for debugging XML files generated by Dam UI")]
- public void DebugWithXmlInputFile()
+ [Test]//, Ignore("This test is only used for debugging XML files generated by Dam UI")]
+ [TestCase(1)]
+ [TestCase(8)]
+ public void DebugWithXmlInputFile(int maxCores)
{
- const string inputFilename = "InputForDebugging.xml"; // or put your own name here;
+ const string inputFilename = "PipingVoorbeeld1_WtiSellmeijerRevisedInputFile.xml";
string fullInputFilename = Path.Combine(mapTestFiles, inputFilename);
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
string inputString = File.ReadAllText(fullInputFilename);
var engineInterface = new EngineInterface(inputString);
Assert.IsNotNull(engineInterface.DamProjectData);
+ engineInterface.DamProjectData.MaxCalculationCores = maxCores;
string result = engineInterface.Validate();
Assert.IsTrue(result == null, "Validation must succeed but does not, see output xml in debugger");
string outputString = engineInterface.Run();
- File.WriteAllText("Output.xml", outputString);
+ string outputName = "PipingVoorbeeld1_WtiSellmeijerRevisedInputFileOutput" + maxCores + ".xml";
+ File.WriteAllText(outputName, outputString);
Output output = DamXmlSerialization.LoadOutputFromXmlString(outputString);
+ int errorCount = GeneralHelper.DetermineNumberOfCalculationErrors(engineInterface.DamProjectData.CalculationMessages);
+ Assert.AreEqual(0, errorCount, "There should be nor errors during the calculation.");
if (engineInterface.DamProjectData.DamProjectType == DamProjectType.Design)
{
Assert.AreNotEqual(null, output.Results.CalculationResults);
@@ -64,4 +71,36 @@
Assert.AreNotEqual(null, output.Results.OperationalOutputTimeSeries);
}
}
+
+ [Test]//, Ignore("This test is only used for debugging XML files generated by Dam UI")]
+ [TestCase(1,"InputFileOnnoBligh.xml")]
+ [TestCase(1,"InputFileOnnoWbiSellmeijer.xml")]
+ [TestCase(8,"InputFileOnnoBligh.xml")]
+ [TestCase(8,"InputFileOnnoWbiSellmeijer.xml")]
+ public void DebugProblemOnno(int maxCores, string fileName)
+ {
+ string fullInputFilename = Path.Combine(mapTestFiles, fileName);
+ Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
+ string inputString = File.ReadAllText(fullInputFilename);
+ var engineInterface = new EngineInterface(inputString);
+ Assert.IsNotNull(engineInterface.DamProjectData);
+ engineInterface.DamProjectData.MaxCalculationCores = maxCores;
+ string result = engineInterface.Validate();
+ Assert.IsTrue(result == null, "Validation must succeed but does not, see output xml in debugger");
+ string outputString = engineInterface.Run();
+ string outputName = fileName + maxCores + ".xml";
+ File.WriteAllText(outputName, outputString);
+ Output output = DamXmlSerialization.LoadOutputFromXmlString(outputString);
+ int errorCount = GeneralHelper.DetermineNumberOfCalculationErrors(engineInterface.DamProjectData.CalculationMessages);
+ Assert.AreEqual(0, errorCount, "There should be nor errors during the calculation.");
+ if (engineInterface.DamProjectData.DamProjectType == DamProjectType.Design)
+ {
+ Assert.AreNotEqual(null, output.Results.CalculationResults);
+ }
+ else
+ {
+ Assert.AreNotEqual(null, output.Results.OperationalOutputTimeSeries);
+ }
+ }
+
}
\ No newline at end of file
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/SurfaceLineShoulderAdapter.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/SurfaceLineShoulderAdapter.cs (.../SurfaceLineShoulderAdapter.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/SurfaceLineShoulderAdapter.cs (.../SurfaceLineShoulderAdapter.cs) (revision 4248)
@@ -34,6 +34,8 @@
///
public class SurfaceLineShoulderAdapter : SurfaceLineAdapter
{
+ private readonly LineHelper lineHelper = new LineHelper();
+
///
/// Initializes a new instance of the class.
///
@@ -123,7 +125,7 @@
GeometryPoint dikeBaseInside = hasShoulderInside ? surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.ShoulderBaseInside) : dikeToeAtPolder;
// Determine intersectionpoint with slope for a horizontal shoulder
GeometryPoint intersectionPointAtDike;
- intersectionPointAtDike = LineHelper.GetIntersectionPointWithExtrapolation(dikeTopAtPolder, dikeBaseInside,
+ intersectionPointAtDike = lineHelper.GetIntersectionPointWithExtrapolation(dikeTopAtPolder, dikeBaseInside,
new GeometryPoint(dikeToeAtPolder.X, shoulderHeight + dikeToeZ),
new GeometryPoint(dikeToeAtPolder.X + 1, shoulderHeight + dikeToeZ));
var newTopShoulder = new GeometryPoint(intersectionPointAtDike.X + shoulderLength, shoulderHeight + dikeToeZ);
@@ -133,7 +135,7 @@
// from the horizontal intersection point. This will result in the actual width of the shoulder being a bit
// larger than the requested size but that can not be helped (classic chicken-egg problem)
var pb = new GeometryPoint(newTopShoulder.X - 100, newTopShoulder.Z + (100 * Location.NewShoulderTopSlope));
- intersectionPointAtDike = LineHelper.GetIntersectionPointWithExtrapolation(dikeTopAtPolder, dikeBaseInside, pb, newTopShoulder);
+ intersectionPointAtDike = lineHelper.GetIntersectionPointWithExtrapolation(dikeTopAtPolder, dikeBaseInside, pb, newTopShoulder);
if (intersectionPointAtDike.Z > MaxShoulderLevel)
{
throw new SurfaceLineAdapterException(Resources.SurfaceLineShoulderAdapterNewShoulderHeightTooLargeTopSlopeError);
Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryPointString.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryPointString.cs (.../GeometryPointString.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryPointString.cs (.../GeometryPointString.cs) (revision 4248)
@@ -89,7 +89,8 @@
private bool isFrozen;
private bool hasNaNx;
private double frozenMaxZ = double.NaN;
-
+ private readonly Routines2D routines2D = new Routines2D();
+
// sortedPoints must never be used outside this class. Either the GPS concerned must have sorted points but then they already are
// (eg. surfaceline, headline) or they may be unsorted in which case using the sorted list in other classes leads to errors (eg.
// geometrysurfaces, waternetlines)
@@ -701,7 +702,7 @@
double slopeBefore = (calcPoints[i].Z - calcPoints[i - 1].Z) / (calcPoints[i].X - calcPoints[i - 1].X);
double slopeAfter = (calcPoints[i + 1].Z - calcPoints[i].Z) / (calcPoints[i + 1].X - calcPoints[i].X);
- if (Routines2D.AreEqual(slopeBefore, slopeAfter, slopeTolerance))
+ if (routines2D.AreEqual(slopeBefore, slopeAfter, slopeTolerance))
{
calcPoints.RemoveAt(i);
}
Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/Routines2D.cs
===================================================================
diff -u -r4185 -r4248
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/Routines2D.cs (.../Routines2D.cs) (revision 4185)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/Routines2D.cs (.../Routines2D.cs) (revision 4248)
@@ -82,7 +82,7 @@
///
/// Static class Routines2D
///
-public static class Routines2D
+public class Routines2D
{
private const double CEpsilon = 1.0e-4;
@@ -101,7 +101,7 @@
///
/// For connected parallel lines, the connection point will be returned as valid intersection point.
///
- public static LineIntersection DetermineIf2DLinesIntersectStrickly(Point2D point1, Point2D point2, Point2D point3,
+ public LineIntersection DetermineIf2DLinesIntersectStrickly(Point2D point1, Point2D point2, Point2D point3,
Point2D point4, out Point2D intersectionPoint)
{
return DetermineIf2DLinesIntersectStrickly(point1, point2, point3, point4,
@@ -116,7 +116,7 @@
/// The point.
/// The tolerance.
///
- public static bool DoesPointExistInLine(Point2D linePoint1, Point2D linePoint2, Point2D point, double tolerance)
+ public bool DoesPointExistInLine(Point2D linePoint1, Point2D linePoint2, Point2D point, double tolerance)
{
// Function to find if lies on or close to a line (within a given tolerance)
// Input - a line defined by lTwo points, a third point to test and tolerance aValue
@@ -168,7 +168,7 @@
///
///
///
- public static Clockwise IsClockWise(IEnumerable aPolygon)
+ public Clockwise IsClockWise(IEnumerable aPolygon)
{
Point2D[] distinctPoints = aPolygon.Distinct().ToArray();
if (distinctPoints.Length < 3)
@@ -227,7 +227,7 @@
/// The x.
/// The z.
///
- public static PointInPolygon CheckIfPointIsInPolygon(GeometryLoop polygon, double x, double z)
+ public PointInPolygon CheckIfPointIsInPolygon(GeometryLoop polygon, double x, double z)
{
// This is done by calculating and adding the angles from the point to all points
// of the polygon (using the ArcTan2 function). If the sum of these angles is
@@ -331,7 +331,7 @@
///
///
///
- public static List IntersectCircleline(double aX, double aY, double aR, double aX1, double aX2, double aY1, double aY2)
+ public List IntersectCircleline(double aX, double aY, double aR, double aX1, double aX2, double aY1, double aY2)
{
// Solve by filling in parametric equation of line :
// X = x1 + u*(x2 - x1)
@@ -413,7 +413,7 @@
///
///
///
- public static double FindAngle(Point2D line1Point1, Point2D line1Point2, Point2D line2Point1,
+ public double FindAngle(Point2D line1Point1, Point2D line1Point2, Point2D line2Point1,
Point2D line2Point2)
{
double x1 = line1Point2.X - line1Point1.X;
@@ -442,7 +442,7 @@
///
///
///
- public static bool AreEqual(double x1, double x2, double tolerance)
+ public bool AreEqual(double x1, double x2, double tolerance)
{
return (Math.Abs(x1 - x2) < tolerance);
}
@@ -456,7 +456,7 @@
/// a point4.
/// a intersection point.
///
- public static LineIntersection DetermineIf2DLinesIntersectWithExtrapolation(Point2D aPoint1, Point2D aPoint2, Point2D aPoint3, Point2D aPoint4, out Point2D aIntersectionPoint)
+ public LineIntersection DetermineIf2DLinesIntersectWithExtrapolation(Point2D aPoint1, Point2D aPoint2, Point2D aPoint3, Point2D aPoint4, out Point2D aIntersectionPoint)
{
LineConstant lLineConstant1 = CalculateNormalLineConstants(aPoint1, aPoint2);
LineConstant lLineConstant2 = CalculateNormalLineConstants(aPoint3, aPoint4);
@@ -475,7 +475,7 @@
///
///
///
- public static LineIntersection DetermineIf2DLinesIntersectWithExtrapolation(LineConstant aLine1Constant, LineConstant aLine2Constant, out Point2D aIntersectionPoint)
+ public LineIntersection DetermineIf2DLinesIntersectWithExtrapolation(LineConstant aLine1Constant, LineConstant aLine2Constant, out Point2D aIntersectionPoint)
{
aIntersectionPoint = new Point2D(0.0, 0.0);
@@ -510,7 +510,7 @@
/// The point2 z.
/// The tolerance.
///
- public static bool DetermineIfPointsCoincide(double point1X, double point1Z, double point2X, double point2Z, double tolerance)
+ public bool DetermineIfPointsCoincide(double point1X, double point1Z, double point2X, double point2Z, double tolerance)
{
if ((Math.Abs(point1X - point2X)) < tolerance && Math.Abs(point1Z - point2Z) < tolerance)
{
@@ -520,7 +520,7 @@
return false;
}
- private static void UndoAddIfNeeded(GeometryLoop polygon, bool needed)
+ private void UndoAddIfNeeded(GeometryLoop polygon, bool needed)
{
if (needed)
{
@@ -536,7 +536,7 @@
/// X-coordinate of the second point
/// Y-coordinate of the second point
///
- private static double CrossProduct(double pointAx, double pointAy, double pointBx, double pointBy)
+ private double CrossProduct(double pointAx, double pointAy, double pointBx, double pointBy)
{
return pointAx * pointBy - pointBx * pointAy;
}
@@ -547,7 +547,7 @@
/// The point1.
/// The point2.
///
- private static LineConstant CalculateNormalLineConstants(Point2D point1, Point2D point2)
+ private LineConstant CalculateNormalLineConstants(Point2D point1, Point2D point2)
{
double point1X = point1.X;
double point1Z = point1.Z;
@@ -573,7 +573,7 @@
/// a line2 constant y.
/// The tolerance.
///
- private static bool AreLinesParallel(double aLine1ConstantX, double aLine1ConstantY, double aLine2ConstantX, double aLine2ConstantY, double tolerance)
+ private bool AreLinesParallel(double aLine1ConstantX, double aLine1ConstantY, double aLine2ConstantX, double aLine2ConstantY, double tolerance)
{
return Math.Abs(CrossProduct(aLine1ConstantX, aLine2ConstantX, aLine1ConstantY, aLine2ConstantY)) < tolerance;
}
@@ -586,7 +586,7 @@
/// X-coordinate of the second point
/// Y-coordinate of the second point
/// The distance between the given points.
- private static double Compute2DDistance(double aX1, double aY1, double aX2, double aY2)
+ private double Compute2DDistance(double aX1, double aY1, double aX2, double aY2)
{
double lX = aX1 - aX2;
double lY = aY1 - aY2;
@@ -610,7 +610,7 @@
///
/// For connected parallel lines, the connection point will be returned as valid intersection point.
///
- private static LineIntersection DetermineIf2DLinesIntersectStrickly(Point2D point1, Point2D point2, Point2D point3,
+ private LineIntersection DetermineIf2DLinesIntersectStrickly(Point2D point1, Point2D point2, Point2D point3,
Point2D point4, out Point2D intersectionPoint, double tolerance)
{
double point1X = point1.X;
@@ -674,7 +674,7 @@
/// The point4 z.
/// The tolerance.
///
- private static bool DoLinesAtLeastPartialyOverlap(double point1X, double point1Z, double point2X, double point2Z,
+ private bool DoLinesAtLeastPartialyOverlap(double point1X, double point1Z, double point2X, double point2Z,
double point3X, double point3Z, double point4X, double point4Z, double tolerance)
{
bool result = AreLinesParallel(point1X, point1Z, point2X, point2Z, point3X, point3Z, point4X, point4Z, tolerance);
@@ -730,7 +730,7 @@
///
/// True when parallel
///
- private static bool AreLinesParallel(double point1X, double point1Z, double point2X, double point2Z,
+ private bool AreLinesParallel(double point1X, double point1Z, double point2X, double point2Z,
double point3X, double point3Z, double point4X, double point4Z, double tolerance)
{
double aX = point2X - point1X;
@@ -747,7 +747,7 @@
///
/// Normalizes this instance.
///
- private static void Normalize(ref double pointX, ref double pointY)
+ private void Normalize(ref double pointX, ref double pointY)
{
double q = Math.Sqrt(pointX * pointX + pointY * pointY);