MeshLib C++ Docs
Loading...
Searching...
No Matches
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
33 [[nodiscard]] MRMESH_API MeshTriPoint mtp( const MeshTopology & topology ) const;
34};
35
37{
38 const AffineXf3f* rigidXfPoint{ nullptr };
39 const AffineXf3f* nonRigidXfTree{ nullptr };
40};
41
49MRMESH_API MeshProjectionTransforms createProjectionTransforms( AffineXf3f& storageXf, const AffineXf3f* pointXf, const AffineXf3f* treeXf );
50
62[[nodiscard]] MRMESH_API MeshProjectionResult findProjection( const Vector3f & pt, const MeshPart & mp,
63 float upDistLimitSq = FLT_MAX,
64 const AffineXf3f * xf = nullptr,
65 float loDistLimitSq = 0,
66 const FacePredicate & validFaces = {},
67 const std::function<bool(const MeshProjectionResult&)> & validProjections = {},
68 bool useLeafBoxes = true );
69
82[[nodiscard]] MRMESH_API MeshProjectionResult findProjectionSubtree( const Vector3f & pt,
83 const MeshPart & mp, const AABBTree & tree,
84 float upDistLimitSq = FLT_MAX,
85 const AffineXf3f * xf = nullptr,
86 float loDistLimitSq = 0,
87 const FacePredicate & validFaces = {},
88 const std::function<bool(const MeshProjectionResult&)> & validProjections = {},
89 bool useLeafBoxes = true );
90
106[[nodiscard]] MRMESH_API MeshProjectionResult findProjection( const Vector3f & pt,
107 const VertCoords & points, const AABBTree & tree,
108 float upDistLimitSq = FLT_MAX,
109 const AffineXf3f * xf = nullptr,
110 float loDistLimitSq = 0,
111 const FacePredicate & validFaces = {},
112 const std::function<bool(const MeshProjectionResult&)> & validProjections = {},
113 const FaceBitSet * region = nullptr,
114 bool useLeafBoxes = true );
115
118using FoundBoxedTriCallback = std::function<Processing( FaceId found, Ball3f & ball )>;
119
123MRMESH_API void findBoxedTrisInBall( const MeshPart & mp, Ball3f ball, const FoundBoxedTriCallback& foundCallback );
124
127MRMESH_API void findBoxedTrisInBall( const AABBTree & tree, Ball3f ball, const FoundBoxedTriCallback& foundCallback, const FaceBitSet * region = nullptr );
128
130using FoundTriCallback = std::function<Processing( const MeshProjectionResult & found, Ball3f & ball )>;
131
134MRMESH_API void findTrisInBall( const MeshPart & mp, const Ball3f& ball, const FoundTriCallback& foundCallback, const FacePredicate & validFaces = {} );
135
139MRMESH_API void findTrisInBall( const VertCoords & points, const AABBTree & tree, const Ball3f& ball, const FoundTriCallback& foundCallback, const FacePredicate & validFaces = {},
140 const FaceBitSet * region = nullptr );
141
143{
149 float dist = 0;
150
152 [[nodiscard]] MRMESH_API MeshTriPoint mtp( const MeshTopology & topology ) const;
153};
154
161[[nodiscard]] MRMESH_API std::optional<SignedDistanceToMeshResult> findSignedDistance( const Vector3f & pt, const MeshPart & mp,
162 float upDistLimitSq = FLT_MAX, float loDistLimitSq = 0 );
163
165
166}
#define MRMESH_API
Definition MRMeshFwd.h:85
Definition MRAABBTree.h:41
Definition MRMeshTopology.h:31
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 MRMeshProject.h:130
std::function< Processing(FaceId found, Ball3f &ball)> FoundBoxedTriCallback
Definition MRMeshProject.h:118
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={}, bool useLeafBoxes=true)
computes the closest point on mesh (or its region) to given point
void findBoxedTrisInBall(const MeshPart &mp, Ball3f ball, const FoundBoxedTriCallback &foundCallback)
MeshProjectionTransforms createProjectionTransforms(AffineXf3f &storageXf, const AffineXf3f *pointXf, const AffineXf3f *treeXf)
Creates structure with simplified transforms for projection functions, with rigidXfPoint applied to p...
MeshMeshSignedDistanceResult findSignedDistance(const MeshPart &a, const MeshPart &b, const AffineXf3f *rigidB2A=nullptr, float upDistLimitSq=FLT_MAX)
computes minimal distance between two meshes
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={}, bool useLeafBoxes=true)
computes the closest point on mesh (or its region) to given point
std::function< bool(FaceId)> FacePredicate
Definition MRMeshFwd.h:592
MeshTriPoint
Definition MRMeshFwd.h:515
TriPointf
Definition MRMeshFwd.h:506
Processing
typically returned from callbacks to control the behavior of main algorithm
Definition MREnums.h:63
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRMeshProject.h:18
MeshTriPoint mtp(const MeshTopology &topology) const
returns the closest point on mesh as MeshTriPoint relative to topology.edgeWithLeft( proj....
float distSq
squared distance from original projected point to proj
Definition MRMeshProject.h:26
bool valid() const
check for validity, otherwise the projection was not found
Definition MRMeshProject.h:29
TriPointf tp
barycentric coordinates of proj relative to the vertices of proj.face in the order of MeshTopology::g...
Definition MRMeshProject.h:23
PointOnFace proj
the closest point on mesh, transformed by xf if it is given
Definition MRMeshProject.h:20
Definition MRMeshProject.h:37
const AffineXf3f * rigidXfPoint
this xf is applied to point to move it into projection space
Definition MRMeshProject.h:38
const AffineXf3f * nonRigidXfTree
this xf is applied to AABB tree to move it into projection space
Definition MRMeshProject.h:39
a point located on some mesh's face
Definition MRPointOnFace.h:16
Definition MRMeshProject.h:143
TriPointf tp
barycentric coordinates of proj relative to the vertices of proj.face in the order of MeshTopology::g...
Definition MRMeshProject.h:147
MeshTriPoint mtp(const MeshTopology &topology) const
returns the closest point on mesh as MeshTriPoint relative to topology.edgeWithLeft( proj....
float dist
distance from pt to proj (positive - outside, negative - inside the mesh)
Definition MRMeshProject.h:149
PointOnFace proj
the closest point on mesh
Definition MRMeshProject.h:145