Class for storing a triangle mesh.
Format:
When adding new vertices no check is done if this vertex already exist. To remove duplicate vertices (and adapt the indices that store the triangles) use removeDuplicateVertices()
#include <TriangleMesh.h>
Public Types | |
using | index_t = uint32_t |
using | vertex_t = Vector3< real_t > |
using | normal_t = Vector3< real_t > |
using | color_t = Vector3< float > |
Public Member Functions | |
Size Information | |
size_t | getNumTriangles () const |
size_t | getNumVertexIndices () const |
size_t | getNumNormalIndices () const |
index_t | getNumVertices () const |
index_t | getNumNormals () const |
math::AABB | getAABB () const |
Data Access | |
const vertex_t & | getVertex (index_t i) const |
const normal_t & | getVertexNormal (index_t i) const |
const color_t & | getVertexColor (index_t i) const |
void | clear () |
index_t | getVertexIndex (index_t i) const |
index_t | getVertexIndex (size_t triangle, uint8_t index) const |
index_t | getNormalIndex (index_t i) const |
index_t | getNormalIndex (size_t triangle, uint8_t index) const |
bool | hasVertexNormals () const |
bool | hasVertexColors () const |
bool | hasNormalIndices () const |
void | getTriangle (size_t triangleIdx, vertex_t &v0, vertex_t &v1, vertex_t &v2) const |
void | getTriangle (size_t triangleIdx, vertex_t &v0, vertex_t &v1, vertex_t &v2, color_t &c0, color_t &c1, color_t &c2) const |
void | getTriangleVertexNormals (size_t triangleIdx, normal_t &n0, normal_t &n1, normal_t &n2) const |
const std::vector< index_t > & | getVertexIndices () const |
const std::vector< index_t > & | getNormalIndices () const |
const std::vector< vertex_t > & | getVertices () const |
const std::vector< normal_t > & | getVertexNormals () const |
const std::vector< color_t > & | getVertexColors () const |
std::vector< index_t > & | getVertexIndices () |
std::vector< index_t > & | getNormalIndices () |
std::vector< vertex_t > & | getVertices () |
std::vector< normal_t > & | getVertexNormals () |
std::vector< color_t > & | getVertexColors () |
template<typename OutputIterator > | |
void | getVerticesOfColor (const color_t &color, OutputIterator outIt) const |
real_t | volume () const |
real_t | surfaceArea () const |
Inserting | |
index_t | addVertex (const vertex_t &v) |
Adds a vertex to the mesh and returns its index No duplicate check is done when inserting, instead use removeDuplicateVertices. More... | |
index_t | addVertex (const vertex_t &v, const color_t &c) |
index_t | addVertexNormal (const normal_t &n) |
void | addTriangle (index_t v0Idx, index_t v1Idx, index_t v2Idx) |
Adds a triangle to the mesh, as parameters use the return values of addVertex() More... | |
void | addTriangle (index_t v0Idx, index_t v1Idx, index_t v2Idx, index_t n0Idx, index_t n1Idx, index_t n2Idx) |
Static Public Member Functions | |
template<typename T > | |
static index_t | index_c (T x) |
Mesh Operations | |
std::vector< index_t > | vertexIndices_ |
std::vector< index_t > | normalIndices_ |
std::vector< vertex_t > | vertices_ |
std::vector< normal_t > | vertexNormals_ |
std::vector< color_t > | vertexColors_ |
void | merge (const TriangleMesh &other, const Vector3< real_t > &offset=Vector3< real_t >(0.0)) |
Merges a second mesh into the given mesh. More... | |
size_t | removeDuplicateVertices (real_t tolerance=real_t(1e-4)) |
Removes duplicate vertices i.e. More... | |
void | translate (const Vector3< real_t > &offset) |
void | scale (real_t scaleFactor) |
void | scale (const Vector3< real_t > &scaleFactors) |
void | split (std::vector< TriangleMesh > &meshes) const |
Split mesh into unconnected meshes. More... | |
void | exchangeAxes (uint_t xAxisId, uint_t yAxisId, uint_t zAxisId) |
using walberla::geometry::TriangleMesh::color_t = Vector3<float> |
Adds a triangle to the mesh, as parameters use the return values of addVertex()
void walberla::geometry::TriangleMesh::addTriangle | ( | index_t | v0Idx, |
index_t | v1Idx, | ||
index_t | v2Idx, | ||
index_t | n0Idx, | ||
index_t | n1Idx, | ||
index_t | n2Idx | ||
) |
TriangleMesh::index_t walberla::geometry::TriangleMesh::addVertex | ( | const vertex_t & | v | ) |
Adds a vertex to the mesh and returns its index No duplicate check is done when inserting, instead use removeDuplicateVertices.
TriangleMesh::index_t walberla::geometry::TriangleMesh::addVertex | ( | const vertex_t & | v, |
const color_t & | c | ||
) |
TriangleMesh::index_t walberla::geometry::TriangleMesh::addVertexNormal | ( | const normal_t & | n | ) |
|
inline |
void walberla::geometry::TriangleMesh::exchangeAxes | ( | uint_t | xAxisId, |
uint_t | yAxisId, | ||
uint_t | zAxisId | ||
) |
math::AABB walberla::geometry::TriangleMesh::getAABB | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void walberla::geometry::TriangleMesh::getVerticesOfColor | ( | const color_t & | color, |
OutputIterator | outIt | ||
) | const |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
void walberla::geometry::TriangleMesh::merge | ( | const TriangleMesh & | other, |
const Vector3< real_t > & | offset = Vector3<real_t>(0.0) |
||
) |
Merges a second mesh into the given mesh.
All vertices and faces of the second mesh are added, no vertex duplicate checking is done.
other | mesh that has to merge into this |
offset | before adding the vertices, they are moved by the given offset |
Removes duplicate vertices i.e.
vertices with same positions
This is expensive, since the vertex array has to be sorted, scanned for duplicates, and the face indices array has to be rewritten.
tolerance | two vertices are considered equal if each of their coordinates does not differ more than the tolerance value (maximum-norm) |
|
inline |
void walberla::geometry::TriangleMesh::split | ( | std::vector< TriangleMesh > & | meshes | ) | const |
Split mesh into unconnected meshes.
All triangle connections are checked. Unconnected meshes are split up.
meshes | empty vector where all unconnected meshes are returned |
real_t walberla::geometry::TriangleMesh::surfaceArea | ( | ) | const |
real_t walberla::geometry::TriangleMesh::volume | ( | ) | const |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |