Isis 3 Programmer Reference
EmbreeTargetShape.h
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.
bool isOccluded(RTCOcclusionRay &ray)
Check if a ray intersects the target body.
void initMesh(pcl::PolygonMesh::Ptr mesh)
Internalize a PointCloudLibrary polygon mesh in the target shape.
pcl::PolygonMesh::Ptr readDSK(FileName file)
Read a NAIF type 2 DSK file into a PointCloudLibrary polygon mesh.
static void occlusionFilter(const RTCFilterFunctionNArguments *args)
Filter function for collecting multiple primitiveIDs This function is called by the Embree library du...
int numberOfPolygons() const
Return the number of polygons in the target shape.
int numberOfVertices() const
Return the number of vertices in the target shape.
virtual ~EmbreeTargetShape()
Desctructor.
bool isValid() const
Return if a valid mesh is internalized and ready for use.
RTCDevice m_device
!< The point cloud representation of the target.
void addVertices(int geomID)
Adds the vertices from the internalized vertex point cloud to the Embree scene.
static void multiHitFilter(const RTCFilterFunctionNArguments *args)
Filter function for collecting multiple hits during ray intersection.
pcl::PolygonMesh::Ptr readPC(FileName file)
Read a PointCloudLibrary file into a PointCloudLibrary polygon mesh.
pcl::PolygonMesh::Ptr m_mesh
!< The name of the target.
RTCScene m_scene
!< The Embree device for rendering the scene.
void addIndices(int geomID)
Adds the polygon vertex indices from the internalized polygon mesh to the Embree scene.
RayHitInformation getHitInformation(RTCMultiHitRay &ray, int hitIndex)
Extract the intersection point and unit surface normal from an RTCMultiHitRay that has been intersect...
RTCBounds sceneBounds() const
Returns the bounds of the Embree scene.
void intersectRay(RTCMultiHitRay &ray)
Intersect a ray with the target shape.
EmbreeTargetShape()
Default empty constructor.
pcl::PointCloud< pcl::PointXYZ > m_cloud
!< A boost shared pointer to the polygon mesh representation of the target.
QString name() const
Return the name of the target shape.
double maximumSceneDistance() const
Return the maximum distance within the scene.
File name manipulation and expansion.
Definition FileName.h:100
boost::numeric::ublas::vector< double > Vector
Definition for an Isis::LinearAlgebra::Vector of doubles.
Container for cube-like labels.
Definition Pvl.h:119
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Container for a tin, or triangular polygon.
int v1
The index of the second vertex in the tin.
int v2
The index of the third vertex in the tin.
int v0
The index of the first vertex in the tin.
float a
Extra float for aligning memory.
Struct for capturing multiple intersections when using embree::rtcintersectscene.
float hitUs[16]
Barycentric u coordinate of the hits.
unsigned hitGeomIDs[16]
IDs of the geometries (bodies) hit.
float hitVs[16]
Barycentric v coordinate of the hits.
unsigned hitPrimIDs[16]
IDs of the primitives (trinagles) hit.
RTCMultiHitRay()
Default constructor for RTCMultiHitRay.
int lastHit
Index of the last hit in the hit containers.
Struct for capturing occluded plates when using embree::rtcintersectscene.
RTCOcclusionRay()
Default constructor for RTCOcclussionRay.
unsigned ignorePrimID
IDs of the primitives (trinagles) which should be ignored.
int lastHit
Index of the last hit in the hit containers.
Container that holds the body fixed intersection point and unit surface normal for a hit.
int primID
The primitive ID of the hit.
LinearAlgebra::Vector intersection
The (x, y, z) intersection location.
LinearAlgebra::Vector surfaceNormal
The unit surface normal vector at the intersection.
RayHitInformation()
Default constructor for RayHitInformation.