MeshLib C++ Docs
Loading...
Searching...
No Matches
MROutlierPoints.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
3#include "MRMesh/MRExpected.h"
4#include "MRUnionFind.h"
5#include "MRBitSet.h"
6#include "MRConstants.h"
7#include "MRFlagOperators.h"
8
9namespace MR
10{
11
13struct OutlierParams
14{
16 int maxClusterSize = 20;
18 int maxNeighbors = 7;
20 float minHeight = 0.3f;
23 float minAngle = PI_F / 3.f;
24};
25
27enum class OutlierTypeMask
28{
29 SmallComponents = 1 << 0,
30 WeaklyConnected = 1 << 1,
31 FarSurface = 1 << 2,
32 AwayNormal = 1 << 3,
33 All = SmallComponents | WeaklyConnected | FarSurface | AwayNormal
34};
35MR_MAKE_FLAG_OPERATORS( OutlierTypeMask )
36
37
39class MRMESH_CLASS OutliersDetector
40{
41public:
42 OutliersDetector() = default;
43
51 MRMESH_API Expected<void> prepare( const PointCloud& pc, float radius, OutlierTypeMask mask, ProgressCallback progress = {} ); // calculate caches
52
54 MRMESH_API void setParams( const OutlierParams& params );
56 MRMESH_API const OutlierParams& getParams() const { return params_; }
57
60 MRMESH_API Expected<VertBitSet> find( OutlierTypeMask mask, ProgressCallback progress = {} ); // unite and calculate actual outliers
61
63 MRMESH_API const std::vector<uint8_t>& getWeaklyConnectedStat() { return weaklyConnectedStat_; }
64
65private:
66 Expected<VertBitSet> findSmallComponents( ProgressCallback progress = {} );
67 Expected<VertBitSet> findWeaklyConnected( ProgressCallback progress = {} );
68 Expected<VertBitSet> findFarSurface( ProgressCallback progress = {} );
69 Expected<VertBitSet> findAwayNormal( ProgressCallback progress = {} );
70
71 float radius_ = 1.f;
72 OutlierParams params_;
73
74 // Cached data
75 UnionFind<VertId> unionFindStructure_; // SmallComponents
76 std::vector<uint8_t> weaklyConnectedStat_; // WeaklyConnected
77 std::vector<float> farSurfaceStat_; // FarSurface
78 std::vector<float> badNormalStat_; // AwayNormal
79
80 OutlierTypeMask maskCached_ = OutlierTypeMask( 0 ); // true means valid cache
81
82 VertBitSet validPoints_;
83};
84
86struct FindOutliersParams
87{
88 OutlierParams finderParams;
89 float radius = 1.f;
90
91 OutlierTypeMask mask = OutlierTypeMask::All;
92
93 ProgressCallback progress = {};
94};
95
97MRMESH_API Expected<VertBitSet> findOutliers( const PointCloud& pc, const FindOutliersParams& params );
98
99}
#define MR_MAKE_FLAG_OPERATORS(T)
Definition MRFlagOperators.h:6
#define MRMESH_API
Definition MRMeshFwd.h:80
#define MRMESH_CLASS
Definition MRMeshFwd.h:87
Definition MROutlierPoints.h:87
new unsafe MR.OutlierParams finderParams
new unsafe ref MR.OutlierTypeMask mask
new unsafe ref float radius
new unsafe ref float minAngle
new unsafe ref float minHeight
new unsafe ref int maxNeighbors
new unsafe ref int maxClusterSize
Definition MRMesh/MRPointCloud.h:17
OutlierTypeMask
MRVOXELS_API double find(const Mesh &mesh, const FindParams &params, FaceBitSet &outUndercuts, const UndercutMetric &metric={})
Definition MRCameraOrientationPlugin.h:8
MRMESH_API Expected< VertBitSet > findOutliers(const PointCloud &pc, const FindOutliersParams &params)
Finding outlier points.