ImFusion SDK 4.3
ImFusion::MeshProcessing::ConnectedComponents Namespace Reference

Mesh processing algorithms based on connected component analysis. More...

Detailed Description

Mesh processing algorithms based on connected component analysis.

Classes

struct  ConnectedComponent
 
struct  ConnectedComponentInfo
 

Functions

ConnectedComponentInfo labelConnectedComponents (const Mesh &mesh)
 Determines the connected triangles.
 
bool reduceToNumberOfLargestComponents (Mesh &mesh, int numComponents, const ConnectedComponentInfo *info=nullptr)
 Removes small connected components.
 
bool reduceToComponentsByLabel (Mesh &mesh, const std::vector< unsigned int > &componentsToKeep, const ConnectedComponentInfo *info=nullptr)
 Removes all connected components that are not among the specified ones.
 
bool reduceToComponentsByArea (Mesh &mesh, float minConnectedArea, float maxConnectedArea, const ConnectedComponentInfo *info=nullptr)
 Removes all connected components that are not within the specified area range.
 
std::vector< std::unique_ptr< Mesh > > splitConnectedComponents (const Mesh &mesh, const std::vector< unsigned int > &componentsToExtract={}, const ConnectedComponentInfo *info=nullptr)
 Split connected components in separate meshes.
 
void analyzeLabels (TriMesh *mesh, int assignedLabels, std::vector< int > &labels, std::vector< int > &labelsSize, std::vector< float > &labelsArea)
 

Function Documentation

◆ labelConnectedComponents()

ConnectedComponentInfo labelConnectedComponents ( const Mesh & mesh)

Determines the connected triangles.

Known duplicate vertices will be taken into account

Parameters
[in,out]meshmesh
Returns
connected component info
Note
Consider removing duplicated vertices by calling Cleaning::mergeCloseVertices before this

◆ reduceToNumberOfLargestComponents()

bool reduceToNumberOfLargestComponents ( Mesh & mesh,
int numComponents,
const ConnectedComponentInfo * info = nullptr )

Removes small connected components.

Parameters
[in,out]meshmesh
numComponentsnumber of largest connected components that should be kept
infooptional connected component info obtained from labelConnectedComponents. If not provided this info will be re-computed internally. It is recommended to pass this information in order to improve the speed
Returns
true upon success
Note
Consider removing duplicated vertices by calling Cleaning::mergeCloseVertices before this

◆ reduceToComponentsByLabel()

bool reduceToComponentsByLabel ( Mesh & mesh,
const std::vector< unsigned int > & componentsToKeep,
const ConnectedComponentInfo * info = nullptr )

Removes all connected components that are not among the specified ones.

Parameters
[in,out]meshmesh
componentsToKeeplabels of connected components that should remain
infooptional connected component info obtained from labelConnectedComponents. If not provided this info will be re-computed internally. It is recommended to pass this information in order to improve the speed
Returns
true upon success
Note
Consider removing duplicated vertices by calling Cleaning::mergeCloseVertices before this

◆ reduceToComponentsByArea()

bool reduceToComponentsByArea ( Mesh & mesh,
float minConnectedArea,
float maxConnectedArea,
const ConnectedComponentInfo * info = nullptr )

Removes all connected components that are not within the specified area range.

Parameters
[in,out]meshmesh
minConnectedAreaminimum allowed area of triangles for the remaining connected components
maxConnectedAreamaximum allowed area of triangles for the remaining connected components
infooptional connected component info obtained from labelConnectedComponents. If not provided this info will be re-computed internally. It is recommended to pass this information in order to improve the speed
Returns
true upon success
Note
Consider removing duplicated vertices by calling Cleaning::mergeCloseVertices before this

◆ splitConnectedComponents()

std::vector< std::unique_ptr< Mesh > > splitConnectedComponents ( const Mesh & mesh,
const std::vector< unsigned int > & componentsToExtract = {},
const ConnectedComponentInfo * info = nullptr )

Split connected components in separate meshes.

Parameters
[in]meshmesh
[in]componentsToExtractoptional parameter specifying the labels of components to extract. If empty, all components will be extracted
infooptional connected component info obtained from labelConnectedComponents. If not provided this info will be re-computed internally. It is recommended to pass this information in order to improve the speed
Returns
new meshes each containing a separate connected component
Note
Consider removing duplicated vertices by calling Cleaning::mergeCloseVertices before this
Search Tab / S to search, Esc to close