Isis 3 Programmer Reference
|
Embree Target Shape for planetary bodies. More...
#include <EmbreeTargetShape.h>
Classes | |
struct | Triangle |
Container for a tin, or triangular polygon. More... | |
struct | Vertex |
Container for a vertex. More... | |
Public Member Functions | |
EmbreeTargetShape () | |
Default empty constructor. More... | |
EmbreeTargetShape (pcl::PolygonMesh::Ptr mesh, const QString &name="") | |
Constructs an EmbreeTargetShape from a PointCloudLibrary polygon mesh. More... | |
EmbreeTargetShape (const QString &dem, const Pvl *conf=0) | |
Constructs an EmbreeTargetShape from a file. More... | |
virtual | ~EmbreeTargetShape () |
Desctructor. More... | |
QString | name () const |
Return the name of the target shape. More... | |
bool | isValid () const |
Return if a valid mesh is internalized and ready for use. More... | |
int | numberOfPolygons () const |
Return the number of polygons in the target shape. More... | |
int | numberOfVertices () const |
Return the number of vertices in the target shape. More... | |
RTCBounds | sceneBounds () const |
Returns the bounds of the Embree scene. More... | |
double | maximumSceneDistance () const |
Return the maximum distance within the scene. More... | |
void | intersectRay (RTCMultiHitRay &ray) |
Intersect a ray with the target shape. More... | |
bool | isOccluded (RTCOcclusionRay &ray) |
Check if a ray intersects the target body. More... | |
RayHitInformation | getHitInformation (RTCMultiHitRay &ray, int hitIndex) |
Extract the intersection point and unit surface normal from an RTCMultiHitRay that has been intersected with the target shape. More... | |
Static Public Member Functions | |
static void | multiHitFilter (void *userDataPtr, RTCMultiHitRay &ray) |
Filter function for collecting multiple hits during ray intersection. More... | |
static void | occlusionFilter (void *userDataPtr, RTCOcclusionRay &ray) |
Filter function for collecting multiple primitiveIDs This function is called by the Embree library during ray tracing. More... | |
Protected Member Functions | |
pcl::PolygonMesh::Ptr | readDSK (FileName file) |
Read a NAIF type 2 DSK file into a PointCloudLibrary polygon mesh. More... | |
pcl::PolygonMesh::Ptr | readPC (FileName file) |
Read a PointCloudLibrary file into a PointCloudLibrary polygon mesh. More... | |
void | initMesh (pcl::PolygonMesh::Ptr mesh) |
Internalize a PointCloudLibrary polygon mesh in the target shape. More... | |
void | addVertices (int geomID) |
Adds the vertices from the internalized vertex point cloud to the Embree scene. More... | |
void | addIndices (int geomID) |
Adds the polygon vertex indices from the internalized polygon mesh to the Embree scene. More... | |
Private Attributes | |
QString | m_name |
pcl::PolygonMesh::Ptr | m_mesh |
!< The name of the target. More... | |
pcl::PointCloud< pcl::PointXYZ > | m_cloud |
!< A boost shared pointer to the polygon mesh representation of the target. More... | |
RTCDevice | m_device |
!< The point cloud representation of the target. More... | |
RTCScene | m_scene |
!< The Embree device for rendering the scene. More... | |
Embree Target Shape for planetary bodies.
This class holds the Embree representation of a target body. All vectors are expected to be in the body-fixed reference frame for the target and all positions are expected to be in kilometers.
Definition at line 155 of file EmbreeTargetShape.h.
Isis::EmbreeTargetShape::EmbreeTargetShape | ( | ) |
Default empty constructor.
The filename defaults to an empty string and the file handle defaults to 0. Counts default to 0 and the cache size defaults to 0.
Definition at line 242 of file EmbreeTargetShape.cpp.
Isis::EmbreeTargetShape::EmbreeTargetShape | ( | pcl::PolygonMesh::Ptr | mesh, |
const QString & | name = "" |
||
) |
Constructs an EmbreeTargetShape from a PointCloudLibrary polygon mesh.
mesh | The polygon mesh to construct the scene from. |
name | The name of the target being represented. |
Definition at line 258 of file EmbreeTargetShape.cpp.
References initMesh().
Isis::EmbreeTargetShape::EmbreeTargetShape | ( | const QString & | dem, |
const Pvl * | conf = 0 |
||
) |
Constructs an EmbreeTargetShape from a file.
dem | The file to construct the target shape from. The file type is determined based on the file extension. |
conf | Pvl containing configuration settings for the target shape. Currently unused. |
IException::Io |
Definition at line 280 of file EmbreeTargetShape.cpp.
References _FILEINFO_, Isis::FileName::baseName(), Isis::FileName::expanded(), Isis::FileName::extension(), initMesh(), Isis::IException::Io, readDSK(), and readPC().
|
virtual |
Desctructor.
The PointCloudLibrary objects are automatically cleaned up, but the Embree scene and device must be manually cleaned up.
Definition at line 550 of file EmbreeTargetShape.cpp.
|
protected |
Adds the polygon vertex indices from the internalized polygon mesh to the Embree scene.
geomID | The Embree geometry ID of the Embree geometry that the indices will be stored in. |
Definition at line 530 of file EmbreeTargetShape.cpp.
References isValid(), m_mesh, m_scene, numberOfPolygons(), Isis::EmbreeTargetShape::Triangle::v0, Isis::EmbreeTargetShape::Triangle::v1, and Isis::EmbreeTargetShape::Triangle::v2.
Referenced by initMesh().
|
protected |
Adds the vertices from the internalized vertex point cloud to the Embree scene.
geomID | The Embree geometry ID of the Embree geometry that the vertices will be stored in. |
Definition at line 505 of file EmbreeTargetShape.cpp.
References isValid(), m_cloud, m_scene, numberOfVertices(), Isis::EmbreeTargetShape::Vertex::x, Isis::EmbreeTargetShape::Vertex::y, and Isis::EmbreeTargetShape::Vertex::z.
Referenced by initMesh().
RayHitInformation Isis::EmbreeTargetShape::getHitInformation | ( | RTCMultiHitRay & | ray, |
int | hitIndex | ||
) |
Extract the intersection point and unit surface normal from an RTCMultiHitRay that has been intersected with the target shape.
This method performs two calculations. First, it converts the intersection point from barycentric coordinates relative to the intersected polygon to the body-fixed (x, y, z) coordinates. Second, it computes the unit normal vector of the intersected polygon. The polygon vertices are assumed to be ordered counter-clockwise about the exterior surface normal as they are in NAIF type 2 DSK files.
ray | The ray to extract intersection information from. |
hitIndex | The index of the intersection to extract. |
IException::Programmer |
Definition at line 700 of file EmbreeTargetShape.cpp.
References _FILEINFO_, Isis::RTCMultiHitRay::hitPrimIDs, Isis::RTCMultiHitRay::hitUs, Isis::RTCMultiHitRay::hitVs, Isis::RTCMultiHitRay::lastHit, m_cloud, m_mesh, Isis::LinearAlgebra::normalize(), Isis::IException::Programmer, and Isis::toString().
Referenced by Isis::EmbreeShapeModel::intersectSurface(), Isis::EmbreeShapeModel::isVisibleFrom(), Isis::EmbreeShapeModel::localRadius(), and Isis::EmbreeShapeModel::sortHits().
|
protected |
Internalize a PointCloudLibrary polygon mesh in the target shape.
The mesh itself is stored along with a duplicate of the vertex point cloud because the point cloud stored in the polygon mesh cannot be read without Robot Operating System routines. The mesh is loaded into the internal Embree scene and the scene is commited. Any changes made to the Embree scene after this method is called will not take effect until embree::rtcCommit is called again.
mesh | The mesh to be internalized. |
Definition at line 466 of file EmbreeTargetShape.cpp.
References addIndices(), addVertices(), m_cloud, m_mesh, m_scene, multiHitFilter(), numberOfPolygons(), numberOfVertices(), and occlusionFilter().
Referenced by EmbreeTargetShape().
void Isis::EmbreeTargetShape::intersectRay | ( | RTCMultiHitRay & | ray | ) |
Intersect a ray with the target shape.
After calling, up to 16 intersections will be stored within the RTCMultiHitRay. The intersection information will be stored in the following arrays:
The index of the last intersection is stored in lastHit.
[in,out] | ray | The ray to intersect with the scene. After calling, The intersection information will be stored in the ray. |
Definition at line 656 of file EmbreeTargetShape.cpp.
References isValid(), and m_scene.
Referenced by Isis::EmbreeShapeModel::intersectSurface(), Isis::EmbreeShapeModel::isVisibleFrom(), and Isis::EmbreeShapeModel::localRadius().
bool Isis::EmbreeTargetShape::isOccluded | ( | RTCOcclusionRay & | ray | ) |
Check if a ray intersects the target body.
Definition at line 670 of file EmbreeTargetShape.cpp.
References m_scene.
Referenced by Isis::EmbreeShapeModel::intersectSurface().
bool Isis::EmbreeTargetShape::isValid | ( | ) | const |
Return if a valid mesh is internalized and ready for use.
Definition at line 757 of file EmbreeTargetShape.cpp.
References m_mesh.
Referenced by addIndices(), addVertices(), intersectRay(), numberOfPolygons(), numberOfVertices(), and sceneBounds().
double Isis::EmbreeTargetShape::maximumSceneDistance | ( | ) | const |
Return the maximum distance within the scene.
This is computed as the length of the diagonal from once corner of the scene to the opposite.
Definition at line 617 of file EmbreeTargetShape.cpp.
References Isis::LinearAlgebra::magnitude(), and sceneBounds().
Referenced by Isis::EmbreeShapeModel::latlonToRay().
|
static |
Filter function for collecting multiple hits during ray intersection.
This function is called by the Embree library during ray tracing. Each time an intersection is found, this method is called.
[in] | userDataPtr | Data pointer from the geometry hit. Not used. |
[in,out] | ray | The ray being traced. Information about the intersection will be stored in the ray. |
Definition at line 771 of file EmbreeTargetShape.cpp.
References Isis::RTCMultiHitRay::hitGeomIDs, Isis::RTCMultiHitRay::hitPrimIDs, Isis::RTCMultiHitRay::hitUs, Isis::RTCMultiHitRay::hitVs, and Isis::RTCMultiHitRay::lastHit.
Referenced by initMesh().
QString Isis::EmbreeTargetShape::name | ( | ) | const |
Return the name of the target shape.
Definition at line 747 of file EmbreeTargetShape.cpp.
int Isis::EmbreeTargetShape::numberOfPolygons | ( | ) | const |
Return the number of polygons in the target shape.
Definition at line 562 of file EmbreeTargetShape.cpp.
References isValid(), and m_mesh.
Referenced by addIndices(), and initMesh().
int Isis::EmbreeTargetShape::numberOfVertices | ( | ) | const |
Return the number of vertices in the target shape.
Definition at line 576 of file EmbreeTargetShape.cpp.
References isValid(), and m_mesh.
Referenced by addVertices(), and initMesh().
|
static |
Filter function for collecting multiple primitiveIDs This function is called by the Embree library during ray tracing.
Each time an intersection is found, this method is called.
[in] | userDataPtr | Data pointer from the geometry hit. Not used. |
[in,out] | ray | The ray being traced. Information about the intersection will be stored in the ray. |
Definition at line 796 of file EmbreeTargetShape.cpp.
References Isis::RTCOcclusionRay::ignorePrimID.
Referenced by initMesh().
|
protected |
Read a NAIF type 2 DSK file into a PointCloudLibrary polygon mesh.
The vertex and plate ordering in the DSK file is maintained in the polygon mesh.
file | The DSK file to load. |
IException::User | |
IException::Io |
NAIF DSK parameter setup
< The DAS file handle of the DSK file.
< The DLA descriptor of the DSK segment representing the target surface.
< The DSK descriptor.
< Number of Plates in the model.
< Number of vertices in the model.
Definition at line 327 of file EmbreeTargetShape.cpp.
References _FILEINFO_, Isis::NaifStatus::CheckErrors(), Isis::FileName::expanded(), Isis::FileName::fileExists(), Isis::IException::Io, Isis::toString(), and Isis::IException::User.
Referenced by EmbreeTargetShape().
|
protected |
Read a PointCloudLibrary file into a PointCloudLibrary polygon mesh.
file | The PointCloudLibrary file to load. |
IException::Io |
Definition at line 437 of file EmbreeTargetShape.cpp.
References _FILEINFO_, Isis::FileName::expanded(), and Isis::IException::Io.
Referenced by EmbreeTargetShape().
RTCBounds Isis::EmbreeTargetShape::sceneBounds | ( | ) | const |
Returns the bounds of the Embree scene.
If the scene has not been initialized, then all bounds are returned as 0.0.
Definition at line 594 of file EmbreeTargetShape.cpp.
References isValid(), and m_scene.
Referenced by maximumSceneDistance().
|
private |
!< A boost shared pointer to the polygon mesh representation of the target.
Definition at line 219 of file EmbreeTargetShape.h.
Referenced by addVertices(), getHitInformation(), and initMesh().
|
private |
!< The point cloud representation of the target.
This is also stored in the polygon mesh, but cannot be accessed, so it is duplicated here.
Definition at line 224 of file EmbreeTargetShape.h.
Referenced by ~EmbreeTargetShape().
|
private |
!< The name of the target.
Definition at line 216 of file EmbreeTargetShape.h.
Referenced by addIndices(), getHitInformation(), initMesh(), isValid(), numberOfPolygons(), and numberOfVertices().
|
private |
!< The Embree device for rendering the scene.
Definition at line 226 of file EmbreeTargetShape.h.
Referenced by addIndices(), addVertices(), initMesh(), intersectRay(), isOccluded(), sceneBounds(), and ~EmbreeTargetShape().