MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMeshComponents.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRUnionFind.h"
4#include "MRExpected.h"
5#include <functional>
6
7namespace MR
8{
9
11{
12
16
23
26[[nodiscard]] MRMESH_API FaceBitSet getComponent( const MeshPart& meshPart, FaceId id,
27 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {} );
28
31[[nodiscard]] MRMESH_API VertBitSet getComponentVerts( const Mesh& mesh, VertId id, const VertBitSet* region = nullptr );
32
34[[nodiscard]] MRMESH_API VertBitSet getLargestComponentVerts( const Mesh& mesh, const VertBitSet* region = nullptr );
35
37[[nodiscard]] MRMESH_API VertBitSet getLargeComponentVerts( const Mesh& mesh, int minVerts, const VertBitSet* region = nullptr );
38
39
41[[nodiscard]] MRMESH_API double getLargestComponentArea( const MeshPart& meshPart,
42 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {}, FaceBitSet * largestComponent = nullptr,
43 int * numSmallerComponents = nullptr );
44
46[[nodiscard]] MRMESH_API FaceBitSet getLargestComponent( const MeshPart& meshPart,
47 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {}, float minArea = 0,
48 int * numSmallerComponents = nullptr );
49
57
62[[nodiscard]] MRMESH_API double getLargestComponentVolume( const MeshPart& meshPart, VolumeSelection selection = VolumeSelection::Abs,
63 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {}, FaceBitSet * largestComponent = nullptr,
64 int * numSmallerComponents = nullptr );
65
67[[nodiscard]] MRMESH_API FaceBitSet getComponents( const MeshPart& meshPart, const FaceBitSet & seeds,
68 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {} );
69[[nodiscard]] MRMESH_API FaceBitSet getComponents( const MeshTopology& topology, const FaceBitSet & seeds, const FaceBitSet* region = nullptr,
70 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {} );
71
73[[nodiscard]] MRMESH_API FaceBitSet getLargeByAreaComponents( const MeshPart& meshPart, float minArea, const UndirectedEdgeBitSet * isCompBd );
74
77[[nodiscard]] MRMESH_API FaceBitSet getLargeByVolumeComponents( const MeshPart& meshPart, float minVolume );
78
80[[nodiscard]] MRMESH_API FaceBitSet getLargeByAreaComponents( const MeshPart& meshPart, BaseUnionFind<FaceId> & unionFind, float minArea,
81 UndirectedEdgeBitSet * outBdEdgesBetweenLargeComps = nullptr );
82
84{
88 float coverRatio = 0.0f;
89
91
93 const UndirectedEdgeBitSet * isCompBd = nullptr;
94
96 int* optOutNumComponents = nullptr;
97
99};
100
102[[nodiscard]] MRMESH_API Expected<FaceBitSet> expandToComponents( const MeshPart& mp, const FaceBitSet& seeds, const ExpandToComponentsParams& params = {} );
103
105{
108
110 int * numSmallerComponents = nullptr;
111
113 float minArea = 0;
114
116 const UndirectedEdgeBitSet * isCompBd = nullptr;
117};
118
120[[nodiscard]] MRMESH_API std::vector<FaceBitSet> getNLargeByAreaComponents( const MeshPart& meshPart, const LargeByAreaComponentsSettings & settings );
121
124[[nodiscard]] MRMESH_API FaceBitSet getLargeByAreaSmoothComponents( const MeshPart& meshPart, float minArea, float angleFromPlanar,
125 UndirectedEdgeBitSet * outBdEdgesBetweenLargeComps = nullptr );
126
128[[nodiscard]] MRMESH_API VertBitSet getComponentsVerts( const Mesh& mesh, const VertBitSet& seeds, const VertBitSet* region = nullptr );
129
130
132[[nodiscard]] MRMESH_API size_t getNumComponents( const MeshPart& meshPart,
133 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {} );
134
137[[nodiscard]] MRMESH_API std::vector<FaceBitSet> getAllComponents( const MeshPart& meshPart,
138 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {} );
139
144[[nodiscard]] MRMESH_API std::pair<std::vector<FaceBitSet>, int> getAllComponents( const MeshPart& meshPart, int maxComponentCount,
145 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {} );
146
151[[nodiscard]] MRMESH_API std::vector<FaceBitSet> getAllComponents( Face2RegionMap& componentsMap, int componentsCount, const FaceBitSet& region,
152 int maxComponentCount );
153
157[[nodiscard]] MRMESH_API std::pair<Face2RegionMap, int> getAllComponentsMap( const MeshPart& meshPart,
158 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {} );
159
163[[nodiscard]] MRMESH_API std::pair<Face2RegionMap, int> getFacePairRegionMap( const Mesh& mesh, const std::vector<FaceFace>& facePairs,
164 FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {} );
165
167[[nodiscard]] MRMESH_API Vector<double, RegionId> getRegionAreas( const MeshPart& meshPart,
168 const Face2RegionMap & regionMap, int numRegions );
169
173[[nodiscard]] MRMESH_API std::pair<FaceBitSet, int> getLargeByAreaRegions( const MeshPart& meshPart,
174 const Face2RegionMap & regionMap, int numRegions, float minArea );
175
177[[nodiscard]] MRMESH_API std::vector<VertBitSet> getAllComponentsVerts( const Mesh& mesh, const VertBitSet* region = nullptr );
178
180[[nodiscard]] MRMESH_API std::vector<VertBitSet> getAllComponentsVertsSeparatedByPath( const Mesh& mesh, const SurfacePath& path );
181
183[[nodiscard]] MRMESH_API std::vector<VertBitSet> getAllComponentsVertsSeparatedByPaths( const Mesh& mesh, const std::vector<SurfacePath>& paths );
184
186[[nodiscard]] MRMESH_API std::vector<EdgeBitSet> getAllComponentsEdges( const Mesh& mesh, const EdgeBitSet & edges );
187
189[[nodiscard]] MRMESH_API std::vector<UndirectedEdgeBitSet> getAllComponentsUndirectedEdges( const Mesh& mesh, const UndirectedEdgeBitSet& edges );
190
192[[nodiscard]] MRMESH_API bool hasFullySelectedComponent( const Mesh& mesh, const VertBitSet & selection );
193[[nodiscard]] MRMESH_API bool hasFullySelectedComponent( const MeshTopology& topology, const VertBitSet & selection );
194
196MRMESH_API void excludeFullySelectedComponents( const Mesh& mesh, VertBitSet& selection );
197
199[[nodiscard]] MRMESH_API BaseUnionFind<FaceId> getUnionFindStructureFaces( const MeshPart& meshPart, FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {} );
200[[nodiscard]] MRMESH_API BaseUnionFind<FaceId> getUnionFindStructureFaces( const MeshTopology& topology, const FaceBitSet* region = nullptr, FaceIncidence incidence = FaceIncidence::PerEdge, const UndirectedEdgeBitSet * isCompBd = {} );
201
204[[nodiscard]] MRMESH_API BaseUnionFind<FaceId> getUnionFindStructureFacesPerEdge( const MeshPart& meshPart, const UndirectedEdgeBitSet * isCompBd = {} );
205[[nodiscard]] MRMESH_API BaseUnionFind<FaceId> getUnionFindStructureFacesPerEdge( const MeshTopology& topology, const FaceBitSet* region = nullptr, const UndirectedEdgeBitSet * isCompBd = {} );
206
208[[nodiscard]] MRMESH_API UnionFind<VertId> getUnionFindStructureVerts( const Mesh& mesh, const VertBitSet* region = nullptr );
209[[nodiscard]] MRMESH_API UnionFind<VertId> getUnionFindStructureVerts( const MeshTopology& topology, const VertBitSet* region = nullptr );
210
212[[nodiscard]] MRMESH_API UnionFind<VertId> getUnionFindStructureVerts( const Mesh& mesh, const EdgeBitSet & edges );
213
215[[nodiscard]] MRMESH_API UnionFind<VertId> getUnionFindStructureVerts( const Mesh& mesh, const UndirectedEdgeBitSet& edges );
216
218[[nodiscard]] MRMESH_API UnionFind<VertId> getUnionFindStructureVertsEx( const Mesh& mesh, const UndirectedEdgeBitSet & ignoreEdges );
219
220
226 VertBitSet * outPathVerts = nullptr );
227
228[[nodiscard]] MRMESH_API UnionFind<VertId> getUnionFindStructureVertsSeparatedByPaths( const Mesh& mesh, const std::vector<SurfacePath>& paths,
229 VertBitSet* outPathVerts = nullptr );
230
233[[nodiscard]] MRMESH_API UnionFind<UndirectedEdgeId> getUnionFindStructureUndirectedEdges( const Mesh& mesh, bool allPointToRoots = false );
234
236[[nodiscard]] MRMESH_API UndirectedEdgeBitSet getComponentsUndirectedEdges( const Mesh& mesh, const UndirectedEdgeBitSet& seeds );
237
239
240}
241
242}
#define MRMESH_API
Definition MRMeshFwd.h:85
base of union-find data structures: stores only the parent forest and the operations that depend on i...
Definition MRUnionFind.h:23
Definition MRMeshTopology.h:30
Union-find data structure for representing disjoint sets of elements with few very quick operations: ...
Definition MRUnionFind.h:152
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:23
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:759
tl::expected< T, E > Expected
Definition MRExpected.h:31
std::vector< MeshEdgePoint > SurfacePath
Definition MRMeshFwd.h:479
FaceBitSet getLargeByAreaComponents(const MeshPart &meshPart, float minArea, const UndirectedEdgeBitSet *isCompBd)
returns the union of connected components, each having at least given area
UndirectedEdgeBitSet getComponentsUndirectedEdges(const Mesh &mesh, const UndirectedEdgeBitSet &seeds)
returns union of connected components, each of which contains at least one seed edge
double getLargestComponentVolume(const MeshPart &meshPart, VolumeSelection selection=VolumeSelection::Abs, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={}, FaceBitSet *largestComponent=nullptr, int *numSmallerComponents=nullptr)
optional output: the number of components in addition to returned one, so all components if none was ...
BaseUnionFind< FaceId > getUnionFindStructureFacesPerEdge(const MeshPart &meshPart, const UndirectedEdgeBitSet *isCompBd={})
std::vector< FaceBitSet > getNLargeByAreaComponents(const MeshPart &meshPart, const LargeByAreaComponentsSettings &settings)
returns requested number of largest by area connected components in descending by area order
std::pair< Face2RegionMap, int > getAllComponentsMap(const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
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 ...
UnionFind< VertId > getUnionFindStructureVertsEx(const Mesh &mesh, const UndirectedEdgeBitSet &ignoreEdges)
gets union-find structure for vertices, considering connections by all edges excluding given ones
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...
FaceBitSet getLargeByVolumeComponents(const MeshPart &meshPart, float minVolume)
FaceIncidence
Face incidence type.
Definition MRMeshComponents.h:19
VertBitSet getComponentVerts(const Mesh &mesh, VertId id, const VertBitSet *region=nullptr)
BaseUnionFind< FaceId > getUnionFindStructureFaces(const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
gets union-find structure for faces with different options of face-connectivity
std::vector< UndirectedEdgeBitSet > getAllComponentsUndirectedEdges(const Mesh &mesh, const UndirectedEdgeBitSet &edges)
subdivides given edges on connected components
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...
VertBitSet getLargestComponentVerts(const Mesh &mesh, const VertBitSet *region=nullptr)
returns the largest by number of elements component
FaceBitSet getComponent(const MeshPart &meshPart, FaceId id, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
std::pair< Face2RegionMap, int > getFacePairRegionMap(const Mesh &mesh, const std::vector< FaceFace > &facePairs, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
Expected< FaceBitSet > expandToComponents(const MeshPart &mp, const FaceBitSet &seeds, const ExpandToComponentsParams &params={})
expands given seeds to whole components
UnionFind< VertId > getUnionFindStructureVerts(const Mesh &mesh, const VertBitSet *region=nullptr)
gets union-find structure for vertices
FaceBitSet 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
bool hasFullySelectedComponent(const Mesh &mesh, const VertBitSet &selection)
returns true if all vertices of a mesh connected component are present in selection
UnionFind< UndirectedEdgeId > getUnionFindStructureUndirectedEdges(const Mesh &mesh, bool allPointToRoots=false)
Vector< double, RegionId > getRegionAreas(const MeshPart &meshPart, const Face2RegionMap &regionMap, int numRegions)
computes the area of each region given via the map
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
std::vector< VertBitSet > getAllComponentsVerts(const Mesh &mesh, const VertBitSet *region=nullptr)
gets all connected components of mesh part
std::vector< FaceBitSet > getAllComponents(const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
UnionFind< VertId > getUnionFindStructureVertsSeparatedByPaths(const Mesh &mesh, const std::vector< SurfacePath > &paths, VertBitSet *outPathVerts=nullptr)
VolumeSelection
the rule of selecting one component by its signed volume
Definition MRMeshComponents.h:52
FaceBitSet 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
size_t getNumComponents(const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={})
returns the number of connected components in mesh part
double getLargestComponentArea(const MeshPart &meshPart, FaceIncidence incidence=FaceIncidence::PerEdge, const UndirectedEdgeBitSet *isCompBd={}, FaceBitSet *largestComponent=nullptr, int *numSmallerComponents=nullptr)
returns the area of the largest by surface area component, and zero if there are no components at all
std::pair< FaceBitSet, int > getLargeByAreaRegions(const MeshPart &meshPart, const Face2RegionMap &regionMap, int numRegions, float minArea)
VertBitSet getLargeComponentVerts(const Mesh &mesh, int minVerts, const VertBitSet *region=nullptr)
returns the union of vertex connected components, each having at least
void excludeFullySelectedComponents(const Mesh &mesh, VertBitSet &selection)
if all vertices of a mesh connected component are present in selection, excludes these vertices
FaceBitSet getLargeByAreaSmoothComponents(const MeshPart &meshPart, float minArea, float angleFromPlanar, UndirectedEdgeBitSet *outBdEdgesBetweenLargeComps=nullptr)
std::vector< EdgeBitSet > getAllComponentsEdges(const Mesh &mesh, const EdgeBitSet &edges)
subdivides given edges on connected components
@ PerVertex
face can have neighbor via vertex
Definition MRMeshComponents.h:21
@ PerEdge
face can have neighbor only via edge
Definition MRMeshComponents.h:20
@ Abs
the component with the largest absolute volume, whatever its sign is
Definition MRMeshComponents.h:53
@ Positive
the component with the largest positive volume (its normals look outside)
Definition MRMeshComponents.h:54
@ Negative
the component with the smallest negative volume (its normals look inside)
Definition MRMeshComponents.h:55
Definition MRMeshComponents.h:11
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRMeshComponents.h:84
const UndirectedEdgeBitSet * isCompBd
optional predicate of boundaries between components
Definition MRMeshComponents.h:93
FaceIncidence incidence
Definition MRMeshComponents.h:90
int * optOutNumComponents
optional output number of components
Definition MRMeshComponents.h:96
float coverRatio
Definition MRMeshComponents.h:88
ProgressCallback cb
Definition MRMeshComponents.h:98
Definition MRMeshComponents.h:105
const UndirectedEdgeBitSet * isCompBd
optional predicate of boundaries between components
Definition MRMeshComponents.h:116
int maxLargeComponents
return at most given number of largest by area connected components
Definition MRMeshComponents.h:107
float minArea
do not consider a component large if its area is below this value
Definition MRMeshComponents.h:113
int * numSmallerComponents
optional output: the number of components in addition to returned ones
Definition MRMeshComponents.h:110
Definition MRMesh.h:24