Code/comments cleanup
git-svn-id: https://triangle.svn.codeplex.com/svn@75046 0e2699bc-83d4-4a8f-98e7-55e24ab8c7a5
This commit is contained in:
@@ -1,33 +1,31 @@
|
||||
|
||||
namespace TriangleNet.Meshing
|
||||
{
|
||||
/// <summary>
|
||||
/// Mesh constraint options for polygon triangulation.
|
||||
/// </summary>
|
||||
public class ConstraintOptions
|
||||
{
|
||||
public static ConstraintOptions Empty
|
||||
{
|
||||
get { return new ConstraintOptions(); }
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating wether to use regions.
|
||||
/// Gets or sets a value indicating whether to use regions.
|
||||
/// </summary>
|
||||
public bool UseRegions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating wether to create a Conforming
|
||||
/// Gets or sets a value indicating whether to create a Conforming
|
||||
/// Delaunay triangulation.
|
||||
/// </summary>
|
||||
public bool ConformingDelaunay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enclose the convex hull with segments.
|
||||
/// Gets or sets a value indicating whether to enclose the convex
|
||||
/// hull with segments.
|
||||
/// </summary>
|
||||
public bool Convex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Suppresses boundary segment splitting.
|
||||
/// Gets or sets a flag indicating whether to suppress boundary
|
||||
/// segment splitting.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 0 = split segments (default)
|
||||
@@ -35,7 +33,5 @@ namespace TriangleNet.Meshing
|
||||
/// 2 = prevent all segment splitting, including internal boundaries
|
||||
/// </remarks>
|
||||
public int SegmentSplitting { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,13 @@ namespace TriangleNet.Meshing
|
||||
using TriangleNet.Geometry;
|
||||
|
||||
/// <summary>
|
||||
/// The DataReader class provides methods for mesh reconstruction.
|
||||
/// The Converter class provides methods for mesh reconstruction.
|
||||
/// </summary>
|
||||
public class Converter
|
||||
{
|
||||
/// <summary>
|
||||
/// Reconstruct a triangulation from its raw data representation.
|
||||
/// </summary>
|
||||
public Mesh ToMesh(Polygon polygon, IList<ITriangle> triangles)
|
||||
{
|
||||
return ToMesh(polygon, triangles.ToArray());
|
||||
@@ -26,25 +29,6 @@ namespace TriangleNet.Meshing
|
||||
/// <summary>
|
||||
/// Reconstruct a triangulation from its raw data representation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Reads an .ele file and reconstructs the original mesh. If the -p switch
|
||||
/// is used, this procedure will also read a .poly file and reconstruct the
|
||||
/// subsegments of the original mesh. If the -a switch is used, this
|
||||
/// procedure will also read an .area file and set a maximum area constraint
|
||||
/// on each triangle.
|
||||
///
|
||||
/// Vertices that are not corners of triangles, such as nodes on edges of
|
||||
/// subparametric elements, are discarded.
|
||||
///
|
||||
/// This routine finds the adjacencies between triangles (and subsegments)
|
||||
/// by forming one stack of triangles for each vertex. Each triangle is on
|
||||
/// three different stacks simultaneously. Each triangle's subsegment
|
||||
/// pointers are used to link the items in each stack. This memory-saving
|
||||
/// feature makes the code harder to read. The most important thing to keep
|
||||
/// in mind is that each triangle is removed from a stack precisely when
|
||||
/// the corresponding pointer is adjusted to refer to a subsegment rather
|
||||
/// than the next triangle of the stack.
|
||||
/// </remarks>
|
||||
public Mesh ToMesh(Polygon polygon, ITriangle[] triangles)
|
||||
{
|
||||
Otri tri = default(Otri);
|
||||
@@ -93,8 +77,8 @@ namespace TriangleNet.Meshing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the adjacencies between triangles by forming a stack of triangles
|
||||
/// for each vertex.
|
||||
/// Finds the adjacencies between triangles by forming a stack of triangles for
|
||||
/// each vertex. Each triangle is on three different stacks simultaneously.
|
||||
/// </summary>
|
||||
private static List<Otri>[] SetNeighbors(Mesh mesh, ITriangle[] triangles)
|
||||
{
|
||||
@@ -102,15 +86,14 @@ namespace TriangleNet.Meshing
|
||||
Otri triangleleft = default(Otri);
|
||||
Otri checktri = default(Otri);
|
||||
Otri checkleft = default(Otri);
|
||||
Otri nexttri; // Triangle
|
||||
Otri nexttri;
|
||||
Vertex tdest, tapex;
|
||||
Vertex checkdest, checkapex;
|
||||
int[] corner = new int[3];
|
||||
int aroundvertex;
|
||||
int i;
|
||||
|
||||
// Allocate a temporary array that maps each vertex to some adjacent
|
||||
// triangle.
|
||||
// Allocate a temporary array that maps each vertex to some adjacent triangle.
|
||||
var vertexarray = new List<Otri>[mesh.vertices.Count];
|
||||
|
||||
// Each vertex is initially unrepresented.
|
||||
@@ -164,11 +147,12 @@ namespace TriangleNet.Meshing
|
||||
{
|
||||
// Take the number for the origin of triangleloop.
|
||||
aroundvertex = corner[tri.orient];
|
||||
|
||||
int index = vertexarray[aroundvertex].Count - 1;
|
||||
|
||||
// Look for other triangles having this vertex.
|
||||
nexttri = vertexarray[aroundvertex][index];
|
||||
// Link the current triangle to the next one in the stack.
|
||||
//tri.triangle.neighbors[tri.orient] = nexttri;
|
||||
|
||||
// Push the current triangle onto the stack.
|
||||
vertexarray[aroundvertex].Add(tri);
|
||||
|
||||
@@ -212,6 +196,9 @@ namespace TriangleNet.Meshing
|
||||
return vertexarray;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the adjacencies between triangles and subsegments.
|
||||
/// </summary>
|
||||
private static void SetSegments(Mesh mesh, Polygon polygon, List<Otri>[] vertexarray)
|
||||
{
|
||||
Otri checktri = default(Otri);
|
||||
|
||||
@@ -7,6 +7,9 @@ namespace TriangleNet.Meshing
|
||||
using TriangleNet.IO;
|
||||
using TriangleNet.Meshing.Algorithm;
|
||||
|
||||
/// <summary>
|
||||
/// Create meshes of point sets or polygons.
|
||||
/// </summary>
|
||||
public class GenericMesher : ITriangulator, IConstraintMesher, IQualityMesher
|
||||
{
|
||||
ITriangulator triangulator;
|
||||
@@ -21,55 +24,31 @@ namespace TriangleNet.Meshing
|
||||
this.triangulator = triangulator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triangulates a point set.
|
||||
/// </summary>
|
||||
/// <param name="points">Collection of points.</param>
|
||||
/// <returns>Mesh</returns>
|
||||
/// <inherit />
|
||||
public IMesh Triangulate(ICollection<Vertex> points)
|
||||
{
|
||||
return triangulator.Triangulate(points);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triangulates a polygon.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon.</param>
|
||||
/// <returns>Mesh</returns>
|
||||
/// <inherit />
|
||||
public IMesh Triangulate(IPolygon polygon)
|
||||
{
|
||||
return Triangulate(polygon, null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triangulates a polygon, applying constraint options.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon.</param>
|
||||
/// <param name="options">Constraint options.</param>
|
||||
/// <returns>Mesh</returns>
|
||||
/// <inherit />
|
||||
public IMesh Triangulate(IPolygon polygon, ConstraintOptions options)
|
||||
{
|
||||
return Triangulate(polygon, options, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triangulates a polygon, applying quality options.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon.</param>
|
||||
/// <param name="quality">Quality options.</param>
|
||||
/// <returns>Mesh</returns>
|
||||
/// <inherit />
|
||||
public IMesh Triangulate(IPolygon polygon, QualityOptions quality)
|
||||
{
|
||||
return Triangulate(polygon, null, quality);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triangulates a polygon, applying quality and constraint options.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon.</param>
|
||||
/// <param name="options">Constraint options.</param>
|
||||
/// <param name="quality">Quality options.</param>
|
||||
/// <returns>Mesh</returns>
|
||||
/// <inherit />
|
||||
public IMesh Triangulate(IPolygon polygon, ConstraintOptions options, QualityOptions quality)
|
||||
{
|
||||
var mesh = (Mesh)triangulator.Triangulate(polygon.Points);
|
||||
@@ -80,7 +59,7 @@ namespace TriangleNet.Meshing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a structured mesh with bounds (0, 0, width, height).
|
||||
/// Generates a structured mesh with bounds [0, 0, width, height].
|
||||
/// </summary>
|
||||
/// <param name="width">Width of the mesh (must be > 0).</param>
|
||||
/// <param name="height">Height of the mesh (must be > 0).</param>
|
||||
|
||||
@@ -3,9 +3,24 @@ namespace TriangleNet.Meshing
|
||||
{
|
||||
using TriangleNet.Geometry;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for polygon triangulation.
|
||||
/// </summary>
|
||||
public interface IConstraintMesher
|
||||
{
|
||||
/// <summary>
|
||||
/// Triangulates a polygon.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon.</param>
|
||||
/// <returns>Mesh</returns>
|
||||
IMesh Triangulate(IPolygon polygon);
|
||||
|
||||
/// <summary>
|
||||
/// Triangulates a polygon, applying constraint options.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon.</param>
|
||||
/// <param name="options">Constraint options.</param>
|
||||
/// <returns>Mesh</returns>
|
||||
IMesh Triangulate(IPolygon polygon, ConstraintOptions options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,17 +5,49 @@ namespace TriangleNet.Meshing
|
||||
using TriangleNet.Data;
|
||||
using TriangleNet.Geometry;
|
||||
|
||||
/// <summary>
|
||||
/// Mesh interface.
|
||||
/// </summary>
|
||||
public interface IMesh
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the vertices of the mesh.
|
||||
/// </summary>
|
||||
ICollection<Vertex> Vertices { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the edges of the mesh.
|
||||
/// </summary>
|
||||
IEnumerable<Edge> Edges { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the segments (constraint edges) of the mesh.
|
||||
/// </summary>
|
||||
ICollection<Segment> Segments { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the triangles of the mesh.
|
||||
/// </summary>
|
||||
ICollection<Triangle> Triangles { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the holes of the mesh.
|
||||
/// </summary>
|
||||
IList<Point> Holes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bounds of the mesh.
|
||||
/// </summary>
|
||||
Rectangle Bounds { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Renumber mesh vertices and triangles.
|
||||
/// </summary>
|
||||
void Renumber();
|
||||
|
||||
/// <summary>
|
||||
/// Refine the mesh.
|
||||
/// </summary>
|
||||
void Refine(QualityOptions quality);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,26 @@ namespace TriangleNet.Meshing
|
||||
{
|
||||
using TriangleNet.Geometry;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for polygon triangulation with quality constraints.
|
||||
/// </summary>
|
||||
public interface IQualityMesher
|
||||
{
|
||||
/// <summary>
|
||||
/// Triangulates a polygon, applying quality options.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon.</param>
|
||||
/// <param name="quality">Quality options.</param>
|
||||
/// <returns>Mesh</returns>
|
||||
IMesh Triangulate(IPolygon polygon, QualityOptions quality);
|
||||
|
||||
/// <summary>
|
||||
/// Triangulates a polygon, applying quality and constraint options.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon.</param>
|
||||
/// <param name="options">Constraint options.</param>
|
||||
/// <param name="quality">Quality options.</param>
|
||||
/// <returns>Mesh</returns>
|
||||
IMesh Triangulate(IPolygon polygon, ConstraintOptions options, QualityOptions quality);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,15 @@ namespace TriangleNet.Meshing
|
||||
using TriangleNet.Geometry;
|
||||
|
||||
/// <summary>
|
||||
/// TODO: Update summary.
|
||||
/// Interface for point set triangulation.
|
||||
/// </summary>
|
||||
public interface ITriangulator
|
||||
{
|
||||
/// <summary>
|
||||
/// Triangulates a point set.
|
||||
/// </summary>
|
||||
/// <param name="points">Collection of points.</param>
|
||||
/// <returns>Mesh</returns>
|
||||
IMesh Triangulate(ICollection<Vertex> points);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,11 @@ namespace TriangleNet.Meshing
|
||||
using System;
|
||||
using TriangleNet.Geometry;
|
||||
|
||||
/// <summary>
|
||||
/// Mesh constraint options for quality triangulation.
|
||||
/// </summary>
|
||||
public class QualityOptions
|
||||
{
|
||||
public static QualityOptions Empty
|
||||
{
|
||||
get { return new QualityOptions(); }
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a maximum angle constraint.
|
||||
/// </summary>
|
||||
@@ -29,10 +25,22 @@ namespace TriangleNet.Meshing
|
||||
public double MaximumArea { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Apply a user-defined triangle constraint.
|
||||
/// Gets or sets a user-defined triangle constraint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The test function will be called for each triangle in the mesh. The
|
||||
/// second argument is the area of the triangle tested. If the function
|
||||
/// returns true, the triangle is considered bad and will be refined.
|
||||
/// </remarks>
|
||||
public Func<ITriangle, double, bool> UserTest { get; set; }
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Gets or sets a area constraint per triangle.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If this flag is set to true, the <see cref="ITriangle.Area"/> value will
|
||||
/// be used to check if a triangle needs refinement.
|
||||
/// </remarks>
|
||||
public bool VariableArea { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user