MeshLib Documentation
Loading...
Searching...
No Matches
MeshComponents

Classes

struct  MR::MeshComponents::LargeByAreaComponentsSettings
 

Enumerations

enum  MR::MeshComponents::FaceIncidence { MR::MeshComponents::PerEdge , MR::MeshComponents::PerVertex }
 Face incidence type. More...
 

Functions

MRMESH_API FaceBitSet MR::MeshComponents::getComponent (const MeshPart &meshPart, FaceId id, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgePredicate &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 UndirectedEdgePredicate &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 UndirectedEdgePredicate &isCompBd={})
 returns union of connected components, each of which contains at least one seed face
 
MRMESH_API FaceBitSet MR::MeshComponents::getLargeByAreaComponents (const MeshPart &meshPart, float minArea, const UndirectedEdgePredicate &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 std::vector< FaceBitSet > MR::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 UndirectedEdgePredicate &isCompBd={})
 returns the number of connected components in mesh part
 
MRMESH_API std::vector< FaceBitSet > MR::MeshComponents::getAllComponents (const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgePredicate &isCompBd={})
 
MRMESH_API std::pair< std::vector< FaceBitSet >, int > MR::MeshComponents::getAllComponents (const MeshPart &meshPart, int maxComponentCount, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgePredicate &isCompBd={})
 
MRMESH_API std::vector< FaceBitSet > MR::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 UndirectedEdgePredicate &isCompBd={})
 
MRMESH_API Vector< double, RegionId > MR::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< VertBitSet > MR::MeshComponents::getAllComponentsVerts (const Mesh &mesh, const VertBitSet *region=nullptr)
 gets all connected components of mesh part
 
MRMESH_API std::vector< VertBitSet > MR::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< VertBitSet > MR::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< EdgeBitSet > MR::MeshComponents::getAllComponentsEdges (const Mesh &mesh, const EdgeBitSet &edges)
 subdivides given edges on connected components
 
MRMESH_API std::vector< UndirectedEdgeBitSet > MR::MeshComponents::getAllComponentsUndirectedEdges (const Mesh &mesh, const UndirectedEdgeBitSet &edges)
 subdivides given edges on connected components
 
MRMESH_API std::vector< FaceBitSet > MR::MeshComponents::getAllFlatComponents (const MeshPart &meshPart, float zTolerance)
 gets all connected components where difference between the highest and the lowest point is less than
 
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 void MR::MeshComponents::excludeFullySelectedComponents (const Mesh &mesh, VertBitSet &selection)
 if all vertices of a mesh connected component are present in selection exludes these vertices
 
MRMESH_API UnionFind< FaceId > MR::MeshComponents::getUnionFindStructureFaces (const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgePredicate &isCompBd={})
 gets union-find structure for faces with different options of face-connectivity
 
MRMESH_API UnionFind< FaceId > MR::MeshComponents::getUnionFindStructureFacesPerEdge (const MeshPart &meshPart, const UndirectedEdgePredicate &isCompBd={})
 
MRMESH_API UnionFind< VertId > MR::MeshComponents::getUnionFindStructureVerts (const Mesh &mesh, const VertBitSet *region=nullptr)
 gets union-find structure for vertices
 
MRMESH_API UnionFind< VertId > MR::MeshComponents::getUnionFindStructureVerts (const Mesh &mesh, const EdgeBitSet &edges)
 gets union-find structure for vertices, considering connections by given edges only
 
MRMESH_API UnionFind< VertId > MR::MeshComponents::getUnionFindStructureVerts (const Mesh &mesh, const UndirectedEdgeBitSet &edges)
 gets union-find structure for vertices, considering connections by given undirected edges only
 
MRMESH_API UnionFind< VertId > MR::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< VertId > MR::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< VertId > MR::MeshComponents::getUnionFindStructureVertsSeparatedByPaths (const Mesh &mesh, const std::vector< SurfacePath > &paths, VertBitSet *outPathVerts=nullptr)
 
MRMESH_API UnionFind< UndirectedEdgeId > MR::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

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
 
UndirectedEdgePredicate MR::MeshComponents::LargeByAreaComponentsSettings::isCompBd
 optional predicate of boundaries between components
 

Detailed Description

Enumeration Type Documentation

◆ FaceIncidence

Face incidence type.

Enumerator
PerEdge 

face can have neighbor only via edge

PerVertex 

face can have neighbor via vertex

Function Documentation

◆ excludeFullySelectedComponents()

MRMESH_API void MR::MeshComponents::excludeFullySelectedComponents ( const Mesh & mesh,
VertBitSet & selection )

if all vertices of a mesh connected component are present in selection exludes these vertices

◆ getAllComponents() [1/3]

MRMESH_API std::vector< FaceBitSet > MR::MeshComponents::getAllComponents ( const MeshPart & meshPart,
FaceIncidence incidence = FaceIncidence::PerEdge,
const UndirectedEdgePredicate & 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 UndirectedEdgePredicate & 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

◆ getAllComponentsEdges()

MRMESH_API std::vector< EdgeBitSet > MR::MeshComponents::getAllComponentsEdges ( const Mesh & mesh,
const EdgeBitSet & edges )
nodiscard

subdivides given edges on connected components

◆ getAllComponentsMap()

MRMESH_API std::pair< Face2RegionMap, int > MR::MeshComponents::getAllComponentsMap ( const MeshPart & meshPart,
FaceIncidence incidence = FaceIncidence::PerEdge,
const UndirectedEdgePredicate & 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

◆ getAllComponentsUndirectedEdges()

MRMESH_API std::vector< UndirectedEdgeBitSet > MR::MeshComponents::getAllComponentsUndirectedEdges ( const Mesh & mesh,
const UndirectedEdgeBitSet & edges )
nodiscard

subdivides given edges on connected components

◆ getAllComponentsVerts()

MRMESH_API std::vector< VertBitSet > MR::MeshComponents::getAllComponentsVerts ( const Mesh & mesh,
const VertBitSet * region = nullptr )
nodiscard

gets all connected components of mesh part

◆ getAllComponentsVertsSeparatedByPath()

MRMESH_API std::vector< VertBitSet > MR::MeshComponents::getAllComponentsVertsSeparatedByPath ( const Mesh & mesh,
const SurfacePath & path )
nodiscard

gets all connected components, separating vertices by given path (either closed or from boundary to boundary)

◆ getAllComponentsVertsSeparatedByPaths()

MRMESH_API std::vector< VertBitSet > MR::MeshComponents::getAllComponentsVertsSeparatedByPaths ( const Mesh & mesh,
const std::vector< SurfacePath > & paths )
nodiscard

gets all connected components, separating vertices by given paths (either closed or from boundary to boundary)

◆ getAllFlatComponents()

MRMESH_API std::vector< FaceBitSet > MR::MeshComponents::getAllFlatComponents ( const MeshPart & meshPart,
float zTolerance )
nodiscard

gets all connected components where difference between the highest and the lowest point is less than

Parameters
zTolerance

◆ getComponent()

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

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

◆ getComponents()

MRMESH_API FaceBitSet MR::MeshComponents::getComponents ( const MeshPart & meshPart,
const FaceBitSet & seeds,
FaceIncidence incidence = FaceIncidence::PerEdge,
const UndirectedEdgePredicate & isCompBd = {} )
nodiscard

returns union of connected components, each of which contains at least one seed face

◆ getComponentsUndirectedEdges()

MRMESH_API UndirectedEdgeBitSet MR::MeshComponents::getComponentsUndirectedEdges ( const Mesh & mesh,
const UndirectedEdgeBitSet & seeds )
nodiscard

returns union of connected components, each of which contains at least one seed edge

◆ getComponentsVerts()

MRMESH_API VertBitSet MR::MeshComponents::getComponentsVerts ( const Mesh & mesh,
const VertBitSet & seeds,
const VertBitSet * region = nullptr )
nodiscard

returns union of connected components, each of which contains at least one seed vert

◆ 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

◆ getLargeByAreaComponents() [1/2]

MRMESH_API FaceBitSet MR::MeshComponents::getLargeByAreaComponents ( const MeshPart & meshPart,
float minArea,
const UndirectedEdgePredicate & isCompBd )
nodiscard

returns the union of connected components, each having at least given area

◆ getLargeByAreaComponents() [2/2]

MRMESH_API FaceBitSet MR::MeshComponents::getLargeByAreaComponents ( const MeshPart & meshPart,
UnionFind< FaceId > & unionFind,
float minArea,
UndirectedEdgeBitSet * outBdEdgesBetweenLargeComps = nullptr )
nodiscard

given prepared union-find structure returns the union of connected components, each having at least given area

◆ 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 UndirectedEdgePredicate & 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

◆ getLargestComponentVerts()

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

returns the largest by number of elements component

◆ getNLargeByAreaComponents()

MRMESH_API std::vector< FaceBitSet > MR::MeshComponents::getNLargeByAreaComponents ( const MeshPart & meshPart,
const LargeByAreaComponentsSettings & settings )
nodiscard

returns requested number of largest by area connected components in descending by area order

◆ getNumComponents()

MRMESH_API size_t MR::MeshComponents::getNumComponents ( const MeshPart & meshPart,
FaceIncidence incidence = FaceIncidence::PerEdge,
const UndirectedEdgePredicate & isCompBd = {} )
nodiscard

returns the number of connected components in mesh part

◆ getRegionAreas()

MRMESH_API Vector< double, RegionId > MR::MeshComponents::getRegionAreas ( const MeshPart & meshPart,
const Face2RegionMap & regionMap,
int numRegions )
nodiscard

computes the area of each region given via the map

◆ getUnionFindStructureFaces()

MRMESH_API UnionFind< FaceId > MR::MeshComponents::getUnionFindStructureFaces ( const MeshPart & meshPart,
FaceIncidence incidence = FaceIncidence::PerEdge,
const UndirectedEdgePredicate & isCompBd = {} )
nodiscard

gets union-find structure for faces with different options of face-connectivity

◆ getUnionFindStructureFacesPerEdge()

MRMESH_API UnionFind< FaceId > MR::MeshComponents::getUnionFindStructureFacesPerEdge ( const MeshPart & meshPart,
const UndirectedEdgePredicate & 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 thead-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

◆ getUnionFindStructureVerts() [1/3]

MRMESH_API UnionFind< VertId > MR::MeshComponents::getUnionFindStructureVerts ( const Mesh & mesh,
const EdgeBitSet & edges )
nodiscard

gets union-find structure for vertices, considering connections by given edges only

◆ getUnionFindStructureVerts() [2/3]

MRMESH_API UnionFind< VertId > MR::MeshComponents::getUnionFindStructureVerts ( const Mesh & mesh,
const UndirectedEdgeBitSet & edges )
nodiscard

gets union-find structure for vertices, considering connections by given undirected edges only

◆ getUnionFindStructureVerts() [3/3]

MRMESH_API UnionFind< VertId > MR::MeshComponents::getUnionFindStructureVerts ( const Mesh & mesh,
const VertBitSet * region = nullptr )
nodiscard

gets union-find structure for vertices

◆ getUnionFindStructureVertsEx()

MRMESH_API UnionFind< VertId > MR::MeshComponents::getUnionFindStructureVertsEx ( const Mesh & mesh,
const UndirectedEdgeBitSet & ignoreEdges )
nodiscard

gets union-find structure for vertices, considering connections by all edges excluding given ones

◆ 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

◆ getUnionFindStructureVertsSeparatedByPaths()

MRMESH_API UnionFind< VertId > MR::MeshComponents::getUnionFindStructureVertsSeparatedByPaths ( const Mesh & mesh,
const std::vector< SurfacePath > & paths,
VertBitSet * outPathVerts = nullptr )
nodiscard

◆ hasFullySelectedComponent()

MRMESH_API bool MR::MeshComponents::hasFullySelectedComponent ( const Mesh & mesh,
const VertBitSet & selection )
nodiscard

returns true if all vertices of a mesh connected component are present in selection

Variable Documentation

◆ isCompBd

UndirectedEdgePredicate MR::MeshComponents::LargeByAreaComponentsSettings::isCompBd

optional predicate of boundaries between components

◆ maxLargeComponents

int MR::MeshComponents::LargeByAreaComponentsSettings::maxLargeComponents = 2

return at most given number of largest by area connected components

◆ minArea

float MR::MeshComponents::LargeByAreaComponentsSettings::minArea = 0

do not consider a component large if its area is below this value

◆ numSmallerComponents

int* MR::MeshComponents::LargeByAreaComponentsSettings::numSmallerComponents = nullptr

optional output: the number of components in addition to returned ones