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
14{
18 int maxNeighbors = 7;
20 float minHeight = 0.3f;
23 float minAngle = PI_F / 3.f;
24};
25
28{
29 SmallComponents = 1 << 0,
30 WeaklyConnected = 1 << 1,
31 FarSurface = 1 << 2,
32 AwayNormal = 1 << 3,
34};
36
37
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
95
98
99}
#define MR_MAKE_FLAG_OPERATORS(T)
Definition MRFlagOperators.h:6
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:83
Definition MROutlierPoints.h:40
MRMESH_API Expected< VertBitSet > find(OutlierTypeMask mask, ProgressCallback progress={})
MRMESH_API Expected< void > prepare(const PointCloud &pc, float radius, OutlierTypeMask mask, ProgressCallback progress={})
MRMESH_API const OutlierParams & getParams() const
Get search parameters.
Definition MROutlierPoints.h:56
OutliersDetector()=default
MRMESH_API void setParams(const OutlierParams &params)
Set search parameters.
MRMESH_API const std::vector< uint8_t > & getWeaklyConnectedStat()
Get statistics on the number of neighbors for each point.
Definition MROutlierPoints.h:63
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:626
tl::expected< T, E > Expected
Definition MRExpected.h:59
MRMESH_API Expected< VertBitSet > findOutliers(const PointCloud &pc, const FindOutliersParams &params)
Finding outlier points.
OutlierTypeMask
Types of outlier points.
Definition MROutlierPoints.h:28
@ AwayNormal
Points whose normals differ from the average norm of their nearest neighbors.
@ WeaklyConnected
Points that have too few neighbors within the radius.
@ SmallComponents
Small groups of points that are far from the rest.
@ FarSurface
Points far from the surface approximating the nearest points.
Outlier point search parameters.
Definition MROutlierPoints.h:87
float radius
Radius of the search for neighboring points for analysis.
Definition MROutlierPoints.h:89
OutlierTypeMask mask
Mask of the types of outliers that are looking for.
Definition MROutlierPoints.h:91
OutlierParams finderParams
Parameters of various criteria for detecting outlier points.
Definition MROutlierPoints.h:88
ProgressCallback progress
Progress callback.
Definition MROutlierPoints.h:93
Parameters of various criteria for detecting outlier points.
Definition MROutlierPoints.h:14
float minHeight
Minimum distance (as proportion of search radius) to the approximate surface from outliers point.
Definition MROutlierPoints.h:20
float minAngle
Definition MROutlierPoints.h:23
int maxNeighbors
Maximum number of adjacent points for an outlier point.
Definition MROutlierPoints.h:18
int maxClusterSize
Maximum points in the outlier component.
Definition MROutlierPoints.h:16
Definition MRMesh/MRPointCloud.h:16