MeshLib C++ Docs
Loading...
Searching...
No Matches
MRPointsProject.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRExpected.h"
5#include "MRId.h"
6
7#include <cfloat>
8
9namespace MR
10{
13
15{
17 float distSq{ 0 };
19 VertId vId;
20
21 auto operator <=>(const PointsProjectionResult &) const = default;
22};
23
24
32[[nodiscard]] MRMESH_API PointsProjectionResult findProjectionOnPoints( const Vector3f& pt, const PointCloud& pc,
33 float upDistLimitSq = FLT_MAX,
34 const AffineXf3f* xf = nullptr,
35 float loDistLimitSq = 0,
36 VertPredicate skipCb = {} );
37
45 float upDistLimitSq = FLT_MAX,
46 const AffineXf3f* xf = nullptr,
47 float loDistLimitSq = 0 );
48
54[[nodiscard]] MRMESH_API Buffer<VertId> findNClosestPointsPerPoint( const PointCloud& pc, int numNei, const ProgressCallback & progress = {} );
55
57[[nodiscard]] MRMESH_API VertPair findTwoClosestPoints( const PointCloud& pc, const ProgressCallback & progress = {} );
58
61{
63 const BitSet* valid = nullptr;
65 const AffineXf3f* xf = nullptr;
67 float upDistLimitSq = FLT_MAX;
69 float loDistLimitSq = 0.f;
71 bool skipSameIndex = false;
74};
75
78{
79public:
80 virtual ~IPointsProjector() = default;
81
83 virtual Expected<void> setPointCloud( const PointCloud& pointCloud ) = 0;
84
86 virtual Expected<void> findProjections( std::vector<PointsProjectionResult>& results,
87 const std::vector<Vector3f>& points, const FindProjectionOnPointsSettings& settings ) const = 0;
88};
89
92{
93public:
95 MRMESH_API Expected<void> setPointCloud( const PointCloud& pointCloud ) override;
96
98 MRMESH_API Expected<void> findProjections( std::vector<PointsProjectionResult>& results,
99 const std::vector<Vector3f>& points, const FindProjectionOnPointsSettings& settings ) const override;
100
101private:
102 const PointCloud* pointCloud_{ nullptr };
103};
104
106}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:83
container of bits
Definition MRMesh/MRBitSet.h:27
std::vector<V>-like container that is 1) resized without initialization of its elements,...
Definition MRBuffer.h:54
the class stores some number of smallest elements from a larger number of candidates
Definition MRFewSmallest.h:14
abstract class for computing the closest points of point clouds
Definition MRPointsProject.h:78
virtual ~IPointsProjector()=default
virtual Expected< void > findProjections(std::vector< PointsProjectionResult > &results, const std::vector< Vector3f > &points, const FindProjectionOnPointsSettings &settings) const =0
computes the closest points on point cloud to given points
virtual Expected< void > setPointCloud(const PointCloud &pointCloud)=0
sets the reference point cloud
default implementation of IPointsProjector
Definition MRPointsProject.h:92
MRMESH_API Expected< void > findProjections(std::vector< PointsProjectionResult > &results, const std::vector< Vector3f > &points, const FindProjectionOnPointsSettings &settings) const override
computes the closest points on point cloud to given points
MRMESH_API Expected< void > setPointCloud(const PointCloud &pointCloud) override
sets the reference point cloud
MRMESH_API void findFewClosestPoints(const Vector3f &pt, const PointCloud &pc, FewSmallest< PointsProjectionResult > &res, float upDistLimitSq=FLT_MAX, const AffineXf3f *xf=nullptr, float loDistLimitSq=0)
finds a number of the closest points in the cloud (as configured in
MRMESH_API Buffer< VertId > findNClosestPointsPerPoint(const PointCloud &pc, int numNei, const ProgressCallback &progress={})
finds given number of closest points (excluding itself) to each valid point in the cloud;
MRMESH_API PointsProjectionResult findProjectionOnPoints(const Vector3f &pt, const PointCloud &pc, float upDistLimitSq=FLT_MAX, const AffineXf3f *xf=nullptr, float loDistLimitSq=0, VertPredicate skipCb={})
computes the closest point on point cloud to given point
MRMESH_API VertPair findTwoClosestPoints(const PointCloud &pc, const ProgressCallback &progress={})
finds two closest points (first id < second id) in whole point cloud
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:636
tl::expected< T, E > Expected
Definition MRExpected.h:59
std::pair< VertId, VertId > VertPair
Definition MRMesh/MRMeshFwd.h:413
settings for IPointsProjector::findProjections
Definition MRPointsProject.h:61
float loDistLimitSq
low limit on the distance in question, if a point is found within this distance then it is immediatel...
Definition MRPointsProject.h:69
const BitSet * valid
bitset of valid input points
Definition MRPointsProject.h:63
bool skipSameIndex
if true, discards a projection candidate with the same index as the target point
Definition MRPointsProject.h:71
float upDistLimitSq
upper limit on the distance in question, if the real distance is larger than the function exits retur...
Definition MRPointsProject.h:67
ProgressCallback cb
progress callback
Definition MRPointsProject.h:73
const AffineXf3f * xf
affine transformation for input points
Definition MRPointsProject.h:65
Definition MRMesh/MRPointCloud.h:16
Definition MRPointsProject.h:15
float distSq
squared distance from pt to proj
Definition MRPointsProject.h:17
auto operator<=>(const PointsProjectionResult &) const =default
VertId vId
the closest vertex in point cloud
Definition MRPointsProject.h:19