diff --git a/src/MeshExplorer/Controls/AngleHistogram.cs b/src/MeshExplorer/Controls/AngleHistogram.cs
index fa50c3f..d6a6fc4 100644
--- a/src/MeshExplorer/Controls/AngleHistogram.cs
+++ b/src/MeshExplorer/Controls/AngleHistogram.cs
@@ -6,13 +6,9 @@
namespace MeshExplorer.Controls
{
- using System;
- using System.Collections.Generic;
- using System.Text;
using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
using System.Drawing.Text;
+ using System.Windows.Forms;
///
/// Displays an angle histogram.
@@ -75,7 +71,7 @@ namespace MeshExplorer.Controls
///
public AngleHistogram()
{
- this.BackColor = ColorScheme.ColorGray78;
+ BackColor = ColorScheme.ColorGray78;
InitializeComponent();
}
@@ -86,19 +82,19 @@ namespace MeshExplorer.Controls
{
maxAngleCount = 0;
- this.minAngles = dataMin;
- this.maxAngles = dataMax;
+ minAngles = dataMin;
+ maxAngles = dataMax;
ParseData(dataMin);
ParseData(dataMax);
if (maxAngleCount == 0)
{
- this.maxAngles = null;
+ maxAngles = null;
return;
}
- this.Invalidate();
+ Invalidate();
}
private void ParseData(int[] data)
@@ -122,28 +118,27 @@ namespace MeshExplorer.Controls
private void DrawHistogram(Graphics g, int offset, int left, int size, int[] data, Brush brush, Brush brushTop)
{
int count = maxAngleCount;
- int totalHeight = this.Height - paddingBottom - paddingTop;
+ int totalHeight = Height - paddingBottom - paddingTop;
int n = offset == 0 ? data.Length / 3 : data.Length;
- float value = 0;
for (int i = offset; i < n; i++)
{
if (data[i] > 0)
{
// Scale to control height
- value = totalHeight * data[i] / count;
+ float value = totalHeight * data[i] / count;
// Fill bar
g.FillRectangle(brush,
- left + i * size, this.Height - paddingBottom - value,
+ left + i * size, Height - paddingBottom - value,
size - 1, value);
// Draw top of bar (just a little effect ...)
if (value > 2)
{
g.FillRectangle(brushTop,
- left + i * size, this.Height - paddingBottom - value,
+ left + i * size, Height - paddingBottom - value,
size - 1, 2);
}
}
@@ -156,51 +151,56 @@ namespace MeshExplorer.Controls
private void DrawStrings(Graphics g, SizeF fSize, int size, int middle)
{
int fHeight = (int)(fSize.Height + 2);
- g.FillRectangle(textBack, 0, this.Height - fHeight, this.Width, fHeight);
- g.DrawString("0", this.Font, Brushes.White, padding, this.Height - fSize.Height - 1);
- g.DrawString("60", this.Font, Brushes.White,
- this.minAngles.Length * size / 3.0f - 2 * fSize.Width,
- this.Height - fSize.Height - 1);
+ g.FillRectangle(textBack, 0, Height - fHeight, Width, fHeight);
- g.DrawString("60", this.Font, Brushes.White, middle, this.Height - fSize.Height - 1);
- g.DrawString("180", this.Font, Brushes.White,
- this.Width - 3 * fSize.Width,
- this.Height - fSize.Height - 1);
+ var p = new Point(0, Height - (int)fSize.Height - 1);
+
+ p.X = padding;
+ TextRenderer.DrawText(g, "0", Font, p, Color.White);
+
+ p.X = (int)(minAngles.Length * size / 3.0f - 2 * fSize.Width);
+ TextRenderer.DrawText(g, "60", Font, p, Color.White);
+
+ p.X = middle;
+ TextRenderer.DrawText(g, "60", Font, p, Color.White);
+
+ p.X = (int)(Width - 3 * fSize.Width);
+ TextRenderer.DrawText(g, "180", Font, p, Color.White);
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
- g.FillRectangle(new SolidBrush(this.BackColor), this.ClientRectangle);
+ g.FillRectangle(new SolidBrush(BackColor), ClientRectangle);
- if (this.minAngles == null || this.maxAngles == null)
+ if (minAngles == null || maxAngles == null)
{
return;
}
- SizeF fSize = g.MeasureString("0", this.Font, this.Width);
-
- int n = this.minAngles.Length;
+ int n = minAngles.Length;
// Hack --- TODO: Change stats class
- if (n != this.maxAngles.Length)
+ if (n != maxAngles.Length)
{
- n = this.minAngles.Length + this.maxAngles.Length;
+ n = minAngles.Length + maxAngles.Length;
}
// Each bar takes up this space
- int size = (this.Width - 2 * padding) / (n + 1);
+ int size = (Width - 2 * padding) / (n + 1);
// Make pixel align
- int middle = this.Width - padding - n * size;
+ int middle = Width - padding - n * size;
- DrawHistogram(g, 0, padding, size, this.minAngles, Brushes.DarkGreen, Brushes.Green);
- DrawHistogram(g, n / 3, middle, size, this.maxAngles, fillBlue1, fillBlue2);
+ DrawHistogram(g, 0, padding, size, minAngles, Brushes.DarkGreen, Brushes.Green);
+ DrawHistogram(g, n / 3, middle, size, maxAngles, fillBlue1, fillBlue2);
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
+ SizeF fSize = g.MeasureString("0", Font, Width);
+
DrawStrings(g, fSize, size, middle + n / 3 * size);
}
}
diff --git a/src/MeshExplorer/Controls/ColorScheme.cs b/src/MeshExplorer/Controls/ColorScheme.cs
index ec6946c..80dd676 100644
--- a/src/MeshExplorer/Controls/ColorScheme.cs
+++ b/src/MeshExplorer/Controls/ColorScheme.cs
@@ -6,10 +6,6 @@
namespace MeshExplorer.Controls
{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
using System.Drawing;
///
diff --git a/src/MeshExplorer/Controls/DarkButton.cs b/src/MeshExplorer/Controls/DarkButton.cs
index 92d8a8a..1c2dd91 100644
--- a/src/MeshExplorer/Controls/DarkButton.cs
+++ b/src/MeshExplorer/Controls/DarkButton.cs
@@ -6,12 +6,8 @@
namespace MeshExplorer.Controls
{
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
- using System.Text;
using System.Windows.Forms;
public class DarkButton : Button
diff --git a/src/MeshExplorer/Controls/DarkCheckBox.cs b/src/MeshExplorer/Controls/DarkCheckBox.cs
index 86dbd73..71793af 100644
--- a/src/MeshExplorer/Controls/DarkCheckBox.cs
+++ b/src/MeshExplorer/Controls/DarkCheckBox.cs
@@ -7,12 +7,10 @@
namespace MeshExplorer.Controls
{
using System;
- using System.Collections.Generic;
- using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
- using System.Windows.Forms;
using System.Drawing.Text;
+ using System.Windows.Forms;
///
/// Dark checkbox control.
diff --git a/src/MeshExplorer/Controls/DarkListBox.cs b/src/MeshExplorer/Controls/DarkListBox.cs
index 12de603..2fc2262 100644
--- a/src/MeshExplorer/Controls/DarkListBox.cs
+++ b/src/MeshExplorer/Controls/DarkListBox.cs
@@ -7,10 +7,8 @@
namespace MeshExplorer.Controls
{
using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Windows.Forms;
using System.Drawing;
+ using System.Windows.Forms;
///
/// Dark listbox control.
diff --git a/src/MeshExplorer/Controls/DarkSlider.cs b/src/MeshExplorer/Controls/DarkSlider.cs
index 03004a3..6f6f83a 100644
--- a/src/MeshExplorer/Controls/DarkSlider.cs
+++ b/src/MeshExplorer/Controls/DarkSlider.cs
@@ -8,12 +8,9 @@
namespace MeshExplorer.Controls
{
using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
+ using System.Windows.Forms;
///
/// Encapsulates control that visualy displays certain integer value and allows user to change
diff --git a/src/MeshExplorer/Controls/DarkTabControl.cs b/src/MeshExplorer/Controls/DarkTabControl.cs
index ce10728..50b58f5 100644
--- a/src/MeshExplorer/Controls/DarkTabControl.cs
+++ b/src/MeshExplorer/Controls/DarkTabControl.cs
@@ -7,11 +7,9 @@
namespace MeshExplorer.Controls
{
- using System;
- using System.ComponentModel;
using System.Drawing;
- using System.Windows.Forms;
using System.Drawing.Text;
+ using System.Windows.Forms;
///
/// Summary description for FlatTabControl.
diff --git a/src/MeshExplorer/Controls/DarkTextBox.cs b/src/MeshExplorer/Controls/DarkTextBox.cs
index d876316..8e72def 100644
--- a/src/MeshExplorer/Controls/DarkTextBox.cs
+++ b/src/MeshExplorer/Controls/DarkTextBox.cs
@@ -7,10 +7,7 @@
namespace MeshExplorer.Controls
{
using System;
- using System.Collections.Generic;
- using System.Text;
using System.Drawing;
- using System.Drawing.Drawing2D;
using System.Windows.Forms;
///
@@ -103,6 +100,20 @@ namespace MeshExplorer.Controls
{
textBox.ForeColor = ColorScheme.ColorGray68;
};
+
+ textBox.KeyDown += delegate(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Enter)
+ {
+ e.SuppressKeyPress = true;
+ OnKeyDown(e);
+ }
+ };
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ base.OnKeyDown(e);
}
protected override void OnPaint(PaintEventArgs e)
diff --git a/src/MeshExplorer/Controls/DarkToolStripRenderer.cs b/src/MeshExplorer/Controls/DarkToolStripRenderer.cs
index 502e87b..331ed22 100644
--- a/src/MeshExplorer/Controls/DarkToolStripRenderer.cs
+++ b/src/MeshExplorer/Controls/DarkToolStripRenderer.cs
@@ -6,13 +6,9 @@
namespace MeshExplorer.Controls
{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
+ using System.Windows.Forms;
///
/// Toolstrip render for dark menu.
diff --git a/src/MeshExplorer/FormTopology.cs b/src/MeshExplorer/FormTopology.cs
index 3ec3d89..bc09e0d 100644
--- a/src/MeshExplorer/FormTopology.cs
+++ b/src/MeshExplorer/FormTopology.cs
@@ -1,6 +1,5 @@
using System;
using System.Windows.Forms;
-using MeshExplorer.Topology;
using TriangleNet;
using TriangleNet.Geometry;
using TriangleNet.Meshing;
diff --git a/src/MeshExplorer/IO/IMeshFile.cs b/src/MeshExplorer/IO/IMeshFile.cs
index 5efe482..47f0092 100644
--- a/src/MeshExplorer/IO/IMeshFile.cs
+++ b/src/MeshExplorer/IO/IMeshFile.cs
@@ -6,11 +6,6 @@
namespace MeshExplorer.IO
{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using TriangleNet;
using TriangleNet.IO;
///
diff --git a/src/MeshExplorer/Views/AboutView.Designer.cs b/src/MeshExplorer/Views/AboutView.Designer.cs
index f8f6cef..cd4a335 100644
--- a/src/MeshExplorer/Views/AboutView.Designer.cs
+++ b/src/MeshExplorer/Views/AboutView.Designer.cs
@@ -40,30 +40,30 @@
// lbCodeplex
//
this.lbCodeplex.AutoSize = true;
- this.lbCodeplex.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lbCodeplex.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point);
this.lbCodeplex.ForeColor = System.Drawing.Color.White;
this.lbCodeplex.Location = new System.Drawing.Point(72, 82);
this.lbCodeplex.Name = "lbCodeplex";
- this.lbCodeplex.Size = new System.Drawing.Size(153, 13);
+ this.lbCodeplex.Size = new System.Drawing.Size(166, 13);
this.lbCodeplex.TabIndex = 9;
- this.lbCodeplex.Text = "http://triangle.codeplex.com";
+ this.lbCodeplex.Text = "github.com/wo80/Triangle.NET";
this.lbCodeplex.Click += new System.EventHandler(this.lbCodeplex_Clicked);
//
// label15
//
this.label15.AutoSize = true;
- this.label15.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label15.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.label15.ForeColor = System.Drawing.Color.White;
this.label15.Location = new System.Drawing.Point(10, 17);
this.label15.Name = "label15";
- this.label15.Size = new System.Drawing.Size(73, 13);
+ this.label15.Size = new System.Drawing.Size(72, 13);
this.label15.TabIndex = 7;
this.label15.Text = "Triangle.NET";
//
// label1
//
this.label1.AutoSize = true;
- this.label1.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label1.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.label1.ForeColor = System.Drawing.Color.White;
this.label1.Location = new System.Drawing.Point(10, 132);
this.label1.Name = "label1";
@@ -73,13 +73,13 @@
//
// label19
//
- this.label19.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label19.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label19.ForeColor = System.Drawing.Color.White;
this.label19.Location = new System.Drawing.Point(72, 42);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(134, 40);
this.label19.TabIndex = 6;
- this.label19.Text = "Beta 4 (2014-05-30)\r\nChristian Woltering\r\nMIT";
+ this.label19.Text = "Beta 5 (2022-03-05)\r\nChristian Woltering";
//
// label18
//
@@ -88,12 +88,12 @@
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(51, 40);
this.label18.TabIndex = 4;
- this.label18.Text = "Version:\r\nAuthor:\r\nLicense:";
+ this.label18.Text = "Version:\r\nAuthor:";
this.label18.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// label7
//
- this.label7.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label7.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label7.ForeColor = System.Drawing.Color.White;
this.label7.Location = new System.Drawing.Point(72, 155);
this.label7.Name = "label7";
@@ -123,7 +123,7 @@
this.Controls.Add(this.label18);
this.Controls.Add(this.label7);
this.Controls.Add(this.lbShortcuts);
- this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.ForeColor = System.Drawing.Color.DarkGray;
this.Name = "AboutView";
this.Size = new System.Drawing.Size(272, 509);
diff --git a/src/MeshExplorer/Views/AboutView.cs b/src/MeshExplorer/Views/AboutView.cs
index d71ee8d..7ac939d 100644
--- a/src/MeshExplorer/Views/AboutView.cs
+++ b/src/MeshExplorer/Views/AboutView.cs
@@ -17,7 +17,11 @@ namespace MeshExplorer.Views
{
try
{
- ProcessStartInfo info = new ProcessStartInfo("http://triangle.codeplex.com/");
+ var info = new ProcessStartInfo("https://github.com/wo80/Triangle.NET")
+ {
+ UseShellExecute = true
+ };
+
Process.Start(info);
}
catch (Exception)
diff --git a/src/MeshExplorer/Views/AboutView.resx b/src/MeshExplorer/Views/AboutView.resx
index 1af7de1..f298a7b 100644
--- a/src/MeshExplorer/Views/AboutView.resx
+++ b/src/MeshExplorer/Views/AboutView.resx
@@ -1,64 +1,4 @@
-
-
-
+
diff --git a/src/MeshExplorer/Views/IView.cs b/src/MeshExplorer/Views/IView.cs
index d4175b7..1cccfbb 100644
--- a/src/MeshExplorer/Views/IView.cs
+++ b/src/MeshExplorer/Views/IView.cs
@@ -6,10 +6,6 @@
namespace MeshExplorer.Views
{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
using TriangleNet;
using TriangleNet.Geometry;
diff --git a/src/Triangle.Rendering/GDI/RenderControl.cs b/src/Triangle.Rendering/GDI/RenderControl.cs
index 75fe27d..c85e680 100644
--- a/src/Triangle.Rendering/GDI/RenderControl.cs
+++ b/src/Triangle.Rendering/GDI/RenderControl.cs
@@ -6,7 +6,6 @@
namespace TriangleNet.Rendering.GDI
{
- using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
@@ -158,7 +157,7 @@ namespace TriangleNet.Rendering.GDI
{
Graphics g = e.Graphics;
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
- g.DrawString(coordinate, this.Font, Brushes.White, 10, 10);
+ TextRenderer.DrawText(g, coordinate, Font, new Point(10, 10), Color.White);
}
}
diff --git a/src/Triangle.Rendering/Projection.cs b/src/Triangle.Rendering/Projection.cs
index 090e199..76792ba 100644
--- a/src/Triangle.Rendering/Projection.cs
+++ b/src/Triangle.Rendering/Projection.cs
@@ -24,7 +24,7 @@ namespace TriangleNet.Rendering
///
///
/// Since the upper-left corner of the display is usually the screen coordinate origin
- /// (0,0), the project will automatically invert the y-axis.
+ /// (0,0), the projection will automatically invert the y-axis.
///
///
public class Projection
@@ -63,13 +63,16 @@ namespace TriangleNet.Rendering
world = viewport = new RectangleF(screen.X, screen.Y, screen.Width, screen.Height);
+ world_ = new TRectangle();
+ scale_ = 0;
+
Level = 1;
}
///
/// Initialize the projection.
///
- /// The world that should be transformed to screen coordinates.
+ /// The world that should be transformed to screen coordinates.
public void Initialize(TRectangle world)
{
Level = 1;
diff --git a/src/Triangle/Geometry/Contour.cs b/src/Triangle/Geometry/Contour.cs
index 0617ed6..94804e8 100644
--- a/src/Triangle/Geometry/Contour.cs
+++ b/src/Triangle/Geometry/Contour.cs
@@ -58,7 +58,7 @@ namespace TriangleNet.Geometry
{
var segments = new List();
- var p = this.Points;
+ var p = Points;
int count = p.Count - 1;
@@ -93,14 +93,16 @@ namespace TriangleNet.Geometry
{
if (convex)
{
- int count = this.Points.Count;
+ var p = Points;
+
+ int count = p.Count;
var point = new Point(0.0, 0.0);
for (int i = 0; i < count; i++)
{
- point.x += this.Points[i].x;
- point.y += this.Points[i].y;
+ point.x += p[i].x;
+ point.y += p[i].y;
}
// If the contour is convex, use its centroid.
@@ -115,7 +117,7 @@ namespace TriangleNet.Geometry
private void AddPoints(IEnumerable points)
{
- this.Points = new List(points);
+ Points = new List(points);
int count = Points.Count - 1;
diff --git a/src/Triangle/Geometry/Edge.cs b/src/Triangle/Geometry/Edge.cs
index a3124d5..d1601f4 100644
--- a/src/Triangle/Geometry/Edge.cs
+++ b/src/Triangle/Geometry/Edge.cs
@@ -14,29 +14,17 @@ namespace TriangleNet.Geometry
///
/// Gets the first endpoints index.
///
- public int P0
- {
- get;
- private set;
- }
+ public int P0 { get; private set; }
///
/// Gets the second endpoints index.
///
- public int P1
- {
- get;
- private set;
- }
+ public int P1 { get; private set; }
///
/// Gets the segments boundary mark.
///
- public int Label
- {
- get;
- private set;
- }
+ public int Label { get; private set; }
///
/// Initializes a new instance of the class.
@@ -50,9 +38,9 @@ namespace TriangleNet.Geometry
///
public Edge(int p0, int p1, int label)
{
- this.P0 = p0;
- this.P1 = p1;
- this.Label = label;
+ P0 = p0;
+ P1 = p1;
+ Label = label;
}
}
}
diff --git a/src/Triangle/Geometry/ITriangle.cs b/src/Triangle/Geometry/ITriangle.cs
index 31049c5..daae5f8 100644
--- a/src/Triangle/Geometry/ITriangle.cs
+++ b/src/Triangle/Geometry/ITriangle.cs
@@ -6,8 +6,6 @@
namespace TriangleNet.Geometry
{
- using TriangleNet.Topology;
-
///
/// Triangle interface.
///
diff --git a/src/Triangle/Geometry/Point.cs b/src/Triangle/Geometry/Point.cs
index da075a7..3ba7bb2 100644
--- a/src/Triangle/Geometry/Point.cs
+++ b/src/Triangle/Geometry/Point.cs
@@ -52,8 +52,8 @@ namespace TriangleNet.Geometry
///
public int ID
{
- get { return this.id; }
- set { this.id = value; }
+ get { return id; }
+ set { id = value; }
}
///
@@ -61,8 +61,8 @@ namespace TriangleNet.Geometry
///
public double X
{
- get { return this.x; }
- set { this.x = value; }
+ get { return x; }
+ set { x = value; }
}
///
@@ -70,8 +70,8 @@ namespace TriangleNet.Geometry
///
public double Y
{
- get { return this.y; }
- set { this.y = value; }
+ get { return y; }
+ set { y = value; }
}
#if USE_Z
@@ -80,8 +80,8 @@ namespace TriangleNet.Geometry
///
public double Z
{
- get { return this.z; }
- set { this.z = value; }
+ get { return z; }
+ set { z = value; }
}
#endif
@@ -93,29 +93,26 @@ namespace TriangleNet.Geometry
///
public int Label
{
- get { return this.label; }
- set { this.label = value; }
+ get { return label; }
+ set { label = value; }
}
#endregion
- #region Operator overloading / overriding Equals
-
- // Compare "Guidelines for Overriding Equals() and Operator =="
- // http://msdn.microsoft.com/en-us/library/ms173147.aspx
+ #region Overriding Equals() and == Operator
public static bool operator ==(Point a, Point b)
{
- // If both are null, or both are same instance, return true.
- if (Object.ReferenceEquals(a, b))
+ if (a is null)
{
- return true;
+ // If one is null, but not both, return false.
+ return b is null;
}
- // If one is null, but not both, return false.
- if (((object)a == null) || ((object)b == null))
+ // If both are same instance, return true.
+ if (ReferenceEquals(a, b))
{
- return false;
+ return true;
}
return a.Equals(b);
@@ -126,33 +123,17 @@ namespace TriangleNet.Geometry
return !(a == b);
}
- public override bool Equals(object obj)
- {
- // If parameter is null return false.
- if (obj == null)
- {
- return false;
- }
-
- Point p = obj as Point;
-
- if ((object)p == null)
- {
- return false;
- }
-
- return (x == p.x) && (y == p.y);
- }
+ public override bool Equals(object obj) => Equals(obj as Point);
public bool Equals(Point p)
{
- // If vertex is null return false.
- if ((object)p == null)
+ // If object is null return false.
+ if (p is null)
{
return false;
}
- // Return true if the fields match:
+ // Return true if the fields match.
return (x == p.x) && (y == p.y);
}
diff --git a/src/Triangle/Geometry/Polygon.cs b/src/Triangle/Geometry/Polygon.cs
index 6e7fb22..f1b9859 100644
--- a/src/Triangle/Geometry/Polygon.cs
+++ b/src/Triangle/Geometry/Polygon.cs
@@ -13,11 +13,10 @@ namespace TriangleNet.Geometry
///
public class Polygon : IPolygon
{
- List points;
- List holes;
- List regions;
-
- List segments;
+ private readonly List points;
+ private readonly List segments;
+ private readonly List holes;
+ private readonly List regions;
///
public List Points => points;
@@ -81,7 +80,7 @@ namespace TriangleNet.Geometry
public Rectangle Bounds()
{
var bounds = new Rectangle();
- bounds.Expand(this.points);
+ bounds.Expand(points);
return bounds;
}
@@ -89,27 +88,27 @@ namespace TriangleNet.Geometry
///
public void Add(Vertex vertex)
{
- this.points.Add(vertex);
+ points.Add(vertex);
}
///
public void Add(ISegment segment, bool insert = false)
{
- this.segments.Add(segment);
+ segments.Add(segment);
if (insert)
{
- this.points.Add(segment.GetVertex(0));
- this.points.Add(segment.GetVertex(1));
+ points.Add(segment.GetVertex(0));
+ points.Add(segment.GetVertex(1));
}
}
///
public void Add(ISegment segment, int index)
{
- this.segments.Add(segment);
+ segments.Add(segment);
- this.points.Add(segment.GetVertex(index));
+ points.Add(segment.GetVertex(index));
}
///
@@ -117,22 +116,22 @@ namespace TriangleNet.Geometry
{
if (hole)
{
- this.Add(contour, contour.FindInteriorPoint());
+ Add(contour, contour.FindInteriorPoint());
}
else
{
- this.points.AddRange(contour.Points);
- this.segments.AddRange(contour.GetSegments());
+ points.AddRange(contour.Points);
+ segments.AddRange(contour.GetSegments());
}
}
///
public void Add(Contour contour, Point hole)
{
- this.points.AddRange(contour.Points);
- this.segments.AddRange(contour.GetSegments());
+ points.AddRange(contour.Points);
+ segments.AddRange(contour.GetSegments());
- this.holes.Add(hole);
+ holes.Add(hole);
}
}
}
diff --git a/src/Triangle/Geometry/RegionPointer.cs b/src/Triangle/Geometry/RegionPointer.cs
index af6a716..e1fc97a 100644
--- a/src/Triangle/Geometry/RegionPointer.cs
+++ b/src/Triangle/Geometry/RegionPointer.cs
@@ -7,11 +7,10 @@
namespace TriangleNet.Geometry
{
using System;
- using System.Collections.Generic;
///
/// Pointer to a region in the mesh geometry. A region is a well-defined
- /// subset of the geomerty (enclosed by subsegments).
+ /// subset of the geometry (enclosed by subsegments).
///
public class RegionPointer
{
diff --git a/src/Triangle/Geometry/Segment.cs b/src/Triangle/Geometry/Segment.cs
index ab5476d..c87cb39 100644
--- a/src/Triangle/Geometry/Segment.cs
+++ b/src/Triangle/Geometry/Segment.cs
@@ -29,18 +29,12 @@ namespace TriangleNet.Geometry
///
/// Gets the first endpoints index.
///
- public int P0
- {
- get { return v0.id; }
- }
+ public int P0 => v0.id;
///
/// Gets the second endpoints index.
///
- public int P1
- {
- get { return v1.id; }
- }
+ public int P1 => v1.id;
///
/// Initializes a new instance of the class.
@@ -68,15 +62,8 @@ namespace TriangleNet.Geometry
///
public Vertex GetVertex(int index)
{
- if (index == 0)
- {
- return v0;
- }
-
- if (index == 1)
- {
- return v1;
- }
+ if (index == 0) return v0;
+ if (index == 1) return v1;
throw new IndexOutOfRangeException();
}
diff --git a/src/Triangle/Geometry/Vertex.cs b/src/Triangle/Geometry/Vertex.cs
index 64f1471..b70cf8b 100644
--- a/src/Triangle/Geometry/Vertex.cs
+++ b/src/Triangle/Geometry/Vertex.cs
@@ -51,7 +51,7 @@ namespace TriangleNet.Geometry
public Vertex(double x, double y, int mark)
: base(x, y, mark)
{
- this.type = VertexType.InputVertex;
+ type = VertexType.InputVertex;
}
#if USE_ATTRIBS
@@ -87,10 +87,7 @@ namespace TriangleNet.Geometry
///
/// Gets the vertex type.
///
- public VertexType Type
- {
- get { return this.type; }
- }
+ public VertexType Type => type;
///
/// Gets the specified coordinate of the vertex.
@@ -101,15 +98,8 @@ namespace TriangleNet.Geometry
{
get
{
- if (i == 0)
- {
- return x;
- }
-
- if (i == 1)
- {
- return y;
- }
+ if (i == 0) return x;
+ if (i == 1) return y;
throw new ArgumentOutOfRangeException("Index must be 0 or 1.");
}
@@ -117,9 +107,6 @@ namespace TriangleNet.Geometry
#endregion
- public override int GetHashCode()
- {
- return this.hash;
- }
+ public override int GetHashCode() => hash;
}
}
diff --git a/src/Triangle/IO/InputTriangle.cs b/src/Triangle/IO/InputTriangle.cs
index 649c95d..130dba1 100644
--- a/src/Triangle/IO/InputTriangle.cs
+++ b/src/Triangle/IO/InputTriangle.cs
@@ -6,7 +6,7 @@
namespace TriangleNet.IO
{
- using TriangleNet.Topology;
+ using System;
using TriangleNet.Geometry;
///
@@ -20,32 +20,26 @@ namespace TriangleNet.IO
public InputTriangle(int p0, int p1, int p2)
{
- this.vertices = new int[] { p0, p1, p2 };
+ vertices = new int[] { p0, p1, p2 };
}
#region Public properties
- ///
- /// Gets the triangle id.
- ///
+ ///
public int ID
{
get { return 0; }
set { }
}
- ///
- /// Region ID the triangle belongs to.
- ///
+ ///
public int Label
{
get { return label; }
set { label = value; }
}
- ///
- /// Gets the triangle area constraint.
- ///
+ ///
public double Area
{
get { return area; }
@@ -53,31 +47,41 @@ namespace TriangleNet.IO
}
///
- /// Gets the specified corners vertex.
+ /// WARNING: not implemented.
///
public Vertex GetVertex(int index)
{
- return null; // TODO: throw NotSupportedException?
+ throw new NotImplementedException();
}
+ ///
public int GetVertexID(int index)
{
return vertices[index];
}
+ ///
+ /// WARNING: not implemented.
+ ///
public ITriangle GetNeighbor(int index)
{
- return null;
+ throw new NotImplementedException();
}
+ ///
+ /// WARNING: not implemented.
+ ///
public int GetNeighborID(int index)
{
- return -1;
+ throw new NotImplementedException();
}
+ ///
+ /// WARNING: not implemented.
+ ///
public ISegment GetSegment(int index)
{
- return null;
+ throw new NotImplementedException();
}
#endregion
diff --git a/src/Triangle/IO/TriangleReader.cs b/src/Triangle/IO/TriangleReader.cs
index c31790c..da4d613 100644
--- a/src/Triangle/IO/TriangleReader.cs
+++ b/src/Triangle/IO/TriangleReader.cs
@@ -18,7 +18,7 @@ namespace TriangleNet.IO
///
public class TriangleReader
{
- static NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;
+ private static readonly NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;
int startIndex = 0;
@@ -35,7 +35,7 @@ namespace TriangleNet.IO
string line = reader.ReadLine().Trim();
- while (String.IsNullOrWhiteSpace(line) || line.StartsWith("#"))
+ while (string.IsNullOrWhiteSpace(line) || line.StartsWith("#"))
{
if (reader.EndOfStream)
{
@@ -101,8 +101,6 @@ namespace TriangleNet.IO
///
public void Read(string filename, out Polygon polygon)
{
- polygon = null;
-
string path = Path.ChangeExtension(filename, ".poly");
if (File.Exists(path))
@@ -138,9 +136,7 @@ namespace TriangleNet.IO
///
public IPolygon Read(string filename)
{
- Polygon geometry = null;
-
- Read(filename, out geometry);
+ Read(filename, out Polygon geometry);
return geometry;
}
@@ -280,7 +276,7 @@ namespace TriangleNet.IO
startIndex = 0;
string[] line;
- int invertices = 0, attributes = 0, nodemarkers = 0;
+ int invertices, attributes = 0, nodemarkers = 0;
using (var reader = new StreamReader(polyfilename))
{
@@ -398,7 +394,7 @@ namespace TriangleNet.IO
if (Log.Verbose)
{
Log.Instance.Warning("Invalid first endpoint of segment.",
- "MeshReader.ReadPolyfile()");
+ "TriangleReader.ReadPolyfile()");
}
}
else if ((end2 < 0) || (end2 >= invertices))
@@ -406,7 +402,7 @@ namespace TriangleNet.IO
if (Log.Verbose)
{
Log.Instance.Warning("Invalid second endpoint of segment.",
- "MeshReader.ReadPolyfile()");
+ "TriangleReader.ReadPolyfile()");
}
}
else
@@ -520,7 +516,6 @@ namespace TriangleNet.IO
/// Read the elements from an .ele file.
///
///
- ///
///
private List ReadEleFile(string elefilename, bool readArea)
{
@@ -541,7 +536,7 @@ namespace TriangleNet.IO
intriangles = int.Parse(line[0]);
- // We irgnore index 1 (number of nodes per triangle)
+ // We ignore index 1 (number of nodes per triangle)
attributes = 0;
if (line.Length > 2)
{
@@ -551,7 +546,8 @@ namespace TriangleNet.IO
if (attributes > 1)
{
- Log.Instance.Warning("Triangle attributes not supported.", "FileReader.Read");
+ Log.Instance.Warning("Triangle attributes not supported.",
+ "TriangleReader.ReadEleFile()");
}
triangles = new List(intriangles);
@@ -624,7 +620,7 @@ namespace TriangleNet.IO
if (int.Parse(line[0]) != intriangles)
{
Log.Instance.Warning("Number of area constraints doesn't match number of triangles.",
- "ReadAreaFile()");
+ "TriangleReader.ReadAreaFile()");
return null;
}
@@ -717,7 +713,7 @@ namespace TriangleNet.IO
if (Log.Verbose)
{
Log.Instance.Warning("Invalid first endpoint of segment.",
- "MeshReader.ReadPolyfile()");
+ "TriangleReader.ReadEdgeFile()");
}
}
else if ((end2 < 0) || (end2 >= invertices))
@@ -725,7 +721,7 @@ namespace TriangleNet.IO
if (Log.Verbose)
{
Log.Instance.Warning("Invalid second endpoint of segment.",
- "MeshReader.ReadPolyfile()");
+ "TriangleReader.ReadEdgeFile()");
}
}
else
diff --git a/src/Triangle/IO/TriangleWriter.cs b/src/Triangle/IO/TriangleWriter.cs
index 2e041c7..f18edb6 100644
--- a/src/Triangle/IO/TriangleWriter.cs
+++ b/src/Triangle/IO/TriangleWriter.cs
@@ -184,7 +184,6 @@ namespace TriangleNet.IO
///
/// Data source.
/// File name.
- /// Write nodes into this file.
/// If the nodes should not be written into this file,
/// make sure a .node file was written before, so that the nodes
/// are numbered right.
diff --git a/src/Triangle/Meshing/Iterators/EdgeIterator.cs b/src/Triangle/Meshing/Iterators/EdgeIterator.cs
index 773eebf..1b1e14d 100644
--- a/src/Triangle/Meshing/Iterators/EdgeIterator.cs
+++ b/src/Triangle/Meshing/Iterators/EdgeIterator.cs
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
-//
+//
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
//
// -----------------------------------------------------------------------
diff --git a/src/Triangle/Meshing/Iterators/RegionIterator.cs b/src/Triangle/Meshing/Iterators/RegionIterator.cs
index 7e668d5..3dcc698 100644
--- a/src/Triangle/Meshing/Iterators/RegionIterator.cs
+++ b/src/Triangle/Meshing/Iterators/RegionIterator.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Original Matlab code by John Burkardt, Florida State University
+// Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
//
// -----------------------------------------------------------------------
diff --git a/src/Triangle/Meshing/Iterators/VertexCirculator.cs b/src/Triangle/Meshing/Iterators/VertexCirculator.cs
index 9122771..d8221ae 100644
--- a/src/Triangle/Meshing/Iterators/VertexCirculator.cs
+++ b/src/Triangle/Meshing/Iterators/VertexCirculator.cs
@@ -1,4 +1,9 @@
-
+// -----------------------------------------------------------------------
+//
+// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
+//
+// -----------------------------------------------------------------------
+
namespace TriangleNet.Meshing.Iterators
{
using System.Collections.Generic;
diff --git a/src/Triangle/Tools/IntersectionHelper.cs b/src/Triangle/Tools/IntersectionHelper.cs
index 8810bf5..53860ba 100644
--- a/src/Triangle/Tools/IntersectionHelper.cs
+++ b/src/Triangle/Tools/IntersectionHelper.cs
@@ -142,10 +142,10 @@ namespace TriangleNet.Tools
/// Intersect a ray with a bounding box.
///
/// The clip rectangle.
- /// The ray startpoint (inside the box).
+ /// The ray start point (inside the box).
/// Any point in ray direction (NOT the direction vector).
/// The intersection point.
- /// Returns false, if startpoint is outside the box.
+ /// Returns false, if start point is outside the box.
public static bool BoxRayIntersection(Rectangle rect, Point p0, Point p1, ref Point c1)
{
return BoxRayIntersection(rect, p0, p1.x - p0.x, p1.y - p0.y, ref c1);
@@ -155,10 +155,10 @@ namespace TriangleNet.Tools
/// Intersect a ray with a bounding box.
///
/// The clip rectangle.
- /// The ray startpoint (inside the box).
+ /// The ray start point (inside the box).
/// X direction.
/// Y direction.
- /// Returns false, if startpoint is outside the box.
+ /// Returns false, if start point is outside the box.
public static Point BoxRayIntersection(Rectangle rect, Point p, double dx, double dy)
{
var intersection = new Point();
diff --git a/src/Triangle/Tools/PolygonValidator.cs b/src/Triangle/Tools/PolygonValidator.cs
index 64c82cc..5c139ee 100644
--- a/src/Triangle/Tools/PolygonValidator.cs
+++ b/src/Triangle/Tools/PolygonValidator.cs
@@ -258,7 +258,7 @@ namespace TriangleNet.Tools
if (p.id < 0 || p.id >= count)
{
horrors++;
- logger.Warning(string.Format("Segment {0} has invalid startpoint.", i),
+ logger.Warning(string.Format("Segment {0} has invalid start point.", i),
"PolygonValidator.IsConsistent()");
}
diff --git a/src/Triangle/Tools/QualityMeasure.cs b/src/Triangle/Tools/QualityMeasure.cs
index 888332b..22476f4 100644
--- a/src/Triangle/Tools/QualityMeasure.cs
+++ b/src/Triangle/Tools/QualityMeasure.cs
@@ -271,7 +271,7 @@ namespace TriangleNet.Tools
public double area_max = -double.MaxValue;
// Total area of geometry
public double area_total = 0;
- // Nmber of triangles with zero area
+ // Number of triangles with zero area
public int area_zero = 0;
///
diff --git a/src/Triangle/Tools/Statistic.cs b/src/Triangle/Tools/Statistic.cs
index d9f5635..f7473a4 100644
--- a/src/Triangle/Tools/Statistic.cs
+++ b/src/Triangle/Tools/Statistic.cs
@@ -63,68 +63,68 @@ namespace TriangleNet.Tools
///
/// Gets the shortest edge.
///
- public double ShortestEdge { get { return minEdge; } }
+ public double ShortestEdge => minEdge;
double maxEdge = 0;
///
/// Gets the longest edge.
///
- public double LongestEdge { get { return maxEdge; } }
+ public double LongestEdge => maxEdge;
//
double minAspect = 0;
///
/// Gets the shortest altitude.
///
- public double ShortestAltitude { get { return minAspect; } }
+ public double ShortestAltitude => minAspect;
double maxAspect = 0;
///
/// Gets the largest aspect ratio.
///
- public double LargestAspectRatio { get { return maxAspect; } }
+ public double LargestAspectRatio => maxAspect;
double minArea = 0;
///
/// Gets the smallest area.
///
- public double SmallestArea { get { return minArea; } }
+ public double SmallestArea => minArea;
double maxArea = 0;
///
/// Gets the largest area.
///
- public double LargestArea { get { return maxArea; } }
+ public double LargestArea => maxArea;
double minAngle = 0;
///
/// Gets the smallest angle.
///
- public double SmallestAngle { get { return minAngle; } }
+ public double SmallestAngle => minAngle;
double maxAngle = 0;
///
/// Gets the largest angle.
///
- public double LargestAngle { get { return maxAngle; } }
+ public double LargestAngle => maxAngle;
int[] angleTable;
///
/// Gets the angle histogram.
///
- public int[] AngleHistogram { get { return angleTable; } }
+ public int[] AngleHistogram => angleTable;
int[] minAngles;
///
/// Gets the min angles histogram.
///
- public int[] MinAngleHistogram { get { return minAngles; } }
+ public int[] MinAngleHistogram => minAngles;
int[] maxAngles;
///
/// Gets the max angles histogram.
///
- public int[] MaxAngleHistogram { get { return maxAngles; } }
+ public int[] MaxAngleHistogram => maxAngles;
#endregion
@@ -258,8 +258,8 @@ namespace TriangleNet.Tools
foreach (var tri in mesh.triangles)
{
- triMinAngle = 0; // Min angle: 0 < a < 60 degress
- triMaxAngle = 1; // Max angle: 60 < a < 180 degress
+ triMinAngle = 0; // Min angle: 0 < a < 60 degrees
+ triMaxAngle = 1; // Max angle: 60 < a < 180 degrees
p[0] = tri.vertices[0];
p[1] = tri.vertices[1];
diff --git a/src/Triangle/Topology/SubSegment.cs b/src/Triangle/Topology/SubSegment.cs
index 6b7e675..4948901 100644
--- a/src/Triangle/Topology/SubSegment.cs
+++ b/src/Triangle/Topology/SubSegment.cs
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
-//
+//
// Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
//