MeshLib C++ Docs
Loading...
Searching...
No Matches
MeshComponents

Classes

class  MR::MeshComponents::ExpandToComponentsParams
 
class  MR::MeshComponents::LargeByAreaComponentsSettings
 

Enumerations

enum  MR::MeshComponents::FaceIncidence
 Face incidence type.
 

Functions

MRMESH_API FaceBitSet MR::MeshComponents::getComponent (const MeshPart &meshPart, FaceId id, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
 
MRMESH_API VertBitSet MR::MeshComponents::getComponentVerts (const Mesh &mesh, VertId id, const VertBitSet *region=nullptr)
 
MRMESH_API VertBitSet MR::MeshComponents::getLargestComponentVerts (const Mesh &mesh, const VertBitSet *region=nullptr)
 returns the largest by number of elements component
 
MRMESH_API VertBitSet MR::MeshComponents::getLargeComponentVerts (const Mesh &mesh, int minVerts, const VertBitSet *region=nullptr)
 returns the union of vertex connected components, each having at least
 
MRMESH_API FaceBitSet MR::MeshComponents::getLargestComponent (const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={}, float minArea=0, int *numSmallerComponents=nullptr)
 returns the largest by surface area component or empty set if its area is smaller than
 
MRMESH_API FaceBitSet MR::MeshComponents::getComponents (const MeshPart &meshPart, const FaceBitSet &seeds, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
 returns union of connected components, each of which contains at least one seed face
 
MRMESH_API FaceBitSet MR::MeshComponents::getComponents (const MeshTopology &topology, const FaceBitSet &seeds, const FaceBitSet *region=nullptr, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
 
MRMESH_API FaceBitSet MR::MeshComponents::getLargeByAreaComponents (const MeshPart &meshPart, float minArea, const UndirectedEdgeBitSet *isCompBd)
 returns the union of connected components, each having at least given area
 
MRMESH_API FaceBitSet MR::MeshComponents::getLargeByAreaComponents (const MeshPart &meshPart, UnionFind< FaceId > &unionFind, float minArea, UndirectedEdgeBitSet *outBdEdgesBetweenLargeComps=nullptr)
 given prepared union-find structure returns the union of connected components, each having at least given area
 
MRMESH_API Expected< FaceBitSetMR::MeshComponents::expandToComponents (const MeshPart &mp, const FaceBitSet &seeds, const ExpandToComponentsParams &params={})
 expands given seeds to whole components
 
MRMESH_API std::vector< FaceBitSetMR::MeshComponents::getNLargeByAreaComponents (const MeshPart &meshPart, const LargeByAreaComponentsSettings &settings)
 returns requested number of largest by area connected components in descending by area order
 
MRMESH_API FaceBitSet MR::MeshComponents::getLargeByAreaSmoothComponents (const MeshPart &meshPart, float minArea, float angleFromPlanar, UndirectedEdgeBitSet *outBdEdgesBetweenLargeComps=nullptr)
 
MRMESH_API VertBitSet MR::MeshComponents::getComponentsVerts (const Mesh &mesh, const VertBitSet &seeds, const VertBitSet *region=nullptr)
 returns union of connected components, each of which contains at least one seed vert
 
MRMESH_API size_t MR::MeshComponents::getNumComponents (const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
 returns the number of connected components in mesh part
 
MRMESH_API std::vector< FaceBitSetMR::MeshComponents::getAllComponents (const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
 
MRMESH_API std::pair< std::vector< FaceBitSet >, int > MR::MeshComponents::getAllComponents (const MeshPart &meshPart, int maxComponentCount, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
 
MRMESH_API std::vector< FaceBitSetMR::MeshComponents::getAllComponents (Face2RegionMap &componentsMap, int componentsCount, const FaceBitSet &region, int maxComponentCount)
 
MRMESH_API std::pair< Face2RegionMap, int > MR::MeshComponents::getAllComponentsMap (const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
 
MRMESH_API Vector< double, RegionIdMR::MeshComponents::getRegionAreas (const MeshPart &meshPart, const Face2RegionMap &regionMap, int numRegions)
 computes the area of each region given via the map
 
MRMESH_API std::pair< FaceBitSet, int > MR::MeshComponents::getLargeByAreaRegions (const MeshPart &meshPart, const Face2RegionMap &regionMap, int numRegions, float minArea)
 
MRMESH_API std::vector< VertBitSetMR::MeshComponents::getAllComponentsVerts (const Mesh &mesh, const VertBitSet *region=nullptr)
 gets all connected components of mesh part
 
MRMESH_API std::vector< VertBitSetMR::MeshComponents::getAllComponentsVertsSeparatedByPath (const Mesh &mesh, const SurfacePath &path)
 gets all connected components, separating vertices by given path (either closed or from boundary to boundary)
 
MRMESH_API std::vector< VertBitSetMR::MeshComponents::getAllComponentsVertsSeparatedByPaths (const Mesh &mesh, const std::vector< SurfacePath > &paths)
 gets all connected components, separating vertices by given paths (either closed or from boundary to boundary)
 
MRMESH_API std::vector< EdgeBitSetMR::MeshComponents::getAllComponentsEdges (const Mesh &mesh, const EdgeBitSet &edges)
 subdivides given edges on connected components
 
MRMESH_API std::vector< UndirectedEdgeBitSetMR::MeshComponents::getAllComponentsUndirectedEdges (const Mesh &mesh, const UndirectedEdgeBitSet &edges)
 subdivides given edges on connected components
 
MRMESH_API bool MR::MeshComponents::hasFullySelectedComponent (const Mesh &mesh, const VertBitSet &selection)
 returns true if all vertices of a mesh connected component are present in selection
 
MRMESH_API bool MR::MeshComponents::hasFullySelectedComponent (const MeshTopology &topology, const VertBitSet &selection)
 
MRMESH_API void MR::MeshComponents::excludeFullySelectedComponents (const Mesh &mesh, VertBitSet &selection)
 if all vertices of a mesh connected component are present in selection, excludes these vertices
 
MRMESH_API UnionFind< FaceIdMR::MeshComponents::getUnionFindStructureFaces (const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
 gets union-find structure for faces with different options of face-connectivity
 
MRMESH_API UnionFind< FaceIdMR::MeshComponents::getUnionFindStructureFaces (const MeshTopology &topology, const FaceBitSet *region=nullptr, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
 
MRMESH_API UnionFind< FaceIdMR::MeshComponents::getUnionFindStructureFacesPerEdge (const MeshPart &meshPart, const UndirectedEdgeBitSet *isCompBd={})
 
MRMESH_API UnionFind< FaceIdMR::MeshComponents::getUnionFindStructureFacesPerEdge (const MeshTopology &topology, const FaceBitSet *region=nullptr, const UndirectedEdgeBitSet *isCompBd={})
 
MRMESH_API UnionFind< VertIdMR::MeshComponents::getUnionFindStructureVerts (const Mesh &mesh, const VertBitSet *region=nullptr)
 gets union-find structure for vertices
 
MRMESH_API UnionFind< VertIdMR::MeshComponents::getUnionFindStructureVerts (const MeshTopology &topology, const VertBitSet *region=nullptr)
 
MRMESH_API UnionFind< VertIdMR::MeshComponents::getUnionFindStructureVerts (const Mesh &mesh, const EdgeBitSet &edges)
 gets union-find structure for vertices, considering connections by given edges only
 
MRMESH_API UnionFind< VertIdMR::MeshComponents::getUnionFindStructureVerts (const Mesh &mesh, const UndirectedEdgeBitSet &edges)
 gets union-find structure for vertices, considering connections by given undirected edges only
 
MRMESH_API UnionFind< VertIdMR::MeshComponents::getUnionFindStructureVertsEx (const Mesh &mesh, const UndirectedEdgeBitSet &ignoreEdges)
 gets union-find structure for vertices, considering connections by all edges excluding given ones
 
MRMESH_API UnionFind< VertIdMR::MeshComponents::getUnionFindStructureVertsSeparatedByPath (const Mesh &mesh, const SurfacePath &path, VertBitSet *outPathVerts=nullptr)
 gets union-find structure for vertices, separating vertices by given path (either closed or from boundary to boundary)
 
MRMESH_API UnionFind< VertIdMR::MeshComponents::getUnionFindStructureVertsSeparatedByPaths (const Mesh &mesh, const std::vector< SurfacePath > &paths, VertBitSet *outPathVerts=nullptr)
 
MRMESH_API UnionFind< UndirectedEdgeIdMR::MeshComponents::getUnionFindStructureUndirectedEdges (const Mesh &mesh, bool allPointToRoots=false)
 
MRMESH_API UndirectedEdgeBitSet MR::MeshComponents::getComponentsUndirectedEdges (const Mesh &mesh, const UndirectedEdgeBitSet &seeds)
 returns union of connected components, each of which contains at least one seed edge
 

Variables

float MR::MeshComponents::ExpandToComponentsParams::coverRatio = 0.0f
 
FaceIncidence MR::MeshComponents::ExpandToComponentsParams::incidence = FaceIncidence::PerEdge
 
const UndirectedEdgeBitSetMR::MeshComponents::ExpandToComponentsParams::isCompBd = nullptr
 optional predicate of boundaries between components
 
int * MR::MeshComponents::ExpandToComponentsParams::optOutNumComponents = nullptr
 optional output number of components
 
ProgressCallback MR::MeshComponents::ExpandToComponentsParams::cb
 
int MR::MeshComponents::LargeByAreaComponentsSettings::maxLargeComponents = 2
 return at most given number of largest by area connected components
 
int * MR::MeshComponents::LargeByAreaComponentsSettings::numSmallerComponents = nullptr
 optional output: the number of components in addition to returned ones
 
float MR::MeshComponents::LargeByAreaComponentsSettings::minArea = 0
 do not consider a component large if its area is below this value
 
const UndirectedEdgeBitSetMR::MeshComponents::LargeByAreaComponentsSettings::isCompBd = nullptr
 optional predicate of boundaries between components
 

Detailed Description

Function Documentation

◆ getAllComponents() [1/3]

MRMESH_API std::vector< FaceBitSet > MR::MeshComponents::getAllComponents ( const MeshPart & meshPart,
FaceIncidence incidence = FaceIncidence::PerEdge,
const UndirectedEdgeBitSet * isCompBd = {} )
nodiscard

gets all connected components of mesh part

Note
be careful, if mesh is large enough and has many components, the memory overflow will occur

◆ getAllComponents() [2/3]

MRMESH_API std::pair< std::vector< FaceBitSet >, int > MR::MeshComponents::getAllComponents ( const MeshPart & meshPart,
int maxComponentCount,
FaceIncidence incidence = FaceIncidence::PerEdge,
const UndirectedEdgeBitSet * isCompBd = {} )
nodiscard

gets all connected components of mesh part \detail if components number more than the maxComponentCount, they will be combined into groups of the same size

Parameters
maxComponentCountshould be more then 1
Returns
pair components bitsets vector and number components in one group if components number more than maxComponentCount

◆ getAllComponents() [3/3]

MRMESH_API std::vector< FaceBitSet > MR::MeshComponents::getAllComponents ( Face2RegionMap & componentsMap,
int componentsCount,
const FaceBitSet & region,
int maxComponentCount )
nodiscard

gets all connected components from components map ( FaceId => RegionId ) \detail if components number more than the maxComponentCount, they will be combined into groups of the same size (this similarly changes componentsMap)

Parameters
maxComponentCountshould be more then 1
Returns
components bitsets vector

◆ getAllComponentsMap()

MRMESH_API std::pair< Face2RegionMap, int > MR::MeshComponents::getAllComponentsMap ( const MeshPart & meshPart,
FaceIncidence incidence = FaceIncidence::PerEdge,
const UndirectedEdgeBitSet * isCompBd = {} )
nodiscard

gets all connected components of mesh part as

  1. the mapping: FaceId -> Component ID in [0, 1, 2, ...)
  2. the total number of components

◆ getComponent()

MRMESH_API FaceBitSet MR::MeshComponents::getComponent ( const MeshPart & meshPart,
FaceId id,
FaceIncidence incidence = FaceIncidence::PerEdge,
const UndirectedEdgeBitSet * isCompBd = {} )
nodiscard

returns one connected component containing given face, not effective to call more than once, if several components are needed use getAllComponents

◆ getComponentVerts()

MRMESH_API VertBitSet MR::MeshComponents::getComponentVerts ( const Mesh & mesh,
VertId id,
const VertBitSet * region = nullptr )
nodiscard

returns one connected component containing given vertex, not effective to call more than once, if several components are needed use getAllComponentsVerts

◆ getLargeByAreaRegions()

MRMESH_API std::pair< FaceBitSet, int > MR::MeshComponents::getLargeByAreaRegions ( const MeshPart & meshPart,
const Face2RegionMap & regionMap,
int numRegions,
float minArea )
nodiscard

returns

  1. the union of all regions with area >= minArea
  2. the number of such regions

◆ getLargeByAreaSmoothComponents()

MRMESH_API FaceBitSet MR::MeshComponents::getLargeByAreaSmoothComponents ( const MeshPart & meshPart,
float minArea,
float angleFromPlanar,
UndirectedEdgeBitSet * outBdEdgesBetweenLargeComps = nullptr )
nodiscard

returns the union of connected components, each having at least given area, and any two faces in a connected component have a path along the surface across the edges, where surface does not deviate from plane more than on given angle

◆ getLargeComponentVerts()

MRMESH_API VertBitSet MR::MeshComponents::getLargeComponentVerts ( const Mesh & mesh,
int minVerts,
const VertBitSet * region = nullptr )
nodiscard

returns the union of vertex connected components, each having at least

Parameters
minVertsvertices

◆ getLargestComponent()

MRMESH_API FaceBitSet MR::MeshComponents::getLargestComponent ( const MeshPart & meshPart,
FaceIncidence incidence = FaceIncidence::PerEdge,
const UndirectedEdgeBitSet * isCompBd = {},
float minArea = 0,
int * numSmallerComponents = nullptr )
nodiscard

returns the largest by surface area component or empty set if its area is smaller than

Parameters
minAreaoptional output: the number of components in addition to returned one

◆ getUnionFindStructureFacesPerEdge()

MRMESH_API UnionFind< FaceId > MR::MeshComponents::getUnionFindStructureFacesPerEdge ( const MeshPart & meshPart,
const UndirectedEdgeBitSet * isCompBd = {} )
nodiscard

gets union-find structure for faces with connectivity by shared edge, and optional edge predicate whether to skip uniting components over it it is guaranteed that isCompBd is invoked in a thread-safe manner (that left and right face are always processed by one thread)

◆ getUnionFindStructureUndirectedEdges()

MRMESH_API UnionFind< UndirectedEdgeId > MR::MeshComponents::getUnionFindStructureUndirectedEdges ( const Mesh & mesh,
bool allPointToRoots = false )
nodiscard

gets union-find structure for all undirected edges in

Parameters
mesh
allPointToRootsif true, then every element in the structure will point directly to the root of its respective component

◆ getUnionFindStructureVertsSeparatedByPath()

MRMESH_API UnionFind< VertId > MR::MeshComponents::getUnionFindStructureVertsSeparatedByPath ( const Mesh & mesh,
const SurfacePath & path,
VertBitSet * outPathVerts = nullptr )
nodiscard

gets union-find structure for vertices, separating vertices by given path (either closed or from boundary to boundary)

Parameters
outPathVertsthis set receives all vertices passed by the path

Variable Documentation

◆ coverRatio

float MR::MeshComponents::ExpandToComponentsParams::coverRatio = 0.0f

expands only if seeds cover at least this ratio of the component area <=0 - expands all seeds

‍1 - none