Isis Developer Reference
EmbreeTargetShape.h
Go to the documentation of this file.
1#ifndef EmbreeTargetShape_h
2#define EmbreeTargetShape_h
8/* SPDX-License-Identifier: CC0-1.0 */
9
10#include <QString>
11
12// Embree includes
13#include <embree3/rtcore.h>
14#include <embree3/rtcore_ray.h>
15
16// PointCloudLibrary includes
17#include <pcl/io/auto_io.h>
18#include <pcl/point_types.h>
19#include <pcl/PolygonMesh.h>
20
21// WARNING
22// The following undefes macros set in pcl. They conflict with ISIS's macros.
23// If pcl tries to use these macros you will get compilation errors.
24// - JAM
25#undef DEG2RAD
26#undef RAD2DEG
27
28#include "FileName.h"
29#include "LinearAlgebra.h"
30
31namespace Isis {
32
33
34 class Pvl;
35
46 RTCMultiHitRay(const std::vector<double> &origin,
47 const std::vector<double> &direction);
49 LinearAlgebra::Vector direction);
50
51// These are the inheritted members from RTCRay
52// float org; //!< Ray origin
53// float dir; //!< Ray direction
54// float tnear; //!< Start of ray segment
55// float tfar; //!< End of ray segment
56// float time; //!< Time of this ray for motion blur.
57// unsigned mask; //!< used to mask out objects during traversal
58// float Ng; //!< Geometric normal.
59// float u; //!< Barycentric u coordinate of hit
60// float v; //!< Barycentric v coordinate of hit
61// unsigned geomID; //!< geometry ID
62// unsigned primID; //!< primitive ID
63// unsigned instID; //!< instance ID
64
65 // ray extensions
66 // we remember up to 16 hits to ignore duplicate hits
67 unsigned hitGeomIDs[16];
68 unsigned hitPrimIDs[16];
69 float hitUs[16];
70 float hitVs[16];
71 int lastHit;
72 };
73
74
85 RTCOcclusionRay(const std::vector<double> &origin,
86 const std::vector<double> &direction);
88 LinearAlgebra::Vector direction);
89
90// These are the inheritted members from RTCRay
91// float org; //!< Ray origin
92// float dir; //!< Ray direction
93// float tnear; //!< Start of ray segment
94// float tfar; //!< End of ray segment
95// float time; //!< Time of this ray for motion blur.
96// unsigned mask; //!< used to mask out objects during traversal
97// float Ng; //!< Geometric normal.
98// float u; //!< Barycentric u coordinate of hit
99// float v; //!< Barycentric v coordinate of hit
100// unsigned geomID; //!< geometry ID
101// unsigned primID; //!< primitive ID
102// unsigned instID; //!< instance ID
103
104 // ray extensions
106 unsigned ignorePrimID;
107 };
108
109
126
127
140 public:
141
143 EmbreeTargetShape(pcl::PolygonMesh::Ptr mesh, const QString &name = "");
144 EmbreeTargetShape(const QString &dem, const Pvl *conf = 0);
145 virtual ~EmbreeTargetShape();
146
147 QString name() const;
148 bool isValid() const;
149
150 int numberOfPolygons() const;
151 int numberOfVertices() const;
152 RTCBounds sceneBounds() const;
153 double maximumSceneDistance() const;
154
155 void intersectRay(RTCMultiHitRay &ray);
156 bool isOccluded(RTCOcclusionRay &ray);
157
159
160 static void multiHitFilter(const RTCFilterFunctionNArguments *args);
161 static void occlusionFilter(const RTCFilterFunctionNArguments *args);
162
163 protected:
164 pcl::PolygonMesh::Ptr readDSK(FileName file);
165 pcl::PolygonMesh::Ptr readPC(FileName file);
166 void initMesh(pcl::PolygonMesh::Ptr mesh);
167 void addVertices(int geomID);
168 void addIndices(int geomID);
169
170 private:
178 struct Vertex {
179 float x;
180 float y;
181 float z;
182 float a;
183 };
184
193 struct Triangle {
194 int v0;
195 int v1;
196 int v2;
197 };
198
199 QString m_name;
200 pcl::PolygonMesh::Ptr m_mesh;
203 pcl::PointCloud<pcl::PointXYZ> m_cloud;
208 RTCDevice m_device;
210 RTCScene m_scene;
216 };
217
218} // namespace Isis
219
220#endif
221
Embree Target Shape for planetary bodies.
Definition EmbreeTargetShape.h:139
bool isOccluded(RTCOcclusionRay &ray)
Check if a ray intersects the target body.
Definition EmbreeTargetShape.cpp:675
void initMesh(pcl::PolygonMesh::Ptr mesh)
Internalize a PointCloudLibrary polygon mesh in the target shape.
Definition EmbreeTargetShape.cpp:450
pcl::PolygonMesh::Ptr readDSK(FileName file)
Read a NAIF type 2 DSK file into a PointCloudLibrary polygon mesh.
Definition EmbreeTargetShape.cpp:311
static void occlusionFilter(const RTCFilterFunctionNArguments *args)
Filter function for collecting multiple primitiveIDs This function is called by the Embree library du...
Definition EmbreeTargetShape.cpp:818
int numberOfPolygons() const
Return the number of polygons in the target shape.
Definition EmbreeTargetShape.cpp:564
int numberOfVertices() const
Return the number of vertices in the target shape.
Definition EmbreeTargetShape.cpp:578
virtual ~EmbreeTargetShape()
Desctructor.
Definition EmbreeTargetShape.cpp:552
bool isValid() const
Return if a valid mesh is internalized and ready for use.
Definition EmbreeTargetShape.cpp:765
void addVertices(int geomID)
Adds the vertices from the internalized vertex point cloud to the Embree scene.
Definition EmbreeTargetShape.cpp:507
static void multiHitFilter(const RTCFilterFunctionNArguments *args)
Filter function for collecting multiple hits during ray intersection.
Definition EmbreeTargetShape.cpp:779
pcl::PolygonMesh::Ptr readPC(FileName file)
Read a PointCloudLibrary file into a PointCloudLibrary polygon mesh.
Definition EmbreeTargetShape.cpp:421
void addIndices(int geomID)
Adds the polygon vertex indices from the internalized polygon mesh to the Embree scene.
Definition EmbreeTargetShape.cpp:532
RayHitInformation getHitInformation(RTCMultiHitRay &ray, int hitIndex)
Extract the intersection point and unit surface normal from an RTCMultiHitRay that has been intersect...
Definition EmbreeTargetShape.cpp:708
RTCBounds sceneBounds() const
Returns the bounds of the Embree scene.
Definition EmbreeTargetShape.cpp:596
void intersectRay(RTCMultiHitRay &ray)
Intersect a ray with the target shape.
Definition EmbreeTargetShape.cpp:658
EmbreeTargetShape()
Default empty constructor.
Definition EmbreeTargetShape.cpp:225
QString name() const
Return the name of the target shape.
Definition EmbreeTargetShape.cpp:755
double maximumSceneDistance() const
Return the maximum distance within the scene.
Definition EmbreeTargetShape.cpp:619
File name manipulation and expansion.
Definition FileName.h:100
boost::numeric::ublas::vector< double > Vector
Definition for an Isis::LinearAlgebra::Vector of doubles.
Definition LinearAlgebra.h:132
Container for cube-like labels.
Definition Pvl.h:119
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Struct for capturing multiple intersections when using embree::rtcintersectscene.
Definition EmbreeTargetShape.h:44
float hitUs[16]
Barycentric u coordinate of the hits.
Definition EmbreeTargetShape.h:69
unsigned hitGeomIDs[16]
IDs of the geometries (bodies) hit.
Definition EmbreeTargetShape.h:67
float hitVs[16]
Barycentric v coordinate of the hits.
Definition EmbreeTargetShape.h:70
unsigned hitPrimIDs[16]
IDs of the primitives (trinagles) hit.
Definition EmbreeTargetShape.h:68
RTCMultiHitRay()
Default constructor for RTCMultiHitRay.
Definition EmbreeTargetShape.cpp:28
int lastHit
Index of the last hit in the hit containers.
Definition EmbreeTargetShape.h:71
Struct for capturing occluded plates when using embree::rtcintersectscene.
Definition EmbreeTargetShape.h:83
RTCOcclusionRay()
Default constructor for RTCOcclussionRay.
Definition EmbreeTargetShape.cpp:112
unsigned ignorePrimID
IDs of the primitives (trinagles) which should be ignored.
Definition EmbreeTargetShape.h:106
int lastHit
Index of the last hit in the hit containers.
Definition EmbreeTargetShape.h:105
Container that holds the body fixed intersection point and unit surface normal for a hit.
Definition EmbreeTargetShape.h:118
int primID
The primitive ID of the hit.
Definition EmbreeTargetShape.h:124
LinearAlgebra::Vector intersection
The (x, y, z) intersection location.
Definition EmbreeTargetShape.h:122
LinearAlgebra::Vector surfaceNormal
The unit surface normal vector at the intersection.
Definition EmbreeTargetShape.h:123
RayHitInformation()
Default constructor for RayHitInformation.
Definition EmbreeTargetShape.cpp:196