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 minWeight = 0;
82
85 float maxWeight = 0;
86
89 float maxWeightGrad = FLT_MAX;
90
95 bool bidirectionalMode = true;
96
97 // To allow passing Python lambdas into `pointWeight`.
98 MR_BIND_PREFER_UNLOCK_GIL_WHEN_USED_AS_PARAM
99};
100
102{
105 float minBidirDist = -FLT_MAX; // default 0 here does not work for negative distances
106
108 float maxBidirDist = FLT_MAX;
109};
110
114[[nodiscard]] MRMESH_API PointAndDistance findClosestWeightedPoint( const Vector3f& loc,
115 const AABBTreePoints& tree, const DistanceFromWeightedPointsComputeParams& params );
116
121 const Mesh& mesh, const DistanceFromWeightedPointsComputeParams& params );
122
123} //namespace MR
#define MRMESH_API
Definition MRMeshFwd.h:80
bounding volume hierarchy for point cloud structure
Definition MRAABBTreePoints.h:16
Definition MRCameraOrientationPlugin.h:8
std::function< float(VertId)> VertMetric
Definition MRMeshFwd.h:578
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:102
float maxBidirDist
find the closest point only if weighted bidirectional distance to it is less than given value
Definition MRClosestWeightedPoint.h:108
float minBidirDist
Definition MRClosestWeightedPoint.h:105
Definition MRClosestWeightedPoint.h:75
float minWeight
Definition MRClosestWeightedPoint.h:81
VertMetric pointWeight
function returning the weight of each point, must be set by the user
Definition MRClosestWeightedPoint.h:77
float maxWeight
Definition MRClosestWeightedPoint.h:85
bool bidirectionalMode
Definition MRClosestWeightedPoint.h:95
float maxWeightGrad
Definition MRClosestWeightedPoint.h:89
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 MRMeshTriPoint.h:23
bool valid() const
consider this valid if the edge ID is valid
Definition MRMeshTriPoint.h:58
Definition MRMesh/MRMesh.h:23
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