Minor updates.

This commit is contained in:
wo80
2022-03-04 13:24:51 +01:00
parent ee6f03d5ce
commit 43b424e62d
36 changed files with 198 additions and 327 deletions
+35 -35
View File
@@ -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;
/// <summary>
/// Displays an angle histogram.
@@ -75,7 +71,7 @@ namespace MeshExplorer.Controls
/// </summary>
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);
}
}
-4
View File
@@ -6,10 +6,6 @@
namespace MeshExplorer.Controls
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
/// <summary>
-4
View File
@@ -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
+1 -3
View File
@@ -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;
/// <summary>
/// Dark checkbox control.
+1 -3
View File
@@ -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;
/// <summary>
/// Dark listbox control.
+1 -4
View File
@@ -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;
/// <summary>
/// Encapsulates control that visualy displays certain integer value and allows user to change
+1 -3
View File
@@ -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>
/// Summary description for FlatTabControl.
+14 -3
View File
@@ -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;
/// <summary>
@@ -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)
@@ -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;
/// <summary>
/// Toolstrip render for dark menu.
-1
View File
@@ -1,6 +1,5 @@
using System;
using System.Windows.Forms;
using MeshExplorer.Topology;
using TriangleNet;
using TriangleNet.Geometry;
using TriangleNet.Meshing;
-5
View File
@@ -6,11 +6,6 @@
namespace MeshExplorer.IO
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TriangleNet;
using TriangleNet.IO;
/// <summary>
+11 -11
View File
@@ -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);
+5 -1
View File
@@ -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)
+1 -61
View File
@@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
-4
View File
@@ -6,10 +6,6 @@
namespace MeshExplorer.Views
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TriangleNet;
using TriangleNet.Geometry;
+1 -2
View File
@@ -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);
}
}
+5 -2
View File
@@ -24,7 +24,7 @@ namespace TriangleNet.Rendering
/// </para>
/// <para>
/// 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.
/// </para>
/// </remarks>
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;
}
/// <summary>
/// Initialize the projection.
/// </summary>
/// <param name="nworld">The world that should be transformed to screen coordinates.</param>
/// <param name="world">The world that should be transformed to screen coordinates.</param>
public void Initialize(TRectangle world)
{
Level = 1;
+7 -5
View File
@@ -58,7 +58,7 @@ namespace TriangleNet.Geometry
{
var segments = new List<ISegment>();
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<Vertex> points)
{
this.Points = new List<Vertex>(points);
Points = new List<Vertex>(points);
int count = Points.Count - 1;
+6 -18
View File
@@ -14,29 +14,17 @@ namespace TriangleNet.Geometry
/// <summary>
/// Gets the first endpoints index.
/// </summary>
public int P0
{
get;
private set;
}
public int P0 { get; private set; }
/// <summary>
/// Gets the second endpoints index.
/// </summary>
public int P1
{
get;
private set;
}
public int P1 { get; private set; }
/// <summary>
/// Gets the segments boundary mark.
/// </summary>
public int Label
{
get;
private set;
}
public int Label { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="Edge" /> class.
@@ -50,9 +38,9 @@ namespace TriangleNet.Geometry
/// </summary>
public Edge(int p0, int p1, int label)
{
this.P0 = p0;
this.P1 = p1;
this.Label = label;
P0 = p0;
P1 = p1;
Label = label;
}
}
}
-2
View File
@@ -6,8 +6,6 @@
namespace TriangleNet.Geometry
{
using TriangleNet.Topology;
/// <summary>
/// Triangle interface.
/// </summary>
+21 -40
View File
@@ -52,8 +52,8 @@ namespace TriangleNet.Geometry
/// </summary>
public int ID
{
get { return this.id; }
set { this.id = value; }
get { return id; }
set { id = value; }
}
/// <summary>
@@ -61,8 +61,8 @@ namespace TriangleNet.Geometry
/// </summary>
public double X
{
get { return this.x; }
set { this.x = value; }
get { return x; }
set { x = value; }
}
/// <summary>
@@ -70,8 +70,8 @@ namespace TriangleNet.Geometry
/// </summary>
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
/// </summary>
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
/// </remarks>
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);
}
+17 -18
View File
@@ -13,11 +13,10 @@ namespace TriangleNet.Geometry
/// </summary>
public class Polygon : IPolygon
{
List<Vertex> points;
List<Point> holes;
List<RegionPointer> regions;
List<ISegment> segments;
private readonly List<Vertex> points;
private readonly List<ISegment> segments;
private readonly List<Point> holes;
private readonly List<RegionPointer> regions;
/// <inheritdoc />
public List<Vertex> 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
/// <inheritdoc />
public void Add(Vertex vertex)
{
this.points.Add(vertex);
points.Add(vertex);
}
/// <inheritdoc />
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));
}
}
/// <inheritdoc />
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));
}
/// <inheritdoc />
@@ -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());
}
}
/// <inheritdoc />
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);
}
}
}
+1 -2
View File
@@ -7,11 +7,10 @@
namespace TriangleNet.Geometry
{
using System;
using System.Collections.Generic;
/// <summary>
/// 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).
/// </summary>
public class RegionPointer
{
+4 -17
View File
@@ -29,18 +29,12 @@ namespace TriangleNet.Geometry
/// <summary>
/// Gets the first endpoints index.
/// </summary>
public int P0
{
get { return v0.id; }
}
public int P0 => v0.id;
/// <summary>
/// Gets the second endpoints index.
/// </summary>
public int P1
{
get { return v1.id; }
}
public int P1 => v1.id;
/// <summary>
/// Initializes a new instance of the <see cref="Segment" /> class.
@@ -68,15 +62,8 @@ namespace TriangleNet.Geometry
/// <returns></returns>
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();
}
+5 -18
View File
@@ -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
/// <summary>
/// Gets the vertex type.
/// </summary>
public VertexType Type
{
get { return this.type; }
}
public VertexType Type => type;
/// <summary>
/// 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;
}
}
+20 -16
View File
@@ -6,7 +6,7 @@
namespace TriangleNet.IO
{
using TriangleNet.Topology;
using System;
using TriangleNet.Geometry;
/// <summary>
@@ -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
/// <summary>
/// Gets the triangle id.
/// </summary>
/// <inheritdoc/>
public int ID
{
get { return 0; }
set { }
}
/// <summary>
/// Region ID the triangle belongs to.
/// </summary>
/// <inheritdoc/>
public int Label
{
get { return label; }
set { label = value; }
}
/// <summary>
/// Gets the triangle area constraint.
/// </summary>
/// <inheritdoc/>
public double Area
{
get { return area; }
@@ -53,31 +47,41 @@ namespace TriangleNet.IO
}
/// <summary>
/// Gets the specified corners vertex.
/// WARNING: not implemented.
/// </summary>
public Vertex GetVertex(int index)
{
return null; // TODO: throw NotSupportedException?
throw new NotImplementedException();
}
/// <inheritdoc/>
public int GetVertexID(int index)
{
return vertices[index];
}
/// <summary>
/// WARNING: not implemented.
/// </summary>
public ITriangle GetNeighbor(int index)
{
return null;
throw new NotImplementedException();
}
/// <summary>
/// WARNING: not implemented.
/// </summary>
public int GetNeighborID(int index)
{
return -1;
throw new NotImplementedException();
}
/// <summary>
/// WARNING: not implemented.
/// </summary>
public ISegment GetSegment(int index)
{
return null;
throw new NotImplementedException();
}
#endregion
+12 -16
View File
@@ -18,7 +18,7 @@ namespace TriangleNet.IO
/// </summary>
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
/// </summary>
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
/// </summary>
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.
/// </summary>
/// <param name="elefilename"></param>
/// <param name="data"></param>
/// <param name="readArea"></param>
private List<ITriangle> 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<ITriangle>(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
-1
View File
@@ -184,7 +184,6 @@ namespace TriangleNet.IO
/// </summary>
/// <param name="polygon">Data source.</param>
/// <param name="filename">File name.</param>
/// <param name="writeNodes">Write nodes into this file.</param>
/// <remarks>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.</remarks>
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
// <copyright file="EdgeEnumerator.cs" company="">
// <copyright file="EdgeIterator.cs" company="">
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
// </copyright>
// -----------------------------------------------------------------------
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
// <copyright file="RegionIterator.cs" company="">
// 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/
// </copyright>
// -----------------------------------------------------------------------
@@ -1,4 +1,9 @@
// -----------------------------------------------------------------------
// <copyright file="VertexCirculator.cs" company="">
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
// </copyright>
// -----------------------------------------------------------------------
namespace TriangleNet.Meshing.Iterators
{
using System.Collections.Generic;
+4 -4
View File
@@ -142,10 +142,10 @@ namespace TriangleNet.Tools
/// Intersect a ray with a bounding box.
/// </summary>
/// <param name="rect">The clip rectangle.</param>
/// <param name="p0">The ray startpoint (inside the box).</param>
/// <param name="p0">The ray start point (inside the box).</param>
/// <param name="p1">Any point in ray direction (NOT the direction vector).</param>
/// <param name="c1">The intersection point.</param>
/// <returns>Returns false, if startpoint is outside the box.</returns>
/// <returns>Returns false, if start point is outside the box.</returns>
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.
/// </summary>
/// <param name="rect">The clip rectangle.</param>
/// <param name="p">The ray startpoint (inside the box).</param>
/// <param name="p">The ray start point (inside the box).</param>
/// <param name="dx">X direction.</param>
/// <param name="dy">Y direction.</param>
/// <returns>Returns false, if startpoint is outside the box.</returns>
/// <returns>Returns false, if start point is outside the box.</returns>
public static Point BoxRayIntersection(Rectangle rect, Point p, double dx, double dy)
{
var intersection = new Point();
+1 -1
View File
@@ -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()");
}
+1 -1
View File
@@ -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;
/// <summary>
+13 -13
View File
@@ -63,68 +63,68 @@ namespace TriangleNet.Tools
/// <summary>
/// Gets the shortest edge.
/// </summary>
public double ShortestEdge { get { return minEdge; } }
public double ShortestEdge => minEdge;
double maxEdge = 0;
/// <summary>
/// Gets the longest edge.
/// </summary>
public double LongestEdge { get { return maxEdge; } }
public double LongestEdge => maxEdge;
//
double minAspect = 0;
/// <summary>
/// Gets the shortest altitude.
/// </summary>
public double ShortestAltitude { get { return minAspect; } }
public double ShortestAltitude => minAspect;
double maxAspect = 0;
/// <summary>
/// Gets the largest aspect ratio.
/// </summary>
public double LargestAspectRatio { get { return maxAspect; } }
public double LargestAspectRatio => maxAspect;
double minArea = 0;
/// <summary>
/// Gets the smallest area.
/// </summary>
public double SmallestArea { get { return minArea; } }
public double SmallestArea => minArea;
double maxArea = 0;
/// <summary>
/// Gets the largest area.
/// </summary>
public double LargestArea { get { return maxArea; } }
public double LargestArea => maxArea;
double minAngle = 0;
/// <summary>
/// Gets the smallest angle.
/// </summary>
public double SmallestAngle { get { return minAngle; } }
public double SmallestAngle => minAngle;
double maxAngle = 0;
/// <summary>
/// Gets the largest angle.
/// </summary>
public double LargestAngle { get { return maxAngle; } }
public double LargestAngle => maxAngle;
int[] angleTable;
/// <summary>
/// Gets the angle histogram.
/// </summary>
public int[] AngleHistogram { get { return angleTable; } }
public int[] AngleHistogram => angleTable;
int[] minAngles;
/// <summary>
/// Gets the min angles histogram.
/// </summary>
public int[] MinAngleHistogram { get { return minAngles; } }
public int[] MinAngleHistogram => minAngles;
int[] maxAngles;
/// <summary>
/// Gets the max angles histogram.
/// </summary>
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];
+1 -1
View File
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
// <copyright file="Segment.cs" company="">
// <copyright file="SubSegment.cs" company="">
// 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/
// </copyright>