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#include "MRPointCloudPart.h"
7#include <cfloat>
8
9namespace MR
10{
13
14struct PointsProjectionResult
15{
17 float distSq{ 0 };
19 VertId vId;
20
21 auto operator <=>(const PointsProjectionResult &) const = default;
22};
23
24
33 float upDistLimitSq = FLT_MAX,
34 const AffineXf3f* xf = nullptr,
35 float loDistLimitSq = 0,
36 VertPredicate skipCb = {} );
37
47 float upDistLimitSq = FLT_MAX,
48 const AffineXf3f* xf = nullptr,
49 float loDistLimitSq = 0,
50 const VertBitSet * region = nullptr,
51 VertPredicate skipCb = {} );
52
60 float upDistLimitSq = FLT_MAX,
61 const AffineXf3f* xf = nullptr,
62 float loDistLimitSq = 0 );
63
69[[nodiscard]] MRMESH_API Buffer<VertId> findNClosestPointsPerPoint( const PointCloud& pc, int numNei, const ProgressCallback & progress = {} );
70
72[[nodiscard]] MRMESH_API VertPair findTwoClosestPoints( const PointCloud& pc, const ProgressCallback & progress = {} );
73
75struct FindProjectionOnPointsSettings
76{
78 const BitSet* valid = nullptr;
80 const AffineXf3f* xf = nullptr;
82 float upDistLimitSq = FLT_MAX;
84 float loDistLimitSq = 0.f;
86 bool skipSameIndex = false;
88 ProgressCallback cb;
89};
90
92class IPointsProjector
93{
94public:
95 virtual ~IPointsProjector() = default;
96
98 virtual Expected<void> setPointCloud( const PointCloud& pointCloud ) = 0;
99
101 virtual Expected<void> findProjections( std::vector<PointsProjectionResult>& results,
102 const std::vector<Vector3f>& points, const FindProjectionOnPointsSettings& settings ) const = 0;
103
105 virtual size_t projectionsHeapBytes( size_t numProjections ) const = 0;
106};
107
109class MRMESH_CLASS PointsProjector : public IPointsProjector
110{
111public:
113 MRMESH_API Expected<void> setPointCloud( const PointCloud& pointCloud ) override;
114
116 MRMESH_API Expected<void> findProjections( std::vector<PointsProjectionResult>& results,
117 const std::vector<Vector3f>& points, const FindProjectionOnPointsSettings& settings ) const override;
118
120 MRMESH_API virtual size_t projectionsHeapBytes( size_t numProjections ) const override;
121private:
122 const PointCloud* pointCloud_{ nullptr };
123};
124
126}
#define MRMESH_API
Definition MRMeshFwd.h:80
#define MRMESH_CLASS
Definition MRMeshFwd.h:87
Definition MRAABBTreePoints.h:16
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
new unsafe ref float loDistLimitSq
new unsafe ref bool skipSameIndex
new unsafe MR.Std.Function_BoolFuncFromFloat cb
new unsafe MR.? ConstBox_AffineXf3f xf
new unsafe ref float upDistLimitSq
new unsafe MR.? Const_BitSet valid
unsafe void setPointCloud(MR.Const_PointCloud pointCloud)
Definition MRPointCloudPart.h:10
Definition MRMesh/MRPointCloud.h:17
Definition MRPointsProject.h:15
new unsafe ref float distSq
new unsafe ref MR.VertId vId
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 PointCloudPart &pcp, 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
Definition MRCameraOrientationPlugin.h:8