MeshLib
 
Loading...
Searching...
No Matches
MRMeshIntersect.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRPointOnFace.h"
4#include "MRTriPoint.h"
5#include "MRMeshPart.h"
6#include "MRMeshTriPoint.h"
7#include <cfloat>
8#include <functional>
9
10namespace MR
11{
12
15
17{
20
23
26
28 explicit operator bool() const { return proj.face.valid(); }
29};
30
36[[nodiscard]] MRMESH_API MeshIntersectionResult rayMeshIntersect( const MeshPart& meshPart, const Line3f& line,
37 float rayStart = 0.0f, float rayEnd = FLT_MAX, const IntersectionPrecomputes<float>* prec = nullptr, bool closestIntersect = true,
38 const FacePredicate & validFaces = {} );
39
45[[nodiscard]] MRMESH_API MeshIntersectionResult rayMeshIntersect( const MeshPart& meshPart, const Line3d& line,
46 double rayStart = 0.0, double rayEnd = DBL_MAX, const IntersectionPrecomputes<double>* prec = nullptr, bool closestIntersect = true,
47 const FacePredicate & validFaces = {} );
48
54
55template<typename T>
57{
60 const Mesh * mesh = nullptr;
61 const AABBTree * tree = nullptr;
62 const FaceBitSet * region = nullptr;
63};
66
69[[nodiscard]] MRMESH_API MultiMeshIntersectionResult rayMultiMeshAnyIntersect( const std::vector<Line3fMesh> & lineMeshes,
70 float rayStart = 0.0f, float rayEnd = FLT_MAX );
72[[nodiscard]] MRMESH_API MultiMeshIntersectionResult rayMultiMeshAnyIntersect( const std::vector<Line3dMesh> & lineMeshes,
73 double rayStart = 0.0, double rayEnd = DBL_MAX );
74
77using MeshIntersectionCallback = std::function<bool(const MeshIntersectionResult &)>;
80MRMESH_API void rayMeshIntersectAll( const MeshPart& meshPart, const Line3f& line, MeshIntersectionCallback callback,
81 float rayStart = 0.0f, float rayEnd = FLT_MAX, const IntersectionPrecomputes<float>* prec = nullptr );
83MRMESH_API void rayMeshIntersectAll( const MeshPart& meshPart, const Line3d& line, MeshIntersectionCallback callback,
84 double rayStart = 0.0, double rayEnd = DBL_MAX, const IntersectionPrecomputes<double>* prec = nullptr );
85
90MRMESH_API void xyPlaneMeshIntersect( const MeshPart& meshPart, float zLevel,
91 FaceBitSet * fs, UndirectedEdgeBitSet * ues, VertBitSet * vs );
92
94
95} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRDotNet/MRBitSet.h:39
Definition MRAABBTree.h:16
MRMESH_API MeshIntersectionResult rayMeshIntersect(const MeshPart &meshPart, const Line3f &line, float rayStart=0.0f, float rayEnd=FLT_MAX, const IntersectionPrecomputes< float > *prec=nullptr, bool closestIntersect=true, const FacePredicate &validFaces={})
MRMESH_API MultiMeshIntersectionResult rayMultiMeshAnyIntersect(const std::vector< Line3fMesh > &lineMeshes, float rayStart=0.0f, float rayEnd=FLT_MAX)
MRMESH_API void xyPlaneMeshIntersect(const MeshPart &meshPart, float zLevel, FaceBitSet *fs, UndirectedEdgeBitSet *ues, VertBitSet *vs)
std::function< bool(const MeshIntersectionResult &)> MeshIntersectionCallback
Definition MRMeshIntersect.h:77
MRMESH_API void rayMeshIntersectAll(const MeshPart &meshPart, const Line3f &line, MeshIntersectionCallback callback, float rayStart=0.0f, float rayEnd=FLT_MAX, const IntersectionPrecomputes< float > *prec=nullptr)
Definition MRCameraOrientationPlugin.h:7
std::function< bool(FaceId)> FacePredicate
Definition MRMesh/MRMeshFwd.h:413
Definition MRMesh/MRMeshFwd.h:364
Definition MRMeshIntersect.h:57
Line3< T > line
in the reference frame of mesh
Definition MRMeshIntersect.h:58
const Mesh * mesh
must be set a valid pointer before use
Definition MRMeshIntersect.h:60
const FaceBitSet * region
may remain nullptr, meaning all mesh
Definition MRMeshIntersect.h:62
const AABBTree * tree
must be set a valid pointer before use
Definition MRMeshIntersect.h:61
IntersectionPrecomputes< T > * prec
set it to a valid pointer for better performance
Definition MRMeshIntersect.h:59
Definition MRLine.h:12
Definition MRMeshIntersect.h:17
PointOnFace proj
stores intersected face and global coordinates
Definition MRMeshIntersect.h:19
float distanceAlongLine
stores the distance from ray origin to the intersection point in direction units
Definition MRMeshIntersect.h:25
MeshTriPoint mtp
stores barycentric coordinates
Definition MRMeshIntersect.h:22
Definition MRMesh/MRMeshPart.h:11
Definition MRMesh/MRMeshTriPoint.h:23
Definition MRMesh/MRMesh.h:23
Definition MRMeshIntersect.h:50
const Mesh * mesh
the intersection found in this mesh
Definition MRMeshIntersect.h:52
Definition MRPointOnFace.h:11
FaceId face
Definition MRPointOnFace.h:12