8#include "EmbreeShapeModel.h"
16#include "IException.h"
20#include "NaifStatus.h"
22#include "ShapeModel.h"
96 QString msg =
"Cannot create a EmbreeShape from " +
m_shapeFile;
134 QString msg =
"Cannot create a EmbreeShape from " +
m_shapeFile;
163 std::vector<double> lookDirection) {
170 m_targetShape->intersectRay(ray);
208 const std::vector<double> &observerPos,
209 const bool &backCheck) {
216 m_targetShape->intersectRay(ray);
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;
253 if ( !m_targetShape->isOccluded(obsRay) ) {
286 const std::vector<double> &observerPos,
287 const bool &backCheck) {
297 m_targetShape->intersectRay(ray);
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;
339 if ( !m_targetShape->isOccluded(obsRay) ) {
365 std::vector<double> intersectArray(3);
368 intersectArray.begin() );
413 m_targetShape->intersectRay(ray);
451 const std::vector<double> lookDirection) {
456 m_targetShape->intersectRay(ray);
467 std::vector<double> intersectVect(3);
505 QString mess =
"Intercept point does not exist - cannot provide normal vector";
528 setNormal(std::vector<double>(norm.begin(), norm.end()));
551 QString msg =
"An intersection must be defined before computing the surface normal.";
556 QString msg =
"The surface point intersection must be valid to compute the surface normal.";
561 QString msg =
"A valid target must be defined before computing the surface normal.";
575 surfnm_c(radii[0].kilometers(), radii[1].kilometers(), radii[2].kilometers(),
620 return ellipsoidEmission;
644 double latAngle = lat.
radians();
645 double lonAngle = lon.
radians();
646 ray.ray.dir_x = cos(latAngle) * cos(lonAngle);
647 ray.ray.dir_y = cos(latAngle) * sin(lonAngle);
648 ray.ray.dir_z = sin(latAngle);
651 ray.ray.tfar = m_targetShape->maximumSceneDistance();
673 ray.hit.instID[0] = RTC_INVALID_GEOMETRY_ID;
674 ray.hit.geomID = RTC_INVALID_GEOMETRY_ID;
675 ray.hit.primID = RTC_INVALID_GEOMETRY_ID;
676 ray.ray.mask = 0xFFFFFFFF;
680 std::vector<double> surfVect(3);
688 ray.ray.dir_x = direction[0];
689 ray.ray.dir_y = direction[1];
690 ray.ray.dir_z = direction[2];
714 int hitCount = ray.
lastHit + 1;
718 for (
int i = 0 ; i < hitCount ; i++) {
double radians() const
Convert an angle to a double.
Distance measurement, usually in meters.
double kilometers() const
Get the distance in kilometers.
@ 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.
@ 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.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
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.
void setLocalNormal(const std::vector< double >)
Sets the local 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.
ShapeModel()
Default constructor creates ShapeModel object, initializing name to an empty string,...
bool hasNormal() const
Returns surface point normal status.
void setName(QString name)
Sets the shape name.
This class defines a body-fixed surface point.
void ToNaifArray(double naifOutput[3]) const
A naif array is a c-style array of size 3.
void FromNaifArray(const double naifValues[3])
A naif array is a c-style array of size 3.
Distance GetLocalRadius() const
Return the radius of the 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.
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.
unsigned ignorePrimID
IDs of the primitives (trinagles) which should be ignored.