8#include "EmbreeShapeModel.h"
16#include "IException.h"
20#include "NaifStatus.h"
22#include "ShapeModel.h"
80 PvlGroup &kernels = pvl.findGroup(
"Kernels", Pvl::Traverse);
82 if (kernels.hasKeyword(
"ElevationModel")) {
95 catch(IException &e) {
96 QString msg =
"Cannot create a EmbreeShape from " +
m_shapeFile;
97 throw IException(e, IException::User, msg, _FILEINFO_);
133 catch(IException &e) {
134 QString msg =
"Cannot create a EmbreeShape from " +
m_shapeFile;
135 throw IException(e, IException::User, msg, _FILEINFO_);
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";
506 throw IException(IException::Programmer, mess, _FILEINFO_);
533 double latAngle = lat.
radians();
534 double lonAngle = lon.
radians();
535 ray.ray.dir_x = cos(latAngle) * cos(lonAngle);
536 ray.ray.dir_y = cos(latAngle) * sin(lonAngle);
537 ray.ray.dir_z = sin(latAngle);
540 ray.ray.tfar = m_targetShape->maximumSceneDistance();
562 ray.hit.instID[0] = RTC_INVALID_GEOMETRY_ID;
563 ray.hit.geomID = RTC_INVALID_GEOMETRY_ID;
564 ray.hit.primID = RTC_INVALID_GEOMETRY_ID;
565 ray.ray.mask = 0xFFFFFFFF;
569 std::vector<double> surfVect(3);
577 ray.ray.dir_x = direction[0];
578 ray.ray.dir_y = direction[1];
579 ray.ray.dir_z = direction[2];
603 int hitCount = ray.
lastHit + 1;
607 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.
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 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.
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 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.
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.
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 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.
virtual void setSurfacePoint(const SurfacePoint &surfacePoint)
Set surface intersection point.
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,...
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.
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.