53 BulletShapeModel::BulletShapeModel() :
ShapeModel(), m_model(), m_tolerance(DBL_MAX),
54 m_intercept(btVector3(0,0,0), btVector3(0,0,0)) {
79 ShapeModel(target), m_model(), m_tolerance(DBL_MAX),
80 m_intercept(btVector3(0,0,0), btVector3(0,0,0)) {
96 shapefile = (QString) kernels[
"ElevationModel"];
99 shapefile = (QString) kernels[
"ShapeModel"];
103 if (v_shape.isNull() ) {
104 QString mess =
"Cannot create a BulletShape from " + shapefile;
111 m_model->addTarget( v_shape.take() );
125 ShapeModel(target), m_model(), m_tolerance(DBL_MAX),
126 m_intercept(btVector3(0,0,0), btVector3(0,0,0)) {
129 btAssert ( shape != 0 );
131 m_model->addTarget( shape );
146 ShapeModel(target), m_model(model), m_tolerance(DBL_MAX),
147 m_intercept(btVector3(0,0,0), btVector3(0,0,0)) {
194 std::vector<double> lookDirection) {
197 btVector3 observer(observerPos[0], observerPos[1], observerPos[2]);
198 btVector3 lookdir(lookDirection[0], lookDirection[1], lookDirection[2]);
201 bool success = m_model->raycast(observer, rayEnd, result);
225 const std::vector<double> &observerPos,
226 const bool &checkOcclusion) {
230 btVector3 origin(0.0, 0.0, 0.0);
236 if ( !m_model->raycast(origin, rayEnd, results) ) {
241 btVector3 observer(observerPos[0], observerPos[1], observerPos[2]);
245 if ( checkOcclusion ) {
246 for (
int i = 0 ; i < points.size() ; i++) {
288 const std::vector<double> &observerPos,
289 const bool &checkOcclusion) {
293 btVector3 origin(0.0, 0.0, 0.0);
295 btVector3 rayEnd =
castLookDir(origin, surfPointVec);
300 if ( !m_model->raycast(origin, rayEnd, results) ) {
308 if ( checkOcclusion ) {
309 btVector3 observer(observerPos[0], observerPos[1], observerPos[2]);
310 for (
int i = 0 ; i < points.size() ; i++) {
343 const btVector3 &observer)
const {
351 btVector3 psB = (observer - hit.
point()).normalized();
352 btScalar angle = std::acos( hit.
normal().dot( psB ) ) *
RAD2DEG;
353 if ( std::fabs( angle ) > 90.0 - DBL_MIN) {
360 if ( !m_model->raycast(observer, hit.
point(), results) ) {
380 std::vector<double> fakepos(3, 0.0);
414 btVector3 origin(0.0, 0.0, 0.0);
419 if ( m_model->raycast(origin, rayEnd, result) ) {
440 QString mess =
"Intercept point does not exist - cannot provide normal vector";
471 const std::vector<double> lookDirection) {
477 btVector3 observer(observerPos[0], observerPos[1], observerPos[2]);
480 if ( std::fabs( angle ) > 90.0 - DBL_MIN) {
484 btVector3 rayEnd =
castLookDir( observer, btVector3(lookDirection[0], lookDirection[1], lookDirection[2]) );
486 (void) m_model->raycast(observer, rayEnd, results);
520 QString mess =
"Intercept point does not exist - cannot provide normal vector";
563 QString msg =
"An intersection must be defined before computing the surface normal.";
568 QString msg =
"The surface point intersection must be valid to compute the surface normal.";
573 QString msg =
"A valid target must be defined before computing the surface normal.";
586 surfnm_c(radii[0].kilometers(), radii[1].kilometers(), radii[2].kilometers(),
611 return m_model->getTarget()->maximumDistance();
627 const btVector3 &lookdir)
const {
628 btScalar lookScale = observer.length() +
maxDistance();
629 return ( observer + lookdir.normalized() * lookScale );
645 double latAngle = lat.
radians();
646 double lonAngle = lon.
radians();
647 btVector3 lookDir( cos(latAngle) * cos(lonAngle),
648 cos(latAngle) * sin(lonAngle),
693 const btVector3 &sortPoint)
const {
695 for (
int i = 0 ; i < hits.
size() ; i++) {
697 sortMap.insert( hit.
distance(sortPoint), hit );
btScalar distance() const
Returns the distance from the intersection point to the beginning of the ray.
This class defines a body-fixed surface point.
std::vector< double > normal()
Returns the local surface normal at the current intersection point.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
btVector3 castLookDir(const btVector3 &observer, const btVector3 &lookdir) const
Compute the end point of a ray based on an observer and look direction.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
QVector< double > ellipsoidNormal()
Compute the true surface normal vector of an ellipsoid.
bool hasValidTarget() const
Returns the status of the target.
void calculateDefaultNormal()
Calculate the surface normal of the ellipsoid as the default.
Bullet ray tracing callback to return all intersections along a ray's path.
void setNormal(const std::vector< double >)
Sets the normal for the currect intersection point.
double radians() const
Convert an angle to a double.
Bullet World manager maintains a proper state for target bodies.
bool hasIntersection()
Returns intersection status.
Distance localRadius(const Latitude &lat, const Longitude &lon)
Compute the radius of the body at a lat/lon point.
bool isDEM() const
Indicates that this shape model is not from a DEM.
static BulletTargetShape * load(const QString &dem, const Pvl *conf=0)
Load a DEM file into the target shape.
Namespace for the standard library.
void calculateLocalNormal(QVector< double *> cornerNeighborPoints)
Compute the normal for a local region of surface points.
This class is designed to encapsulate the concept of a Latitude.
The distance is being specified in kilometers.
double m_tolerance
! Bullet collision world that contains the representation of the body.
SurfacePoint * surfaceIntersection() const
Returns the surface intersection for this ShapeModel.
bool intersectSurface(std::vector< double > observerPos, std::vector< double > lookDirection)
This method computes a DEM intercept point given an observer location and look direction using the Bu...
btScalar maxDistance() const
! The results of the last ray cast.
SurfacePoint makeSurfacePoint(const btVector3 &point) const
Convert a vector into a surface point.
This error is for when a programmer made an API call that was illegal.
Distance measurement, usually in meters.
double getTolerance() const
Returns the occlusion tolerance in kilometers.
btVector3 point() const
Return the intersection point, if one exists.
std::vector< Distance > targetRadii() const
Returns the radii of the body in km.
This class is designed to encapsulate the concept of a Longitude.
QVector< BulletClosestRayCallback > sortHits(const BulletAllHitsRayCallback &hits, const btVector3 &sortPoint) const
Sort the hits in an AllHitsRayCallback based on distance to a point.
btVector3 normal() const
Return the local surface normal at the intersection, if an intersection exists.
virtual void setSurfacePoint(const SurfacePoint &surfacePoint)
Set the internal surface point.
void calculateSurfaceNormal()
compute the ellipsoid surface normal of the target
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
Bullet ray tracing callback for closest hit on target surface.
A type of error that could only have occurred due to a mistake on the user's part (e...
~BulletShapeModel()
Destructor.
bool isOccluded(const BulletClosestRayCallback &hit, const btVector3 &observer) const
Check if an intersection is occluded from an observer.
BulletShapeModel()
Default constructor that creates a shape model without any internal model.
Container for cube-like labels.
virtual void clearSurfacePoint()
Clears or resets the current surface point.
This class is used to create and store valid Isis3 targets.
BulletClosestRayCallback m_intercept
! Tolerance of occlusion check in kilometers.
virtual void clearSurfacePoint()
Clear the saved surface point and reset the saved intersection.
Define shapes and provide utilities for Isis3 targets.
void updateShapeModel(const BulletClosestRayCallback &result)
Update shape model - carefully!!
void setLocalNormalFromIntercept()
Set the normal vector to the intercept point normal.
btVector3 pointToVector(const SurfacePoint &point) const
Convert a surface point into a vector.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
const BulletClosestRayCallback & hit(const int &index=0) const
Return a callback for the intersection at a given index.
void ToNaifArray(double naifOutput[3]) const
A naif array is a c-style array of size 3.
QString name() const
Return name of the target shape.
void FromNaifArray(const double naifValues[3])
A naif array is a c-style array of size 3.
virtual void setSurfacePoint(const SurfacePoint &surfacePoint)
Set surface intersection point.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
int size() const
Returns the number of intersections found.
bool isVisible(const BulletClosestRayCallback &other, const btScalar tolerance=DBL_MAX) const
Check if the intersection in this is visible based on another callback.
Namespace for ISIS/Bullet specific routines.
void setName(QString name)
Sets the shape name.
bool isValid() const
Checks if the callback is valid/has a valid intersection.
void setHasNormal(bool status)
Sets the flag to indicate whether this ShapeModel has a surface normal.
const double RAD2DEG
Multiplier for converting from radians to degrees.
btVector3 latlonToVector(const Latitude &lat, const Longitude &lon) const
Convert a pair of latitude and longitude values into a unit vector pointing from the origin of the bo...
void setTolerance(const double &tolerance)
Sets the occlusion tolerance.
Bullet Target Shape for planetary bodies.
const BulletWorldManager & model() const
Returns a direct reference to the Bullet world that contains the target shape and can perform ray cas...
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
virtual bool isVisibleFrom(const std::vector< double > observerPos, const std::vector< double > lookDirection)
Check if the saved intercept is visible from a observer with a given look direction.