MeshLib C++ Docs
Loading...
Searching...
No Matches
MRClosestWeightedPoint.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRMeshTriPoint.h"
5#include "MRPch/MRBindingMacros.h"
6#include <cfloat>
7
8namespace MR
9{
10
12{
14 VertId vId;
15
17 float dist = 0;
18
20 [[nodiscard]] bool valid() const { return vId.valid(); }
21 [[nodiscard]] explicit operator bool() const { return vId.valid(); }
22};
23
25{
27 Vector3f loc;
28
31
33 float eucledeanDist = 0;
34
36 float w = 0;
37
43
45 [[nodiscard]] float bidirDist() const
46 {
47 return eucledeanDist - w;
48 }
49
53 [[nodiscard]] float dist() const
54 {
56 }
57
60 {
61 if ( bidirectionalOrOutside && other.bidirectionalOrOutside )
62 return eucledeanDist - w <=> other.eucledeanDist - other.w;
63 if ( bidirectionalOrOutside != other.bidirectionalOrOutside )
64 return eucledeanDist <=> other.eucledeanDist;
65 return eucledeanDist + ( bidirectionalOrOutside ? -w : w ) <=>
66 other.eucledeanDist + ( other.bidirectionalOrOutside ? -other.w : other.w );
67 }
68
70 [[nodiscard]] bool valid() const { return mtp.valid(); }
71 [[nodiscard]] explicit operator bool() const { return mtp.valid(); }
72};
73
75{
78
81 float maxWeight = 0;
82
85 float maxWeightGrad = FLT_MAX;
86
91 bool bidirectionalMode = true;
92
93 // To allow passing Python lambdas into `pointWeight`.
94 MR_BIND_PREFER_UNLOCK_GIL_WHEN_USED_AS_PARAM
95};
96
98{
101 float minBidirDist = -FLT_MAX; // default 0 here does not work for negative distances
102
104 float maxBidirDist = FLT_MAX;
105};
106
110[[nodiscard]] MRMESH_API PointAndDistance findClosestWeightedPoint( const Vector3f& loc,
111 const AABBTreePoints& tree, const DistanceFromWeightedPointsComputeParams& params );
112
117 const Mesh& mesh, const DistanceFromWeightedPointsComputeParams& params );
118
119} //namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
bounding volume hierarchy for point cloud structure
Definition MRAABBTreePoints.h:16
Definition MRCameraOrientationPlugin.h:8
std::function< float(VertId)> VertMetric
Definition MRMesh/MRMeshFwd.h:504
MRMESH_API PointAndDistance findClosestWeightedPoint(const Vector3f &loc, const AABBTreePoints &tree, const DistanceFromWeightedPointsComputeParams &params)
MRMESH_API MeshPointAndDistance findClosestWeightedMeshPoint(const Vector3f &loc, const Mesh &mesh, const DistanceFromWeightedPointsComputeParams &params)
Definition MRClosestWeightedPoint.h:98
float maxBidirDist
find the closest point only if weighted bidirectional distance to it is less than given value
Definition MRClosestWeightedPoint.h:104
float minBidirDist
Definition MRClosestWeightedPoint.h:101
Definition MRClosestWeightedPoint.h:75
VertMetric pointWeight
function returning the weight of each point, must be set by the user
Definition MRClosestWeightedPoint.h:77
float maxWeight
Definition MRClosestWeightedPoint.h:81
bool bidirectionalMode
Definition MRClosestWeightedPoint.h:91
float maxWeightGrad
Definition MRClosestWeightedPoint.h:85
Definition MRClosestWeightedPoint.h:25
MeshTriPoint mtp
the corresponding point on mesh in barycentric representation
Definition MRClosestWeightedPoint.h:30
float eucledeanDist
euclidean distance from input location to mtp
Definition MRClosestWeightedPoint.h:33
float dist() const
Definition MRClosestWeightedPoint.h:53
float w
point's weight
Definition MRClosestWeightedPoint.h:36
bool bidirectionalOrOutside
Definition MRClosestWeightedPoint.h:42
Vector3f loc
point location
Definition MRClosestWeightedPoint.h:27
float bidirDist() const
bidirectional distance from input location to mtp considering point's weight
Definition MRClosestWeightedPoint.h:45
auto operator<=>(const MeshPointAndDistance &other) const
comparison telling which point is closer to the location
Definition MRClosestWeightedPoint.h:59
bool valid() const
check for validity, otherwise there is no point closer than maxBidirDist
Definition MRClosestWeightedPoint.h:70
Definition MRMesh/MRMeshTriPoint.h:23
bool valid() const
consider this valid if the edge ID is valid
Definition MRMesh/MRMeshTriPoint.h:58
Definition MRMesh/MRMesh.h:22
Definition MRClosestWeightedPoint.h:12
bool valid() const
check for validity, otherwise there is no point closer than maxBidirDist
Definition MRClosestWeightedPoint.h:20
float dist
the distance from input location to point vId considering point's weight
Definition MRClosestWeightedPoint.h:17
VertId vId
a cloud's point
Definition MRClosestWeightedPoint.h:14