Core 1.0
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members

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. More...
 
 Mesh2 (const Quadrangle2 &, int, int)
 Generate a grid geometry over an input quadrangle. More...
 
 Mesh2 (const Box2 &, int, int)
 Generate a grid geometry. More...
 
 Mesh2 (const Circle2 &, int)
 Create an n-adic subdivision of a circle. More...
 
 Mesh2 (const Ellipse2 &, int)
 Create an n-adic subdivision of an ellipse. More...
 
 Mesh2 (const Polygon2 &)
 Create triangle mesh from a polygon. More...
 
 ~Mesh2 ()
 Empty.
 
Triangle2 GetTriangle (int) const
 Get a triangle. More...
 
Vector2 Vertex (int) const
 Get a vertex. More...
 
Vector2 Vertex (int, int) const
 Get a vertex from a specific triangle. More...
 
Box2 GetBox () const
 Compute the boudning box. More...
 
int VertexSize () const
 Get the number of vertices in the geometry. More...
 
int TriangleSize () const
 Get the number of triangles. More...
 
int IndexSize () const
 Get the size of the index array. More...
 
int index (int) const
 Get the vertex index. More...
 
int index (int, int) const
 Get a vertex/normal index according to triangle information. More...
 
QVector< int > Indexes () const
 Return the set of indexes.
 
QVector< int > & Indexes ()
 Return the set of indexes.
 
QVector< Vector2Vertices () const
 Get the array of vertices.
 
QVector< int > Valences () const
 Compute the valence of the vertices. More...
 
void Transform (const Frame2 &)
 Transform a mesh. More...
 
void Translate (const Vector2 &)
 Translate a mesh. More...
 
void Scale (const Vector2 &)
 Translate a mesh. More...
 
void Rotate (const Matrix2 &)
 Rotate a mesh. More...
 
void Draw (QGraphicsScene &, const QPen &=QPen(), bool=true) const
 Draw the mesh. More...
 

Static Public Member Functions

static Mesh2 Delaunay (QVector< Vector2 > &)
 Compute the Delaunay triangulation of a set of points. More...
 
static Mesh2 DelaunayN4 (const QVector< Vector2 > &)
 Compute the Delaunay triangulation of a set of points in the plane. More...
 

Protected Attributes

QVector< Vector2vertices
 Vertices.
 
QVector< int > indices
 Triangle vertex indices.
 

Detailed Description

Planar triangle mesh. ,.

Constructor & Destructor Documentation

◆ Mesh2() [1/6]

Mesh2::Mesh2 ( const QVector< Vector2 > &  v,
const QVector< int > &  i 
)
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.

See also
Mesh2::TriangleSize
Parameters
vSet of vertices.
iIndexes that represent the triangles.

◆ Mesh2() [2/6]

Mesh2::Mesh2 ( const Quadrangle2 quad,
int  nx,
int  ny 
)
explicit

Generate a grid geometry over an input quadrangle.

Parameters
quadQuadrangle.
nx,nyNumber of points in the subdivision.

◆ Mesh2() [3/6]

Mesh2::Mesh2 ( const Box2 box,
int  x,
int  y 
)
explicit

Generate a grid geometry.

Parameters
boxThe box.
x,yNumber of points in the subdivision.

◆ Mesh2() [4/6]

Mesh2::Mesh2 ( const Circle2 circle,
int  n 
)
explicit

Create an n-adic subdivision of a circle.

Creates an hexagon an applies an n-adic subdivision. The code of this function strongly relies on the more general function Polygon2::Subdivide().

Parameters
circleThe circle.
nSubdivision level.

◆ Mesh2() [5/6]

Mesh2::Mesh2 ( const Ellipse2 ellipse,
int  n 
)
explicit

Create an n-adic subdivision of an ellipse.

Create a circle and apply scaling and translation.

See also
Mesh2::Mesh2(const Circle&, int)

This constructor is the same as the following:

Ellipse2 ellipse(Vector2(2.0,3.0),4.0,2.0);
Mesh2 mesh(Circle(1.0),n);
mesh.Scale(ellipse.A(),ellipse.B());
mesh.Translate(ellipse.Center());
Circles.
Definition: circle.h:12
Axis aligned ellipses.
Definition: ellipse.h:107
Planar triangle mesh. ,.
Definition: mesh.h:338
Vectors in two dimensions.
Definition: evector.h:617
Parameters
ellipseThe ellipse.
nSubdivision level.

◆ Mesh2() [6/6]

Mesh2::Mesh2 ( const Polygon2 polygon)
explicit

Create triangle mesh from a polygon.

Perform a decomposition of the polygon into triangles using the ear-clipping algorithm.

See also
Polygon::EarClip()
Parameters
polygonThe polygon.

Member Function Documentation

◆ Delaunay()

Mesh2 Mesh2::Delaunay ( QVector< Vector2 > &  points)
static

Compute the Delaunay triangulation of a set of points.

Bowyer-Watson algorithm, O(n log n) complexity, C++ implementation of http://paulbourke.net/papers/triangulate.

◆ DelaunayN4()

Mesh2 Mesh2::DelaunayN4 ( const QVector< Vector2 > &  p)
static

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.

Parameters
pSet of input points.
See also
Mesh2::Delaunay

◆ Draw()

void Mesh2::Draw ( QGraphicsScene &  graphics,
const QPen &  pen = QPen(),
bool  vertexes = true 
) const

Draw the mesh.

Parameters
graphicsGraphics scene.
penPen used for the edges and vertexes.
vertexesBoolean defining whether vertexes should be drawn as discs.

◆ GetBox()

Box2 Mesh2::GetBox ( ) const

Compute the boudning box.

Simply eqsuivalent as:

Mesh2 mesh;
Box2 box=Box2(mesh.Vertices());
Axis aligned box in the plane.
Definition: box.h:371
QVector< Vector2 > Vertices() const
Get the array of vertices.
Definition: mesh.h:404

◆ GetTriangle()

Triangle2 Mesh2::GetTriangle ( int  i) const
inline

Get a triangle.

Parameters
iIndex.
Returns
The triangle.

◆ index() [1/2]

int Mesh2::index ( int  i) const
inline

Get the vertex index.

Parameters
iThe number in indices of the wanted vertex.
Returns
The index of the wanted vertex.

◆ index() [2/2]

int Mesh2::index ( int  t,
int  v 
) const
inline

Get a vertex/normal index according to triangle information.

Parameters
tThe triangle number.
vThe triangle vertex index.
Returns
The index of the wanted vertex.

◆ IndexSize()

int Mesh2::IndexSize ( ) const
inline

Get the size of the index array.

See also
Mesh2::TriangleSize()

◆ Rotate()

void Mesh2::Rotate ( const Matrix2 r)

Rotate a mesh.

Parameters
rRotation matrix.

◆ Scale()

void Mesh2::Scale ( const Vector2 s)

Translate a mesh.

Parameters
sScaling vector.

◆ Transform()

void Mesh2::Transform ( const Frame2 f)

Transform a mesh.

Parameters
fTransform.

◆ Translate()

void Mesh2::Translate ( const Vector2 t)

Translate a mesh.

Parameters
tTranslation vector.

◆ TriangleSize()

int Mesh2::TriangleSize ( ) const
inline

Get the number of triangles.

This is the size of the array of indexes divided by three.

Returns
The effective number of triangle in the geometry.

◆ Valences()

QVector< int > Mesh2::Valences ( ) const

Compute the valence of the vertices.

Returns
A vector with the computed valences.

◆ Vertex() [1/2]

Vector2 Mesh2::Vertex ( int  i) const
inline

Get a vertex.

Parameters
iThe index of the wanted vertex.
Returns
The wanted vertex (as a 3D Vector).

◆ Vertex() [2/2]

Vector2 Mesh2::Vertex ( int  t,
int  v 
) const
inline

Get a vertex from a specific triangle.

Parameters
tThe number of the triangle that contains the wanted vertex.
vThe triangle vertex: 0, 1, or 2.
Returns
The wanted vertex.

◆ VertexSize()

int Mesh2::VertexSize ( ) const
inline

Get the number of vertices in the geometry.

Returns
The number of vertices in the geometry, in other words the size of vertices.