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 &) |
Translate 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 | SetTrigoOrder (bool trigo=true) |
Set all triangles in the same trigonometric order. | |
Static Public Member Functions | |
static Mesh2 | Delaunay (const QVector< Vector2 > &) |
Compute the Delaunay triangulation 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 Attributes | |
QVector< Vector2 > | vertices |
Vertices. | |
QVector< int > | indices |
Triangle vertex indices. | |
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 Delaunay triangulation of a set of points.
p | Point set. |
Bowyer-Watson algorithm, O(n log n) complexity, C++ implementation of http://paulbourke.net/papers/triangulate.
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(n4) 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. |
Box2 Mesh2::GetBox | ( | ) | const |
|
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. |
void Mesh2::Rotate | ( | const Matrix2 & | r | ) |
Rotate a mesh.
r | Rotation matrix. |
void Mesh2::Scale | ( | const Vector2 & | s | ) |
Translate a mesh.
s | Scaling vector. |
void Mesh2::SetTrigoOrder | ( | bool | trigo = true | ) |
Set all triangles in the same trigonometric order.
trigo | Trigonometric (counterclockwise) is true, clockwise if false. |
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.