Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit b434c0e9 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

moved max coordinates into the DrawGraph Debug Method, code formatting

parent 8071cebb
No related branches found
No related tags found
No related merge requests found
...@@ -96,11 +96,6 @@ namespace TUGraz.VectoCore.Utils ...@@ -96,11 +96,6 @@ namespace TUGraz.VectoCore.Utils
var points = Points.ToArray(); var points = Points.ToArray();
var xmin = points.Min(p => p.X);
var xmax = points.Max(p => p.X);
var ymin = points.Min(p => p.Y);
var ymax = points.Max(p => p.Y);
// iteratively add each point into the correct triangle and split up the triangle // iteratively add each point into the correct triangle and split up the triangle
foreach (var point in points) { foreach (var point in points) {
// If the vertex lies inside the circumcircle of a triangle, the edges of this triangle are // If the vertex lies inside the circumcircle of a triangle, the edges of this triangle are
...@@ -131,7 +126,7 @@ namespace TUGraz.VectoCore.Utils ...@@ -131,7 +126,7 @@ namespace TUGraz.VectoCore.Utils
} }
} }
//DrawGraph(pointCount, triangles, superTriangle, xmin, xmax, ymin, ymax); DrawGraph(pointCount, triangles, superTriangle, points);
_convexHull = triangles.FindAll(t => t.SharesVertexWith(superTriangle)). _convexHull = triangles.FindAll(t => t.SharesVertexWith(superTriangle)).
SelectMany(t => t.GetEdges()). SelectMany(t => t.GetEdges()).
...@@ -158,9 +153,13 @@ namespace TUGraz.VectoCore.Utils ...@@ -158,9 +153,13 @@ namespace TUGraz.VectoCore.Utils
/// Draws the delaunay map (except supertriangle). /// Draws the delaunay map (except supertriangle).
/// </summary> /// </summary>
[Conditional("TRACE")] [Conditional("TRACE")]
private static void DrawGraph(int i, List<Triangle> triangles, Triangle superTriangle, double xmin, double xmax, double ymin, private static void DrawGraph(int i, List<Triangle> triangles, Triangle superTriangle, Point[] points, Point lastPoint = null)
double ymax, Point lastPoint = null)
{ {
var xmin = points.Min(p => p.X);
var xmax = points.Max(p => p.X);
var ymin = points.Min(p => p.Y);
var ymax = points.Max(p => p.Y);
using (var chart = new Chart { Width = 1000, Height = 1000 }) { using (var chart = new Chart { Width = 1000, Height = 1000 }) {
chart.ChartAreas.Add(new ChartArea("main") { chart.ChartAreas.Add(new ChartArea("main") {
AxisX = new Axis { Minimum = Math.Min(xmin, xmin), Maximum = Math.Max(xmax, xmax) }, AxisX = new Axis { Minimum = Math.Min(xmin, xmin), Maximum = Math.Max(xmax, xmax) },
...@@ -196,6 +195,7 @@ namespace TUGraz.VectoCore.Utils ...@@ -196,6 +195,7 @@ namespace TUGraz.VectoCore.Utils
var frame = new StackFrame(2); var frame = new StackFrame(2);
var method = frame.GetMethod(); var method = frame.GetMethod();
System.Diagnostics.Debug.Assert(method.DeclaringType != null, "method.DeclaringType != null");
var type = string.Join("", method.DeclaringType.Name.Split(Path.GetInvalidFileNameChars())); var type = string.Join("", method.DeclaringType.Name.Split(Path.GetInvalidFileNameChars()));
var methodName = string.Join("", method.Name.Split(Path.GetInvalidFileNameChars())); var methodName = string.Join("", method.Name.Split(Path.GetInvalidFileNameChars()));
Directory.CreateDirectory("delaunay"); Directory.CreateDirectory("delaunay");
...@@ -267,13 +267,13 @@ namespace TUGraz.VectoCore.Utils ...@@ -267,13 +267,13 @@ namespace TUGraz.VectoCore.Utils
} }
// 2d vector of the edge: A--->B // 2d vector of the edge: A--->B
var AB = new Point(edge.Vector.X, edge.Vector.Y); var ab = new Point(edge.Vector.X, edge.Vector.Y);
// 2d vector of the point: A---->P // 2d vector of the point: A---->P
var AP = new Point(x - edge.P1.X, y - edge.P1.Y); var ap = new Point(x - edge.P1.X, y - edge.P1.Y);
// projection of point (x,y) onto the edge // projection of point (x,y) onto the edge
var z = edge.P1.Z + edge.Vector.Z * (AP.Dot(AB) / AB.Dot(AB)); var z = edge.P1.Z + edge.Vector.Z * (ap.Dot(ab) / ab.Dot(ab));
return z; return z;
} }
......
...@@ -177,16 +177,17 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData ...@@ -177,16 +177,17 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData
}; };
target.Parameters.Add(new MethodCallParameter("${level}")); target.Parameters.Add(new MethodCallParameter("${level}"));
target.Parameters.Add(new MethodCallParameter("${message}")); target.Parameters.Add(new MethodCallParameter("${message}"));
SimpleConfigurator.ConfigureForTargetLogging(target, LogLevel.Debug); SimpleConfigurator.ConfigureForTargetLogging(target, LogLevel.Warn);
EngineFullLoadCurve.ReadFromFile(@"TestData\Components\FullLoadCurve wrong header.vfld"); EngineFullLoadCurve.ReadFromFile(@"TestData\Components\FullLoadCurve wrong header.vfld");
Assert.IsTrue(LogList.Contains("FullLoadCurve: Header Line is not valid. Expected: \'engine speed, full load torque, motoring torque\', Got: \'n, Mfull, Mdrag, PT1\'. Falling back to column index.")); Assert.IsTrue(
LogList.Contains(
"FullLoadCurve: Header Line is not valid. Expected: \'engine speed, full load torque, motoring torque\', Got: \'n, Mfull, Mdrag, PT1\'. Falling back to column index."));
LogList.Clear(); LogList.Clear();
} }
public static void LogMethod_Test_FileRead_HeaderColumnsNotNamedCorrectly(string level, string message) public static void LogMethod_Test_FileRead_HeaderColumnsNotNamedCorrectly(string level, string message)
{ {
if (level == "Warn") LogList.Add(message);
LogList.Add(message);
} }
/// <summary> /// <summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment