Visual Computing Library
Loading...
Searching...
No Matches
Cleaning and Repairing Algorithms

List of Mesh Cleaning and repairing algorithms. More...

Collaboration diagram for Cleaning and Repairing Algorithms:

Functions

template<MeshConcept MeshType>
uint vcl::numberUnreferencedVertices (const MeshType &m)
 Returns the number of non-deleted unreferenced vertices of the mesh.
 
template<MeshConcept MeshType>
uint vcl::removeUnreferencedVertices (MeshType &m)
 Marks as deleted all the non-deleted unreferenced vertices of the mesh.
 
template<MeshConcept MeshType>
uint vcl::removeDuplicatedVertices (MeshType &m)
 Marks as deleted the duplicate vertices of the mesh, by looking only at their spatial positions.
 
template<FaceMeshConcept MeshType>
uint vcl::removeDuplicatedFaces (MeshType &m)
 Removes all duplicate faces of the mesh by looking only at their vertex references.
 
template<MeshConcept MeshType>
uint vcl::removeDegeneratedVertices (MeshType &m, bool deleteAlsoFaces)
 Removes all vertices that have coordinates with invalid floating point values (NaN or inf).
 
template<FaceMeshConcept MeshType>
uint vcl::removeDegenerateFaces (MeshType &m)
 Removes all degenerate faces from the input mesh.
 
template<FaceMeshConcept MeshType>
uint vcl::numberNonManifoldVertices (const MeshType &m)
 Counts the number of non-manifold vertices in the input mesh.
 
template<FaceMeshConcept MeshType>
bool vcl::isWaterTight (const MeshType &m)
 Determines whether the input mesh is water tight.
 
template<FaceMeshConcept MeshType>
requires HasPerFaceAdjacentFaces<MeshType>
uint vcl::numberHoles (const MeshType &m)
 Counts the number of holes in the input mesh.
 
template<FaceMeshConcept MeshType>
requires HasPerFaceAdjacentFaces<MeshType>
std::vector< std::set< uint > > vcl::connectedComponents (const MeshType &m)
 Computes the connected components of the input mesh based on its topology.
 
template<FaceMeshConcept MeshType>
uint vcl::numberConnectedComponents (const MeshType &m)
 Computes the number of connected components of the input mesh based on its topology.
 

Detailed Description

List of Mesh Cleaning and repairing algorithms.

You can access these algorithms by including #include <vclib/algorithms/clean.h>

Function Documentation

◆ connectedComponents()

template<FaceMeshConcept MeshType>
requires HasPerFaceAdjacentFaces<MeshType>
std::vector< std::set< uint > > vcl::connectedComponents ( const MeshType &  m)

Computes the connected components of the input mesh based on its topology.

This function computes the connected components of the input mesh based on its topology, and returns a vector of sets, where each set represents a connected component and contains the face indices of the mesh that compose it. The function uses a depth-first search algorithm to traverse the mesh and find the connected components. The function requires the input MeshType to have per-face adjacent faces, and uses the vcl::requirePerFaceAdjacentFaces function to enforce this requirement.

Template Parameters
MeshTypeThe type of the input Mesh. It must satisfy the FaceMeshConcept and have per-face adjacent faces.
Parameters
[in]mThe input mesh for which to compute the connected components.
Returns
A vector of sets representing the connected components of the input mesh. Each set contains the face indices of the mesh that compose a connected component.

◆ isWaterTight()

template<FaceMeshConcept MeshType>
bool vcl::isWaterTight ( const MeshType &  m)

Determines whether the input mesh is water tight.

This function performs a simple test of water tightness on the input mesh, checking that there are no boundary and no non-manifold edges, assuming that the mesh is orientable. It could be debated whether a closed non-orientable surface is water tight or not, but this function does not take orientability into account.

Template Parameters
MeshTypeThe type of the input Mesh. It must satisfy the FaceMeshConcept.
Parameters
[in]mThe input mesh to check for water tightness.
Returns
true if the input mesh is water tight (i.e., closed and manifold), false otherwise.

◆ numberConnectedComponents()

template<FaceMeshConcept MeshType>
uint vcl::numberConnectedComponents ( const MeshType &  m)

Computes the number of connected components of the input mesh based on its topology.

This function computes the number of connected components of the input mesh based on its topology, and returns the result as an unsigned integer. The function simply calls the connectedComponents function to compute the connected components and then returns the size of the resulting vector.

Template Parameters
MeshTypeThe type of the input Mesh. It must satisfy the FaceMeshConcept and have per-face adjacent faces.
Parameters
[in]mThe input mesh for which to compute the number of connected components.
Returns
The number of connected components of the input mesh.

◆ numberHoles()

template<FaceMeshConcept MeshType>
requires HasPerFaceAdjacentFaces<MeshType>
uint vcl::numberHoles ( const MeshType &  m)

Counts the number of holes in the input mesh.

This function counts the number of holes in the input mesh, where a hole is defined as a closed loop of border edges. The function uses a depth-first search algorithm to traverse the mesh and find all the holes. The function requires the input MeshType to have per-face adjacent faces, and uses the vcl::requirePerFaceAdjacentFaces function to enforce this requirement.

Template Parameters
MeshTypeThe type of the input Mesh. It must satisfy the FaceMeshConcept and have per-face adjacent faces.
Parameters
[in]mThe input mesh for which to count the number of holes.
Returns
The number of holes in the input mesh.

◆ numberNonManifoldVertices()

template<FaceMeshConcept MeshType>
uint vcl::numberNonManifoldVertices ( const MeshType &  m)

Counts the number of non-manifold vertices in the input mesh.

This function counts the number of vertices in the input mesh that are non-manifold, meaning that they are connected to more than two faces. A non-manifold vertex is one that belongs to two or more different edges that are not part of the same face.

Template Parameters
MeshTypeThe type of the input Mesh. It must satisfy the FaceMeshConcept.
Parameters
[in]mThe input mesh for which to count the number of non-manifold vertices. This mesh will not be modified by the function.
Returns
The number of non-manifold vertices in the input mesh.

◆ numberUnreferencedVertices()

template<MeshConcept MeshType>
uint vcl::numberUnreferencedVertices ( const MeshType &  m)

Returns the number of non-deleted unreferenced vertices of the mesh.

This function calculates the number of vertices that are not referenced by any of the elements of the mesh, and which have not been marked as deleted.

Template Parameters
MeshTypethe type of the input Mesh. It must satisfy the MeshConcept.
Parameters
[in]mThe input mesh for which to calculate the number of unreferenced vertices.
Returns
The number of non-deleted unreferenced vertices in the mesh.

◆ removeDegeneratedVertices()

template<MeshConcept MeshType>
uint vcl::removeDegeneratedVertices ( MeshType &  m,
bool  deleteAlsoFaces 
)

Removes all vertices that have coordinates with invalid floating point values (NaN or inf).

This function removes all vertices in the input mesh that have coordinates with invalid floating point values, such as NaN or inf. If the input mesh has faces, and if the flag deleteAlsoFaces is set to true, all faces incident on deleted vertices are also deleted.

Template Parameters
MeshTypeThe type of the input Mesh. It must satisfy the MeshConcept.
Parameters
[in,out]mThe input mesh for which to remove degenerated vertices. This mesh will be modified in place, with all degenerated vertices being marked as deleted.
[in]deleteAlsoFacesIf true, all faces incident on deleted vertices will also be deleted.
Returns
The number of degenerated vertices that were marked as deleted.

◆ removeDegenerateFaces()

template<FaceMeshConcept MeshType>
uint vcl::removeDegenerateFaces ( MeshType &  m)

Removes all degenerate faces from the input mesh.

This function removes all faces in the input mesh that are topologically degenerate, meaning that they have two or more vertex references that link the same vertex. All degenerate faces are zero area faces, but not all zero area faces are degenerate (for example, a face with three different vertex references, but two of them have the same coordinates). Therefore, if you also want to remove these kinds of faces, you should call removeDuplicatedVertices(m) first. This function does not adjust topology.

Template Parameters
MeshTypeThe type of the input Mesh. It must satisfy the FaceMeshConcept.
Parameters
[in,out]mThe input mesh for which to remove degenerate faces. This mesh will be modified in place, with all degenerate faces being marked as deleted.
Returns
The number of degenerate faces that were marked as deleted.

◆ removeDuplicatedFaces()

template<FaceMeshConcept MeshType>
uint vcl::removeDuplicatedFaces ( MeshType &  m)

Removes all duplicate faces of the mesh by looking only at their vertex references.

This function removes all faces in the input mesh that have the same vertex references as another face in the mesh. The comparison of face vertex references is based on the indices of the face vertices, so it assumes that the mesh's vertices have already been unified.

Note
This function currently only works for triangle meshes. It should be made more general to work for polygonal meshes as well.
This function does not update any topology relation that could be affected by the removal of duplicate faces, such as the VF or FF relation. Therefore, it is usually performed before building any topology information.
Template Parameters
MeshTypeThe type of the input Mesh. It must satisfy the TriangleMeshConcept.
Parameters
[in,out]mThe input mesh for which to remove duplicate faces. This mesh will be modified in place, with all duplicate faces being marked as deleted.
Returns
The number of duplicated faces that were marked as deleted.

◆ removeDuplicatedVertices()

template<MeshConcept MeshType>
uint vcl::removeDuplicatedVertices ( MeshType &  m)

Marks as deleted the duplicate vertices of the mesh, by looking only at their spatial positions.

This function marks as deleted all vertices in the input mesh that have the same spatial position as another vertex in the mesh. The comparison of vertex positions is based on the coord() function of the vertex type, which must return a 3D point representing the vertex coordinates.

Template Parameters
MeshTypeThe type of the input Mesh. It must satisfy the MeshConcept.
Parameters
[in,out]mThe input mesh for which to remove duplicate vertices. This mesh will be modified in place, with all duplicate vertices being marked as deleted.
Returns
The number of duplicated vertices that were marked as deleted.

◆ removeUnreferencedVertices()

template<MeshConcept MeshType>
uint vcl::removeUnreferencedVertices ( MeshType &  m)

Marks as deleted all the non-deleted unreferenced vertices of the mesh.

This function marks as deleted all vertices in the input mesh that are not referenced by any of the mesh's elements, and which have not already been marked as deleted.

Template Parameters
MeshTypeThe type of the input Mesh. It must satisfy the MeshConcept.
Parameters
[in,out]mThe input mesh for which to remove the unreferenced vertices. This mesh will be modified in place, with all unreferenced vertices being marked as deleted.
Returns
The number of non-deleted vertices that were marked as deleted.