EmbreeRaycaster.hpp
Go to the documentation of this file.
1 
28 /*
29  * EmbreeRaycaster.hpp
30  *
31  * @date 25.01.2020
32  * @author Alexander Mock <amock@uos.de>
33  */
34 
35 #ifndef LVR2_ALGORITHM_RAYCASTING_EMBREERAYCASTER
36 #define LVR2_ALGORITHM_RAYCASTING_EMBREERAYCASTER
37 
38 #include <embree3/rtcore.h>
39 #include <stdio.h>
40 
42 #include "lvr2/io/MeshBuffer.hpp"
44 #include "Intersection.hpp"
45 
46 namespace lvr2 {
47 
48 void EmbreeErrorFunction(void* userPtr, enum RTCError error, const char* str);
49 
50 template<typename IntT>
51 class EmbreeRaycaster : public RaycasterBase<IntT> {
52 public:
55 
65  bool castRay(
66  const Vector3f& origin,
67  const Vector3f& direction,
68  IntT& intersection);
69 
70 protected:
71 
72  RTCDevice initializeDevice();
73  RTCScene initializeScene(RTCDevice device, const MeshBufferPtr mesh);
74 
75  inline RTCRayHit lvr2embree(
76  const Vector3f& origin,
77  const Vector3f& direction) const
78  {
79  RTCRayHit rayhit;
80  rayhit.ray.org_x = origin.x();
81  rayhit.ray.org_y = origin.y();
82  rayhit.ray.org_z = origin.z();
83  rayhit.ray.dir_x = direction.x();
84  rayhit.ray.dir_y = direction.y();
85  rayhit.ray.dir_z = direction.z();
86  rayhit.ray.tnear = 0;
87  rayhit.ray.tfar = INFINITY;
88  rayhit.ray.mask = 0;
89  rayhit.ray.flags = 0;
90  rayhit.hit.geomID = RTC_INVALID_GEOMETRY_ID;
91  rayhit.hit.instID[0] = RTC_INVALID_GEOMETRY_ID;
92  return rayhit;
93  }
94 
95  RTCDevice m_device;
96  RTCScene m_scene;
97  RTCIntersectContext m_context;
98 };
99 
100 } // namespace lvr2
101 
102 #include "EmbreeRaycaster.tcc"
103 
104 #endif // LVR2_ALGORITHM_RAYCASTING_EMBREERAYCASTER
HalfEdgeMesh< Vec > mesh
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
bool castRay(const Vector3f &origin, const Vector3f &direction, IntT &intersection)
Cast a single ray onto the mesh.
RTCScene initializeScene(RTCDevice device, const MeshBufferPtr mesh)
RTCIntersectContext m_context
RTCRayHit lvr2embree(const Vector3f &origin, const Vector3f &direction) const
RaycasterBase interface.
Eigen::Vector3f Vector3f
Eigen 3D vector, single precision.
RTCDevice initializeDevice()
EmbreeRaycaster(const MeshBufferPtr mesh)
KF_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func="")
Error handler. All GPU functions from this subsystem call the function to report an error...
void EmbreeErrorFunction(void *userPtr, enum RTCError error, const char *str)


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:06