|
Core 1.0
|
Planar triangle mesh. ,. More...
#include <mesh.h>
Public Member Functions | |
| Mesh2 () | |
| Create an empty mesh. | |
| Mesh2 (const QVector< Vector2 > &, const QVector< int > &) | |
| Create a mesh from a list of vertices and a indexes. | |
| Mesh2 (const Quadrangle2 &, int, int) | |
| Generate a grid geometry over an input quadrangle. | |
| Mesh2 (const Box2 &, int, int) | |
| Generate a grid geometry. | |
| Mesh2 (const Circle2 &, int) | |
| Create an n-adic subdivision of a circle. | |
| Mesh2 (const Ellipse2 &, int) | |
| Create an n-adic subdivision of an ellipse. | |
| Mesh2 (const Polygon2 &) | |
| Create triangle mesh from a polygon. | |
| ~Mesh2 () | |
| Empty. | |
| Triangle2 | GetTriangle (int) const |
| Get a triangle. | |
| Vector2 | Vertex (int) const |
| Get a vertex. | |
| Vector2 | Vertex (int, int) const |
| Get a vertex from a specific triangle. | |
| Box2 | GetBox () const |
| Compute the boudning box. | |
| int | VertexSize () const |
| Get the number of vertices in the geometry. | |
| int | TriangleSize () const |
| Get the number of triangles. | |
| int | IndexSize () const |
| Get the size of the index array. | |
| int | index (int) const |
| Get the vertex index. | |
| int | index (int, int) const |
| Get a vertex/normal index according to triangle information. | |
| QVector< int > | Indexes () const |
| Return the set of indexes. | |
| QVector< int > & | Indexes () |
| Return the set of indexes. | |
| QVector< Vector2 > | Vertices () const |
| Get the array of vertices. | |
| QVector< int > | Valences () const |
| Compute the valence of the vertices. | |
| void | Transform (const Frame2 &) |
| Transform a mesh. | |
| void | Translate (const Vector2 &) |
| Translate a mesh. | |
| void | Scale (const Vector2 &) |
| Scale a mesh. | |
| void | Rotate (const Matrix2 &) |
| Rotate a mesh. | |
| void | Draw (QGraphicsScene &, const QPen &=QPen(), bool=true) const |
| Draw the mesh. | |
| double | Aspect () const |
| Compute the average aspect ratio of the triangles of the mesh. | |
| Mesh2 | Intersect (const Box2 &) const |
| Keep triangles that intersect the a box. | |
| void | SetTrigonometric (bool=true) |
| Set all triangles in the same trigonometric order. | |
| double | AverageEdgeLength () const |
| Compute the average edge length. | |
| Ia | EdgeLengthRange () const |
| Compute the range of edge lengths. | |
| QVector< int > | AspectRatios (int=4) const |
| Compute the histogram of the aspect ratio of the triangles of the mesh. | |
| void | EdgeCollapse (const double &) |
| Run a simple edge collapse algorithm over a triangle mesh. | |
| void | EdgeCollapse (int) |
| Collapse an edge of the mesh. | |
| Mesh2 | SubMesh (const QVector< int > &, const QSet< int > &={}) const |
| Create a mesh by removing vertices that are not in the list (and the triangles connected to these vertices). | |
| Mesh2 | SubMesh (const Box2 &) const |
| Select the sub-mesh by removing all vertices outside the given box. | |
| Mesh2 | SubMesh (const ScalarField2 &) const |
| Select the sub-mesh by removing all vertices outside the given mask. | |
| Mesh2 | SubMesh (const Polygon2 &) const |
| Select the sub-mesh by removing all vertices and triangles outside the given polygon. | |
| Mesh2 | SubMesh (const Circle2 &) const |
| Select the sub-mesh by removing all vertices outside the given circle. | |
Static Public Member Functions | |
| static Mesh2 | Delaunay (const QVector< Vector2 > &) |
| Compute the Delaunay triangulation of a set of points. | |
| static Mesh2 | Alpha (const QVector< Vector2 > &, const double &) |
| Compute the alpha shape of a set of points. | |
| static Mesh2 | DelaunayN4 (const QVector< Vector2 > &) |
| Compute the Delaunay triangulation of a set of points in the plane. | |
| static int | NextIndex (int) |
| Compute the next index of an edge in a triangle. | |
Protected Member Functions | |
| bool | FindEdge (int, int, int &, int=0) const |
| Find a half-edge from a vertex to another vertex. | |
Static Protected Member Functions | |
| static int | PrevIndex (int) |
| Compute the previous index of an edge in a triangle. | |
| static int | BaseIndex (int) |
| Compute the base triangle index given an edge index. | |
Protected Attributes | |
| QVector< Vector2 > | vertices |
| Vertices. | |
| QVector< int > | indices |
| Triangle vertex indices. | |
Friends | |
| std::ostream & | operator<< (std::ostream &s, const Mesh2 &mesh) |
| Overloaded. | |
Planar triangle mesh. ,.
|
explicit |
Create a mesh from a list of vertices and a indexes.
Indices should be a multiple of three; the number of triangles is derived from the size of indices.
| v | Set of vertices. |
| i | Indexes that represent the triangles. |
|
explicit |
Generate a grid geometry over an input quadrangle.
| quad | Quadrangle. |
| nx,ny | Number of points in the subdivision. |
|
explicit |
Generate a grid geometry.
| box | The box. |
| x,y | Number of points in the subdivision. |
|
explicit |
Create an n-adic subdivision of a circle.
Creates an hexagon an applies an n-adic subdivision.
| circle | The circle. |
| n | Subdivision level. |
|
explicit |
Create an n-adic subdivision of an ellipse.
Create a circle and apply scaling and translation.
This constructor is the same as the following:
| ellipse | The ellipse. |
| n | Subdivision level. |
|
explicit |
Create triangle mesh from a polygon.
Perform a decomposition of the polygon into triangles using the ear-clipping algorithm.
| polygon | The polygon. |
Compute the alpha shape of a set of points.
The Delaunay triangulation of the points is computed, then the triangles whose circumscribed circle has a radius greater than radius are removed: the larger the radius, the closer the result is to the convex hull of the points, and the smaller the radius, the more the boundary of the shape follows the points. The order of the remaining triangles is not preserved. The mesh is empty if there are less than three points.
| points | The points. |
| radius | Maximum radius of the circumscribed circle of the triangles which are kept. |
| double Mesh2::Aspect | ( | ) | const |
Compute the average aspect ratio of the triangles of the mesh.
| QVector< int > Mesh2::AspectRatios | ( | int | n = 4 | ) | const |
Compute the histogram of the aspect ratio of the triangles of the mesh.
| n | Number of classes. |
| double Mesh2::AverageEdgeLength | ( | ) | const |
Compute the average edge length.
|
inlinestaticprotected |
Compute the base triangle index given an edge index.
| i | Edge index. |
Compute the Delaunay triangulation of a set of points.
In some cases, the triangulation may contain anti-trigonometric order triangles. Therefore the function calls SetTrigonometric(true) to guarantee that all triangles are properly oriented.
| p | Point set. |
Bowyer-Watson algorithm, \( O(n^2) \) complexity.
Compute the Delaunay triangulation of a set of points in the plane.
This function return the set of index of vertices
This function is only provided as a reference: it uses a brute force approach with an \( O(n^4) \) complexity.
Basically it computes all the possible triangles and checks whether they are valid by testing if some points lie inside the circumscribed circle.
| p | Set of input points. |
| void Mesh2::Draw | ( | QGraphicsScene & | graphics, |
| const QPen & | pen = QPen(), | ||
| bool | vertexes = true ) const |
Draw the mesh.
| graphics | Graphics scene. |
| pen | Pen used for the edges and vertexes. |
| vertexes | Boolean defining whether vertexes should be drawn as discs. |
| void Mesh2::EdgeCollapse | ( | const double & | epsilon | ) |
Run a simple edge collapse algorithm over a triangle mesh.
This algorithm runs in \( O(n^2) \) where n denotes the number of triangles in the mesh.
| epsilon | Threshold length for collapsing an edge. |
| void Mesh2::EdgeCollapse | ( | int | i | ) |
Collapse an edge of the mesh.
The half-edge i, from the vertex ia to the vertex ib, and the opposite half-edge of the adjacent triangle are collapsed: the two vertexes are replaced by their middle point, and the two triangles which share the edge are removed. The vertex with the smallest index is kept, and the one with the largest index is replaced by the last vertex of the array. Nothing is done if the edge is on the boundary of the mesh, i.e., if there is no opposite half-edge.
| i | Index of the half-edge. |
|
protected |
Find a half-edge from a vertex to another vertex.
The half-edge k of a triangle goes from the vertex indices[k] to the vertex indices[NextIndex(k)]. The search starts at the half-edge s and stops at the first half-edge from a to b.
| a,b | Indexes of the starting and ending vertexes of the half-edge. |
| k | Index of the half-edge in the array of vertex indexes, set to the end of the array if there is no such half-edge. |
| s | Index of the first half-edge of the search. |
|
inline |
Get a triangle.
| i | Index. |
|
inline |
Get the vertex index.
| i | The number in indices of the wanted vertex. |
|
inline |
Get a vertex/normal index according to triangle information.
| t | The triangle number. |
| v | The triangle vertex index. |
|
inline |
Get the size of the index array.
Keep triangles that intersect the a box.
| box | The box. |
|
inlinestatic |
Compute the next index of an edge in a triangle.
| i | Index of the starting vertex of an edge. |
|
inlinestaticprotected |
Compute the previous index of an edge in a triangle.
| i | Index of the starting vertex of an edge. |
| void Mesh2::Rotate | ( | const Matrix2 & | r | ) |
Rotate a mesh.
| r | Rotation matrix. |
| void Mesh2::Scale | ( | const Vector2 & | s | ) |
Scale a mesh.
| s | Scaling vector. |
| void Mesh2::SetTrigonometric | ( | bool | trigo = true | ) |
Set all triangles in the same trigonometric order.
| trigo | Trigonometric (counterclockwise) is true, clockwise if false. |
Select the sub-mesh by removing all vertices outside the given box.
| box | The box. |
Select the sub-mesh by removing all vertices outside the given circle.
| circle | The circle. |
Select the sub-mesh by removing all vertices and triangles outside the given polygon.
| poly | The polygon |
| Mesh2 Mesh2::SubMesh | ( | const QVector< int > & | verticesInd, |
| const QSet< int > & | removedTrianglesInd = {} ) const |
Create a mesh by removing vertices that are not in the list (and the triangles connected to these vertices).
| verticesInd | Indexes of the preserved vertexes. |
| removedTrianglesInd | Extra triangles to remove within the submesh. |
| Mesh2 Mesh2::SubMesh | ( | const ScalarField2 & | mask | ) | const |
Select the sub-mesh by removing all vertices outside the given mask.
| mask | The mask, negative values mean that the vertex is not in the mask, positive values inside. |
| void Mesh2::Transform | ( | const Frame2 & | f | ) |
Transform a mesh.
| f | Transform. |
| void Mesh2::Translate | ( | const Vector2 & | t | ) |
Translate a mesh.
| t | Translation vector. |
|
inline |
Get the number of triangles.
This is the size of the array of indexes divided by three.
| QVector< int > Mesh2::Valences | ( | ) | const |
Compute the valence of the vertices.
|
inline |
Get a vertex.
| i | The index of the wanted vertex. |
|
inline |
Get a vertex from a specific triangle.
| t | The number of the triangle that contains the wanted vertex. |
| v | The triangle vertex: 0, 1, or 2. |
|
inline |
Get the number of vertices in the geometry.
|
friend |
Overloaded.
| s | Stream. |
| mesh | The mesh. |