diff --git a/src/Triangle/Configuration.cs b/src/Triangle/Configuration.cs index f723b35..c8add8c 100644 --- a/src/Triangle/Configuration.cs +++ b/src/Triangle/Configuration.cs @@ -13,16 +13,28 @@ namespace TriangleNet /// public class Configuration { + /// + /// Initializes a new instance of the class. + /// public Configuration() : this(() => RobustPredicates.Default, () => new TrianglePool()) { } + /// + /// Initializes a new instance of the class. + /// + /// Factory method for . public Configuration(Func predicates) : this(predicates, () => new TrianglePool()) { } + /// + /// Initializes a new instance of the class. + /// + /// Factory method for . + /// Factory method for . public Configuration(Func predicates, Func trianglePool) { Predicates = predicates; diff --git a/src/Triangle/Geometry/Contour.cs b/src/Triangle/Geometry/Contour.cs index 1fb2ea8..ec9d54c 100644 --- a/src/Triangle/Geometry/Contour.cs +++ b/src/Triangle/Geometry/Contour.cs @@ -10,6 +10,9 @@ namespace TriangleNet.Geometry using System.Collections.Generic; using TriangleNet.Tools; + /// + /// Represents a contour of a polygon (outer boundary or internal holes). + /// public class Contour { int marker; @@ -54,6 +57,10 @@ namespace TriangleNet.Geometry this.convex = convex; } + /// + /// Gets the list of segments of the contour. + /// + /// public List GetSegments() { var segments = new List(); diff --git a/src/Triangle/Geometry/ExtensionMethods.cs b/src/Triangle/Geometry/ExtensionMethods.cs index d583738..fae7666 100644 --- a/src/Triangle/Geometry/ExtensionMethods.cs +++ b/src/Triangle/Geometry/ExtensionMethods.cs @@ -4,6 +4,9 @@ namespace TriangleNet.Geometry using System; using TriangleNet.Meshing; + /// + /// Extension methods. + /// public static class ExtensionMethods { #region IPolygon extensions @@ -19,6 +22,7 @@ namespace TriangleNet.Geometry /// /// Triangulates a polygon, applying constraint options. /// + /// Polygon instance. /// Constraint options. public static IMesh Triangulate(this IPolygon polygon, ConstraintOptions options) { @@ -28,6 +32,7 @@ namespace TriangleNet.Geometry /// /// Triangulates a polygon, applying quality options. /// + /// Polygon instance. /// Quality options. public static IMesh Triangulate(this IPolygon polygon, QualityOptions quality) { @@ -37,6 +42,7 @@ namespace TriangleNet.Geometry /// /// Triangulates a polygon, applying quality and constraint options. /// + /// Polygon instance. /// Constraint options. /// Quality options. public static IMesh Triangulate(this IPolygon polygon, ConstraintOptions options, QualityOptions quality) @@ -47,6 +53,7 @@ namespace TriangleNet.Geometry /// /// Triangulates a polygon, applying quality and constraint options. /// + /// Polygon instance. /// Constraint options. /// Quality options. /// The triangulation algorithm. @@ -67,6 +74,7 @@ namespace TriangleNet.Geometry /// /// Test whether a given point lies inside a triangle or not. /// + /// Triangle instance. /// Point to locate. /// True, if point is inside or on the edge of this triangle. public static bool Contains(this ITriangle triangle, Point p) @@ -77,6 +85,7 @@ namespace TriangleNet.Geometry /// /// Test whether a given point lies inside a triangle or not. /// + /// Triangle instance. /// Point to locate. /// Point to locate. /// True, if point is inside or on the edge of this triangle. @@ -117,6 +126,11 @@ namespace TriangleNet.Geometry return false; } + /// + /// Returns the bounding box of the triangle. + /// + /// Triangle instance. + /// public static Rectangle Bounds(this ITriangle triangle) { var bounds = new Rectangle(); diff --git a/src/Triangle/Geometry/IEdge.cs b/src/Triangle/Geometry/IEdge.cs index b34c16f..988db4c 100644 --- a/src/Triangle/Geometry/IEdge.cs +++ b/src/Triangle/Geometry/IEdge.cs @@ -6,6 +6,9 @@ namespace TriangleNet.Geometry { + /// + /// Simple edge interface. + /// public interface IEdge { /// diff --git a/src/Triangle/Geometry/Point.cs b/src/Triangle/Geometry/Point.cs index 976c36e..beec352 100644 --- a/src/Triangle/Geometry/Point.cs +++ b/src/Triangle/Geometry/Point.cs @@ -28,16 +28,30 @@ namespace TriangleNet.Geometry internal double z; #endif + /// + /// Initializes a new instance of the class. + /// public Point() : this(0.0, 0.0, 0) { } + /// + /// Initializes a new instance of the class. + /// + /// The x coordinate. + /// The y coordinate. public Point(double x, double y) : this(x, y, 0) { } + /// + /// Initializes a new instance of the class. + /// + /// The x coordinate. + /// The y coordinate. + /// The point label. public Point(double x, double y, int label) { this.x = x; @@ -101,6 +115,7 @@ namespace TriangleNet.Geometry #region Overriding Equals() and == Operator + /// public static bool operator ==(Point a, Point b) { if (a is null) @@ -118,13 +133,16 @@ namespace TriangleNet.Geometry return a.Equals(b); } + /// public static bool operator !=(Point a, Point b) { return !(a == b); } + /// public override bool Equals(object obj) => Equals(obj as Point); + /// public bool Equals(Point p) { // If object is null return false. @@ -139,6 +157,7 @@ namespace TriangleNet.Geometry #endregion + /// public int CompareTo(Point other) { if (x == other.x && y == other.y) @@ -149,6 +168,7 @@ namespace TriangleNet.Geometry return (x < other.x || (x == other.x && y < other.y)) ? -1 : 1; } + /// public override int GetHashCode() { int hash = 19; diff --git a/src/Triangle/Geometry/Rectangle.cs b/src/Triangle/Geometry/Rectangle.cs index ce7e55d..049baca 100644 --- a/src/Triangle/Geometry/Rectangle.cs +++ b/src/Triangle/Geometry/Rectangle.cs @@ -25,6 +25,10 @@ namespace TriangleNet.Geometry xmax = ymax = -double.MaxValue; } + /// + /// Initializes a new instance of the class. + /// + /// public Rectangle(Rectangle other) : this(other.Left, other.Bottom, other.Right, other.Top) { @@ -125,8 +129,7 @@ namespace TriangleNet.Geometry /// /// Expand rectangle to include given rectangle. /// - /// X coordinate. - /// Y coordinate. + /// The other rectangle. public void Expand(Rectangle other) { xmin = Math.Min(xmin, other.xmin); diff --git a/src/Triangle/Geometry/Vertex.cs b/src/Triangle/Geometry/Vertex.cs index fdeb317..8b3a1c3 100644 --- a/src/Triangle/Geometry/Vertex.cs +++ b/src/Triangle/Geometry/Vertex.cs @@ -106,6 +106,7 @@ namespace TriangleNet.Geometry #endregion + /// public override int GetHashCode() => hash; } } diff --git a/src/Triangle/IO/FileProcessor.cs b/src/Triangle/IO/FileProcessor.cs index b4b9224..43dcb97 100644 --- a/src/Triangle/IO/FileProcessor.cs +++ b/src/Triangle/IO/FileProcessor.cs @@ -64,7 +64,7 @@ namespace TriangleNet.IO /// /// Save a polygon geometry to disk. /// - /// An instance of the class. + /// An instance of the class. /// The path of the file to save. public static void Write(IPolygon polygon, string filename) { diff --git a/src/Triangle/IO/InputTriangle.cs b/src/Triangle/IO/InputTriangle.cs index 16d428d..f98d17b 100644 --- a/src/Triangle/IO/InputTriangle.cs +++ b/src/Triangle/IO/InputTriangle.cs @@ -18,6 +18,9 @@ namespace TriangleNet.IO internal int label; internal double area; + /// + /// Initializes a new instance of the class. + /// public InputTriangle(int p0, int p1, int p2) { vertices = new int[] { p0, p1, p2 }; diff --git a/src/Triangle/IO/TriangleFormat.cs b/src/Triangle/IO/TriangleFormat.cs index 244280b..2bd6d75 100644 --- a/src/Triangle/IO/TriangleFormat.cs +++ b/src/Triangle/IO/TriangleFormat.cs @@ -17,6 +17,11 @@ namespace TriangleNet.IO /// public class TriangleFormat : IPolygonFormat, IMeshFormat { + /// + /// Returns a value indicating whether the given file is supported by this format. + /// + /// + /// public bool IsSupported(string file) { string ext = Path.GetExtension(file).ToLower(); @@ -29,6 +34,7 @@ namespace TriangleNet.IO return false; } + /// public IMesh Import(string filename) { string ext = Path.GetExtension(filename); @@ -49,6 +55,7 @@ namespace TriangleNet.IO throw new NotSupportedException("Could not load '" + filename + "' file."); } + /// public void Write(IMesh mesh, string filename) { var writer = new TriangleWriter(); @@ -57,11 +64,13 @@ namespace TriangleNet.IO writer.WriteElements((Mesh)mesh, Path.ChangeExtension(filename, ".ele")); } + /// public void Write(IMesh mesh, Stream stream) { throw new NotImplementedException(); } + /// public IPolygon Read(string filename) { string ext = Path.GetExtension(filename); @@ -79,11 +88,13 @@ namespace TriangleNet.IO } + /// public void Write(IPolygon polygon, string filename) { (new TriangleWriter()).WritePoly(polygon, filename); } + /// public void Write(IPolygon polygon, Stream stream) { throw new NotImplementedException(); diff --git a/src/Triangle/IO/TriangleReader.cs b/src/Triangle/IO/TriangleReader.cs index 3b627b9..245f3b1 100644 --- a/src/Triangle/IO/TriangleReader.cs +++ b/src/Triangle/IO/TriangleReader.cs @@ -267,7 +267,7 @@ namespace TriangleNet.IO /// /// /// If true, look for an associated .ele file. - /// If true, look for an associated .area file. + /// If true, look for an associated .area file. public Polygon ReadPolyFile(string polyfilename, bool readElements, bool readArea) { // Read poly file @@ -603,7 +603,6 @@ namespace TriangleNet.IO /// /// /// - /// private double[] ReadAreaFile(string areafilename, int intriangles) { double[] data = null; diff --git a/src/Triangle/IO/TriangleWriter.cs b/src/Triangle/IO/TriangleWriter.cs index 2fbd2d2..b78d316 100644 --- a/src/Triangle/IO/TriangleWriter.cs +++ b/src/Triangle/IO/TriangleWriter.cs @@ -100,8 +100,11 @@ namespace TriangleNet.IO /// /// Write the vertices to a stream. /// - /// /// + /// + /// + /// + /// private void WriteNodes(StreamWriter writer, IEnumerable nodes, bool markers, int attribs, bool jettison) { diff --git a/src/Triangle/IPredicates.cs b/src/Triangle/IPredicates.cs index 27e5e94..1c027a0 100644 --- a/src/Triangle/IPredicates.cs +++ b/src/Triangle/IPredicates.cs @@ -3,14 +3,68 @@ namespace TriangleNet { using TriangleNet.Geometry; + /// + /// Geometric predicates interface. + /// public interface IPredicates { + /// + /// Check, if the three points appear in counterclockwise order. The result is + /// also a rough approximation of twice the signed area of the triangle defined + /// by the three points. + /// + /// Point a. + /// Point b. + /// Point c. + /// Return a positive value if the points pa, pb, and pc occur in + /// counterclockwise order; a negative value if they occur in clockwise order; + /// and zero if they are collinear. double CounterClockwise(Point a, Point b, Point c); + /// + /// Check if the point pd lies inside the circle passing through pa, pb, and pc. The + /// points pa, pb, and pc must be in counterclockwise order, or the sign of the result + /// will be reversed. + /// + /// Point a. + /// Point b. + /// Point c. + /// Point d. + /// Return a positive value if the point pd lies inside the circle passing through + /// pa, pb, and pc; a negative value if it lies outside; and zero if the four points + /// are cocircular. double InCircle(Point a, Point b, Point c, Point p); + /// + /// Find the circumcenter of a triangle. + /// + /// Triangle point. + /// Triangle point. + /// Triangle point. + /// Relative coordinate of new location. + /// Relative coordinate of new location. + /// Coordinates of the circumcenter + /// + /// The result is returned both in terms of x-y coordinates and xi-eta + /// (barycentric) coordinates. The xi-eta coordinate system is defined in + /// terms of the triangle: the origin of the triangle is the origin of the + /// coordinate system; the destination of the triangle is one unit along the + /// xi axis; and the apex of the triangle is one unit along the eta axis. + /// This procedure also returns the square of the length of the triangle's + /// shortest edge. + /// Point FindCircumcenter(Point org, Point dest, Point apex, ref double xi, ref double eta); + /// + /// Find the circumcenter of a triangle. + /// + /// Triangle point. + /// Triangle point. + /// Triangle point. + /// Relative coordinate of new location. + /// Relative coordinate of new location. + /// Off-center constant. + /// Coordinates of the circumcenter (or off-center) Point FindCircumcenter(Point org, Point dest, Point apex, ref double xi, ref double eta, double offconstant); } diff --git a/src/Triangle/Log.cs b/src/Triangle/Log.cs index 369a328..14ccda3 100644 --- a/src/Triangle/Log.cs +++ b/src/Triangle/Log.cs @@ -9,6 +9,9 @@ namespace TriangleNet using System; using System.Collections.Generic; + /// + /// The log level. + /// public enum LogLevel { Info, Warning, Error } /// @@ -68,6 +71,7 @@ namespace TriangleNet /// /// A simple logger, which logs messages to a List. + /// public sealed class Log { /// @@ -95,13 +99,10 @@ namespace TriangleNet private Log() { } - public static Log Instance - { - get - { - return instance; - } - } + /// + /// Gets the instance. + /// + public static Log Instance => instance; #endregion diff --git a/src/Triangle/Mesh.cs b/src/Triangle/Mesh.cs index 6b15dcb..b17cc89 100644 --- a/src/Triangle/Mesh.cs +++ b/src/Triangle/Mesh.cs @@ -219,6 +219,11 @@ namespace TriangleNet TransferNodes(points); } + /// + /// Refine the mesh to match given quality options. + /// + /// The quality constraints. + /// A value indicating, whether the refined mesh should be Conforming Delaunay. public void Refine(QualityOptions quality, bool delaunay = false) { invertices = vertices.Count; @@ -319,10 +324,8 @@ namespace TriangleNet target.hullsize = this.hullsize; } - /// - /// Reset all the mesh data. This method will also wipe - /// out all mesh data. - /// + + // TODO: Remove unused method. private void ResetData() { vertices.Clear(); @@ -369,7 +372,7 @@ namespace TriangleNet /// /// Read the vertices from memory. /// - /// The input data. + /// The input data. private void TransferNodes(IList points) { invertices = points.Count; @@ -1392,55 +1395,55 @@ namespace TriangleNet /// A flag that determines whether the new triangles should /// be tested for quality, and enqueued if they are bad. /// - // This is a conceptually difficult routine. The starting assumption is - // that we have a polygon with n sides. n - 1 of these sides are currently - // represented as edges in the mesh. One side, called the "base", need not - // be. - // - // Inside the polygon is a structure I call a "fan", consisting of n - 1 - // triangles that share a common origin. For each of these triangles, the - // edge opposite the origin is one of the sides of the polygon. The - // primary edge of each triangle is the edge directed from the origin to - // the destination; note that this is not the same edge that is a side of - // the polygon. 'firstedge' is the primary edge of the first triangle. - // From there, the triangles follow in counterclockwise order about the - // polygon, until 'lastedge', the primary edge of the last triangle. - // 'firstedge' and 'lastedge' are probably connected to other triangles - // beyond the extremes of the fan, but their identity is not important, as - // long as the fan remains connected to them. - // - // Imagine the polygon oriented so that its base is at the bottom. This - // puts 'firstedge' on the far right, and 'lastedge' on the far left. - // The right vertex of the base is the destination of 'firstedge', and the - // left vertex of the base is the apex of 'lastedge'. - // - // The challenge now is to find the right sequence of edge flips to - // transform the fan into a Delaunay triangulation of the polygon. Each - // edge flip effectively removes one triangle from the fan, committing it - // to the polygon. The resulting polygon has one fewer edge. If 'doflip' - // is set, the final flip will be performed, resulting in a fan of one - // (useless?) triangle. If 'doflip' is not set, the final flip is not - // performed, resulting in a fan of two triangles, and an unfinished - // triangular polygon that is not yet filled out with a single triangle. - // On completion of the routine, 'lastedge' is the last remaining triangle, - // or the leftmost of the last two. - // - // Although the flips are performed in the order described above, the - // decisions about what flips to perform are made in precisely the reverse - // order. The recursive triangulatepolygon() procedure makes a decision, - // uses up to two recursive calls to triangulate the "subproblems" - // (polygons with fewer edges), and then performs an edge flip. - // - // The "decision" it makes is which vertex of the polygon should be - // connected to the base. This decision is made by testing every possible - // vertex. Once the best vertex is found, the two edges that connect this - // vertex to the base become the bases for two smaller polygons. These - // are triangulated recursively. Unfortunately, this approach can take - // O(n^2) time not only in the worst case, but in many common cases. It's - // rarely a big deal for vertex deletion, where n is rarely larger than - // ten, but it could be a big deal for segment insertion, especially if - // there's a lot of long segments that each cut many triangles. I ought to - // code a faster algorithm some day. + /// This is a conceptually difficult routine. The starting assumption is + /// that we have a polygon with n sides. n - 1 of these sides are currently + /// represented as edges in the mesh. One side, called the "base", need not + /// be. + /// + /// Inside the polygon is a structure I call a "fan", consisting of n - 1 + /// triangles that share a common origin. For each of these triangles, the + /// edge opposite the origin is one of the sides of the polygon. The + /// primary edge of each triangle is the edge directed from the origin to + /// the destination; note that this is not the same edge that is a side of + /// the polygon. 'firstedge' is the primary edge of the first triangle. + /// From there, the triangles follow in counterclockwise order about the + /// polygon, until 'lastedge', the primary edge of the last triangle. + /// 'firstedge' and 'lastedge' are probably connected to other triangles + /// beyond the extremes of the fan, but their identity is not important, as + /// long as the fan remains connected to them. + /// + /// Imagine the polygon oriented so that its base is at the bottom. This + /// puts 'firstedge' on the far right, and 'lastedge' on the far left. + /// The right vertex of the base is the destination of 'firstedge', and the + /// left vertex of the base is the apex of 'lastedge'. + /// + /// The challenge now is to find the right sequence of edge flips to + /// transform the fan into a Delaunay triangulation of the polygon. Each + /// edge flip effectively removes one triangle from the fan, committing it + /// to the polygon. The resulting polygon has one fewer edge. If 'doflip' + /// is set, the final flip will be performed, resulting in a fan of one + /// (useless?) triangle. If 'doflip' is not set, the final flip is not + /// performed, resulting in a fan of two triangles, and an unfinished + /// triangular polygon that is not yet filled out with a single triangle. + /// On completion of the routine, 'lastedge' is the last remaining triangle, + /// or the leftmost of the last two. + /// + /// Although the flips are performed in the order described above, the + /// decisions about what flips to perform are made in precisely the reverse + /// order. The recursive triangulatepolygon() procedure makes a decision, + /// uses up to two recursive calls to triangulate the "subproblems" + /// (polygons with fewer edges), and then performs an edge flip. + /// + /// The "decision" it makes is which vertex of the polygon should be + /// connected to the base. This decision is made by testing every possible + /// vertex. Once the best vertex is found, the two edges that connect this + /// vertex to the base become the bases for two smaller polygons. These + /// are triangulated recursively. Unfortunately, this approach can take + /// O(n^2) time not only in the worst case, but in many common cases. It's + /// rarely a big deal for vertex deletion, where n is rarely larger than + /// ten, but it could be a big deal for segment insertion, especially if + /// there's a lot of long segments that each cut many triangles. I ought to + /// code a faster algorithm some day. /// private void TriangulatePolygon(Otri firstedge, Otri lastedge, int edgecount, bool doflip, bool triflaws) diff --git a/src/Triangle/MeshValidator.cs b/src/Triangle/MeshValidator.cs index cacec5e..e2d9bcb 100644 --- a/src/Triangle/MeshValidator.cs +++ b/src/Triangle/MeshValidator.cs @@ -14,6 +14,9 @@ namespace TriangleNet using TriangleNet.Tools; using TriangleNet.Topology; + /// + /// Mesh validation helper. + /// public static class MeshValidator { private static RobustPredicates predicates = RobustPredicates.Default; diff --git a/src/Triangle/Meshing/Algorithm/Dwyer.cs b/src/Triangle/Meshing/Algorithm/Dwyer.cs index d161b22..7d4425e 100644 --- a/src/Triangle/Meshing/Algorithm/Dwyer.cs +++ b/src/Triangle/Meshing/Algorithm/Dwyer.cs @@ -57,7 +57,7 @@ namespace TriangleNet.Meshing.Algorithm Mesh mesh; /// - /// Form a Delaunay triangulation by the divide-and-conquer method. + /// Compute a Delaunay triangulation by the divide-and-conquer method. /// /// /// diff --git a/src/Triangle/Meshing/Algorithm/Incremental.cs b/src/Triangle/Meshing/Algorithm/Incremental.cs index 0badf61..100bb9d 100644 --- a/src/Triangle/Meshing/Algorithm/Incremental.cs +++ b/src/Triangle/Meshing/Algorithm/Incremental.cs @@ -19,10 +19,9 @@ namespace TriangleNet.Meshing.Algorithm Mesh mesh; /// - /// Form a Delaunay triangulation by incrementally inserting vertices. + /// Compute a Delaunay triangulation by incrementally inserting vertices. /// - /// Returns the number of edges on the convex hull of the - /// triangulation. + /// public IMesh Triangulate(IList points, Configuration config) { mesh = new Mesh(config, points); diff --git a/src/Triangle/Meshing/Algorithm/SweepLine.cs b/src/Triangle/Meshing/Algorithm/SweepLine.cs index 7074e52..4362fb5 100644 --- a/src/Triangle/Meshing/Algorithm/SweepLine.cs +++ b/src/Triangle/Meshing/Algorithm/SweepLine.cs @@ -33,6 +33,9 @@ namespace TriangleNet.Meshing.Algorithm double xminextreme; // Nonexistent x value used as a flag in sweepline. List splaynodes; + /// + /// Compute a Delaunay triangulation by the sweepline method. + /// public IMesh Triangulate(IList points, Configuration config) { predicates = config.Predicates(); diff --git a/src/Triangle/Meshing/Converter.cs b/src/Triangle/Meshing/Converter.cs index bd8392a..7d3f0ce 100644 --- a/src/Triangle/Meshing/Converter.cs +++ b/src/Triangle/Meshing/Converter.cs @@ -351,6 +351,11 @@ namespace TriangleNet.Meshing #region DCEL conversion + /// + /// Convert the triangle mesh topology to DCEL. + /// + /// + /// public DcelMesh ToDCEL(Mesh mesh) { var dcel = new DcelMesh(); diff --git a/src/Triangle/Meshing/Data/BadTriQueue.cs b/src/Triangle/Meshing/Data/BadTriQueue.cs index c4ab1ef..f8e382e 100644 --- a/src/Triangle/Meshing/Data/BadTriQueue.cs +++ b/src/Triangle/Meshing/Data/BadTriQueue.cs @@ -14,9 +14,9 @@ namespace TriangleNet.Meshing.Data /// A (priority) queue for bad triangles. /// /// - // The queue is actually a set of 4096 queues. I use multiple queues to - // give priority to smaller angles. I originally implemented a heap, but - // the queues are faster by a larger margin than I'd suspected. + /// The queue is actually a set of 4096 queues. I use multiple queues to + /// give priority to smaller angles. I originally implemented a heap, but + /// the queues are faster by a larger margin than I'd suspected. /// class BadTriQueue { diff --git a/src/Triangle/Meshing/GenericMesher.cs b/src/Triangle/Meshing/GenericMesher.cs index b83a889..f29bfe5 100644 --- a/src/Triangle/Meshing/GenericMesher.cs +++ b/src/Triangle/Meshing/GenericMesher.cs @@ -15,26 +15,45 @@ namespace TriangleNet.Meshing /// /// Create meshes of point sets or polygons. /// + /// + /// If not specified otherwise, the default triangulation algorithm used is . + /// public class GenericMesher { Configuration config; ITriangulator triangulator; + /// + /// Initializes a new instance of the class. + /// public GenericMesher() : this(new Dwyer(), new Configuration()) { } + /// + /// Initializes a new instance of the class. + /// + /// The algorithm implementation. public GenericMesher(ITriangulator triangulator) : this(triangulator, new Configuration()) { } + /// + /// Initializes a new instance of the class. + /// + /// The . public GenericMesher(Configuration config) : this(new Dwyer(), config) { } + /// + /// Initializes a new instance of the class. + /// + /// The algorithm implementation. + /// The . public GenericMesher(ITriangulator triangulator, Configuration config) { this.config = config; diff --git a/src/Triangle/Meshing/IMesh.cs b/src/Triangle/Meshing/IMesh.cs index 1203c31..03f11ef 100644 --- a/src/Triangle/Meshing/IMesh.cs +++ b/src/Triangle/Meshing/IMesh.cs @@ -49,7 +49,7 @@ namespace TriangleNet.Meshing /// Refine the mesh. /// /// The quality constraints. - /// + /// /// A value indicating, if the refined mesh should be Conforming Delaunay. /// void Refine(QualityOptions quality, bool delaunay); diff --git a/src/Triangle/Meshing/Iterators/EdgeIterator.cs b/src/Triangle/Meshing/Iterators/EdgeIterator.cs index b823481..6e7db3f 100644 --- a/src/Triangle/Meshing/Iterators/EdgeIterator.cs +++ b/src/Triangle/Meshing/Iterators/EdgeIterator.cs @@ -15,6 +15,11 @@ namespace TriangleNet.Meshing.Iterators /// public class EdgeIterator { + /// + /// Enumerate all edges of the given mesh. + /// + /// + /// public IEnumerable EnumerateEdges(IMesh mesh) { Otri tri = default; @@ -51,7 +56,7 @@ namespace TriangleNet.Meshing.Iterators } /// - /// Enumerate the edges of the mesh. + /// Enumerate all edges of the given mesh. /// /// /// diff --git a/src/Triangle/Meshing/Iterators/RegionIterator.cs b/src/Triangle/Meshing/Iterators/RegionIterator.cs index 93d355a..ae6511a 100644 --- a/src/Triangle/Meshing/Iterators/RegionIterator.cs +++ b/src/Triangle/Meshing/Iterators/RegionIterator.cs @@ -22,6 +22,9 @@ namespace TriangleNet.Meshing.Iterators { List region; + /// + /// Initializes a new instance of the class. + /// public RegionIterator(Mesh mesh) { this.region = new List(); diff --git a/src/Triangle/Meshing/Iterators/VertexCirculator.cs b/src/Triangle/Meshing/Iterators/VertexCirculator.cs index 69191d2..2d33833 100644 --- a/src/Triangle/Meshing/Iterators/VertexCirculator.cs +++ b/src/Triangle/Meshing/Iterators/VertexCirculator.cs @@ -10,10 +10,16 @@ namespace TriangleNet.Meshing.Iterators using TriangleNet.Geometry; using TriangleNet.Topology; + /// + /// Vertex circulator to enumerate the vertices connected to a mesh vertex. + /// public class VertexCirculator { List cache = new List(); + /// + /// Initializes a new instance of the class. + /// public VertexCirculator(Mesh mesh) { mesh.MakeVertexMap(); diff --git a/src/Triangle/Meshing/QualityMesher.cs b/src/Triangle/Meshing/QualityMesher.cs index a54416d..aa66115 100644 --- a/src/Triangle/Meshing/QualityMesher.cs +++ b/src/Triangle/Meshing/QualityMesher.cs @@ -52,7 +52,7 @@ namespace TriangleNet.Meshing /// Apply quality constraints to a mesh. /// /// The quality constraints. - /// A value indicating, if the refined mesh should be Conforming Delaunay. + /// A value indicating, whether the refined mesh should be Conforming Delaunay. public void Apply(QualityOptions quality, bool delaunay = false) { // Copy quality options diff --git a/src/Triangle/NewLocation.cs b/src/Triangle/NewLocation.cs index cadc324..a520fcb 100644 --- a/src/Triangle/NewLocation.cs +++ b/src/Triangle/NewLocation.cs @@ -83,7 +83,6 @@ namespace TriangleNet /// /// /// - /// /// /// /// @@ -101,7 +100,7 @@ namespace TriangleNet double dx, dy, dxoff, dyoff; ////////////////////////////// HALE'S VARIABLES ////////////////////////////// - // keeps the difference of coordinates edge + // keeps the difference of coordinates edge double xShortestEdge = 0, yShortestEdge = 0; // keeps the square of edge lengths @@ -112,7 +111,7 @@ namespace TriangleNet // keeps the type of orientation if the triangle int orientation = 0; - // keeps the coordinates of circumcenter of itself and neighbor triangle circumcenter + // keeps the coordinates of circumcenter of itself and neighbor triangle circumcenter Point myCircumcenter, neighborCircumcenter; // keeps if bad triangle is almost good or not @@ -134,7 +133,7 @@ namespace TriangleNet Vertex neighborvertex_1; Vertex neighborvertex_2; Vertex neighborvertex_3; - // dummy variables + // dummy variables double xi_tmp = 0, eta_tmp = 0; //vertex thirdVertex; // for petal intersection @@ -187,7 +186,7 @@ namespace TriangleNet // Don't count the above as an orientation test. Statistic.CounterClockwiseCount--; } - // calculate the circumcenter in terms of distance to origin point + // calculate the circumcenter in terms of distance to origin point dx = (yao * dodist - ydo * aodist) * denominator; dy = (xdo * aodist - xao * dodist) * denominator; // for debugging and for keeping circumcenter to use later @@ -200,12 +199,12 @@ namespace TriangleNet // serves as a conservative estimate of the insertion radius of the // circumcenter's parent. The estimate is used to ensure that // the algorithm terminates even if very small angles appear in - // the input PSLG. + // the input PSLG. // find the orientation of the triangle, basically shortest and longest edges orientation = LongestShortestEdge(aodist, dadist, dodist); //printf("org: (%f,%f), dest: (%f,%f), apex: (%f,%f)\n",torg[0],torg[1],tdest[0],tdest[1],tapex[0],tapex[1]); ///////////////////////////////////////////////////////////////////////////////////////////// - // 123: shortest: aodist // 213: shortest: dadist // 312: shortest: dodist // + // 123: shortest: aodist // 213: shortest: dadist // 312: shortest: dodist // // middle: dadist // middle: aodist // middle: aodist // // longest: dodist // longest: dodist // longest: dadist // // 132: shortest: aodist // 231: shortest: dadist // 321: shortest: dodist // @@ -216,8 +215,8 @@ namespace TriangleNet switch (orientation) { case 123: // assign necessary information - /// smallest angle corner: dest - /// largest angle corner: apex + // smallest angle corner: dest + // largest angle corner: apex xShortestEdge = xao; yShortestEdge = yao; shortestEdgeDist = aodist; @@ -230,8 +229,8 @@ namespace TriangleNet break; case 132: // assign necessary information - /// smallest angle corner: dest - /// largest angle corner: org + // smallest angle corner: dest + // largest angle corner: org xShortestEdge = xao; yShortestEdge = yao; shortestEdgeDist = aodist; @@ -244,8 +243,8 @@ namespace TriangleNet break; case 213: // assign necessary information - /// smallest angle corner: org - /// largest angle corner: apex + // smallest angle corner: org + // largest angle corner: apex xShortestEdge = xda; yShortestEdge = yda; shortestEdgeDist = dadist; @@ -257,8 +256,8 @@ namespace TriangleNet largestAngleCorner = tapex; break; case 231: // assign necessary information - /// smallest angle corner: org - /// largest angle corner: dest + // smallest angle corner: org + // largest angle corner: dest xShortestEdge = xda; yShortestEdge = yda; shortestEdgeDist = dadist; @@ -270,8 +269,8 @@ namespace TriangleNet largestAngleCorner = tdest; break; case 312: // assign necessary information - /// smallest angle corner: apex - /// largest angle corner: org + // smallest angle corner: apex + // largest angle corner: org xShortestEdge = xdo; yShortestEdge = ydo; shortestEdgeDist = dodist; @@ -284,8 +283,8 @@ namespace TriangleNet break; case 321: // assign necessary information default: // TODO: is this safe? - /// smallest angle corner: apex - /// largest angle corner: dest + // smallest angle corner: apex + // largest angle corner: dest xShortestEdge = xdo; yShortestEdge = ydo; shortestEdgeDist = dodist; @@ -297,7 +296,7 @@ namespace TriangleNet largestAngleCorner = tdest; break; - }// end of switch + }// end of switch // check for offcenter condition if (offcenter && (offconstant > 0.0)) { @@ -309,19 +308,19 @@ namespace TriangleNet dyoff = 0.5 * yShortestEdge + offconstant * xShortestEdge; // If the off-center is closer to destination than the // circumcenter, use the off-center instead. - /// doubleLY BAD CASE /// + //- doubleLY BAD CASE -// if (dxoff * dxoff + dyoff * dyoff < (dx - xdo) * (dx - xdo) + (dy - ydo) * (dy - ydo)) { dx = xdo + dxoff; dy = ydo + dyoff; } - /// ALMOST GOOD CASE /// + //- ALMOST GOOD CASE -// else { almostGood = 1; } - // destination has the smallest angle + // destination has the smallest angle } else if (orientation == 123 || orientation == 132) { @@ -330,33 +329,33 @@ namespace TriangleNet dyoff = 0.5 * yShortestEdge - offconstant * xShortestEdge; // If the off-center is closer to the origin than the // circumcenter, use the off-center instead. - /// doubleLY BAD CASE /// + //- doubleLY BAD CASE -// if (dxoff * dxoff + dyoff * dyoff < dx * dx + dy * dy) { dx = dxoff; dy = dyoff; } - /// ALMOST GOOD CASE /// + //- ALMOST GOOD CASE -// else { almostGood = 1; } - // apex has the smallest angle + // apex has the smallest angle } else - {//orientation == 312 || orientation == 321 + {//orientation == 312 || orientation == 321 // Find the position of the off-center, as described by Alper Ungor. dxoff = 0.5 * xShortestEdge - offconstant * yShortestEdge; dyoff = 0.5 * yShortestEdge + offconstant * xShortestEdge; // If the off-center is closer to the origin than the // circumcenter, use the off-center instead. - /// doubleLY BAD CASE /// + //- doubleLY BAD CASE -// if (dxoff * dxoff + dyoff * dyoff < dx * dx + dy * dy) { dx = dxoff; dy = dyoff; } - /// ALMOST GOOD CASE /// + //- ALMOST GOOD CASE -// else { almostGood = 1; @@ -367,7 +366,7 @@ namespace TriangleNet if (almostGood == 1) { - /// calculate cosine of largest angle /// + // calculate cosine of largest angle cosMaxAngle = (middleEdgeDist + shortestEdgeDist - longestEdgeDist) / (2 * Math.Sqrt(middleEdgeDist) * Math.Sqrt(shortestEdgeDist)); if (cosMaxAngle < 0.0) { @@ -384,10 +383,10 @@ namespace TriangleNet // nonobtuse isObtuse = false; } - /// RELOCATION (LOCAL SMOOTHING) /// - /// check for possible relocation of one of triangle's points /// + //- RELOCATION (LOCAL SMOOTHING) -// + // check for possible relocation of one of triangle's points relocated = DoSmoothing(delotri, torg, tdest, tapex, ref newloc); - /// if relocation is possible, delete that vertex and insert a vertex at the new location /// + // if relocation is possible, delete that vertex and insert a vertex at the new location if (relocated > 0) { Statistic.RelocationCount++; @@ -399,16 +398,16 @@ namespace TriangleNet switch (relocated) { case 1: - //printf("Relocate: (%f,%f)\n", torg[0],torg[1]); + //printf("Relocate: (%f,%f)\n", torg[0],torg[1]); mesh.DeleteVertex(ref delotri); break; case 2: - //printf("Relocate: (%f,%f)\n", tdest[0],tdest[1]); + //printf("Relocate: (%f,%f)\n", tdest[0],tdest[1]); delotri.Lnext(); mesh.DeleteVertex(ref delotri); break; case 3: - //printf("Relocate: (%f,%f)\n", tapex[0],tapex[1]); + //printf("Relocate: (%f,%f)\n", tapex[0],tapex[1]); delotri.Lprev(); mesh.DeleteVertex(ref delotri); break; @@ -421,7 +420,7 @@ namespace TriangleNet // first find the visible region, PETAL // find the center of the circle and radius petalRadius = Math.Sqrt(shortestEdgeDist) / (2 * Math.Sin(behavior.MinAngle * Math.PI / 180.0)); - /// compute two possible centers of the petal /// + //- compute two possible centers of the petal -// // finding the center // first find the middle point of smallest edge xMidOfShortestEdge = (middleAngleCorner.x + largestAngleCorner.x) / 2.0; @@ -453,10 +452,10 @@ namespace TriangleNet xPetalCtr = xPetalCtr_2; yPetalCtr = yPetalCtr_2; } - /// find the third point of the neighbor triangle /// + // find the third point of the neighbor triangle neighborNotFound = GetNeighborsVertex(badotri, middleAngleCorner.x, middleAngleCorner.y, smallestAngleCorner.x, smallestAngleCorner.y, ref thirdPoint, ref neighborotri); - /// find the circumcenter of the neighbor triangle /// + // find the circumcenter of the neighbor triangle dxFirstSuggestion = dx; // if we cannot find any appropriate suggestion, we use circumcenter dyFirstSuggestion = dy; // if there is a neighbor triangle @@ -469,8 +468,8 @@ namespace TriangleNet neighborCircumcenter = predicates.FindCircumcenter(neighborvertex_1, neighborvertex_2, neighborvertex_3, ref xi_tmp, ref eta_tmp); - /// compute petal and Voronoi edge intersection /// - // in order to avoid degenerate cases, we need to do a vector based calculation for line + // compute petal and Voronoi edge intersection + // in order to avoid degenerate cases, we need to do a vector based calculation for line vector_x = (middleAngleCorner.y - smallestAngleCorner.y);//(-y, x) vector_y = smallestAngleCorner.x - middleAngleCorner.x; vector_x = myCircumcenter.x + vector_x; @@ -481,7 +480,7 @@ namespace TriangleNet // then this line and circle should be intersected CircleLineIntersection(myCircumcenter.x, myCircumcenter.y, vector_x, vector_y, xPetalCtr, yPetalCtr, petalRadius, ref p); - /// choose the correct intersection point /// + // choose the correct intersection point // calculate middle point of the longest edge(bisector) xMidOfLongestEdge = (middleAngleCorner.x + smallestAngleCorner.x) / 2.0; yMidOfLongestEdge = (middleAngleCorner.y + smallestAngleCorner.y) / 2.0; @@ -499,15 +498,15 @@ namespace TriangleNet inter_x = p[1]; inter_y = p[2]; } - /// check if there is a Voronoi vertex between before intersection /// + // check if there is a Voronoi vertex between before intersection // check if the voronoi vertex is between the intersection and circumcenter PointBetweenPoints(inter_x, inter_y, myCircumcenter.x, myCircumcenter.y, neighborCircumcenter.x, neighborCircumcenter.y, ref voronoiOrInter); - /// determine the point to be suggested /// + // determine the point to be suggested if (p[0] > 0.0) { // there is at least one intersection point - // if it is between circumcenter and intersection + // if it is between circumcenter and intersection // if it returns 1.0 this means we have a voronoi vertex within feasible region if (Math.Abs(voronoiOrInter[0] - 1.0) <= EPS) { @@ -530,7 +529,7 @@ namespace TriangleNet { // there is no voronoi vertex between intersection point and circumcenter if (IsBadTriangleAngle(largestAngleCorner.x, largestAngleCorner.y, middleAngleCorner.x, middleAngleCorner.y, inter_x, inter_y)) { - // if it is inside feasible region, then insert v2 + // if it is inside feasible region, then insert v2 // apply perturbation // find the distance between circumcenter and intersection point d = Math.Sqrt((inter_x - myCircumcenter.x) * (inter_x - myCircumcenter.x) + @@ -566,7 +565,7 @@ namespace TriangleNet dyFirstSuggestion = inter_y - torg.y; } } - /// if it is an acute triangle, check if it is a good enough location /// + // if it is an acute triangle, check if it is a good enough location // for acute triangle case, we need to check if it is ok to use either of them if ((smallestAngleCorner.x - myCircumcenter.x) * (smallestAngleCorner.x - myCircumcenter.x) + (smallestAngleCorner.y - myCircumcenter.y) * (smallestAngleCorner.y - myCircumcenter.y) > @@ -578,16 +577,16 @@ namespace TriangleNet // use circumcenter dxFirstSuggestion = dx; dyFirstSuggestion = dy; - }// else we stick to what we have found + }// else we stick to what we have found }// intersection point - }// if it is on the boundary, meaning no neighbor triangle in this direction, try other direction + }// if it is on the boundary, meaning no neighbor triangle in this direction, try other direction - /// DO THE SAME THING FOR THE OTHER DIRECTION /// - /// find the third point of the neighbor triangle /// + //- DO THE SAME THING FOR THE OTHER DIRECTION -// + // find the third point of the neighbor triangle neighborNotFound = GetNeighborsVertex(badotri, largestAngleCorner.x, largestAngleCorner.y, smallestAngleCorner.x, smallestAngleCorner.y, ref thirdPoint, ref neighborotri); - /// find the circumcenter of the neighbor triangle /// + // find the circumcenter of the neighbor triangle dxSecondSuggestion = dx; // if we cannot find any appropriate suggestion, we use circumcenter dySecondSuggestion = dy; // if there is a neighbor triangle @@ -600,8 +599,8 @@ namespace TriangleNet neighborCircumcenter = predicates.FindCircumcenter(neighborvertex_1, neighborvertex_2, neighborvertex_3, ref xi_tmp, ref eta_tmp); - /// compute petal and Voronoi edge intersection /// - // in order to avoid degenerate cases, we need to do a vector based calculation for line + // compute petal and Voronoi edge intersection + // in order to avoid degenerate cases, we need to do a vector based calculation for line vector_x = (largestAngleCorner.y - smallestAngleCorner.y);//(-y, x) vector_y = smallestAngleCorner.x - largestAngleCorner.x; vector_x = myCircumcenter.x + vector_x; @@ -613,7 +612,7 @@ namespace TriangleNet CircleLineIntersection(myCircumcenter.x, myCircumcenter.y, vector_x, vector_y, xPetalCtr, yPetalCtr, petalRadius, ref p); - /// choose the correct intersection point /// + // choose the correct intersection point // calcuwedgeslate middle point of the longest edge(bisector) xMidOfMiddleEdge = (largestAngleCorner.x + smallestAngleCorner.x) / 2.0; yMidOfMiddleEdge = (largestAngleCorner.y + smallestAngleCorner.y) / 2.0; @@ -633,15 +632,15 @@ namespace TriangleNet inter_y = p[2]; } - /// check if there is a Voronoi vertex between before intersection /// + // check if there is a Voronoi vertex between before intersection // check if the voronoi vertex is between the intersection and circumcenter PointBetweenPoints(inter_x, inter_y, myCircumcenter.x, myCircumcenter.y, neighborCircumcenter.x, neighborCircumcenter.y, ref voronoiOrInter); - /// determine the point to be suggested /// + // determine the point to be suggested if (p[0] > 0.0) { // there is at least one intersection point - // if it is between circumcenter and intersection + // if it is between circumcenter and intersection // if it returns 1.0 this means we have a voronoi vertex within feasible region if (Math.Abs(voronoiOrInter[0] - 1.0) <= EPS) { @@ -665,7 +664,7 @@ namespace TriangleNet { // there is no voronoi vertex between intersection point and circumcenter if (IsBadTriangleAngle(middleAngleCorner.x, middleAngleCorner.y, largestAngleCorner.x, largestAngleCorner.y, inter_x, inter_y)) { - // if it is inside feasible region, then insert v2 + // if it is inside feasible region, then insert v2 // apply perturbation // find the distance between circumcenter and intersection point d = Math.Sqrt((inter_x - myCircumcenter.x) * (inter_x - myCircumcenter.x) + @@ -701,7 +700,7 @@ namespace TriangleNet dySecondSuggestion = inter_y - torg.y; } } - /// if it is an acute triangle, check if it is a good enough location /// + // if it is an acute triangle, check if it is a good enough location // for acute triangle case, we need to check if it is ok to use either of them if ((smallestAngleCorner.x - myCircumcenter.x) * (smallestAngleCorner.x - myCircumcenter.x) + (smallestAngleCorner.y - myCircumcenter.y) * (smallestAngleCorner.y - myCircumcenter.y) > @@ -713,17 +712,17 @@ namespace TriangleNet // use circumcenter dxSecondSuggestion = dx; dySecondSuggestion = dy; - }// else we stick on what we have found + }// else we stick on what we have found } - }// if it is on the boundary, meaning no neighbor triangle in this direction, the other direction might be ok + }// if it is on the boundary, meaning no neighbor triangle in this direction, the other direction might be ok if (isObtuse) { - //obtuse: do nothing + //obtuse: do nothing dx = dxFirstSuggestion; dy = dyFirstSuggestion; } else - { // acute : consider other direction + { // acute : consider other direction if (justAcute * ((smallestAngleCorner.x - (dxSecondSuggestion + torg.x)) * (smallestAngleCorner.x - (dxSecondSuggestion + torg.x)) + (smallestAngleCorner.y - (dySecondSuggestion + torg.y)) * @@ -743,8 +742,8 @@ namespace TriangleNet } }// end if obtuse - }// end of relocation - }// end of almostGood + }// end of relocation + }// end of almostGood Point circumcenter = new Point(); @@ -771,7 +770,6 @@ namespace TriangleNet /// /// /// - /// /// /// /// @@ -789,7 +787,7 @@ namespace TriangleNet double dx, dy, dxoff, dyoff; ////////////////////////////// HALE'S VARIABLES ////////////////////////////// - // keeps the difference of coordinates edge + // keeps the difference of coordinates edge double xShortestEdge = 0, yShortestEdge = 0; // keeps the square of edge lengths @@ -800,7 +798,7 @@ namespace TriangleNet // keeps the type of orientation if the triangle int orientation = 0; - // keeps the coordinates of circumcenter of itself and neighbor triangle circumcenter + // keeps the coordinates of circumcenter of itself and neighbor triangle circumcenter Point myCircumcenter, neighborCircumcenter; // keeps if bad triangle is almost good or not @@ -821,7 +819,7 @@ namespace TriangleNet Vertex neighborvertex_1; Vertex neighborvertex_2; Vertex neighborvertex_3; - // dummy variables + // dummy variables double xi_tmp = 0, eta_tmp = 0; //vertex thirdVertex; // for petal intersection @@ -888,7 +886,7 @@ namespace TriangleNet // Don't count the above as an orientation test. Statistic.CounterClockwiseCount--; } - // calculate the circumcenter in terms of distance to origin point + // calculate the circumcenter in terms of distance to origin point dx = (yao * dodist - ydo * aodist) * denominator; dy = (xdo * aodist - xao * dodist) * denominator; // for debugging and for keeping circumcenter to use later @@ -901,12 +899,12 @@ namespace TriangleNet // serves as a conservative estimate of the insertion radius of the // circumcenter's parent. The estimate is used to ensure that // the algorithm terminates even if very small angles appear in - // the input PSLG. + // the input PSLG. // find the orientation of the triangle, basically shortest and longest edges orientation = LongestShortestEdge(aodist, dadist, dodist); //printf("org: (%f,%f), dest: (%f,%f), apex: (%f,%f)\n",torg[0],torg[1],tdest[0],tdest[1],tapex[0],tapex[1]); ///////////////////////////////////////////////////////////////////////////////////////////// - // 123: shortest: aodist // 213: shortest: dadist // 312: shortest: dodist // + // 123: shortest: aodist // 213: shortest: dadist // 312: shortest: dodist // // middle: dadist // middle: aodist // middle: aodist // // longest: dodist // longest: dodist // longest: dadist // // 132: shortest: aodist // 231: shortest: dadist // 321: shortest: dodist // @@ -917,8 +915,8 @@ namespace TriangleNet switch (orientation) { case 123: // assign necessary information - /// smallest angle corner: dest - /// largest angle corner: apex + // smallest angle corner: dest + // largest angle corner: apex xShortestEdge = xao; yShortestEdge = yao; shortestEdgeDist = aodist; @@ -931,8 +929,8 @@ namespace TriangleNet break; case 132: // assign necessary information - /// smallest angle corner: dest - /// largest angle corner: org + // smallest angle corner: dest + // largest angle corner: org xShortestEdge = xao; yShortestEdge = yao; shortestEdgeDist = aodist; @@ -945,8 +943,8 @@ namespace TriangleNet break; case 213: // assign necessary information - /// smallest angle corner: org - /// largest angle corner: apex + // smallest angle corner: org + // largest angle corner: apex xShortestEdge = xda; yShortestEdge = yda; shortestEdgeDist = dadist; @@ -958,8 +956,8 @@ namespace TriangleNet largestAngleCorner = tapex; break; case 231: // assign necessary information - /// smallest angle corner: org - /// largest angle corner: dest + // smallest angle corner: org + // largest angle corner: dest xShortestEdge = xda; yShortestEdge = yda; shortestEdgeDist = dadist; @@ -971,8 +969,8 @@ namespace TriangleNet largestAngleCorner = tdest; break; case 312: // assign necessary information - /// smallest angle corner: apex - /// largest angle corner: org + // smallest angle corner: apex + // largest angle corner: org xShortestEdge = xdo; yShortestEdge = ydo; shortestEdgeDist = dodist; @@ -985,8 +983,8 @@ namespace TriangleNet break; case 321: // assign necessary information default: // TODO: is this safe? - /// smallest angle corner: apex - /// largest angle corner: dest + // smallest angle corner: apex + // largest angle corner: dest xShortestEdge = xdo; yShortestEdge = ydo; shortestEdgeDist = dodist; @@ -998,7 +996,7 @@ namespace TriangleNet largestAngleCorner = tdest; break; - }// end of switch + }// end of switch // check for offcenter condition if (offcenter && (offconstant > 0.0)) { @@ -1010,19 +1008,19 @@ namespace TriangleNet dyoff = 0.5 * yShortestEdge + offconstant * xShortestEdge; // If the off-center is closer to destination than the // circumcenter, use the off-center instead. - /// doubleLY BAD CASE /// + // doubleLY BAD CASE if (dxoff * dxoff + dyoff * dyoff < (dx - xdo) * (dx - xdo) + (dy - ydo) * (dy - ydo)) { dx = xdo + dxoff; dy = ydo + dyoff; } - /// ALMOST GOOD CASE /// + // ALMOST GOOD CASE else { almostGood = 1; } - // destination has the smallest angle + // destination has the smallest angle } else if (orientation == 123 || orientation == 132) { @@ -1031,33 +1029,33 @@ namespace TriangleNet dyoff = 0.5 * yShortestEdge - offconstant * xShortestEdge; // If the off-center is closer to the origin than the // circumcenter, use the off-center instead. - /// doubleLY BAD CASE /// + // doubleLY BAD CASE if (dxoff * dxoff + dyoff * dyoff < dx * dx + dy * dy) { dx = dxoff; dy = dyoff; } - /// ALMOST GOOD CASE /// + // ALMOST GOOD CASE else { almostGood = 1; } - // apex has the smallest angle + // apex has the smallest angle } else - {//orientation == 312 || orientation == 321 + {//orientation == 312 || orientation == 321 // Find the position of the off-center, as described by Alper Ungor. dxoff = 0.5 * xShortestEdge - offconstant * yShortestEdge; dyoff = 0.5 * yShortestEdge + offconstant * xShortestEdge; // If the off-center is closer to the origin than the // circumcenter, use the off-center instead. - /// doubleLY BAD CASE /// + // doubleLY BAD CASE if (dxoff * dxoff + dyoff * dyoff < dx * dx + dy * dy) { dx = dxoff; dy = dyoff; } - /// ALMOST GOOD CASE /// + // ALMOST GOOD CASE else { almostGood = 1; @@ -1068,7 +1066,7 @@ namespace TriangleNet if (almostGood == 1) { - /// calculate cosine of largest angle /// + // calculate cosine of largest angle cosMaxAngle = (middleEdgeDist + shortestEdgeDist - longestEdgeDist) / (2 * Math.Sqrt(middleEdgeDist) * Math.Sqrt(shortestEdgeDist)); if (cosMaxAngle < 0.0) { @@ -1085,10 +1083,10 @@ namespace TriangleNet // nonobtuse isObtuse = false; } - /// RELOCATION (LOCAL SMOOTHING) /// - /// check for possible relocation of one of triangle's points /// + // RELOCATION (LOCAL SMOOTHING) + // check for possible relocation of one of triangle's points relocated = DoSmoothing(delotri, torg, tdest, tapex, ref newloc); - /// if relocation is possible, delete that vertex and insert a vertex at the new location /// + // if relocation is possible, delete that vertex and insert a vertex at the new location if (relocated > 0) { Statistic.RelocationCount++; @@ -1100,16 +1098,16 @@ namespace TriangleNet switch (relocated) { case 1: - //printf("Relocate: (%f,%f)\n", torg[0],torg[1]); + //printf("Relocate: (%f,%f)\n", torg[0],torg[1]); mesh.DeleteVertex(ref delotri); break; case 2: - //printf("Relocate: (%f,%f)\n", tdest[0],tdest[1]); + //printf("Relocate: (%f,%f)\n", tdest[0],tdest[1]); delotri.Lnext(); mesh.DeleteVertex(ref delotri); break; case 3: - //printf("Relocate: (%f,%f)\n", tapex[0],tapex[1]); + //printf("Relocate: (%f,%f)\n", tapex[0],tapex[1]); delotri.Lprev(); mesh.DeleteVertex(ref delotri); break; @@ -1131,7 +1129,7 @@ namespace TriangleNet minangle = minangle + 0.5; } petalRadius = Math.Sqrt(shortestEdgeDist) / (2 * Math.Sin(minangle * Math.PI / 180.0)); - /// compute two possible centers of the petal /// + // compute two possible centers of the petal // finding the center // first find the middle point of smallest edge xMidOfShortestEdge = (middleAngleCorner.x + largestAngleCorner.x) / 2.0; @@ -1162,34 +1160,34 @@ namespace TriangleNet { xPetalCtr = xPetalCtr_2; yPetalCtr = yPetalCtr_2; } - /// find the third point of the neighbor triangle /// + // find the third point of the neighbor triangle neighborNotFound_first = GetNeighborsVertex(badotri, middleAngleCorner.x, middleAngleCorner.y, smallestAngleCorner.x, smallestAngleCorner.y, ref thirdPoint, ref neighborotri); - /// find the circumcenter of the neighbor triangle /// + // find the circumcenter of the neighbor triangle dxFirstSuggestion = dx; // if we cannot find any appropriate suggestion, we use circumcenter dyFirstSuggestion = dy; - /// before checking the neighbor, find the petal and slab intersections /// + // before checking the neighbor, find the petal and slab intersections // calculate the intersection point of the petal and the slab lines - // first find the vector - // distance between xmid and petal center + // first find the vector + // distance between xmid and petal center dist = Math.Sqrt((xPetalCtr - xMidOfShortestEdge) * (xPetalCtr - xMidOfShortestEdge) + (yPetalCtr - yMidOfShortestEdge) * (yPetalCtr - yMidOfShortestEdge)); - // find the unit vector goes from mid point to petal center + // find the unit vector goes from mid point to petal center line_vector_x = (xPetalCtr - xMidOfShortestEdge) / dist; line_vector_y = (yPetalCtr - yMidOfShortestEdge) / dist; // find the third point other than p and q petal_bisector_x = xPetalCtr + line_vector_x * petalRadius; petal_bisector_y = yPetalCtr + line_vector_y * petalRadius; alpha = (2.0 * behavior.MaxAngle + minangle - 180.0) * Math.PI / 180.0; - // rotate the vector cw around the petal center + // rotate the vector cw around the petal center x_1 = petal_bisector_x * Math.Cos(alpha) + petal_bisector_y * Math.Sin(alpha) + xPetalCtr - xPetalCtr * Math.Cos(alpha) - yPetalCtr * Math.Sin(alpha); y_1 = -petal_bisector_x * Math.Sin(alpha) + petal_bisector_y * Math.Cos(alpha) + yPetalCtr + xPetalCtr * Math.Sin(alpha) - yPetalCtr * Math.Cos(alpha); - // rotate the vector ccw around the petal center + // rotate the vector ccw around the petal center x_2 = petal_bisector_x * Math.Cos(alpha) - petal_bisector_y * Math.Sin(alpha) + xPetalCtr - xPetalCtr * Math.Cos(alpha) + yPetalCtr * Math.Sin(alpha); y_2 = petal_bisector_x * Math.Sin(alpha) + petal_bisector_y * Math.Cos(alpha) + yPetalCtr - xPetalCtr * Math.Sin(alpha) - yPetalCtr * Math.Cos(alpha); // we need to find correct intersection point, since there are two possibilities // weather it is obtuse/acute the one closer to the minimum angle corner is the first direction isCorrect = ChooseCorrectPoint(x_2, y_2, middleAngleCorner.x, middleAngleCorner.y, x_1, y_1, true); - // make sure which point is the correct one to be considered + // make sure which point is the correct one to be considered if (isCorrect) { petal_slab_inter_x_first = x_1; @@ -1204,7 +1202,7 @@ namespace TriangleNet petal_slab_inter_x_second = x_1; petal_slab_inter_y_second = y_1; } - /// choose the correct intersection point /// + // choose the correct intersection point // calculate middle point of the longest edge(bisector) xMidOfLongestEdge = (middleAngleCorner.x + smallestAngleCorner.x) / 2.0; yMidOfLongestEdge = (middleAngleCorner.y + smallestAngleCorner.y) / 2.0; @@ -1218,8 +1216,8 @@ namespace TriangleNet neighborCircumcenter = predicates.FindCircumcenter(neighborvertex_1, neighborvertex_2, neighborvertex_3, ref xi_tmp, ref eta_tmp); - /// compute petal and Voronoi edge intersection /// - // in order to avoid degenerate cases, we need to do a vector based calculation for line + // compute petal and Voronoi edge intersection + // in order to avoid degenerate cases, we need to do a vector based calculation for line vector_x = (middleAngleCorner.y - smallestAngleCorner.y);//(-y, x) vector_y = smallestAngleCorner.x - middleAngleCorner.x; vector_x = myCircumcenter.x + vector_x; @@ -1249,7 +1247,7 @@ namespace TriangleNet // vector from middleAngleCorner to largestAngleCorner line_vector_x = largestAngleCorner.x - middleAngleCorner.x; line_vector_y = largestAngleCorner.y - middleAngleCorner.y; - // rotate the vector around middleAngleCorner in cw by maxangle degrees + // rotate the vector around middleAngleCorner in cw by maxangle degrees linepnt2_x = petal_slab_inter_x_first; linepnt2_y = petal_slab_inter_y_first; // now calculate the intersection of two lines @@ -1268,15 +1266,15 @@ namespace TriangleNet } //---------------------------------------------------------------------// - /// check if there is a Voronoi vertex between before intersection /// + // check if there is a Voronoi vertex between before intersection // check if the voronoi vertex is between the intersection and circumcenter PointBetweenPoints(inter_x, inter_y, myCircumcenter.x, myCircumcenter.y, neighborCircumcenter.x, neighborCircumcenter.y, ref voronoiOrInter); - /// determine the point to be suggested /// + // determine the point to be suggested if (p[0] > 0.0) { // there is at least one intersection point - // if it is between circumcenter and intersection + // if it is between circumcenter and intersection // if it returns 1.0 this means we have a voronoi vertex within feasible region if (Math.Abs(voronoiOrInter[0] - 1.0) <= EPS) { @@ -1343,7 +1341,7 @@ namespace TriangleNet } else { - /// NOW APPLY A BREADTH-FIRST SEARCH ON THE VORONOI + // NOW APPLY A BREADTH-FIRST SEARCH ON THE VORONOI if (IsBadTriangleAngle(middleAngleCorner.x, middleAngleCorner.y, largestAngleCorner.x, largestAngleCorner.y, neighborCircumcenter.x, neighborCircumcenter.y)) { // go back to circumcenter @@ -1382,7 +1380,7 @@ namespace TriangleNet dyFirstSuggestion = petal_slab_inter_y_first - torg.y; } else - { // slab intersection point is further away + { // slab intersection point is further away if (IsBadTriangleAngle(largestAngleCorner.x, largestAngleCorner.y, middleAngleCorner.x, middleAngleCorner.y, line_inter_x, line_inter_y)) { // apply perturbation @@ -1424,8 +1422,8 @@ namespace TriangleNet { if (IsBadTriangleAngle(largestAngleCorner.x, largestAngleCorner.y, middleAngleCorner.x, middleAngleCorner.y, inter_x, inter_y)) { - //printf("testtriangle returned false! bad triangle\n"); - // if it is inside feasible region, then insert v2 + //printf("testtriangle returned false! bad triangle\n"); + // if it is inside feasible region, then insert v2 // apply perturbation // find the distance between circumcenter and intersection point d = Math.Sqrt((inter_x - myCircumcenter.x) * (inter_x - myCircumcenter.x) + @@ -1460,7 +1458,7 @@ namespace TriangleNet } } } - /// if it is an acute triangle, check if it is a good enough location /// + // if it is an acute triangle, check if it is a good enough location // for acute triangle case, we need to check if it is ok to use either of them if ((smallestAngleCorner.x - myCircumcenter.x) * (smallestAngleCorner.x - myCircumcenter.x) + (smallestAngleCorner.y - myCircumcenter.y) * (smallestAngleCorner.y - myCircumcenter.y) > @@ -1473,20 +1471,20 @@ namespace TriangleNet dxFirstSuggestion = dx; dyFirstSuggestion = dy; - }// else we stick to what we have found + }// else we stick to what we have found }// intersection point - }// if it is on the boundary, meaning no neighbor triangle in this direction, try other direction + }// if it is on the boundary, meaning no neighbor triangle in this direction, try other direction - /// DO THE SAME THING FOR THE OTHER DIRECTION /// - /// find the third point of the neighbor triangle /// + // DO THE SAME THING FOR THE OTHER DIRECTION + // find the third point of the neighbor triangle neighborNotFound_second = GetNeighborsVertex(badotri, largestAngleCorner.x, largestAngleCorner.y, smallestAngleCorner.x, smallestAngleCorner.y, ref thirdPoint, ref neighborotri); - /// find the circumcenter of the neighbor triangle /// + // find the circumcenter of the neighbor triangle dxSecondSuggestion = dx; // if we cannot find any appropriate suggestion, we use circumcenter dySecondSuggestion = dy; - /// choose the correct intersection point /// + // choose the correct intersection point // calculate middle point of the longest edge(bisector) xMidOfMiddleEdge = (largestAngleCorner.x + smallestAngleCorner.x) / 2.0; yMidOfMiddleEdge = (largestAngleCorner.y + smallestAngleCorner.y) / 2.0; @@ -1500,8 +1498,8 @@ namespace TriangleNet neighborCircumcenter = predicates.FindCircumcenter(neighborvertex_1, neighborvertex_2, neighborvertex_3, ref xi_tmp, ref eta_tmp); - /// compute petal and Voronoi edge intersection /// - // in order to avoid degenerate cases, we need to do a vector based calculation for line + // compute petal and Voronoi edge intersection + // in order to avoid degenerate cases, we need to do a vector based calculation for line vector_x = (largestAngleCorner.y - smallestAngleCorner.y);//(-y, x) vector_y = smallestAngleCorner.x - largestAngleCorner.x; vector_x = myCircumcenter.x + vector_x; @@ -1528,14 +1526,14 @@ namespace TriangleNet inter_x = p[1]; inter_y = p[2]; } - //----------------------hale new second direction:for slab calculation---------------// + //----------------------hale new second direction:for slab calculation---------------// // calculate the intersection of angle lines and Voronoi linepnt1_x = largestAngleCorner.x; linepnt1_y = largestAngleCorner.y; - // vector from largestAngleCorner to middleAngleCorner + // vector from largestAngleCorner to middleAngleCorner line_vector_x = middleAngleCorner.x - largestAngleCorner.x; line_vector_y = middleAngleCorner.y - largestAngleCorner.y; - // rotate the vector around largestAngleCorner in ccw by maxangle degrees + // rotate the vector around largestAngleCorner in ccw by maxangle degrees linepnt2_x = petal_slab_inter_x_second; linepnt2_y = petal_slab_inter_y_second; // now calculate the intersection of two lines @@ -1553,14 +1551,14 @@ namespace TriangleNet //printf("(%.14f,%.14f) (%.14f,%.14f) (%.14f,%.14f) (%.14f,%.14f)\n",myCircumcenter.x,myCircumcenter.y,vector_x,vector_y,linepnt1_x,linepnt1_y,linepnt2_x,linepnt2_y); } //---------------------------------------------------------------------// - /// check if there is a Voronoi vertex between before intersection /// + // check if there is a Voronoi vertex between before intersection // check if the voronoi vertex is between the intersection and circumcenter PointBetweenPoints(inter_x, inter_y, myCircumcenter.x, myCircumcenter.y, neighborCircumcenter.x, neighborCircumcenter.y, ref voronoiOrInter); - /// determine the point to be suggested /// + // determine the point to be suggested if (p[0] > 0.0) - { // there is at least one intersection point - // if it is between circumcenter and intersection + { // there is at least one intersection point + // if it is between circumcenter and intersection // if it returns 1.0 this means we have a voronoi vertex within feasible region if (Math.Abs(voronoiOrInter[0] - 1.0) <= EPS) { @@ -1571,7 +1569,7 @@ namespace TriangleNet { // check if we can go further by picking the slab line and petal intersection // calculate the distance to the smallest angle corner - // + // if (((smallestAngleCorner.x - petal_slab_inter_x_second) * (smallestAngleCorner.x - petal_slab_inter_x_second) + (smallestAngleCorner.y - petal_slab_inter_y_second) * (smallestAngleCorner.y - petal_slab_inter_y_second) > lengthConst * ((smallestAngleCorner.x - line_inter_x) * @@ -1586,7 +1584,7 @@ namespace TriangleNet dySecondSuggestion = petal_slab_inter_y_second - torg.y; } else - { // slab intersection point is further away + { // slab intersection point is further away if (IsBadTriangleAngle(middleAngleCorner.x, middleAngleCorner.y, largestAngleCorner.x, largestAngleCorner.y, line_inter_x, line_inter_y)) { // apply perturbation @@ -1707,7 +1705,7 @@ namespace TriangleNet { if (IsBadTriangleAngle(middleAngleCorner.x, middleAngleCorner.y, largestAngleCorner.x, largestAngleCorner.y, inter_x, inter_y)) { - // if it is inside feasible region, then insert v2 + // if it is inside feasible region, then insert v2 // apply perturbation // find the distance between circumcenter and intersection point d = Math.Sqrt((inter_x - myCircumcenter.x) * (inter_x - myCircumcenter.x) + @@ -1743,7 +1741,7 @@ namespace TriangleNet } } - /// if it is an acute triangle, check if it is a good enough location /// + // if it is an acute triangle, check if it is a good enough location // for acute triangle case, we need to check if it is ok to use either of them if ((smallestAngleCorner.x - myCircumcenter.x) * (smallestAngleCorner.x - myCircumcenter.x) + (smallestAngleCorner.y - myCircumcenter.y) * (smallestAngleCorner.y - myCircumcenter.y) > @@ -1756,14 +1754,14 @@ namespace TriangleNet dxSecondSuggestion = dx; dySecondSuggestion = dy; - }// else we stick on what we have found + }// else we stick on what we have found } - }// if it is on the boundary, meaning no neighbor triangle in this direction, the other direction might be ok + }// if it is on the boundary, meaning no neighbor triangle in this direction, the other direction might be ok if (isObtuse) { if (neighborNotFound_first && neighborNotFound_second) { - //obtuse: check if the other direction works + //obtuse: check if the other direction works if (justAcute * ((smallestAngleCorner.x - (xMidOfMiddleEdge)) * (smallestAngleCorner.x - (xMidOfMiddleEdge)) + (smallestAngleCorner.y - (yMidOfMiddleEdge)) * @@ -1784,7 +1782,7 @@ namespace TriangleNet } else if (neighborNotFound_first) { - //obtuse: check if the other direction works + //obtuse: check if the other direction works if (justAcute * ((smallestAngleCorner.x - (dxSecondSuggestion + torg.x)) * (smallestAngleCorner.x - (dxSecondSuggestion + torg.x)) + (smallestAngleCorner.y - (dySecondSuggestion + torg.y)) * @@ -1805,7 +1803,7 @@ namespace TriangleNet } else if (neighborNotFound_second) { - //obtuse: check if the other direction works + //obtuse: check if the other direction works if (justAcute * ((smallestAngleCorner.x - (xMidOfMiddleEdge)) * (smallestAngleCorner.x - (xMidOfMiddleEdge)) + (smallestAngleCorner.y - (yMidOfMiddleEdge)) * @@ -1826,7 +1824,7 @@ namespace TriangleNet } else { - //obtuse: check if the other direction works + //obtuse: check if the other direction works if (justAcute * ((smallestAngleCorner.x - (dxSecondSuggestion + torg.x)) * (smallestAngleCorner.x - (dxSecondSuggestion + torg.x)) + (smallestAngleCorner.y - (dySecondSuggestion + torg.y)) * @@ -1850,7 +1848,7 @@ namespace TriangleNet { // acute : consider other direction if (neighborNotFound_first && neighborNotFound_second) { - //obtuse: check if the other direction works + //obtuse: check if the other direction works if (justAcute * ((smallestAngleCorner.x - (xMidOfMiddleEdge)) * (smallestAngleCorner.x - (xMidOfMiddleEdge)) + (smallestAngleCorner.y - (yMidOfMiddleEdge)) * @@ -1871,7 +1869,7 @@ namespace TriangleNet } else if (neighborNotFound_first) { - //obtuse: check if the other direction works + //obtuse: check if the other direction works if (justAcute * ((smallestAngleCorner.x - (dxSecondSuggestion + torg.x)) * (smallestAngleCorner.x - (dxSecondSuggestion + torg.x)) + (smallestAngleCorner.y - (dySecondSuggestion + torg.y)) * @@ -1892,7 +1890,7 @@ namespace TriangleNet } else if (neighborNotFound_second) { - //obtuse: check if the other direction works + //obtuse: check if the other direction works if (justAcute * ((smallestAngleCorner.x - (xMidOfMiddleEdge)) * (smallestAngleCorner.x - (xMidOfMiddleEdge)) + (smallestAngleCorner.y - (yMidOfMiddleEdge)) * @@ -1913,7 +1911,7 @@ namespace TriangleNet } else { - //obtuse: check if the other direction works + //obtuse: check if the other direction works if (justAcute * ((smallestAngleCorner.x - (dxSecondSuggestion + torg.x)) * (smallestAngleCorner.x - (dxSecondSuggestion + torg.x)) + (smallestAngleCorner.y - (dySecondSuggestion + torg.y)) * @@ -1934,8 +1932,8 @@ namespace TriangleNet } }// end if obtuse - }// end of relocation - }// end of almostGood + }// end of relocation + }// end of almostGood Point circumcenter = new Point(); @@ -1957,7 +1955,7 @@ namespace TriangleNet /// /// Given square of edge lengths of a triangle, - // determine its orientation + /// determine its orientation /// /// /// @@ -1965,11 +1963,11 @@ namespace TriangleNet /// Returns a number indicating an orientation. private int LongestShortestEdge(double aodist, double dadist, double dodist) { - // 123: shortest: aodist // 213: shortest: dadist // 312: shortest: dodist - // middle: dadist // middle: aodist // middle: aodist + // 123: shortest: aodist // 213: shortest: dadist // 312: shortest: dodist + // middle: dadist // middle: aodist // middle: aodist // longest: dodist // longest: dodist // longest: dadist - // 132: shortest: aodist // 231: shortest: dadist // 321: shortest: dodist - // middle: dodist // middle: dodist // middle: dadist + // 132: shortest: aodist // 231: shortest: dadist // 321: shortest: dodist + // middle: dodist // middle: dodist // middle: dadist // longest: dadist // longest: aodist // longest: aodist int max = 0, min = 0, mid = 0, minMidMax; @@ -1978,12 +1976,12 @@ namespace TriangleNet min = 3; // apex is the smallest angle, dodist is the longest edge if (aodist < dadist) { - max = 2; // dadist is the longest edge + max = 2; // dadist is the longest edge mid = 1; // aodist is the middle longest edge } else { - max = 1; // aodist is the longest edge + max = 1; // aodist is the longest edge mid = 2; // dadist is the middle longest edge } } @@ -1992,12 +1990,12 @@ namespace TriangleNet min = 1; // dest is the smallest angle, aodist is the biggest edge if (dodist < dadist) { - max = 2; // dadist is the longest edge + max = 2; // dadist is the longest edge mid = 3; // dodist is the middle longest edge } else { - max = 3; // dodist is the longest edge + max = 3; // dodist is the longest edge mid = 2; // dadist is the middle longest edge } } @@ -2006,12 +2004,12 @@ namespace TriangleNet min = 2; // origin is the smallest angle, dadist is the biggest edge if (aodist < dodist) { - max = 3; // dodist is the longest edge + max = 3; // dodist is the longest edge mid = 1; // aodist is the middle longest edge } else { - max = 1; // aodist is the longest edge + max = 1; // aodist is the longest edge mid = 3; // dodist is the middle longest edge } } @@ -2036,7 +2034,7 @@ namespace TriangleNet int numpoints_p = 0;// keeps the number of points in a star of point p, q, r int numpoints_q = 0; int numpoints_r = 0; - //int i; + //int i; double[] possibilities = new double[6];//there can be more than one possibilities int num_pos = 0; // number of possibilities int flag1 = 0, flag2 = 0, flag3 = 0; @@ -2054,11 +2052,11 @@ namespace TriangleNet // p1[0] = points_p[0]; p1[1] = points_p[1]; // p2[0] = points_p[2]; p2[1] = points_p[3]; // p3[0] = points_p[4]; p3[1] = points_p[5]; - // v1 = (vertex)p1; v2 = (vertex)p2; v3 = (vertex)p3; + // v1 = (vertex)p1; v2 = (vertex)p2; v3 = (vertex)p3; // if(counterclockwise(m,b,v1,v2,v3) < 0){ // // reverse the order to ccw // for(i = 0; i < numpoints_p/2; i++){ - // temp[0] = points_p[2*i]; + // temp[0] = points_p[2*i]; // temp[1] = points_p[2*i+1]; // points_p[2*i] = points_p[2*(numpoints_p-1)-2*i]; // points_p[2*i+1] = points_p[2*(numpoints_p-1)+1-2*i]; @@ -2082,7 +2080,7 @@ namespace TriangleNet newLocFound = GetWedgeIntersection(numpoints_p, points_p, ref newloc); } //printf("call petal intersection for p\n"); - // make sure the relocated point is a free vertex + // make sure the relocated point is a free vertex if (newLocFound) { possibilities[0] = newloc[0];// something found @@ -2092,7 +2090,7 @@ namespace TriangleNet } } - //********************* TRY TO RELOCATE POINT "q" *************** + //********************* TRY TO RELOCATE POINT "q" *************** // get the surrounding points of q, so this gives us the triangles numpoints_q = GetStarPoints(badotri, torg, tdest, tapex, 2, ref points_q); @@ -2103,7 +2101,7 @@ namespace TriangleNet // if(counterclockwise(m,b,v1,v2,v3) < 0){ // // reverse the order to ccw // for(i = 0; i < numpoints_q/2; i++){ - // temp[0] = points_q[2*i]; + // temp[0] = points_q[2*i]; // temp[1] = points_q[2*i+1]; // points_q[2*i] = points_q[2*(numpoints_q-1)-2*i]; // points_q[2*i+1] = points_q[2*(numpoints_q-1)+1-2*i]; @@ -2126,9 +2124,9 @@ namespace TriangleNet { newLocFound = GetWedgeIntersection(numpoints_q, points_q, ref newloc); } - //printf("call petal intersection for q\n"); + //printf("call petal intersection for q\n"); - // make sure the relocated point is a free vertex + // make sure the relocated point is a free vertex if (newLocFound) { possibilities[2] = newloc[0];// something found @@ -2139,7 +2137,7 @@ namespace TriangleNet } - //********************* TRY TO RELOCATE POINT "q" *************** + //********************* TRY TO RELOCATE POINT "q" *************** // get the surrounding points of r, so this gives us the triangles numpoints_r = GetStarPoints(badotri, torg, tdest, tapex, 3, ref points_r); // check if the points in counterclockwise order @@ -2149,7 +2147,7 @@ namespace TriangleNet // if(counterclockwise(m,b,v1,v2,v3) < 0){ // // reverse the order to ccw // for(i = 0; i < numpoints_r/2; i++){ - // temp[0] = points_r[2*i]; + // temp[0] = points_r[2*i]; // temp[1] = points_r[2*i+1]; // points_r[2*i] = points_r[2*(numpoints_r-1)-2*i]; // points_r[2*i+1] = points_r[2*(numpoints_r-1)+1-2*i]; @@ -2176,7 +2174,7 @@ namespace TriangleNet //printf("call petal intersection for r\n"); - // make sure the relocated point is a free vertex + // make sure the relocated point is a free vertex if (newLocFound) { possibilities[4] = newloc[0];// something found @@ -2186,7 +2184,7 @@ namespace TriangleNet } } //printf("numpossibilities %d\n",num_pos); - //////////// AFTER FINISH CHECKING EVERY POSSIBILITY, CHOOSE ANY OF THE AVAILABLE ONE ////////////////////// + //////////// AFTER FINISH CHECKING EVERY POSSIBILITY, CHOOSE ANY OF THE AVAILABLE ONE ////////////////////// if (num_pos > 0) { if (flag1 > 0) @@ -2240,7 +2238,7 @@ namespace TriangleNet double first_x = 0, first_y = 0; // keeps the first point to be considered double second_x = 0, second_y = 0; // for determining the edge we will begin double third_x = 0, third_y = 0; // termination - double[] returnPoint = new double[2]; // for keeping the returned point + double[] returnPoint = new double[2]; // for keeping the returned point int numvertices = 0; // for keeping number of surrounding vertices // first determine which point to be used to find its neighbor triangles @@ -2279,7 +2277,7 @@ namespace TriangleNet numvertices++; // assign as dummy value returnPoint[0] = second_x; returnPoint[1] = second_y; - // until we reach the third point of the beginning triangle + // until we reach the third point of the beginning triangle do { // find the neighbor's third point where it is incident to given edge @@ -2287,7 +2285,7 @@ namespace TriangleNet { // go to next triangle tempotri = neighotri; - // now the second point is the neighbor's third vertex + // now the second point is the neighbor's third vertex second_x = returnPoint[0]; second_y = returnPoint[1]; @@ -2342,19 +2340,19 @@ namespace TriangleNet // used for finding neighbor triangle int firstVertexMatched = 0, secondVertexMatched = 0; // to find the correct neighbor //triangle ptr; // Temporary variable used by sym() - //int i; // index variable + //int i; // index variable // find neighbors // Check each of the triangle's three neighbors to find the correct one for (badotri.orient = 0; badotri.orient < 3; badotri.orient++) { // Find the neighbor. badotri.Sym(ref neighbor); - // check if it is the one we are looking for by checking the corners + // check if it is the one we are looking for by checking the corners // first check if the neighbor is nonexistent, since it can be on the border if (neighbor.tri.id != Mesh.DUMMY) { // then check if two wanted corners are also in this triangle - // take the vertices of the candidate neighbor + // take the vertices of the candidate neighbor neighborvertex_1 = neighbor.Org(); neighborvertex_2 = neighbor.Dest(); neighborvertex_3 = neighbor.Apex(); @@ -2387,7 +2385,7 @@ namespace TriangleNet { firstVertexMatched = 13; // neighbor's 3rd vertex is matched to first vertex - }/*else{ + }/*else{ // none of them matched } // end of first vertex matching */ @@ -2406,7 +2404,7 @@ namespace TriangleNet (Math.Abs(second_y - neighborvertex_3.y) < EPS)) { secondVertexMatched = 23; // neighbor's 3rd vertex is matched to second vertex - }/*else{ + }/*else{ // none of them matched } // end of second vertex matching*/ @@ -2496,7 +2494,7 @@ namespace TriangleNet double d01;//, d12 - //double petalx0, petaly0, petalr0, petalx1, petaly1, petalr1; + //double petalx0, petaly0, petalr0, petalx1, petaly1, petalr1; //double p[5]; @@ -2557,7 +2555,7 @@ namespace TriangleNet d01 = Math.Sqrt(x01 * x01 + y01 * y01); // find the petal of each edge 01; - // printf("PETAL CONSTANT (%.12f, %.12f)\n", + // printf("PETAL CONSTANT (%.12f, %.12f)\n", // b.petalcenterconstant, b.petalradiusconstant ); // printf("PETAL DIFFS (%.6f, %.6f, %.4f)\n", x01, y01, d01); @@ -2569,11 +2567,11 @@ namespace TriangleNet petalr[numpoints + i / 2] = petalr[i / 2]; //printf("PETAL POINTS #%d (%.12f, %.12f) R= %.12f\n", i/2, petalx[i/2],petaly[i/2], petalr[i/2]); - /// FIRST FIND THE HALF-PLANE POINTS FOR EACH PETAL + // FIRST FIND THE HALF-PLANE POINTS FOR EACH PETAL xmid = (x0 + x1) / 2.0; // mid point of pq ymid = (y0 + y1) / 2.0; - // distance between xmid and petal center + // distance between xmid and petal center dist = Math.Sqrt((petalx[i / 2] - xmid) * (petalx[i / 2] - xmid) + (petaly[i / 2] - ymid) * (petaly[i / 2] - ymid)); // find the unit vector goes from mid point to petal center ux = (petalx[i / 2] - xmid) / dist; @@ -2581,30 +2579,30 @@ namespace TriangleNet // find the third point other than p and q x3 = petalx[i / 2] + ux * petalr[i / 2]; y3 = petaly[i / 2] + uy * petalr[i / 2]; - /// FIND THE LINE POINTS BY THE ROTATION MATRIX + // FIND THE LINE POINTS BY THE ROTATION MATRIX // cw rotation matrix [cosX sinX; -sinX cosX] // cw rotation about (x,y) [ux*cosX + uy*sinX + x - x*cosX - y*sinX; -ux*sinX + uy*cosX + y + x*sinX - y*cosX] // ccw rotation matrix [cosX -sinX; sinX cosX] // ccw rotation about (x,y) [ux*cosX - uy*sinX + x - x*cosX + y*sinX; ux*sinX + uy*cosX + y - x*sinX - y*cosX] - /// LINE #1: (x1,y1) & (x_1,y_1) + // LINE #1: (x1,y1) & (x_1,y_1) // vector from p to q ux = x1 - x0; uy = y1 - y0; // rotate the vector around p = (x0,y0) in ccw by alpha degrees x_1 = x1 * Math.Cos(alpha) - y1 * Math.Sin(alpha) + x0 - x0 * Math.Cos(alpha) + y0 * Math.Sin(alpha); y_1 = x1 * Math.Sin(alpha) + y1 * Math.Cos(alpha) + y0 - x0 * Math.Sin(alpha) - y0 * Math.Cos(alpha); - // add these to wedges list as lines in order + // add these to wedges list as lines in order wedges[i * 16] = x0; wedges[i * 16 + 1] = y0; wedges[i * 16 + 2] = x_1; wedges[i * 16 + 3] = y_1; //printf("LINE #1 (%.12f, %.12f) (%.12f, %.12f)\n", x0,y0,x_1,y_1); - /// LINE #2: (x2,y2) & (x_2,y_2) + // LINE #2: (x2,y2) & (x_2,y_2) // vector from p to q ux = x0 - x1; uy = y0 - y1; // rotate the vector around q = (x1,y1) in cw by alpha degrees x_2 = x0 * Math.Cos(alpha) + y0 * Math.Sin(alpha) + x1 - x1 * Math.Cos(alpha) - y1 * Math.Sin(alpha); y_2 = -x0 * Math.Sin(alpha) + y0 * Math.Cos(alpha) + y1 + x1 * Math.Sin(alpha) - y1 * Math.Cos(alpha); - // add these to wedges list as lines in order + // add these to wedges list as lines in order wedges[i * 16 + 4] = x_2; wedges[i * 16 + 5] = y_2; wedges[i * 16 + 6] = x1; wedges[i * 16 + 7] = y1; //printf("LINE #2 (%.12f, %.12f) (%.12f, %.12f)\n", x_2,y_2,x1,y1); @@ -2612,34 +2610,34 @@ namespace TriangleNet ux = x3 - petalx[i / 2]; uy = y3 - petaly[i / 2]; tempx = x3; tempy = y3; - /// LINE #3, #4, #5: (x3,y3) & (x_3,y_3) + // LINE #3, #4, #5: (x3,y3) & (x_3,y_3) for (j = 1; j < 4; j++) { - // rotate the vector around (petalx,petaly) in cw by (60 - alpha)*j degrees + // rotate the vector around (petalx,petaly) in cw by (60 - alpha)*j degrees x_3 = x3 * Math.Cos((Math.PI / 3.0 - alpha) * j) + y3 * Math.Sin((Math.PI / 3.0 - alpha) * j) + petalx[i / 2] - petalx[i / 2] * Math.Cos((Math.PI / 3.0 - alpha) * j) - petaly[i / 2] * Math.Sin((Math.PI / 3.0 - alpha) * j); y_3 = -x3 * Math.Sin((Math.PI / 3.0 - alpha) * j) + y3 * Math.Cos((Math.PI / 3.0 - alpha) * j) + petaly[i / 2] + petalx[i / 2] * Math.Sin((Math.PI / 3.0 - alpha) * j) - petaly[i / 2] * Math.Cos((Math.PI / 3.0 - alpha) * j); - // add these to wedges list as lines in order + // add these to wedges list as lines in order wedges[i * 16 + 8 + 4 * (j - 1)] = x_3; wedges[i * 16 + 9 + 4 * (j - 1)] = y_3; wedges[i * 16 + 10 + 4 * (j - 1)] = tempx; wedges[i * 16 + 11 + 4 * (j - 1)] = tempy; tempx = x_3; tempy = y_3; } tempx = x3; tempy = y3; - /// LINE #6, #7, #8: (x3,y3) & (x_4,y_4) + // LINE #6, #7, #8: (x3,y3) & (x_4,y_4) for (j = 1; j < 4; j++) { // rotate the vector around (petalx,petaly) in ccw by (60 - alpha)*j degrees x_4 = x3 * Math.Cos((Math.PI / 3.0 - alpha) * j) - y3 * Math.Sin((Math.PI / 3.0 - alpha) * j) + petalx[i / 2] - petalx[i / 2] * Math.Cos((Math.PI / 3.0 - alpha) * j) + petaly[i / 2] * Math.Sin((Math.PI / 3.0 - alpha) * j); y_4 = x3 * Math.Sin((Math.PI / 3.0 - alpha) * j) + y3 * Math.Cos((Math.PI / 3.0 - alpha) * j) + petaly[i / 2] - petalx[i / 2] * Math.Sin((Math.PI / 3.0 - alpha) * j) - petaly[i / 2] * Math.Cos((Math.PI / 3.0 - alpha) * j); - // add these to wedges list as lines in order + // add these to wedges list as lines in order wedges[i * 16 + 20 + 4 * (j - 1)] = tempx; wedges[i * 16 + 21 + 4 * (j - 1)] = tempy; wedges[i * 16 + 22 + 4 * (j - 1)] = x_4; wedges[i * 16 + 23 + 4 * (j - 1)] = y_4; tempx = x_4; tempy = y_4; } - //printf("LINE #3 (%.12f, %.12f) (%.12f, %.12f)\n", x_3,y_3,x3,y3); + //printf("LINE #3 (%.12f, %.12f) (%.12f, %.12f)\n", x_3,y_3,x3,y3); //printf("LINE #4 (%.12f, %.12f) (%.12f, %.12f)\n", x3,y3,x_4,y_4); - /// IF IT IS THE FIRST ONE, FIND THE CONVEX POLYGON + // IF IT IS THE FIRST ONE, FIND THE CONVEX POLYGON if (i == 0) { // line1 & line2: p1 @@ -2670,7 +2668,7 @@ namespace TriangleNet x1 = x2; y1 = y2; } - /// HALF PLANE INTERSECTION: START SPLITTING THE INITIAL POLYGON TO FIND FEASIBLE REGION + // HALF PLANE INTERSECTION: START SPLITTING THE INITIAL POLYGON TO FIND FEASIBLE REGION if (numpoints != 0) { // first intersect the opposite located ones @@ -2702,7 +2700,7 @@ namespace TriangleNet flag = (flag + 1) % 2; count++; } - /// IF THERE IS A FEASIBLE INTERSECTION POLYGON, FIND ITS CENTROID AS THE NEW LOCATION + // IF THERE IS A FEASIBLE INTERSECTION POLYGON, FIND ITS CENTROID AS THE NEW LOCATION FindPolyCentroid(numpolypoints, initialConvexPoly, ref newloc); if (behavior.fixedArea) @@ -2710,15 +2708,15 @@ namespace TriangleNet // numBadTriangle = 0; // for(j= 0; j < numpoints *2-2; j = j+2){ // if(testTriangleAngleArea(m,b,&newloc[0],&newloc[1], &points[j], &points[j+1], &points[j+2], &points[j+3] )){ - // numBadTriangle++; + // numBadTriangle++; // } // } // if(testTriangleAngleArea(m,b, &newloc[0],&newloc[1], &points[0], &points[1], &points[numpoints*2-2], &points[numpoints*2-1] )){ // numBadTriangle++; // } - // + // // if (numBadTriangle == 0) { - // + // // return 1; // } } @@ -2727,7 +2725,7 @@ namespace TriangleNet //printf("yes, we found a feasible region num: %d newloc (%.12f,%.12f)\n", numpolypoints, newloc[0], newloc[1]); // for(i = 0; i < 2*numpolypoints; i = i+2){ // printf("point %d) (%.12f,%.12f)\n", i/2, initialConvexPoly[i], initialConvexPoly[i+1]); - // } + // } // printf("numpoints %d\n",numpoints); return true; } @@ -2758,7 +2756,7 @@ namespace TriangleNet double d01;//, d12 - //double petalx0, petaly1, petaly0, petalr0, petalx1, petalr1; + //double petalx0, petaly1, petaly0, petalr0, petalx1, petalr1; //double p[5]; @@ -2836,7 +2834,7 @@ namespace TriangleNet d01 = Math.Sqrt(x01 * x01 + y01 * y01); // find the petal of each edge 01; - // printf("PETAL CONSTANT (%.12f, %.12f)\n", + // printf("PETAL CONSTANT (%.12f, %.12f)\n", // b.petalcenterconstant, b.petalradiusconstant ); // printf("PETAL DIFFS (%.6f, %.6f, %.4f)\n", x01, y01, d01); //printf("i:%d numpoints:%d\n", i, numpoints); @@ -2848,11 +2846,11 @@ namespace TriangleNet petalr[numpoints + i / 2] = petalr[i / 2]; //printf("PETAL POINTS #%d (%.12f, %.12f) R= %.12f\n", i/2, petalx[i/2],petaly[i/2], petalr[i/2]); - /// FIRST FIND THE HALF-PLANE POINTS FOR EACH PETAL + // FIRST FIND THE HALF-PLANE POINTS FOR EACH PETAL xmid = (x0 + x1) / 2.0; // mid point of pq ymid = (y0 + y1) / 2.0; - // distance between xmid and petal center + // distance between xmid and petal center dist = Math.Sqrt((petalx[i / 2] - xmid) * (petalx[i / 2] - xmid) + (petaly[i / 2] - ymid) * (petaly[i / 2] - ymid)); // find the unit vector goes from mid point to petal center ux = (petalx[i / 2] - xmid) / dist; @@ -2860,30 +2858,30 @@ namespace TriangleNet // find the third point other than p and q x3 = petalx[i / 2] + ux * petalr[i / 2]; y3 = petaly[i / 2] + uy * petalr[i / 2]; - /// FIND THE LINE POINTS BY THE ROTATION MATRIX + // FIND THE LINE POINTS BY THE ROTATION MATRIX // cw rotation matrix [cosX sinX; -sinX cosX] // cw rotation about (x,y) [ux*cosX + uy*sinX + x - x*cosX - y*sinX; -ux*sinX + uy*cosX + y + x*sinX - y*cosX] // ccw rotation matrix [cosX -sinX; sinX cosX] // ccw rotation about (x,y) [ux*cosX - uy*sinX + x - x*cosX + y*sinX; ux*sinX + uy*cosX + y - x*sinX - y*cosX] - /// LINE #1: (x1,y1) & (x_1,y_1) + // LINE #1: (x1,y1) & (x_1,y_1) // vector from p to q ux = x1 - x0; uy = y1 - y0; // rotate the vector around p = (x0,y0) in ccw by alpha degrees x_1 = x1 * cosAlpha - y1 * sinAlpha + x0 - x0 * cosAlpha + y0 * sinAlpha; y_1 = x1 * sinAlpha + y1 * cosAlpha + y0 - x0 * sinAlpha - y0 * cosAlpha; - // add these to wedges list as lines in order + // add these to wedges list as lines in order wedges[i * 20] = x0; wedges[i * 20 + 1] = y0; wedges[i * 20 + 2] = x_1; wedges[i * 20 + 3] = y_1; //printf("LINE #1 (%.12f, %.12f) (%.12f, %.12f)\n", x0,y0,x_1,y_1); - /// LINE #2: (x2,y2) & (x_2,y_2) + // LINE #2: (x2,y2) & (x_2,y_2) // vector from q to p ux = x0 - x1; uy = y0 - y1; // rotate the vector around q = (x1,y1) in cw by alpha degrees x_2 = x0 * cosAlpha + y0 * sinAlpha + x1 - x1 * cosAlpha - y1 * sinAlpha; y_2 = -x0 * sinAlpha + y0 * cosAlpha + y1 + x1 * sinAlpha - y1 * cosAlpha; - // add these to wedges list as lines in order + // add these to wedges list as lines in order wedges[i * 20 + 4] = x_2; wedges[i * 20 + 5] = y_2; wedges[i * 20 + 6] = x1; wedges[i * 20 + 7] = y1; //printf("LINE #2 (%.12f, %.12f) (%.12f, %.12f)\n", x_2,y_2,x1,y1); @@ -2892,7 +2890,7 @@ namespace TriangleNet uy = y3 - petaly[i / 2]; tempx = x3; tempy = y3; - /// DETERMINE HOW MANY POINTS TO USE ACCORDING TO THE MINANGLE-MAXANGLE COMBINATION + // DETERMINE HOW MANY POINTS TO USE ACCORDING TO THE MINANGLE-MAXANGLE COMBINATION // petal center angle alpha = (2.0 * behavior.MaxAngle + behavior.MinAngle - 180.0); if (alpha <= 0.0) @@ -2928,20 +2926,20 @@ namespace TriangleNet line789 = 4.0; } alpha = alpha * Math.PI / 180.0; - /// LINE #3, #4, #5: (x3,y3) & (x_3,y_3) + // LINE #3, #4, #5: (x3,y3) & (x_3,y_3) for (j = 1; j < line345; j++) { if (line345 == 1) continue; - // rotate the vector around (petalx,petaly) in cw by (alpha/3.0)*j degrees + // rotate the vector around (petalx,petaly) in cw by (alpha/3.0)*j degrees x_3 = x3 * Math.Cos((alpha / (line345 - 1.0)) * j) + y3 * Math.Sin(((alpha / (line345 - 1.0)) * j)) + petalx[i / 2] - petalx[i / 2] * Math.Cos(((alpha / (line345 - 1.0)) * j)) - petaly[i / 2] * Math.Sin(((alpha / (line345 - 1.0)) * j)); y_3 = -x3 * Math.Sin(((alpha / (line345 - 1.0)) * j)) + y3 * Math.Cos(((alpha / (line345 - 1.0)) * j)) + petaly[i / 2] + petalx[i / 2] * Math.Sin(((alpha / (line345 - 1.0)) * j)) - petaly[i / 2] * Math.Cos(((alpha / (line345 - 1.0)) * j)); - // add these to wedges list as lines in order + // add these to wedges list as lines in order wedges[i * 20 + 8 + 4 * (j - 1)] = x_3; wedges[i * 20 + 9 + 4 * (j - 1)] = y_3; wedges[i * 20 + 10 + 4 * (j - 1)] = tempx; wedges[i * 20 + 11 + 4 * (j - 1)] = tempy; tempx = x_3; tempy = y_3; } - /// LINE #6: (x2,y2) & (x_3,y_3) + // LINE #6: (x2,y2) & (x_3,y_3) // vector from q to p ux = x0 - x1; uy = y0 - y1; @@ -2952,7 +2950,7 @@ namespace TriangleNet wedges[i * 20 + 22] = x_5; wedges[i * 20 + 23] = y_5; tempx = x3; tempy = y3; - /// LINE #7, #8, #9: (x3,y3) & (x_4,y_4) + // LINE #7, #8, #9: (x3,y3) & (x_4,y_4) for (j = 1; j < line789; j++) { if (line789 == 1) @@ -2961,12 +2959,12 @@ namespace TriangleNet x_4 = x3 * Math.Cos((alpha / (line789 - 1.0)) * j) - y3 * Math.Sin((alpha / (line789 - 1.0)) * j) + petalx[i / 2] - petalx[i / 2] * Math.Cos((alpha / (line789 - 1.0)) * j) + petaly[i / 2] * Math.Sin((alpha / (line789 - 1.0)) * j); y_4 = x3 * Math.Sin((alpha / (line789 - 1.0)) * j) + y3 * Math.Cos((alpha / (line789 - 1.0)) * j) + petaly[i / 2] - petalx[i / 2] * Math.Sin((alpha / (line789 - 1.0)) * j) - petaly[i / 2] * Math.Cos((alpha / (line789 - 1.0)) * j); - // add these to wedges list as lines in order + // add these to wedges list as lines in order wedges[i * 20 + 24 + 4 * (j - 1)] = tempx; wedges[i * 20 + 25 + 4 * (j - 1)] = tempy; wedges[i * 20 + 26 + 4 * (j - 1)] = x_4; wedges[i * 20 + 27 + 4 * (j - 1)] = y_4; tempx = x_4; tempy = y_4; } - /// LINE #10: (x1,y1) & (x_3,y_3) + // LINE #10: (x1,y1) & (x_3,y_3) // vector from p to q ux = x1 - x0; uy = y1 - y0; @@ -2977,7 +2975,7 @@ namespace TriangleNet wedges[i * 20 + 38] = x0; wedges[i * 20 + 39] = y0; //printf("LINE #1 (%.12f, %.12f) (%.12f, %.12f)\n", x0,y0,x_1,y_1); - /// IF IT IS THE FIRST ONE, FIND THE CONVEX POLYGON + // IF IT IS THE FIRST ONE, FIND THE CONVEX POLYGON if (i == 0) { switch (howManyPoints) @@ -3084,7 +3082,7 @@ namespace TriangleNet x0 = x1; y0 = y1; x1 = x2; y1 = y2; } - /// HALF PLANE INTERSECTION: START SPLITTING THE INITIAL POLYGON TO FIND FEASIBLE REGION + // HALF PLANE INTERSECTION: START SPLITTING THE INITIAL POLYGON TO FIND FEASIBLE REGION if (numpoints != 0) { // first intersect the opposite located ones @@ -3108,8 +3106,8 @@ namespace TriangleNet { continue; } - // printf("%d 1 INITIAL POLY [%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;]\n",num, initialConvexPoly[0],initialConvexPoly[1],initialConvexPoly[2],initialConvexPoly[3],initialConvexPoly[4],initialConvexPoly[5],initialConvexPoly[6],initialConvexPoly[7],initialConvexPoly[8],initialConvexPoly[9],initialConvexPoly[10],initialConvexPoly[11],initialConvexPoly[12],initialConvexPoly[13],initialConvexPoly[14],initialConvexPoly[15],initialConvexPoly[16],initialConvexPoly[17],initialConvexPoly[18],initialConvexPoly[19]); - // printf("line (%f, %f) (%f, %f)\n",wedges[40*s+j],wedges[40*s+1+j], wedges[40*s+2+j], wedges[40*s+3+j]); + // printf("%d 1 INITIAL POLY [%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;]\n",num, initialConvexPoly[0],initialConvexPoly[1],initialConvexPoly[2],initialConvexPoly[3],initialConvexPoly[4],initialConvexPoly[5],initialConvexPoly[6],initialConvexPoly[7],initialConvexPoly[8],initialConvexPoly[9],initialConvexPoly[10],initialConvexPoly[11],initialConvexPoly[12],initialConvexPoly[13],initialConvexPoly[14],initialConvexPoly[15],initialConvexPoly[16],initialConvexPoly[17],initialConvexPoly[18],initialConvexPoly[19]); + // printf("line (%f, %f) (%f, %f)\n",wedges[40*s+j],wedges[40*s+1+j], wedges[40*s+2+j], wedges[40*s+3+j]); numpolypoints = HalfPlaneIntersection(num, ref initialConvexPoly, wedges[40 * s + j], wedges[40 * s + 1 + j], wedges[40 * s + 2 + j], wedges[40 * s + 3 + j]); if (numpolypoints == 0) @@ -3118,7 +3116,7 @@ namespace TriangleNet num = numpolypoints; } count++; - //printf("yes here\n"); + //printf("yes here\n"); while (count < numpoints - 1) { for (j = 0; j < 40; j = j + 4) @@ -3136,7 +3134,7 @@ namespace TriangleNet { continue; } - ////printf("%d 2 INITIAL POLY [%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;]\n",numpolypoints, initialConvexPoly[0],initialConvexPoly[1],initialConvexPoly[2],initialConvexPoly[3],initialConvexPoly[4],initialConvexPoly[5],initialConvexPoly[6],initialConvexPoly[7],initialConvexPoly[8],initialConvexPoly[9],initialConvexPoly[10],initialConvexPoly[11],initialConvexPoly[12],initialConvexPoly[13],initialConvexPoly[14],initialConvexPoly[15],initialConvexPoly[16],initialConvexPoly[17],initialConvexPoly[18],initialConvexPoly[19]); + ////printf("%d 2 INITIAL POLY [%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;%.12f, %.12f;]\n",numpolypoints, initialConvexPoly[0],initialConvexPoly[1],initialConvexPoly[2],initialConvexPoly[3],initialConvexPoly[4],initialConvexPoly[5],initialConvexPoly[6],initialConvexPoly[7],initialConvexPoly[8],initialConvexPoly[9],initialConvexPoly[10],initialConvexPoly[11],initialConvexPoly[12],initialConvexPoly[13],initialConvexPoly[14],initialConvexPoly[15],initialConvexPoly[16],initialConvexPoly[17],initialConvexPoly[18],initialConvexPoly[19]); //printf("line (%.20f, %.20f) (%.20f, %.20f)\n", wedges[40 * (i + s * flag) + j], wedges[40 * (i + s * flag) + 1 + j], wedges[40 * (i + s * flag) + 2 + j], wedges[40 * (i + s * flag) + 3 + j]); numpolypoints = HalfPlaneIntersection(num, ref initialConvexPoly, wedges[40 * (i + s * flag) + j], wedges[40 * (i + s * flag) + 1 + j], wedges[40 * (i + s * flag) + 2 + j], wedges[40 * (i + s * flag) + 3 + j]); @@ -3149,7 +3147,7 @@ namespace TriangleNet flag = (flag + 1) % 2; count++; } - /// IF THERE IS A FEASIBLE INTERSECTION POLYGON, FIND ITS CENTROID AS THE NEW LOCATION + // IF THERE IS A FEASIBLE INTERSECTION POLYGON, FIND ITS CENTROID AS THE NEW LOCATION FindPolyCentroid(numpolypoints, initialConvexPoly, ref newloc); if (behavior.MaxAngle != 0.0) @@ -3221,7 +3219,7 @@ namespace TriangleNet //printf("yes, we found a feasible region num: %d newloc (%.12f,%.12f)\n", numpolypoints, newloc[0], newloc[1]); // for(i = 0; i < 2*numpolypoints; i = i+2){ // printf("point %d) (%.12f,%.12f)\n", i/2, initialConvexPoly[i], initialConvexPoly[i+1]); - // } + // } // printf("numpoints %d\n",numpoints); return true; } @@ -3268,7 +3266,7 @@ namespace TriangleNet } /// - /// Given three coordinates of a polygon, tests to see if it satisfies the minimum + /// Given three coordinates of a polygon, tests to see if it satisfies the minimum /// angle condition for relocation. /// /// @@ -3277,7 +3275,7 @@ namespace TriangleNet /// /// /// - /// Returns true, if it is a BAD polygon corner, returns false if it is a GOOD + /// Returns true, if it is a BAD polygon corner, returns false if it is a GOOD /// polygon corner private bool IsBadPolygonAngle(double x1, double y1, double x2, double y2, double x3, double y3) @@ -3301,9 +3299,9 @@ namespace TriangleNet dist23 = dx23 * dx23 + dy23 * dy23; dist31 = dx31 * dx31 + dy31 * dy31; - /// calculate cosine of largest angle /// + // calculate cosine of largest angle cosAngle = (dist12 + dist23 - dist31) / (2 * Math.Sqrt(dist12) * Math.Sqrt(dist23)); - // Check whether the angle is smaller than permitted which is 2*minangle!!! + // Check whether the angle is smaller than permitted which is 2*minangle!!! //printf("angle: %f 2*minangle = %f\n",acos(cosAngle)*180/PI, 2*acos(Math.Sqrt(b.goodangle))*180/PI); if (Math.Acos(cosAngle) < 2 * Math.Acos(Math.Sqrt(behavior.goodAngle))) { @@ -3326,7 +3324,7 @@ namespace TriangleNet /// /// The intersection point. /// - // referenced to: http://local.wasp.uwa.edu.au/~pbourke/geometry/ + /// referenced to: http://local.wasp.uwa.edu.au/~pbourke/geometry/ /// private void LineLineIntersection( double x1, double y1, @@ -3335,7 +3333,7 @@ namespace TriangleNet double x4, double y4, ref double[] p) { // x1,y1 P1 coordinates (point of line 1) - // x2,y2 P2 coordinates (point of line 1) + // x2,y2 P2 coordinates (point of line 1) // x3,y3 P3 coordinates (point of line 2) // x4,y4 P4 coordinates (point of line 2) // p[1],p[2] intersection coordinates @@ -3370,8 +3368,8 @@ namespace TriangleNet } /// - /// Returns the convex polygon which is the intersection of the given convex - /// polygon with the halfplane on the left side (regarding the directional vector) + /// Returns the convex polygon which is the intersection of the given convex + /// polygon with the halfplane on the left side (regarding the directional vector) /// of the given line. /// /// @@ -3409,7 +3407,7 @@ namespace TriangleNet min = double.MaxValue; max = double.MinValue; // compute the minimum and maximum of the - // third coordinate of the cross product + // third coordinate of the cross product for (j = 1; j <= 2 * polys[i][0] - 1; j = j + 2) { z = dx * (polys[i][j + 1] - y1) - dy * (polys[i][j] - x1); @@ -3443,7 +3441,7 @@ namespace TriangleNet } /// - /// Splits a convex polygons into one or two polygons through the intersection + /// Splits a convex polygons into one or two polygons through the intersection /// with the given line (regarding the directional vector of the given line). /// /// @@ -3470,7 +3468,7 @@ namespace TriangleNet int numpolys; int i; double compConst = 0.000000000001; - // for debugging + // for debugging int case1 = 0, case2 = 0, case3 = 0, case31 = 0, case32 = 0, case33 = 0, case311 = 0, case3111 = 0; // intersect all edges of poly with line for (i = 0; i < 2 * numvertices; i = i + 2) @@ -3610,7 +3608,7 @@ namespace TriangleNet // printf("case1: %d\ncase2: %d\ncase3: %d\ncase31: %d case311: %d case3111: %d\ncase32: %d\ncase33: %d\n", case1, case2, case3, case31, case311, case3111, case32, case33); // printf("numvertices %d\n=============\n", numvertices); - // if there is something wrong with the intersection, just ignore this one + // if there is something wrong with the intersection, just ignore this one numpolys = 3; } else @@ -3619,7 +3617,7 @@ namespace TriangleNet numpolys = (state == 0) ? 1 : 2; poly1[0] = poly1counter; poly2[0] = poly2counter; - // convert the first convex polygon + // convert the first convex polygon polys[0] = poly1; // convert the second convex polygon if (state == 2) @@ -3631,7 +3629,7 @@ namespace TriangleNet } /// - /// Determines on which side (relative to the direction) of the given line and the + /// Determines on which side (relative to the direction) of the given line and the /// point lies (regarding the directional vector) of the given line. /// /// @@ -3695,7 +3693,7 @@ namespace TriangleNet double x4, double y4, ref double[] p) { // x1,y1 P1 coordinates (point of line) - // x2,y2 P2 coordinates (point of line) + // x2,y2 P2 coordinates (point of line) // x3,y3 P3 coordinates (point of line segment) // x4,y4 P4 coordinates (point of line segment) // p[1],p[2] intersection coordinates @@ -3731,8 +3729,8 @@ namespace TriangleNet u_a = u_a / denom; // printf("u_b %.20f\n", u_b); if (u_b < -compConst || u_b > 1.0 + compConst) - { // check if it is on the line segment - // printf("line (%.20f, %.20f) (%.20f, %.20f) line seg (%.20f, %.20f) (%.20f, %.20f) \n",x1, y1 ,x2, y2 ,x3, y3 , x4, y4); + { // check if it is on the line segment + // printf("line (%.20f, %.20f) (%.20f, %.20f) line seg (%.20f, %.20f) (%.20f, %.20f) \n",x1, y1 ,x2, y2 ,x3, y3 , x4, y4); p[0] = 0.0; } else @@ -3746,7 +3744,7 @@ namespace TriangleNet } /// - /// Returns the centroid of a given polygon + /// Returns the centroid of a given polygon /// /// /// @@ -3769,7 +3767,7 @@ namespace TriangleNet } /// - /// Given two points representing a line and a radius together with a center point + /// Given two points representing a line and a radius together with a center point /// representing a circle, returns the intersection points. /// /// @@ -3790,7 +3788,7 @@ namespace TriangleNet { // x1,y1 P1 coordinates [point of line] // x2,y2 P2 coordinates [point of line] - // x3,y3, r P3 coordinates(circle center) and radius [circle] + // x3,y3, r P3 coordinates(circle center) and radius [circle] // p[1],p[2]; p[3],p[4] intersection coordinates // // This function returns a pointer array which first index indicates @@ -3888,13 +3886,13 @@ namespace TriangleNet p = false; // means take the other point } } - /// HANDLE RIGHT TRIANGLE CASE!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // HANDLE RIGHT TRIANGLE CASE!!!!!!!!!!!!!!!!!!!!!!!!!!!! return p; } /// - /// This function returns a pointer array which first index indicates the whether + /// This function returns a pointer array which first index indicates the whether /// the point is in between the other points, followed by coordinate pairs. /// /// P1 coordinates [point of line] (point on Voronoi edge - intersection) @@ -3926,7 +3924,7 @@ namespace TriangleNet } /// - /// Given three coordinates of a triangle, tests a triangle to see if it satisfies + /// Given three coordinates of a triangle, tests a triangle to see if it satisfies /// the minimum and/or maximum angle condition. /// /// @@ -3943,7 +3941,7 @@ namespace TriangleNet double dxod2, dyod2, dxda2, dyda2, dxao2, dyao2; double apexlen, orglen, destlen; - double angle; // in order to check minimum angle condition + double angle; // in order to check minimum angle condition double maxangle; // in order to check minimum angle condition // calculate the side lengths @@ -4015,7 +4013,7 @@ namespace TriangleNet } /// - /// Given the triangulation, and a vertex returns the minimum distance to the + /// Given the triangulation, and a vertex returns the minimum distance to the /// vertices of the triangle where the given vertex located. /// /// @@ -4034,7 +4032,7 @@ namespace TriangleNet // printf("newvertex %f,%f\n", newvertex[0], newvertex[1]); // Find the location of the vertex to be inserted. Check if a good - // starting triangle has already been provided by the caller. + // starting triangle has already been provided by the caller. // Find a boundary triangle. //horiz.tri = m.dummytri; //horiz.orient = 0; diff --git a/src/Triangle/RobustPredicates.cs b/src/Triangle/RobustPredicates.cs index 16e0d73..336d66a 100644 --- a/src/Triangle/RobustPredicates.cs +++ b/src/Triangle/RobustPredicates.cs @@ -121,22 +121,15 @@ namespace TriangleNet #endregion + /// + /// Initializes a new instance of the class. + /// public RobustPredicates() { AllocateWorkspace(); } - /// - /// Check, if the three points appear in counterclockwise order. The result is - /// also a rough approximation of twice the signed area of the triangle defined - /// by the three points. - /// - /// Point a. - /// Point b. - /// Point c. - /// Return a positive value if the points pa, pb, and pc occur in - /// counterclockwise order; a negative value if they occur in clockwise order; - /// and zero if they are collinear. + /// public double CounterClockwise(Point pa, Point pb, Point pc) { double detleft, detright, det; @@ -190,18 +183,7 @@ namespace TriangleNet return CounterClockwiseAdapt(pa, pb, pc, detsum); } - /// - /// Check if the point pd lies inside the circle passing through pa, pb, and pc. The - /// points pa, pb, and pc must be in counterclockwise order, or the sign of the result - /// will be reversed. - /// - /// Point a. - /// Point b. - /// Point c. - /// Point d. - /// Return a positive value if the point pd lies inside the circle passing through - /// pa, pb, and pc; a negative value if it lies outside; and zero if the four points - /// are cocircular. + /// public double InCircle(Point pa, Point pb, Point pc, Point pd) { double adx, bdx, cdx, ady, bdy, cdy; @@ -273,16 +255,7 @@ namespace TriangleNet return InCircle(pa, pb, pc, pd); } - /// - /// Find the circumcenter of a triangle. - /// - /// Triangle point. - /// Triangle point. - /// Triangle point. - /// Relative coordinate of new location. - /// Relative coordinate of new location. - /// Off-center constant. - /// Coordinates of the circumcenter (or off-center) + /// public Point FindCircumcenter(Point org, Point dest, Point apex, ref double xi, ref double eta, double offconstant) { @@ -384,24 +357,7 @@ namespace TriangleNet return new Point(org.x + dx, org.y + dy); } - /// - /// Find the circumcenter of a triangle. - /// - /// Triangle point. - /// Triangle point. - /// Triangle point. - /// Relative coordinate of new location. - /// Relative coordinate of new location. - /// Coordinates of the circumcenter - /// - /// The result is returned both in terms of x-y coordinates and xi-eta - /// (barycentric) coordinates. The xi-eta coordinate system is defined in - /// terms of the triangle: the origin of the triangle is the origin of the - /// coordinate system; the destination of the triangle is one unit along the - /// xi axis; and the apex of the triangle is one unit along the eta axis. - /// This procedure also returns the square of the length of the triangle's - /// shortest edge. - /// + /// public Point FindCircumcenter(Point org, Point dest, Point apex, ref double xi, ref double eta) { diff --git a/src/Triangle/Tools/AdjacencyMatrix.cs b/src/Triangle/Tools/AdjacencyMatrix.cs index 8900ffc..2e4e349 100644 --- a/src/Triangle/Tools/AdjacencyMatrix.cs +++ b/src/Triangle/Tools/AdjacencyMatrix.cs @@ -46,6 +46,10 @@ namespace TriangleNet.Tools get { return irow; } } + /// + /// Initializes a new instance of the class. + /// + /// The mesh. public AdjacencyMatrix(Mesh mesh) { this.N = mesh.vertices.Count; @@ -60,6 +64,12 @@ namespace TriangleNet.Tools SortIndices(); } + /// + /// Initializes a new instance of the class. + /// + /// The column pointers. + /// The row indices. + /// public AdjacencyMatrix(int[] pcol, int[] irow) { this.N = pcol.Length - 1; @@ -265,6 +275,9 @@ namespace TriangleNet.Tools return list; } + /// + /// Sort indices. + /// public void SortIndices() { int k1, k2, n = N; diff --git a/src/Triangle/Tools/CuthillMcKee.cs b/src/Triangle/Tools/CuthillMcKee.cs index 9e5cd96..d8c9473 100644 --- a/src/Triangle/Tools/CuthillMcKee.cs +++ b/src/Triangle/Tools/CuthillMcKee.cs @@ -34,7 +34,7 @@ namespace TriangleNet.Tools /// /// Gets the permutation vector for the Reverse Cuthill-McKee numbering. /// - /// The mesh. + /// The adjacency matrix. /// Permutation vector. public int[] Renumber(AdjacencyMatrix matrix) { @@ -89,11 +89,11 @@ namespace TriangleNet.Tools int iccsze = 0; int level_num = 0; - /// Index vector for a level structure. The level structure is stored in the - /// currently unused spaces in the permutation vector PERM. + // Index vector for a level structure. The level structure is stored in the + // currently unused spaces in the permutation vector PERM. int[] level_row = new int[n + 1]; - /// Marks variables that have been numbered. + // Marks variables that have been numbered. int[] mask = new int[n]; for (i = 0; i < n; i++) @@ -139,8 +139,8 @@ namespace TriangleNet.Tools /// nonzero input mask values are considered by the routine. The nodes numbered by RCM will have /// their mask values set to zero. /// Output, int PERM(NODE_NUM), the RCM ordering. + /// Internal array offset. /// Output, int ICCSZE, the size of the connected component that has been numbered. - /// the number of nodes. /// /// The connected component is specified by a node ROOT and a mask. /// The numbering starts at the root node. @@ -169,8 +169,8 @@ namespace TriangleNet.Tools // Number of nodes in the mesh. int n = matrix.N; - /// Workspace, int DEG[NODE_NUM], a temporary vector used to hold - /// the degree of the nodes in the section graph specified by mask and root. + // Workspace, int DEG[NODE_NUM], a temporary vector used to hold + // the degree of the nodes in the section graph specified by mask and root. int[] deg = new int[n]; // Find the degrees of the nodes in the component specified by MASK and ROOT. @@ -269,7 +269,7 @@ namespace TriangleNet.Tools /// containing the level structure found. /// Output, int LEVEL(NODE_NUM), the level structure array pair /// containing the level structure found. - /// the number of nodes. + /// Internal array offset. /// /// The diameter of a graph is the maximum distance (number of edges) /// between any two nodes of the graph. @@ -409,7 +409,7 @@ namespace TriangleNet.Tools /// in level 1. The neighbors of ROOT are in level 2, and so on. /// Output, int LEVEL_ROW[NODE_NUM+1], the rooted level structure. /// Output, int LEVEL[NODE_NUM], the rooted level structure. - /// the number of nodes. + /// Internal array offset. /// /// Only nodes for which MASK is nonzero will be considered. /// @@ -502,7 +502,7 @@ namespace TriangleNet.Tools /// Output, int ICCSIZE, the number of nodes in the connected component. /// Output, int LS[NODE_NUM], stores in entries 1 through ICCSIZE the nodes in the /// connected component, starting with ROOT, and proceeding by levels. - /// the number of nodes. + /// Internal array offset. /// /// The connected component is specified by MASK and ROOT. /// Nodes for which MASK is zero are ignored. @@ -621,7 +621,6 @@ namespace TriangleNet.Tools /// /// Produces the inverse of a given permutation. /// - /// Number of items permuted. /// PERM[N], a permutation. /// The inverse permutation. int[] PermInverse(int[] perm) @@ -642,6 +641,7 @@ namespace TriangleNet.Tools /// Reverses the elements of an integer vector. /// /// number of entries in the array. + /// Internal array offset. /// the array to be reversed. /// /// Input: diff --git a/src/Triangle/Tools/Interpolation.cs b/src/Triangle/Tools/Interpolation.cs index 227e020..99e9747 100644 --- a/src/Triangle/Tools/Interpolation.cs +++ b/src/Triangle/Tools/Interpolation.cs @@ -9,6 +9,9 @@ namespace TriangleNet.Tools { using TriangleNet.Geometry; + /// + /// Interpolation helper. + /// public static class Interpolation { /// diff --git a/src/Triangle/Tools/IntersectionHelper.cs b/src/Triangle/Tools/IntersectionHelper.cs index 2257005..0310481 100644 --- a/src/Triangle/Tools/IntersectionHelper.cs +++ b/src/Triangle/Tools/IntersectionHelper.cs @@ -9,6 +9,9 @@ namespace TriangleNet.Tools using System; using TriangleNet.Geometry; + /// + /// Segment intersection helper. + /// public static class IntersectionHelper { /// diff --git a/src/Triangle/Tools/PolygonValidator.cs b/src/Triangle/Tools/PolygonValidator.cs index 765c68d..cc6e7a9 100644 --- a/src/Triangle/Tools/PolygonValidator.cs +++ b/src/Triangle/Tools/PolygonValidator.cs @@ -10,6 +10,9 @@ namespace TriangleNet.Tools using System.Collections.Generic; using TriangleNet.Geometry; + /// + /// Polygon validation helper. + /// public static class PolygonValidator { /// diff --git a/src/Triangle/Tools/QualityMeasure.cs b/src/Triangle/Tools/QualityMeasure.cs index e98a901..d79a979 100644 --- a/src/Triangle/Tools/QualityMeasure.cs +++ b/src/Triangle/Tools/QualityMeasure.cs @@ -59,6 +59,9 @@ namespace TriangleNet.Tools Mesh mesh; + /// + /// Initializes a new instance of the class. + /// public QualityMeasure() { areaMeasure = new AreaMeasure(); @@ -158,6 +161,9 @@ namespace TriangleNet.Tools #endregion + /// + /// Update all quality measures. + /// public void Update(Mesh mesh) { this.mesh = mesh; diff --git a/src/Triangle/Tools/Statistic.cs b/src/Triangle/Tools/Statistic.cs index 77497d1..642ceb1 100644 --- a/src/Triangle/Tools/Statistic.cs +++ b/src/Triangle/Tools/Statistic.cs @@ -22,12 +22,20 @@ namespace TriangleNet.Tools /// Number of incircle tests performed. /// public static long InCircleCount = 0; + + /// + /// Number of adaptive incircle tests performed. + /// public static long InCircleAdaptCount = 0; /// /// Number of counterclockwise tests performed. /// public static long CounterClockwiseCount = 0; + + /// + /// Number of adaptive counterclockwise tests performed. + /// public static long CounterClockwiseAdaptCount = 0; /// @@ -201,6 +209,8 @@ namespace TriangleNet.Tools /// Update statistics about the quality of the mesh. /// /// + /// Number of degrees to sample + /// (currently fixed to 60 = sample every 3 degrees). public void Update(Mesh mesh, int sampleDegrees) { Point[] p = new Point[3]; diff --git a/src/Triangle/Tools/TriangleQuadTree.cs b/src/Triangle/Tools/TriangleQuadTree.cs index 9956f24..8c14f31 100644 --- a/src/Triangle/Tools/TriangleQuadTree.cs +++ b/src/Triangle/Tools/TriangleQuadTree.cs @@ -50,6 +50,12 @@ namespace TriangleNet.Tools root.CreateSubRegion(++currentDepth); } + /// + /// Query the quadtree a given point. + /// + /// The x coordinate. + /// The y coordinate. + /// public ITriangle Query(double x, double y) { var point = new Point(x, y); diff --git a/src/Triangle/Topology/DCEL/DcelMesh.cs b/src/Triangle/Topology/DCEL/DcelMesh.cs index c0359bd..3cbff97 100644 --- a/src/Triangle/Topology/DCEL/DcelMesh.cs +++ b/src/Triangle/Topology/DCEL/DcelMesh.cs @@ -9,10 +9,18 @@ namespace TriangleNet.Topology.DCEL using System.Collections.Generic; using TriangleNet.Geometry; + /// + /// DCEL mesh. + /// public class DcelMesh { + /// List of vertices. protected List vertices; + + /// List of half-edges. protected List edges; + + /// List of faces. protected List faces; /// @@ -24,7 +32,7 @@ namespace TriangleNet.Topology.DCEL } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// If false, lists will not be initialized. protected DcelMesh(bool initialize) diff --git a/src/Triangle/Topology/DCEL/Face.cs b/src/Triangle/Topology/DCEL/Face.cs index df6c87a..c0c2e7e 100644 --- a/src/Triangle/Topology/DCEL/Face.cs +++ b/src/Triangle/Topology/DCEL/Face.cs @@ -10,12 +10,15 @@ namespace TriangleNet.Topology.DCEL using TriangleNet.Geometry; /// - /// A face of DCEL mesh. + /// A face of the DCEL datastructure. /// public class Face { #region Static initialization of "Outer Space" face + /// + /// A face representing "outer space". + /// public static readonly Face Empty; static Face() @@ -105,6 +108,7 @@ namespace TriangleNet.Topology.DCEL } while (edge.ID != first); } + /// public override string ToString() { return string.Format("F-ID {0}", id); diff --git a/src/Triangle/Topology/DCEL/HalfEdge.cs b/src/Triangle/Topology/DCEL/HalfEdge.cs index e77863c..cbf536d 100644 --- a/src/Triangle/Topology/DCEL/HalfEdge.cs +++ b/src/Triangle/Topology/DCEL/HalfEdge.cs @@ -6,6 +6,9 @@ namespace TriangleNet.Topology.DCEL { + /// + /// A half-edge of the DCEL datastructure. + /// public class HalfEdge { internal int id; @@ -25,6 +28,9 @@ namespace TriangleNet.Topology.DCEL set { id = value; } } + /// + /// Gets or sets a boundary marker. + /// public int Boundary { get { return mark; } @@ -93,6 +99,7 @@ namespace TriangleNet.Topology.DCEL } } + /// public override string ToString() { return string.Format("HE-ID {0} (Origin = VID-{1})", id, origin.id); diff --git a/src/Triangle/Topology/DCEL/Vertex.cs b/src/Triangle/Topology/DCEL/Vertex.cs index f66b628..1239f6d 100644 --- a/src/Triangle/Topology/DCEL/Vertex.cs +++ b/src/Triangle/Topology/DCEL/Vertex.cs @@ -8,6 +8,9 @@ namespace TriangleNet.Topology.DCEL { using System.Collections.Generic; + /// + /// A vertex of the DCEL datastructure. + /// public class Vertex : TriangleNet.Geometry.Point { internal HalfEdge leaving; @@ -60,6 +63,7 @@ namespace TriangleNet.Topology.DCEL } while (edge.ID != first); } + /// public override string ToString() { return string.Format("V-ID {0}", base.id); diff --git a/src/Triangle/Topology/Osub.cs b/src/Triangle/Topology/Osub.cs index d3a2aef..7f401bb 100644 --- a/src/Triangle/Topology/Osub.cs +++ b/src/Triangle/Topology/Osub.cs @@ -23,11 +23,12 @@ namespace TriangleNet.Topology internal SubSegment seg; internal int orient; // Ranges from 0 to 1. - public SubSegment Segment - { - get { return seg; } - } + /// + /// Gets the subsegment. + /// + public SubSegment Segment => seg; + /// public override string ToString() { if (seg == null) diff --git a/src/Triangle/Topology/Otri.cs b/src/Triangle/Topology/Otri.cs index d3feeab..e230389 100644 --- a/src/Triangle/Topology/Otri.cs +++ b/src/Triangle/Topology/Otri.cs @@ -23,12 +23,16 @@ namespace TriangleNet.Topology internal Triangle tri; internal int orient; // Ranges from 0 to 2. + /// + /// Gets or sets the triangle. + /// public Triangle Triangle { get { return tri; } set { tri = value; } } + /// public override string ToString() { if (tri == null) @@ -77,6 +81,7 @@ namespace TriangleNet.Topology /// /// Find the abutting triangle; same edge. [sym(abc) -> ba*] /// + /// /// Note that the edge direction is necessarily reversed, because the handle specified /// by an oriented triangle is directed counterclockwise around the triangle. /// diff --git a/src/Triangle/Topology/SubSegment.cs b/src/Triangle/Topology/SubSegment.cs index 4c936c7..e370155 100644 --- a/src/Triangle/Topology/SubSegment.cs +++ b/src/Triangle/Topology/SubSegment.cs @@ -23,6 +23,9 @@ namespace TriangleNet.Topology internal Otri[] triangles; internal int boundary; + /// + /// Initializes a new instance of the class. + /// public SubSegment() { // Four NULL vertices. @@ -83,11 +86,13 @@ namespace TriangleNet.Topology return triangles[index].tri.hash == Mesh.DUMMY ? null : triangles[index].tri; } + /// public override int GetHashCode() { return this.hash; } + /// public override string ToString() { return String.Format("SID {0}", hash); diff --git a/src/Triangle/Topology/Triangle.cs b/src/Triangle/Topology/Triangle.cs index 5981663..d73d01f 100644 --- a/src/Triangle/Topology/Triangle.cs +++ b/src/Triangle/Topology/Triangle.cs @@ -77,11 +77,18 @@ namespace TriangleNet.Topology /// /// Gets the specified corners vertex. /// + /// The corner index (0, 1 or 2). + /// public Vertex GetVertex(int index) { return this.vertices[index]; // TODO: Check range? } + /// + /// Gets the specified corners vertex id. + /// + /// The corner index (0, 1 or 2). + /// public int GetVertexID(int index) { return this.vertices[index].id; @@ -115,11 +122,13 @@ namespace TriangleNet.Topology #endregion + /// public override int GetHashCode() { return this.hash; } + /// public override string ToString() { return String.Format("TID {0}", hash); diff --git a/src/Triangle/TriangleLocator.cs b/src/Triangle/TriangleLocator.cs index b59a936..ec6f807 100644 --- a/src/Triangle/TriangleLocator.cs +++ b/src/Triangle/TriangleLocator.cs @@ -32,12 +32,21 @@ namespace TriangleNet // Pointer to a recently visited triangle. Improves point location if // proximate vertices are inserted sequentially. internal Otri recenttri; - + + /// + /// Initializes a new instance of the class. + /// + /// The mesh. public TriangleLocator(Mesh mesh) : this(mesh, RobustPredicates.Default) { } + /// + /// Initializes a new instance of the class. + /// + /// The mesh. + /// The predicates. public TriangleLocator(Mesh mesh, IPredicates predicates) { this.mesh = mesh; @@ -55,7 +64,8 @@ namespace TriangleNet otri.Copy(ref recenttri); } - public void Reset() + // TODO: Remove unused method. + internal void Reset() { sampler.Reset(); recenttri.tri = null; // No triangle has been visited yet. diff --git a/src/Triangle/TrianglePool.cs b/src/Triangle/TrianglePool.cs index 04cac3d..8b7f1ef 100644 --- a/src/Triangle/TrianglePool.cs +++ b/src/Triangle/TrianglePool.cs @@ -10,6 +10,9 @@ namespace TriangleNet using System.Collections.Generic; using TriangleNet.Topology; + /// + /// Pool datastructure storing triangles of a . + /// public class TrianglePool : ICollection { // Determines the size of each block in the pool. @@ -32,6 +35,9 @@ namespace TriangleNet /// public int Capacity => size; + /// + /// Initializes a new instance of the class. + /// public TrianglePool() { size = 0; @@ -97,6 +103,9 @@ namespace TriangleNet return triangle; } + /// + /// Release triangle (making it a free triangle). + /// public void Release(Triangle triangle) { stack.Push(triangle); @@ -172,11 +181,17 @@ namespace TriangleNet } } + /// + /// Not supported for this . + /// public void Add(Triangle item) { - throw new NotImplementedException(); + throw new NotSupportedException(); } + /// + /// Clear the pool. + /// public void Clear() { stack.Clear(); @@ -199,6 +214,7 @@ namespace TriangleNet size = count = 0; } + /// public bool Contains(Triangle item) { int i = item.hash; @@ -211,6 +227,7 @@ namespace TriangleNet return pool[i / BLOCKSIZE][i % BLOCKSIZE].hash >= 0; } + /// public void CopyTo(Triangle[] array, int index) { var enumerator = GetEnumerator(); @@ -222,21 +239,19 @@ namespace TriangleNet } } - public int Count - { - get { return count - stack.Count; } - } + /// + public int Count => count - stack.Count; - public bool IsReadOnly - { - get { return true; } - } + /// + public bool IsReadOnly => true; + /// public bool Remove(Triangle item) { throw new NotImplementedException(); } + /// public IEnumerator GetEnumerator() { return new Enumerator(this); diff --git a/src/Triangle/Voronoi/BoundedVoronoi.cs b/src/Triangle/Voronoi/BoundedVoronoi.cs index 6f271bc..d82bc1e 100644 --- a/src/Triangle/Voronoi/BoundedVoronoi.cs +++ b/src/Triangle/Voronoi/BoundedVoronoi.cs @@ -12,15 +12,28 @@ namespace TriangleNet.Voronoi using TVertex = TriangleNet.Geometry.Vertex; + /// + /// Computing the bounded Voronoi diagram of a constrained and conforming Delaunay triangulation. + /// public class BoundedVoronoi : VoronoiBase { int offset; + /// + /// Initializes a new instance of the class. + /// + /// The mesh. public BoundedVoronoi(Mesh mesh) : this(mesh, new DefaultVoronoiFactory(), RobustPredicates.Default) { } + /// + /// Initializes a new instance of the class. + /// + /// The mesh. + /// + /// public BoundedVoronoi(Mesh mesh, IVoronoiFactory factory, IPredicates predicates) : base(mesh, factory, predicates, true) { diff --git a/src/Triangle/Voronoi/DefaultVoronoiFactory.cs b/src/Triangle/Voronoi/DefaultVoronoiFactory.cs index c1773e6..43f2cfc 100644 --- a/src/Triangle/Voronoi/DefaultVoronoiFactory.cs +++ b/src/Triangle/Voronoi/DefaultVoronoiFactory.cs @@ -9,24 +9,29 @@ namespace TriangleNet.Voronoi /// public class DefaultVoronoiFactory : IVoronoiFactory { + /// public void Initialize(int vertexCount, int edgeCount, int faceCount) { } + /// public void Reset() { } + /// public Vertex CreateVertex(double x, double y) { return new Vertex(x, y); } + /// public HalfEdge CreateHalfEdge(Vertex origin, Face face) { return new HalfEdge(origin, face); } + /// public Face CreateFace(Geometry.Vertex vertex) { return new Face(vertex); diff --git a/src/Triangle/Voronoi/IVoronoiFactory.cs b/src/Triangle/Voronoi/IVoronoiFactory.cs index 476de74..2c3108d 100644 --- a/src/Triangle/Voronoi/IVoronoiFactory.cs +++ b/src/Triangle/Voronoi/IVoronoiFactory.cs @@ -3,16 +3,45 @@ namespace TriangleNet.Voronoi { using TriangleNet.Topology.DCEL; + /// + /// Factory for Voronoi DCEL datastructure. + /// public interface IVoronoiFactory { + /// + /// Initialize object pool. + /// + /// + /// + /// void Initialize(int vertexCount, int edgeCount, int faceCount); + /// + /// Reset object pool. + /// void Reset(); + /// + /// Return a . + /// + /// + /// + /// Vertex CreateVertex(double x, double y); + /// + /// Return a . + /// + /// + /// + /// HalfEdge CreateHalfEdge(Vertex origin, Face face); + /// + /// Return a . + /// + /// + /// Face CreateFace(Geometry.Vertex vertex); } } diff --git a/src/Triangle/Voronoi/StandardVoronoi.cs b/src/Triangle/Voronoi/StandardVoronoi.cs index db26b97..5a88830 100644 --- a/src/Triangle/Voronoi/StandardVoronoi.cs +++ b/src/Triangle/Voronoi/StandardVoronoi.cs @@ -11,18 +11,37 @@ namespace TriangleNet.Voronoi using TriangleNet.Tools; using TriangleNet.Topology.DCEL; + /// + /// Computing the standard Voronoi diagram of a Delaunay triangulation. + /// public class StandardVoronoi : VoronoiBase { + /// + /// Initializes a new instance of the class. + /// + /// The mesh. public StandardVoronoi(Mesh mesh) : this(mesh, mesh.bounds, new DefaultVoronoiFactory(), RobustPredicates.Default) { } + /// + /// Initializes a new instance of the class. + /// + /// The mesh. + /// The bounding box used to clip infinite Voronoi edges. public StandardVoronoi(Mesh mesh, Rectangle box) : this(mesh, box, new DefaultVoronoiFactory(), RobustPredicates.Default) { } + /// + /// Initializes a new instance of the class. + /// + /// The mesh. + /// The bounding box used for clipping (not implemented.) + /// + /// public StandardVoronoi(Mesh mesh, Rectangle box, IVoronoiFactory factory, IPredicates predicates) : base(mesh, factory, predicates, true) {