-
Notifications
You must be signed in to change notification settings - Fork 44
/
MRMeshProject.h
60 lines (51 loc) · 2.15 KB
/
MRMeshProject.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include "MRPointOnFace.h"
#include "MRMeshTriPoint.h"
#include "MRMeshPart.h"
#include <cfloat>
#include <optional>
namespace MR
{
/// \addtogroup AABBTreeGroup
/// \{
struct MeshProjectionResult
{
/// the closest point on mesh, transformed by xf if it is given
PointOnFace proj;
/// its barycentric representation
MeshTriPoint mtp;
/// squared distance from pt to proj
float distSq = 0;
};
///
/**
* \brief computes the closest point on mesh (or its region) to given point
* \param upDistLimitSq upper limit on the distance in question, if the real distance is larger than the function exits returning upDistLimitSq and no valid point
* \param xf mesh-to-point transformation, if not specified then identity transformation is assumed
* \param loDistLimitSq low limit on the distance in question, if a point is found within this distance then it is immediately returned without searching for a closer one
* \param skipFace this triangle will be skipped and never returned as a projection
*/
[[nodiscard]] MRMESH_API MeshProjectionResult findProjection( const Vector3f & pt, const MeshPart & mp,
float upDistLimitSq = FLT_MAX,
const AffineXf3f * xf = nullptr,
float loDistLimitSq = 0,
FaceId skipFace = {} );
struct SignedDistanceToMeshResult
{
/// the closest point on mesh
PointOnFace proj;
/// its barycentric representation
MeshTriPoint mtp;
/// distance from pt to proj (positive - outside, negative - inside the mesh)
float dist = 0;
};
/**
* \brief computes the closest point on mesh (or its region) to given point,
* and finds the distance with sign to it (positive - outside, negative - inside the mesh)
* \param upDistLimitSq upper limit on the distance in question, if the real distance is larger then the function exits returning nullopt
* \param loDistLimitSq low limit on the distance in question, if the real distance smaller then the function exits returning nullopt
*/
[[nodiscard]] MRMESH_API std::optional<SignedDistanceToMeshResult> findSignedDistance( const Vector3f & pt, const MeshPart & mp,
float upDistLimitSq = FLT_MAX, float loDistLimitSq = 0 );
/// \}
} // namespace MR