RecFusion SDK
 All Classes Functions Variables Enumerations Enumerator
RecFusion::Mesh Class Reference

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

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...
 
bool setTriangle (int idx, const Triangle &triangle)
 Set triangle 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)
 Crop mesh with given bounding box. More...
 
bool fillHoles ()
 Fill holes in mesh to make it manifold. More...
 
bool makeHollow (double wall)
 Make mesh hollow. Input mesh has to be manifold. More...
 
bool isManifold () const
 Checks mesh manifoldness, i.e. whether the mesh is watertight. 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)
 Creates mesh from user data. More...
 

Detailed Description

Provides functionality for mesh post-processing and export.

Member Enumeration Documentation

Supported mesh export formats.

Enumerator
PLY 

Binary PLY format.

OBJ 

OBJ format.

STL 

STL format (does not include color)

Member Function Documentation

Vec3 RecFusion::Mesh::center ( ) const

Get mesh bounding box center.

Returns
Bounding box center
bool RecFusion::Mesh::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.
Color RecFusion::Mesh::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.

static Mesh* RecFusion::Mesh::create ( int  vertexCount,
const double *  vertices,
int  triangleCount,
const int *  triangleIndices,
const double *  colors = 0,
const double *  normals = 0 
)
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.
Returns
Pointer to newly created mesh. User needs to delete mesh after usage. Returns null pointer if an error occurs (inconsistent mesh, no license)
bool RecFusion::Mesh::crop ( const Vec3 boxCenter,
const Vec3 boxExtent 
)

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
Returns
True if successful, false otherwise.
bool RecFusion::Mesh::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.
Vec3 RecFusion::Mesh::extent ( ) const

Get mesh bounding box extent.

Returns
Bounding box extent
bool RecFusion::Mesh::fillHoles ( )

Fill holes in mesh to make it manifold.

Returns
True if successful, false otherwise
bool RecFusion::Mesh::isManifold ( ) const

Checks mesh manifoldness, i.e. whether the mesh is watertight.

Returns
True if mesh is manifold, false otherwise.
bool RecFusion::Mesh::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.
Coordinate RecFusion::Mesh::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.

bool RecFusion::Mesh::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.
bool RecFusion::Mesh::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
bool RecFusion::Mesh::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
bool RecFusion::Mesh::setTriangle ( int  idx,
const Triangle triangle 
)

Set triangle vertex indices.

Parameters
idxThe index of the triangle.
triangleTriangle information.
Returns
If the index does not exist in the mesh false is returned
bool RecFusion::Mesh::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
bool RecFusion::Mesh::smooth ( int  iterations)

Smooth mesh.

Parameters
iterationsNumber of smoothing iterations.
Returns
True if successful, false on error.
void RecFusion::Mesh::transform ( const Mat3 R,
const Vec3 t 
)

Transform mesh with the given rotation and translation.

Parameters
R3x3 rotation matrix
tTranslation vector
Triangle RecFusion::Mesh::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.

int RecFusion::Mesh::triangleCount ( ) const

Return number of triangles in the mesh.

Returns
Number of mesh triangles.
Coordinate RecFusion::Mesh::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.

int RecFusion::Mesh::vertexCount ( ) const

Return number of vertices in the mesh.

Returns
Number of mesh vertices.

The documentation for this class was generated from the following file: