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{
13
14
17{
21 int maxNeighbors = 7;
23 float minHeight = 0.3f;
26 float minAngle = PI_F / 3.f;
27};
28
31{
32 SmallComponents = 1 << 0,
33 WeaklyConnected = 1 << 1,
34 FarSurface = 1 << 2,
35 AwayNormal = 1 << 3,
37};
39
40
42class MRMESH_CLASS OutliersDetector
43{
44public:
45 OutliersDetector() = default;
46
54 MRMESH_API Expected<void> prepare( const PointCloud& pc, float radius, OutlierTypeMask mask, ProgressCallback progress = {} );
55
57 MRMESH_API void setParams( const OutlierParams& params );
59 MRMESH_API const OutlierParams& getParams() const { return params_; }
60
63 MRMESH_API Expected<VertBitSet> find( OutlierTypeMask mask, ProgressCallback progress = {} );
64
66 MRMESH_API const std::vector<uint8_t>& getWeaklyConnectedStat() { return weaklyConnectedStat_; }
67
68private:
69 Expected<VertBitSet> findSmallComponents( ProgressCallback progress = {} );
70 Expected<VertBitSet> findWeaklyConnected( ProgressCallback progress = {} );
71 Expected<VertBitSet> findFarSurface( ProgressCallback progress = {} );
72 Expected<VertBitSet> findAwayNormal( ProgressCallback progress = {} );
73
74 float radius_ = 1.f;
75 OutlierParams params_;
76
78 UnionFind<VertId> unionFindStructure_;
79 std::vector<uint8_t> weaklyConnectedStat_;
80 std::vector<float> farSurfaceStat_;
81 std::vector<float> badNormalStat_;
82
83 OutlierTypeMask maskCached_ = OutlierTypeMask( 0 );
84
85 VertBitSet validPoints_;
86};
87
98
100MRMESH_API Expected<VertBitSet> findOutliers( const PointCloud& pc, const FindOutliersParams& params );
101
102}
#define MR_MAKE_FLAG_OPERATORS(T)
Generates operators for a enum (at namespace scope).
Definition MRFlagOperators.h:6
Definition MROutlierPoints.h:43
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:59
float minHeight
Minimum distance (as proportion of search radius) to the approximate surface from outliers point.
Definition MROutlierPoints.h:23
float radius
Radius of the search for neighboring points for analysis.
Definition MROutlierPoints.h:92
OutliersDetector()=default
tl::expected< T, E > Expected
Definition MRExpected.h:31
float minAngle
Definition MROutlierPoints.h:26
OutlierTypeMask mask
Mask of the types of outliers that are looking for.
Definition MROutlierPoints.h:94
MRMESH_API Expected< VertBitSet > findOutliers(const PointCloud &pc, const FindOutliersParams &params)
Finding outlier points.
OutlierParams finderParams
Parameters of various criteria for detecting outlier points.
Definition MROutlierPoints.h:91
int maxNeighbors
Maximum number of adjacent points for an outlier point.
Definition MROutlierPoints.h:21
ProgressCallback progress
Progress callback.
Definition MROutlierPoints.h:96
MRMESH_API void setParams(const OutlierParams &params)
calculate caches
OutlierTypeMask
Types of outlier points.
Definition MROutlierPoints.h:31
MRMESH_API const std::vector< uint8_t > & getWeaklyConnectedStat()
unite and calculate actual outliers
Definition MROutlierPoints.h:66
int maxClusterSize
Maximum points in the outlier component.
Definition MROutlierPoints.h:19
@ 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.
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Outlier point search parameters.
Definition MROutlierPoints.h:90
Parameters of various criteria for detecting outlier points.
Definition MROutlierPoints.h:17
Definition MRPointCloud.h:17