Isis 3 Programmer Reference
Isis::EmbreeTargetShape Class Reference

Embree Target Shape for planetary bodies. More...

#include <EmbreeTargetShape.h>

Collaboration diagram for Isis::EmbreeTargetShape:
Collaboration graph

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.
 
 EmbreeTargetShape (pcl::PolygonMesh::Ptr mesh, const QString &name="")
 Constructs an EmbreeTargetShape from a PointCloudLibrary polygon mesh.
 
 EmbreeTargetShape (const QString &dem, const Pvl *conf=0)
 Constructs an EmbreeTargetShape from a file.
 
virtual ~EmbreeTargetShape ()
 Desctructor.
 
QString name () const
 Return the name of the target shape.
 
bool isValid () const
 Return if a valid mesh is internalized and ready for use.
 
int numberOfPolygons () const
 Return the number of polygons in the target shape.
 
int numberOfVertices () const
 Return the number of vertices in the target shape.
 
RTCBounds sceneBounds () const
 Returns the bounds of the Embree scene.
 
double maximumSceneDistance () const
 Return the maximum distance within the scene.
 
void intersectRay (RTCMultiHitRay &ray)
 Intersect a ray with the target shape.
 
bool isOccluded (RTCOcclusionRay &ray)
 Check if a ray intersects the target body.
 
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.
 

Static Public Member Functions

static void multiHitFilter (const RTCFilterFunctionNArguments *args)
 Filter function for collecting multiple hits during ray intersection.
 
static void occlusionFilter (const RTCFilterFunctionNArguments *args)
 Filter function for collecting multiple primitiveIDs This function is called by the Embree library during ray tracing.
 

Protected Member Functions

pcl::PolygonMesh::Ptr readDSK (FileName file)
 Read a NAIF type 2 DSK file into a PointCloudLibrary polygon mesh.
 
pcl::PolygonMesh::Ptr readPC (FileName file)
 Read a PointCloudLibrary file into a PointCloudLibrary polygon mesh.
 
void initMesh (pcl::PolygonMesh::Ptr mesh)
 Internalize a PointCloudLibrary polygon mesh in the target shape.
 
void addVertices (int geomID)
 Adds the vertices from the internalized vertex point cloud to the Embree scene.
 
void addIndices (int geomID)
 Adds the polygon vertex indices from the internalized polygon mesh to the Embree scene.
 

Private Attributes

QString m_name
 
pcl::PolygonMesh::Ptr m_mesh
 !< The name of the target.
 
pcl::PointCloud< pcl::PointXYZ > m_cloud
 !< A boost shared pointer to the polygon mesh representation of the target.
 
RTCDevice m_device
 !< The point cloud representation of the target.
 
RTCScene m_scene
 !< The Embree device for rendering the scene.
 

Detailed Description

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.

Author
2017-05-11 Jeannie Backer & Jesse Mapel
History
2017-05-11 Jeannie Backer & Jesse Mapel - Original Version

Definition at line 139 of file EmbreeTargetShape.h.

Constructor & Destructor Documentation

◆ EmbreeTargetShape() [1/3]

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 225 of file EmbreeTargetShape.cpp.

References m_scene.

◆ EmbreeTargetShape() [2/3]

Isis::EmbreeTargetShape::EmbreeTargetShape ( pcl::PolygonMesh::Ptr mesh,
const QString & name = "" )

Constructs an EmbreeTargetShape from a PointCloudLibrary polygon mesh.

Parameters
meshThe polygon mesh to construct the scene from.
nameThe name of the target being represented.

Definition at line 242 of file EmbreeTargetShape.cpp.

References initMesh(), and m_scene.

◆ EmbreeTargetShape() [3/3]

Isis::EmbreeTargetShape::EmbreeTargetShape ( const QString & dem,
const Pvl * conf = 0 )

Constructs an EmbreeTargetShape from a file.

Parameters
demThe file to construct the target shape from. The file type is determined based on the file extension.
confPvl containing configuration settings for the target shape. Currently unused.
Exceptions
IException::Io

Definition at line 264 of file EmbreeTargetShape.cpp.

References initMesh(), Isis::IException::Io, m_scene, readDSK(), and readPC().

◆ ~EmbreeTargetShape()

Isis::EmbreeTargetShape::~EmbreeTargetShape ( )
virtual

Desctructor.

The PointCloudLibrary objects are automatically cleaned up, but the Embree scene and device must be manually cleaned up.

Definition at line 552 of file EmbreeTargetShape.cpp.

