MeshLib Documentation
Loading...
Searching...
No Matches
MRMesh/MRMeshComponents.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRUnionFind.h"
4#include <functional>
5
6namespace MR
7{
8
9namespace MeshComponents
10{
11
15
22
25[[nodiscard]] MRMESH_API FaceBitSet getComponent( const MeshPart& meshPart, FaceId id,
26 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgePredicate & isCompBd = {} );
27
30[[nodiscard]] MRMESH_API VertBitSet getComponentVerts( const Mesh& mesh, VertId id, const VertBitSet* region = nullptr );
31
33[[nodiscard]] MRMESH_API VertBitSet getLargestComponentVerts( const Mesh& mesh, const VertBitSet* region = nullptr );
34
36[[nodiscard]] MRMESH_API VertBitSet getLargeComponentVerts( const Mesh& mesh, int minVerts, const VertBitSet* region = nullptr );
37
38
40[[nodiscard]] MRMESH_API FaceBitSet getLargestComponent( const MeshPart& meshPart,
41 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgePredicate & isCompBd = {}, float minArea = 0,
42 int * numSmallerComponents = nullptr );
43
45[[nodiscard]] MRMESH_API FaceBitSet getComponents( const MeshPart& meshPart, const FaceBitSet & seeds,
46 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgePredicate & isCompBd = {} );
47
49[[nodiscard]] MRMESH_API FaceBitSet getLargeByAreaComponents( const MeshPart& meshPart, float minArea, const UndirectedEdgePredicate & isCompBd );
50
52[[nodiscard]] MRMESH_API FaceBitSet getLargeByAreaComponents( const MeshPart& meshPart, UnionFind<FaceId> & unionFind, float minArea,
53 UndirectedEdgeBitSet * outBdEdgesBetweenLargeComps = nullptr );
54
69
71[[nodiscard]] MRMESH_API std::vector<FaceBitSet> getNLargeByAreaComponents( const MeshPart& meshPart, const LargeByAreaComponentsSettings & settings );
72
75[[nodiscard]] MRMESH_API FaceBitSet getLargeByAreaSmoothComponents( const MeshPart& meshPart, float minArea, float angleFromPlanar,
76 UndirectedEdgeBitSet * outBdEdgesBetweenLargeComps = nullptr );
77
79[[nodiscard]] MRMESH_API VertBitSet getComponentsVerts( const Mesh& mesh, const VertBitSet& seeds, const VertBitSet* region = nullptr );
80
81
83[[nodiscard]] MRMESH_API size_t getNumComponents( const MeshPart& meshPart,
84 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgePredicate & isCompBd = {} );
85
88[[nodiscard]] MRMESH_API std::vector<FaceBitSet> getAllComponents( const MeshPart& meshPart,
89 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgePredicate& isCompBd = {} );
90
95[[nodiscard]] MRMESH_API std::pair<std::vector<FaceBitSet>, int> getAllComponents( const MeshPart& meshPart, int maxComponentCount,
96 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgePredicate& isCompBd = {} );
97
102[[nodiscard]] MRMESH_API std::vector<FaceBitSet> getAllComponents( Face2RegionMap& componentsMap, int componentsCount, const FaceBitSet& region,
103 int maxComponentCount );
104
108[[nodiscard]] MRMESH_API std::pair<Face2RegionMap, int> getAllComponentsMap( const MeshPart& meshPart,
109 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgePredicate & isCompBd = {} );
110
112[[nodiscard]] MRMESH_API Vector<double, RegionId> getRegionAreas( const MeshPart& meshPart,
113 const Face2RegionMap & regionMap, int numRegions );
114
118[[nodiscard]] MRMESH_API std::pair<FaceBitSet, int> getLargeByAreaRegions( const MeshPart& meshPart,
119 const Face2RegionMap & regionMap, int numRegions, float minArea );
120
122[[nodiscard]] MRMESH_API std::vector<VertBitSet> getAllComponentsVerts( const Mesh& mesh, const VertBitSet* region = nullptr );
123
125[[nodiscard]] MRMESH_API std::vector<VertBitSet> getAllComponentsVertsSeparatedByPath( const Mesh& mesh, const SurfacePath& path );
126
128[[nodiscard]] MRMESH_API std::vector<VertBitSet> getAllComponentsVertsSeparatedByPaths( const Mesh& mesh, const std::vector<SurfacePath>& paths );
129
131[[nodiscard]] MRMESH_API std::vector<EdgeBitSet> getAllComponentsEdges( const Mesh& mesh, const EdgeBitSet & edges );
132
134[[nodiscard]] MRMESH_API std::vector<UndirectedEdgeBitSet> getAllComponentsUndirectedEdges( const Mesh& mesh, const UndirectedEdgeBitSet& edges );
135
137[[nodiscard]] MRMESH_API std::vector<FaceBitSet> getAllFlatComponents( const MeshPart& meshPart, float zTolerance );
138
140[[nodiscard]] MRMESH_API bool hasFullySelectedComponent( const Mesh& mesh, const VertBitSet & selection );
141
143MRMESH_API void excludeFullySelectedComponents( const Mesh& mesh, VertBitSet& selection );
144
146[[nodiscard]] MRMESH_API UnionFind<FaceId> getUnionFindStructureFaces( const MeshPart& meshPart, FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgePredicate & isCompBd = {} );
147
150[[nodiscard]] MRMESH_API UnionFind<FaceId> getUnionFindStructureFacesPerEdge( const MeshPart& meshPart, const UndirectedEdgePredicate& isCompBd = {} );
151
153[[nodiscard]] MRMESH_API UnionFind<VertId> getUnionFindStructureVerts( const Mesh& mesh, const VertBitSet* region = nullptr );
154
156[[nodiscard]] MRMESH_API UnionFind<VertId> getUnionFindStructureVerts( const Mesh& mesh, const EdgeBitSet & edges );
157
159[[nodiscard]] MRMESH_API UnionFind<VertId> getUnionFindStructureVerts( const Mesh& mesh, const UndirectedEdgeBitSet& edges );
160
162[[nodiscard]] MRMESH_API UnionFind<VertId> getUnionFindStructureVertsEx( const Mesh& mesh, const UndirectedEdgeBitSet & ignoreEdges );
163
164
170 VertBitSet * outPathVerts = nullptr );
171
172[[nodiscard]] MRMESH_API UnionFind<VertId> getUnionFindStructureVertsSeparatedByPaths( const Mesh& mesh, const std::vector<SurfacePath>& paths,
173 VertBitSet* outPathVerts = nullptr );
174
177[[nodiscard]] MRMESH_API UnionFind<UndirectedEdgeId> getUnionFindStructureUndirectedEdges( const Mesh& mesh, bool allPointToRoots = false );
178
180[[nodiscard]] MRMESH_API UndirectedEdgeBitSet getComponentsUndirectedEdges( const Mesh& mesh, const UndirectedEdgeBitSet& seeds );
181
182// \}
183
184} // namespace MeshComponents
185
186} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Simple union find data structure.
Definition MRUnionFind.h:16
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:20
MRMESH_API std::vector< VertBitSet > getAllComponentsVertsSeparatedByPaths(const Mesh &mesh, const std::vector< SurfacePath > &paths)
gets all connected components, separating vertices by given paths (either closed or from boundary to ...
MRMESH_API UnionFind< FaceId > getUnionFindStructureFacesPerEdge(const MeshPart &meshPart, const UndirectedEdgePredicate &isCompBd={})
MRMESH_API UnionFind< VertId > getUnionFindStructureVerts(const Mesh &mesh, const VertBitSet *region=nullptr)
gets union-find structure for vertices
MRMESH_API VertBitSet getComponentVerts(const Mesh &mesh, VertId id, const VertBitSet *region=nullptr)
MRMESH_API std::vector< VertBitSet > getAllComponentsVertsSeparatedByPath(const Mesh &mesh, const SurfacePath &path)
gets all connected components, separating vertices by given path (either closed or from boundary to b...
int maxLargeComponents
return at most given number of largest by area connected components
Definition MRMesh/MRMeshComponents.h:58
MRMESH_API UnionFind< VertId > 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 boun...
MRMESH_API UndirectedEdgeBitSet getComponentsUndirectedEdges(const Mesh &mesh, const UndirectedEdgeBitSet &seeds)
returns union of connected components, each of which contains at least one seed edge
MRMESH_API Vector< double, RegionId > getRegionAreas(const MeshPart &meshPart, const Face2RegionMap &regionMap, int numRegions)
computes the area of each region given via the map
MRMESH_API FaceBitSet 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 std::vector< FaceBitSet > getNLargeByAreaComponents(const MeshPart &meshPart, const LargeByAreaComponentsSettings &settings)
returns requested number of largest by area connected components in descending by area order
float minArea
do not consider a component large if its area is below this value
Definition MRMesh/MRMeshComponents.h:64
UndirectedEdgePredicate isCompBd
optional predicate of boundaries between components
Definition MRMesh/MRMeshComponents.h:67
FaceIncidence
Face incidence type.
Definition MRMesh/MRMeshComponents.h:18
MRMESH_API std::vector< EdgeBitSet > getAllComponentsEdges(const Mesh &mesh, const EdgeBitSet &edges)
subdivides given edges on connected components
MRMESH_API VertBitSet getLargestComponentVerts(const Mesh &mesh, const VertBitSet *region=nullptr)
returns the largest by number of elements component
MRMESH_API UnionFind< FaceId > 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 size_t getNumComponents(const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgePredicate &isCompBd={})
returns the number of connected components in mesh part
MRMESH_API std::vector< UndirectedEdgeBitSet > getAllComponentsUndirectedEdges(const Mesh &mesh, const UndirectedEdgeBitSet &edges)
subdivides given edges on connected components
MRMESH_API std::pair< Face2RegionMap, int > getAllComponentsMap(const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgePredicate &isCompBd={})
MRMESH_API FaceBitSet getLargeByAreaSmoothComponents(const MeshPart &meshPart, float minArea, float angleFromPlanar, UndirectedEdgeBitSet *outBdEdgesBetweenLargeComps=nullptr)
MRMESH_API std::pair< FaceBitSet, int > getLargeByAreaRegions(const MeshPart &meshPart, const Face2RegionMap &regionMap, int numRegions, float minArea)
MRMESH_API bool hasFullySelectedComponent(const Mesh &mesh, const VertBitSet &selection)
returns true if all vertices of a mesh connected component are present in selection
MRMESH_API FaceBitSet getComponent(const MeshPart &meshPart, FaceId id, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgePredicate &isCompBd={})
MRMESH_API UnionFind< VertId > getUnionFindStructureVertsEx(const Mesh &mesh, const UndirectedEdgeBitSet &ignoreEdges)
gets union-find structure for vertices, considering connections by all edges excluding given ones
MRMESH_API std::vector< VertBitSet > getAllComponentsVerts(const Mesh &mesh, const VertBitSet *region=nullptr)
gets all connected components of mesh part
MRMESH_API std::vector< FaceBitSet > getAllFlatComponents(const MeshPart &meshPart, float zTolerance)
gets all connected components where difference between the highest and the lowest point is less than
MRMESH_API void excludeFullySelectedComponents(const Mesh &mesh, VertBitSet &selection)
if all vertices of a mesh connected component are present in selection exludes these vertices
MRMESH_API FaceBitSet 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 VertBitSet getLargeComponentVerts(const Mesh &mesh, int minVerts, const VertBitSet *region=nullptr)
returns the union of vertex connected components, each having at least
MRMESH_API VertBitSet 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 UnionFind< UndirectedEdgeId > getUnionFindStructureUndirectedEdges(const Mesh &mesh, bool allPointToRoots=false)
int * numSmallerComponents
optional output: the number of components in addition to returned ones
Definition MRMesh/MRMeshComponents.h:61
MRMESH_API UnionFind< VertId > getUnionFindStructureVertsSeparatedByPaths(const Mesh &mesh, const std::vector< SurfacePath > &paths, VertBitSet *outPathVerts=nullptr)
MRMESH_API std::vector< FaceBitSet > getAllComponents(const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgePredicate &isCompBd={})
MRMESH_API FaceBitSet getLargeByAreaComponents(const MeshPart &meshPart, float minArea, const UndirectedEdgePredicate &isCompBd)
returns the union of connected components, each having at least given area
@ PerVertex
face can have neighbor via vertex
Definition MRMesh/MRMeshComponents.h:20
@ PerEdge
face can have neighbor only via edge
Definition MRMesh/MRMeshComponents.h:19
Definition MRCameraOrientationPlugin.h:8
std::function< bool(UndirectedEdgeId)> UndirectedEdgePredicate
Definition MRMesh/MRMeshFwd.h:425
std::vector< MeshEdgePoint > SurfacePath
Definition MRMesh/MRMeshFwd.h:350
Definition MRMesh/MRMeshComponents.h:56
Definition MRMesh/MRMesh.h:23