MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMesh/MRMeshProject.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRPointOnFace.h"
4#include "MRMeshTriPoint.h"
5#include "MRMeshPart.h"
6#include "MREnums.h"
7#include <cfloat>
8#include <optional>
9#include <functional>
10
11namespace MR
12{
13
16
18{
21
24
26 float distSq = 0;
27
29 [[nodiscard]] bool valid() const { return proj.valid(); }
30 [[nodiscard]] explicit operator bool() const { return proj.valid(); }
31};
32
34{
35 const AffineXf3f* rigidXfPoint{ nullptr };
36 const AffineXf3f* nonRigidXfTree{ nullptr };
37};
38
46MRMESH_API MeshProjectionTransforms createProjectionTransforms( AffineXf3f& storageXf, const AffineXf3f* pointXf, const AffineXf3f* treeXf );
47
56[[nodiscard]] MRMESH_API MeshProjectionResult findProjection( const Vector3f & pt, const MeshPart & mp,
57 float upDistLimitSq = FLT_MAX,
58 const AffineXf3f * xf = nullptr,
59 float loDistLimitSq = 0,
60 const FacePredicate & validFaces = {},
61 const std::function<bool(const MeshProjectionResult&)> & validProjections = {} );
62
72[[nodiscard]] MRMESH_API MeshProjectionResult findProjectionSubtree( const Vector3f & pt,
73 const MeshPart & mp, const AABBTree & tree,
74 float upDistLimitSq = FLT_MAX,
75 const AffineXf3f * xf = nullptr,
76 float loDistLimitSq = 0,
77 const FacePredicate & validFaces = {},
78 const std::function<bool(const MeshProjectionResult&)> & validProjections = {} );
79
82using FoundBoxedTriCallback = std::function<Processing( FaceId found, Ball3f & ball )>;
83
87MRMESH_API void findBoxedTrisInBall( const MeshPart & mp, Ball3f ball, const FoundBoxedTriCallback& foundCallback );
88
90using FoundTriCallback = std::function<Processing( const MeshProjectionResult & found, Ball3f & ball )>;
91
94MRMESH_API void findTrisInBall( const MeshPart & mp, const Ball3f& ball, const FoundTriCallback& foundCallback, const FacePredicate & validFaces = {} );
95
105
112[[nodiscard]] MRMESH_API std::optional<SignedDistanceToMeshResult> findSignedDistance( const Vector3f & pt, const MeshPart & mp,
113 float upDistLimitSq = FLT_MAX, float loDistLimitSq = 0 );
114
116
117} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
Definition MRAABBTree.h:16
MRMESH_API MeshMeshSignedDistanceResult findSignedDistance(const MeshPart &a, const MeshPart &b, const AffineXf3f *rigidB2A=nullptr, float upDistLimitSq=FLT_MAX)
computes minimal distance between two meshes
MRMESH_API MeshProjectionTransforms createProjectionTransforms(AffineXf3f &storageXf, const AffineXf3f *pointXf, const AffineXf3f *treeXf)
Creates structure with simplified transforms for projection functions, with rigidXfPoint applied to p...
MRMESH_API void findTrisInBall(const MeshPart &mp, const Ball3f &ball, const FoundTriCallback &foundCallback, const FacePredicate &validFaces={})
std::function< Processing(const MeshProjectionResult &found, Ball3f &ball)> FoundTriCallback
this callback is invoked on every triangle at least partially in the ball, and allows changing (shrin...
Definition MRMesh/MRMeshProject.h:90
MRMESH_API MeshProjectionResult findProjectionSubtree(const Vector3f &pt, const MeshPart &mp, const AABBTree &tree, float upDistLimitSq=FLT_MAX, const AffineXf3f *xf=nullptr, float loDistLimitSq=0, const FacePredicate &validFaces={}, const std::function< bool(const MeshProjectionResult &)> &validProjections={})
computes the closest point on mesh (or its region) to given point
std::function< Processing(FaceId found, Ball3f &ball)> FoundBoxedTriCallback
Definition MRMesh/MRMeshProject.h:82
MRMESH_API void findBoxedTrisInBall(const MeshPart &mp, Ball3f ball, const FoundBoxedTriCallback &foundCallback)
MRMESH_API MeshProjectionResult findProjection(const Vector3f &pt, const MeshPart &mp, float upDistLimitSq=FLT_MAX, const AffineXf3f *xf=nullptr, float loDistLimitSq=0, const FacePredicate &validFaces={}, const std::function< bool(const MeshProjectionResult &)> &validProjections={})
computes the closest point on mesh (or its region) to given point
std::function< bool(FaceId)> FacePredicate
Definition MRMesh/MRMeshFwd.h:479
Processing
typically returned from callbacks to control the behavior of main algorithm
Definition MREnums.h:31
Definition MRMesh/MRMeshProject.h:18
float distSq
squared distance from original projected point to proj
Definition MRMesh/MRMeshProject.h:26
bool valid() const
check for validity, otherwise the projection was not found
Definition MRMesh/MRMeshProject.h:29
MeshTriPoint mtp
its barycentric representation
Definition MRMesh/MRMeshProject.h:23
PointOnFace proj
the closest point on mesh, transformed by xf if it is given
Definition MRMesh/MRMeshProject.h:20
Definition MRMesh/MRMeshProject.h:34
const AffineXf3f * rigidXfPoint
this xf is applied to point to move it into projection space
Definition MRMesh/MRMeshProject.h:35
const AffineXf3f * nonRigidXfTree
this xf is applied to AABB tree to move it into projection space
Definition MRMesh/MRMeshProject.h:36
Definition MRMesh/MRMeshTriPoint.h:23
a point located on some mesh's face
Definition MRMesh/MRPointOnFace.h:11
bool valid() const
check for validity, otherwise the point is not defined
Definition MRMesh/MRPointOnFace.h:19
Definition MRMesh/MRMeshProject.h:97
float dist
distance from pt to proj (positive - outside, negative - inside the mesh)
Definition MRMesh/MRMeshProject.h:103
PointOnFace proj
the closest point on mesh
Definition MRMesh/MRMeshProject.h:99
MeshTriPoint mtp
its barycentric representation
Definition MRMesh/MRMeshProject.h:101