References m_device, and m_scene.

Member Function Documentation

◆ addIndices()

void Isis::EmbreeTargetShape::addIndices ( int geomID)
protected

Adds the polygon vertex indices from the internalized polygon mesh to the Embree scene.

Parameters
geomIDThe Embree geometry ID of the Embree geometry that the indices will be stored in.
See also
EmbreeTargetShape::initMesh

Definition at line 532 of file EmbreeTargetShape.cpp.

◆ addVertices()

void Isis::EmbreeTargetShape::addVertices ( int geomID)
protected

Adds the vertices from the internalized vertex point cloud to the Embree scene.

Parameters
geomIDThe Embree geometry ID of the Embree geometry that the vertices will be stored in.
See also
EmbreeTargetShape::initMesh

Definition at line 507 of file EmbreeTargetShape.cpp.

◆ getHitInformation()

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.

Parameters
rayThe ray to extract intersection information from.
hitIndexThe index of the intersection to extract.
Returns
RayHitInformation The body-fixed intersection coordinate in kilometers and the unit surface normal at the intersection.
Exceptions
IException::Programmer

Definition at line 708 of file EmbreeTargetShape.cpp.

References 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().

◆ initMesh()

void Isis::EmbreeTargetShape::initMesh ( pcl::PolygonMesh::Ptr mesh)
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.

Note
This method is NOT reentrant. Calling this again with a new mesh will remove the PointCloudLibrary representation of the old mesh but the Embree scene will contain all previous meshes along with the new mesh. Use embree::rtcDeleteGeometry to remove an old mesh from the scene.
Parameters
meshThe mesh to be internalized.

Definition at line 450 of file EmbreeTargetShape.cpp.

References isValid(), m_cloud, m_device, m_mesh, m_scene, multiHitFilter(), numberOfPolygons(), numberOfVertices(), occlusionFilter(), Isis::EmbreeTargetShape::Triangle::v0, Isis::EmbreeTargetShape::Vertex::x, Isis::EmbreeTargetShape::Vertex::y, and Isis::EmbreeTargetShape::Vertex::z.

Referenced by EmbreeTargetShape(), and EmbreeTargetShape().

◆ intersectRay()

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:

  • hitGeomIDs: The Embree Geometry ID of the intersected geometry
  • hitPrimIDs: The index of the intersected polygon
  • hitUs: The Barycentric u coordinate of the intersection relative to the intersected polygon
  • hitVs: The Barycentric V coordinate of the intersection relative to the intersected polygon

The index of the last intersection is stored in lastHit.

Note
The intersection information is stored in the order that Embree finds them. This is not necessarily their order along the ray. Only the first intersection is guaranteed to be in the correct order. Other intersections may be swapped with the next, or previous, intersection relative to their order along the ray.
Parameters
[in,out]rayThe ray to intersect with the scene. After calling, The intersection information will be stored in the ray.
See also
embree::rtcIntersect

Definition at line 658 of file EmbreeTargetShape.cpp.

References isValid(), and m_scene.

Referenced by Isis::EmbreeShapeModel::intersectSurface(), Isis::EmbreeShapeModel::intersectSurface(), Isis::EmbreeShapeModel::intersectSurface(), Isis::EmbreeShapeModel::isVisibleFrom(), and Isis::EmbreeShapeModel::localRadius().

◆ isOccluded()

bool Isis::EmbreeTargetShape::isOccluded ( RTCOcclusionRay & ray)

Check if a ray intersects the target body.

Returns
bool If the ray intersects anything.
See also
embree::rtcOccluded

Definition at line 675 of file EmbreeTargetShape.cpp.

References m_scene.

Referenced by Isis::EmbreeShapeModel::intersectSurface(), and Isis::EmbreeShapeModel::intersectSurface().

◆ isValid()

bool Isis::EmbreeTargetShape::isValid ( ) const

Return if a valid mesh is internalized and ready for use.

Returns
bool If a mesh is internalized and the Embree scene is ready.

Definition at line 765 of file EmbreeTargetShape.cpp.

References m_mesh.

Referenced by initMesh(), intersectRay(), numberOfPolygons(), numberOfVertices(), and sceneBounds().

◆ maximumSceneDistance()

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.

Returns
double The maximum distance within the Embree scene in kilometers.

Definition at line 619 of file EmbreeTargetShape.cpp.

References Isis::LinearAlgebra::magnitude(), and sceneBounds().

Referenced by Isis::EmbreeShapeModel::latlonToRay().

◆ multiHitFilter()

void Isis::EmbreeTargetShape::multiHitFilter ( const RTCFilterFunctionNArguments * args)
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.

Parameters
[in]userDataPtrData pointer from the geometry hit. Not used.
[in,out]rayThe ray being traced. Information about the intersection will be stored in the ray.

Definition at line 779 of file EmbreeTargetShape.cpp.

Referenced by initMesh().

◆ name()

QString Isis::EmbreeTargetShape::name ( ) const

Return the name of the target shape.

Returns
QString The name of the target.

Definition at line 755 of file EmbreeTargetShape.cpp.

◆ numberOfPolygons()

int Isis::EmbreeTargetShape::numberOfPolygons ( ) const

Return the number of polygons in the target shape.

Returns
int The number of polygons in the polygon mesh representation of the target.

Definition at line 564 of file EmbreeTargetShape.cpp.

References isValid(), and m_mesh.

Referenced by initMesh().

◆ numberOfVertices()

int Isis::EmbreeTargetShape::numberOfVertices ( ) const

Return the number of vertices in the target shape.

Returns
int The number of vertices in the polygon mesh representation of the target.

Definition at line 578 of file EmbreeTargetShape.cpp.

References isValid(), and m_mesh.

Referenced by initMesh().

◆ occlusionFilter()

void Isis::EmbreeTargetShape::occlusionFilter ( const RTCFilterFunctionNArguments * args)
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.

Parameters
[in]userDataPtrData pointer from the geometry hit. Not used.
[in,out]rayThe ray being traced. Information about the intersection will be stored in the ray.

Definition at line 818 of file EmbreeTargetShape.cpp.

Referenced by initMesh().

◆ readDSK()

pcl::PolygonMesh::Ptr Isis::EmbreeTargetShape::readDSK ( FileName file)
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.

Parameters
fileThe DSK file to load.
Returns
pcl::PolygonMesh::Ptr A boost shared pointer to the mesh.
Exceptions
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 311 of file EmbreeTargetShape.cpp.

References Isis::NaifStatus::CheckErrors(), Isis::IException::Io, Isis::toString(), and Isis::IException::User.

Referenced by EmbreeTargetShape().

◆ readPC()

pcl::PolygonMesh::Ptr Isis::EmbreeTargetShape::readPC ( FileName file)
protected

Read a PointCloudLibrary file into a PointCloudLibrary polygon mesh.

Parameters
fileThe PointCloudLibrary file to load.
Returns
pcl::PolygonMesh::Ptr A boost shared pointer to the mesh.
Exceptions
IException::Io

Definition at line 421 of file EmbreeTargetShape.cpp.

References Isis::IException::Io.

Referenced by EmbreeTargetShape().

◆ sceneBounds()

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.

Returns
RTCBounds Struct containing the upper and lower bounds on each dimension of the scene. Bounds are stored as floats in lower_x, upper_x, lower_y, upper_y, lower_z, and upper_z.

Definition at line 596 of file EmbreeTargetShape.cpp.

References isValid(), m_scene, and sceneBounds().

Referenced by maximumSceneDistance(), and sceneBounds().

Member Data Documentation

◆ m_cloud

pcl::PointCloud<pcl::PointXYZ> Isis::EmbreeTargetShape::m_cloud
private

!< A boost shared pointer to the polygon mesh representation of the target.

Definition at line 203 of file EmbreeTargetShape.h.

Referenced by getHitInformation(), and initMesh().

◆ m_device

RTCDevice Isis::EmbreeTargetShape::m_device
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 208 of file EmbreeTargetShape.h.

Referenced by initMesh(), and ~EmbreeTargetShape().

◆ m_mesh

pcl::PolygonMesh::Ptr Isis::EmbreeTargetShape::m_mesh
private

!< The name of the target.

Definition at line 200 of file EmbreeTargetShape.h.

Referenced by getHitInformation(), initMesh(), isValid(), numberOfPolygons(), and numberOfVertices().

◆ m_name

QString Isis::EmbreeTargetShape::m_name
private

Definition at line 199 of file EmbreeTargetShape.h.

◆ m_scene

RTCScene Isis::EmbreeTargetShape::m_scene
private

!< The Embree device for rendering the scene.

Definition at line 210 of file EmbreeTargetShape.h.

Referenced by EmbreeTargetShape(), EmbreeTargetShape(), EmbreeTargetShape(), initMesh(), intersectRay(), isOccluded(), sceneBounds(), and ~EmbreeTargetShape().


The documentation for this class was generated from the following files: