8#include "EmbreeShapeModel.h" 
   16#include "IException.h" 
   20#include "NaifStatus.h" 
   22#include "ShapeModel.h" 
   66        m_targetManager(targetManager),
 
   96      QString msg = 
"Cannot create a EmbreeShape from " + 
m_shapeFile;
 
 
  113        m_targetManager(targetManager),
 
  114        m_tolerance(DBL_MAX),
 
  115        m_shapeFile(shapefile) {
 
  134      QString msg = 
"Cannot create a EmbreeShape from " + 
m_shapeFile;
 
 
  163                                          std::vector<double> lookDirection) {
 
  173    if (ray.lastHit < 0) {
 
 
  208                                          const std::vector<double> &observerPos,
 
  209                                          const bool &backCheck) {
 
  219    if ( ray.lastHit < 0 ) {
 
  227    QVector<RayHitInformation> hits = 
sortHits(ray, observer);
 
  231      for (
int i = 0 ; i < hits.size() ; i++) {
 
  237        obsRay.ray.org_x = observerPos[0];
 
  238        obsRay.ray.org_y = observerPos[1];
 
  239        obsRay.ray.org_z = observerPos[2];
 
  240        obsRay.ray.dir_x = lookVector[0];
 
  241        obsRay.ray.dir_y = lookVector[1];
 
  242        obsRay.ray.dir_z = lookVector[2];
 
  243        obsRay.ray.tnear = 0.0;
 
  245        obsRay.hit.instID[0] = RTC_INVALID_GEOMETRY_ID;
 
  246        obsRay.hit.geomID = RTC_INVALID_GEOMETRY_ID;
 
  247        obsRay.hit.primID = RTC_INVALID_GEOMETRY_ID;
 
  248        obsRay.ray.mask = 0xFFFFFFFF;
 
  249        obsRay.ignorePrimID = hits[i].primID;
 
 
  286                                          const std::vector<double> &observerPos,
 
  287                                          const bool &backCheck) {
 
  300    if ( ray.lastHit < 0 ) {
 
  310    surfpt.ToNaifArray( &surfPoint[0] );
 
  313    QVector< RayHitInformation > hits = 
sortHits(ray, surfPoint);
 
  317      for (
int i = 0 ; i < hits.size() ; i++) {
 
  323        obsRay.ray.org_x = observerPos[0];
 
  324        obsRay.ray.org_y = observerPos[1];
 
  325        obsRay.ray.org_z = observerPos[2];
 
  326        obsRay.ray.dir_x = lookVector[0];
 
  327        obsRay.ray.dir_y = lookVector[1];
 
  328        obsRay.ray.dir_z = lookVector[2];
 
  329        obsRay.ray.tnear = 0.0;
 
  331        obsRay.hit.instID[0] = RTC_INVALID_GEOMETRY_ID;
 
  332        obsRay.hit.geomID = RTC_INVALID_GEOMETRY_ID;
 
  333        obsRay.hit.primID = RTC_INVALID_GEOMETRY_ID;
 
  334        obsRay.ray.mask = 0xFFFFFFFF;
 
  335        obsRay.ignorePrimID = hits[i].primID; 
 
 
  365    std::vector<double> intersectArray(3);
 
  366    std::copy( hitInfo.intersection.data().begin(),
 
  367               hitInfo.intersection.data().end(),
 
  368               intersectArray.begin() );
 
  369    intersectPoint.FromNaifArray( &intersectArray[0] );
 
  374               hitInfo.surfaceNormal[1],
 
  375               hitInfo.surfaceNormal[2] );
 
 
  416    if ( ray.lastHit < 0 ) {
 
 
  451                                       const std::vector<double> lookDirection)  {
 
  459    if (ray.lastHit < 0) {
 
  467      std::vector<double> intersectVect(3);
 
 
  505      QString mess = 
"Intercept point does not exist - cannot provide normal vector";
 
 
  550       QString msg = 
"An intersection must be defined before computing the surface normal.";
 
  555       QString msg = 
"The surface point intersection must be valid to compute the surface normal.";
 
  560       QString msg = 
"A valid target must be defined before computing the surface normal.";
 
  569    QVector<double> norm(3);
 
  573    surfnm_c(radii[0].kilometers(), radii[1].kilometers(), radii[2].kilometers(),
 
 
  618    return ellipsoidEmission;
 
 
  642    double latAngle = lat.radians();
 
  643    double lonAngle = lon.radians();
 
  644    ray.ray.dir_x = cos(latAngle) * cos(lonAngle);
 
  645    ray.ray.dir_y = cos(latAngle) * sin(lonAngle);
 
  646    ray.ray.dir_z = sin(latAngle);
 
 
  671    ray.hit.instID[0] = RTC_INVALID_GEOMETRY_ID; 
 
  672    ray.hit.geomID = RTC_INVALID_GEOMETRY_ID;
 
  673    ray.hit.primID = RTC_INVALID_GEOMETRY_ID; 
 
  674    ray.ray.mask = 0xFFFFFFFF;
 
  678    std::vector<double> surfVect(3);
 
  679    surfpt.ToNaifArray( &surfVect[0] );
 
  686    ray.ray.dir_x = direction[0];
 
  687    ray.ray.dir_y = direction[1];
 
  688    ray.ray.dir_z = direction[2];
 
  691    ray.ray.tfar = surfpt.GetLocalRadius().kilometers();
 
 
  712    int hitCount = ray.lastHit + 1;
 
  715    QMap< double , RayHitInformation > hitsMap;
 
  716    for (
int i = 0 ; i < hitCount ; i++) {
 
 
Distance measurement, usually in meters.
 
@ Kilometers
The distance is being specified in kilometers.
 
EmbreeTargetManager * m_targetManager
!< The target body and Embree objects for intersection.
 
QVector< double > ellipsoidNormal()
Compute the true surface normal vector of an ellipsoid.
 
virtual bool isVisibleFrom(const std::vector< double > observerPos, const std::vector< double > lookDirection)
Check if the current internalized surface point is visible from an observer position and look directi...
 
RTCMultiHitRay pointToRay(const SurfacePoint &point) const
Given a surface point, create a ray that goes from the origin of the target to the surface point.
 
virtual bool intersectSurface(std::vector< double > observerPos, std::vector< double > lookDirection)
This method computes an intercept point given an observer location and look direction using the Embre...
 
virtual Distance localRadius(const Latitude &lat, const Longitude &lon)
Determine radius at a given lat/lon grid point.
 
virtual void calculateDefaultNormal()
Return the surface normal of the ellipsoid as the default.
 
virtual void clearSurfacePoint()
Flag that the ShapeModel does not have a surface point or normal.
 
void setTolerance(const double &tolerance)
Set the tolerance used when checking if the stored surface point is visible.
 
QString m_shapeFile
!< Tolerance for checking visibility.
 
virtual void calculateSurfaceNormal()
Return the surface normal of the ellipsoid.
 
RTCMultiHitRay latlonToRay(const Latitude &lat, const Longitude &lon) const
Given a latitude and longitude, create a ray that goes from the origin of the target through that lat...
 
virtual ~EmbreeShapeModel()
Destructor that notifies the target shape manager that the target shape is no longer in use.
 
void updateIntersection(const RayHitInformation hitInfo)
Update the ShapeModel given an intersection and normal.
 
double getTolerance() const
Get the tolerance used when checking if the stored surface point is visible.
 
double m_tolerance
!< This manages EmbreeTargetShapes to allow for sharing of them between EmbreeShapeModels and deletes...
 
virtual double incidenceAngle(const std::vector< double > &uB)
Computes and returns incidence angle, in degrees, given the illuminator position.
 
virtual bool isDEM() const
Indicates that this shape model is not from a DEM.
 
QVector< RayHitInformation > sortHits(RTCMultiHitRay &ray, LinearAlgebra::Vector &observer)
Sort all intersections by a ray based on distance to a point.
 
virtual void calculateLocalNormal(QVector< double * > cornerNeighborPoints)
Compute the normal for a local region of surface points.
 
EmbreeShapeModel()
Default constructor sets type to a TIN.
 
Class for managing the construction and destruction of EmbreeTargetShapes.
 
EmbreeTargetShape * create(const QString &shapeFile)
Get a pointer to an EmbreeTargetShape containing the information from a shape file.
 
void free(const QString &shapeFile)
Notify the manager that an EmbreeTargetShape is no longer in use.
 
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 intersect...
 
void intersectRay(RTCMultiHitRay &ray)
Intersect a ray with the target shape.
 
double maximumSceneDistance() const
Return the maximum distance within the scene.
 
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
 
@ Programmer
This error is for when a programmer made an API call that was illegal.
 
This class is designed to encapsulate the concept of a Latitude.
 
static Vector vector(double v0, double v1, double v2)
Constructs a 3 dimensional vector with the given component values.
 
static double magnitude(const Vector &vector)
Computes the magnitude (i.e., the length) of the given vector using the Euclidean norm (L2 norm).
 
boost::numeric::ublas::vector< double > Vector
Definition for an Isis::LinearAlgebra::Vector of doubles.
 
static Vector normalize(const Vector &vector)
Returns a unit vector that is codirectional with the given vector by dividing each component of the v...
 
This class is designed to encapsulate the concept of a Longitude.
 
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
 
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
 
Contains multiple PvlContainers.
 
Container for cube-like labels.
 
@ Traverse
Search child objects.
 
Define shapes and provide utilities for Isis targets.
 
virtual void clearSurfacePoint()
Clears or resets the current surface point.
 
void setHasNormal(bool status)
Sets the flag to indicate whether this ShapeModel has a surface normal.
 
bool hasIntersection()
Returns intersection status.
 
void setHasIntersection(bool b)
Sets the flag to indicate whether this ShapeModel has an intersection.
 
void setNormal(const std::vector< double >)
Sets the surface normal for the currect intersection point.
 
virtual SurfacePoint * surfaceIntersection() const
Returns the surface intersection for this ShapeModel.
 
bool hasValidTarget() const
Returns the status of the target.
 
virtual double incidenceAngle(const std::vector< double > &uB)
Computes and returns incidence angle, in degrees, given the illuminator position.
 
virtual void setSurfacePoint(const SurfacePoint &surfacePoint)
Set surface intersection point.
 
virtual std::vector< double > normal()
Returns the surface normal at the current intersection point.
 
virtual std::vector< double > localNormal()
Returns the local surface normal at the current intersection point.
 
std::vector< Distance > targetRadii() const
Returns the radii of the body in km.
 
void setHasLocalNormal(bool status)
Sets the flag to indicate whether this ShapeModel has a local normal.
 
bool hasNormal() const
Returns surface point normal status.
 
void setName(QString name)
Sets the shape name.
 
This class defines a body-fixed surface point.
 
This class is used to create and store valid Isis targets.
 
This is free and unencumbered software released into the public domain.
 
This is free and unencumbered software released into the public domain.
 
Namespace for the standard library.
 
Struct for capturing multiple intersections when using embree::rtcintersectscene.
 
int lastHit
Index of the last hit in the hit containers.
 
Struct for capturing occluded plates when using embree::rtcintersectscene.