RecFusion SDK
Mesh Class Reference

#include <Mesh.h>

Provides functionality for mesh post-processing and export. More...

Detailed Description

Provides functionality for mesh post-processing and export.

Classes

struct  Color
 Vertex color struct. More...
 
struct  Coordinate
 Vertex coordinate struct. More...
 
struct  Triangle
 Triangle vertex-index struct. More...
 

Public Types

enum  MeshFormat { PLY , OBJ , STL }
 Supported mesh export formats. More...
 

Public Member Functions

 Mesh ()
 Construct empty mesh.
 
 ~Mesh ()
 Destructor.
 
int vertexCount () const
 Return number of vertices in the mesh. More...
 
int triangleCount () const
 Return number of triangles in the mesh. More...
 
Coordinate vertex (int idx) const
 Returns the specified vertex. More...
 
bool setVertex (int idx, const Coordinate &vertex)
 Set vertex coordinates. More...
 
Coordinate normal (int idx) const
 Returns the specified vertex normal at vertex idx. More...
 
bool setNormal (int idx, const Coordinate &normal)
 Set vertex normal. More...
 
Color color (int idx) const
 Returns the vertex color at vertex idx. More...
 
bool setColor (int idx, const Color &color)
 Set vertex color. More...
 
Triangle triangle (int idx) const
 Returns the specified triangle vertex indices. More...
 
int addTriangle (const Triangle &triangle)
 Add triangle consisting of the given vertex indices. More...
 
Vec3 center () const
 Get mesh bounding box center. More...
 
Vec3 extent () const
 Get mesh bounding box extent. More...
 
bool save (const char *filename, MeshFormat format)
 Save mesh to file. More...
 
void transform (const Mat3 &R, const Vec3 &t)
 Transform mesh with the given rotation and translation. More...
 
bool decimate (int minEdgeLength, int maxEdgeLength, bool preserveColors)
 Decimate mesh. More...
 
bool smooth (int iterations)
 Smooth mesh. More...
 
bool clean (double minComponentArea, double maxComponentArea)
 Clean mesh by removing connected components with certain surface area. More...
 
bool crop (const Vec3 &boxCenter, const Vec3 &boxExtent, const bool discardPointsInside=false)
 Crop mesh with given bounding box. More...
 
bool fillHoles (int level=-1)
 Fill holes in mesh to make it manifold. More...
 
bool makeHollow (double wall)
 Make mesh hollow. More...
 
bool removeBoundaryFaces (int layers)
 Remove boundary faces from the mesh. More...
 
bool isManifold () const
 Checks mesh manifoldness, i.e. More...
 
bool applyTexture ()
 Apply texture mapping to the mesh. More...
 

Static Public Member Functions

static Meshcreate (int vertexCount, const double *vertices, int triangleCount, const int *triangleIndices, const double *colors=0, const double *normals=0, int volRes=512)
 Creates mesh from user data. More...
 

Member Enumeration Documentation

◆ MeshFormat

enum MeshFormat

Supported mesh export formats.

Enumerator
PLY 

Binary PLY format.

OBJ 

OBJ format.

STL 

STL format (does not include color)

Member Function Documentation

◆ create()

static Mesh* create ( int  vertexCount,
const double *  vertices,
int  triangleCount,
const int *  triangleIndices,
const double *  colors = 0,
const double *  normals = 0,
int  volRes = 512 
)
static

Creates mesh from user data.

Parameters
vertexCountNumber of vertices in vertices array.
verticesPointer to array of vertex coordinates with x, y and z-coordinates. Array must have size 3*vertexCount.
triangleCountNumber of triangles in triangleIndices array.
trianglesPointer to array of triangle vertex indeces. A triangle is described by the three zero-based indices of its vertices. Array must have size 3*triangleCount.
colorsPointer to array of vertex colors with RGB color values in the range [0;1]. Array must have size 3*vertexCount. If not specified mesh will not contain color.
colorsPointer to array of vertex normals with x, y and z-coordinates. The normal vectors should be normalized. Array must have size 3*vertexCount. If not specified normals are computed automatically.
volResVolume resolution used during reconstruction
Returns
Pointer to newly created mesh. User needs to delete mesh after usage. Returns null pointer if an error occurs (inconsistent mesh, no license)

◆ vertexCount()

int vertexCount ( ) const

Return number of vertices in the mesh.

Returns
Number of mesh vertices.

◆ triangleCount()

int triangleCount ( ) const

Return number of triangles in the mesh.

Returns
Number of mesh triangles.

◆ vertex()

Coordinate vertex ( int  idx) const

Returns the specified vertex.

Parameters
idxVertex index
Returns
Coordinate of vertex.

If idx is bigger than the vertex count (0,0,0) is returned.

◆ setVertex()

bool setVertex ( int  idx,
const Coordinate vertex 
)

Set vertex coordinates.

Parameters
idxThe index of the vertex.
vertexVertex coordinates.
Returns
If the index does not exist in the mesh false is returned

◆ normal()

Coordinate normal ( int  idx) const

Returns the specified vertex normal at vertex idx.

Parameters
idxVertex index
Returns
Normal of vertex.

If idx is bigger than the vertex count or there is no normal associated with the vertex (0,0,0) is returned.

◆ setNormal()

bool setNormal ( int  idx,
const Coordinate normal 
)

Set vertex normal.

Parameters
idxThe index of the normal.
normalNormal.
Returns
If the index does not exist in the mesh false is returned

◆ color()

Color color ( int  idx) const

Returns the vertex color at vertex idx.

Returns
Color of vertex.

If idx is bigger than the vertex count or if there is no color information associated with the vertex (0,0,0) is returned.

◆ setColor()

bool setColor ( int  idx,
const Color color 
)

Set vertex color.

Parameters
idxThe index of the color.
colorColor.
Returns
If the index does not exist in the mesh false is returned

◆ triangle()

Triangle triangle ( int  idx) const

Returns the specified triangle vertex indices.

Returns
Triangle information.

If idx is bigger than the triangle count the (0,0,0) is returned.

◆ addTriangle()

int addTriangle ( const Triangle triangle)

Add triangle consisting of the given vertex indices.

Parameters
triangleTriangle information.
Returns
The index of the triangle or -1 in case of failure

◆ center()

Vec3 center ( ) const

Get mesh bounding box center.

Returns
Bounding box center

◆ extent()

Vec3 extent ( ) const

Get mesh bounding box extent.

Returns
Bounding box extent

◆ save()

bool save ( const char *  filename,
MeshFormat  format 
)

Save mesh to file.

Parameters
filenameFile to save mesh to.
formatMesh format.
Returns
True if successful, false on error.

◆ transform()

void transform ( const Mat3 R,
const Vec3 t 
)

Transform mesh with the given rotation and translation.

Parameters
R3x3 rotation matrix
tTranslation vector

◆ decimate()

bool decimate ( int  minEdgeLength,
int  maxEdgeLength,
bool  preserveColors 
)

Decimate mesh.

Parameters
minEdgeLengthMinimum edge length in decimated mesh.
maxEdgeLengthMaximum edge length in decimated mesh.
preserveColorsIf set to true color is taken into account when decimating the mesh. Areas with high color variation will be decimated less.
Returns
True if successful, false on error.

◆ smooth()

bool smooth ( int  iterations)

Smooth mesh.

Parameters
iterationsNumber of smoothing iterations.
Returns
True if successful, false on error.

◆ clean()

bool clean ( double  minComponentArea,
double  maxComponentArea 
)

Clean mesh by removing connected components with certain surface area.

Parameters
minComponentAreaMinimum surface area of components to remove.
maxComponentAreaMaximum surface area of components to remove.
Returns
True if successful, false on error.

◆ crop()

bool crop ( const Vec3 boxCenter,
const Vec3 boxExtent,
const bool  discardPointsInside = false 
)

Crop mesh with given bounding box.

Parameters
boxCenterCenter of mesh bounding box in mesh coordinate system
boxExtentExtent of mesh bounding box along mesh X, Y and Z axis
discardPointsInsideIf set to true, points inside of the bounding box will be discarded
Returns
True if successful, false otherwise.

◆ fillHoles()

bool fillHoles ( int  level = -1)

Fill holes in mesh to make it manifold.

Parameters
levelof the remeshing. If set to -1 it is chosen automatically based on the original volume resolution. Level l roughly corresponds to a volume resolution of 2^l.
Returns
True if successful, false otherwise

◆ makeHollow()

bool makeHollow ( double  wall)

Make mesh hollow.

Input mesh has to be manifold.

Parameters
wallwall strength in mm. Reasonable values are in the range of 2-5 mm.
Returns
True if successful, false on error.

◆ removeBoundaryFaces()

bool removeBoundaryFaces ( int  layers)

Remove boundary faces from the mesh.

Parameters
layersnumber of mesh boundary layers
Returns
True if successful, false on error.

◆ isManifold()

bool isManifold ( ) const

Checks mesh manifoldness, i.e.

whether the mesh is watertight

Returns
True if mesh is manifold, false otherwise.

◆ applyTexture()

bool applyTexture ( )

Apply texture mapping to the mesh.

Returns
True if successful, false on error.

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close