Isis 3 Programmer Reference
BulletShapeModel.h
Go to the documentation of this file.
1 #ifndef BulletShapeModel_h
2 #define BulletShapeModel_h
3 
25 #include "ShapeModel.h"
26 
27 #include <vector>
28 
29 #include <QList>
30 #include <QMap>
31 
32 #include "Intercept.h"
35 #include "BulletTargetShape.h"
36 #include "BulletWorldManager.h"
37 #include "Target.h"
38 
39 namespace Isis {
40  class Target;
41 
51  class BulletShapeModel : public ShapeModel {
52  public:
53  // Constructors
55  BulletShapeModel(Target *target, Pvl &pvl);
56  BulletShapeModel(const QString &shapefile, Target *target, Pvl &pvl);
57  BulletShapeModel(BulletTargetShape *shape, Target *target, Pvl &pvl);
59 
60  // Destructor
62 
63  double getTolerance() const;
64  void setTolerance(const double &tolerance);
65 
66  // Intersect the shape model
67  bool intersectSurface(std::vector<double> observerPos,
68  std::vector<double> lookDirection);
69  virtual bool intersectSurface(const Latitude &lat, const Longitude &lon,
70  const std::vector<double> &observerPos,
71  const bool &checkOcclusion = true);
72  virtual bool intersectSurface(const SurfacePoint &surfpt,
73  const std::vector<double> &observerPos,
74  const bool &checkOcclusion = true);
75 
76  virtual void setSurfacePoint(const SurfacePoint &surfacePoint);
77  virtual void clearSurfacePoint();
78 
79  // Calculate the default normal of the current intersection point
81 
82  bool isDEM() const;
83 
84  // Calculate the surface normal of the current intersection point
86  void calculateLocalNormal(QVector<double *> cornerNeighborPoints);
88 
89  Distance localRadius(const Latitude &lat, const Longitude &lon);
90 
92 
93  const BulletWorldManager &model() const;
94 
95 
96  // Determine if the internal intercept is occluded from the observer/lookdir
97  virtual bool isVisibleFrom(const std::vector<double> observerPos,
98  const std::vector<double> lookDirection);
99 
100  private:
101  // Disallow copying because ShapeModel is not copyable
102  Q_DISABLE_COPY(BulletShapeModel)
103 
104  QScopedPointer<BulletWorldManager> m_model;
106  double m_tolerance;
110  btScalar maxDistance() const;
111 
112  btVector3 castLookDir(const btVector3 &observer, const btVector3 &lookdir) const;
113  btVector3 latlonToVector(const Latitude &lat, const Longitude &lon) const;
114  btVector3 pointToVector(const SurfacePoint &point) const;
115  SurfacePoint makeSurfacePoint(const btVector3 &point) const;
116 
118  const btVector3 &sortPoint) const;
119  bool isOccluded(const BulletClosestRayCallback &hit,
120  const btVector3 &observer) const;
121 
122  void updateShapeModel(const BulletClosestRayCallback &result);
123 
124 
125  };
126 }
127 
128 #endif
This class defines a body-fixed surface point.
Definition: SurfacePoint.h:148
btVector3 castLookDir(const btVector3 &observer, const btVector3 &lookdir) const
Compute the end point of a ray based on an observer and look direction.
QVector< double > ellipsoidNormal()
Compute the true surface normal vector of an ellipsoid.
void calculateDefaultNormal()
Calculate the surface normal of the ellipsoid as the default.
Bullet ray tracing callback to return all intersections along a ray&#39;s path.
Bullet World manager maintains a proper state for target bodies.
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.
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.
Definition: Latitude.h:63
double m_tolerance
! Bullet collision world that contains the representation of the body.
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.
Distance measurement, usually in meters.
Definition: Distance.h:47
double getTolerance() const
Returns the occlusion tolerance in kilometers.
This class is designed to encapsulate the concept of a Longitude.
Definition: Longitude.h:52
QVector< BulletClosestRayCallback > sortHits(const BulletAllHitsRayCallback &hits, const btVector3 &sortPoint) const
Sort the hits in an AllHitsRayCallback based on distance to a point.
virtual void setSurfacePoint(const SurfacePoint &surfacePoint)
Set the internal surface point.
void calculateSurfaceNormal()
compute the ellipsoid surface normal of the target
Bullet ray tracing callback for closest hit on target surface.
bool isOccluded(const BulletClosestRayCallback &hit, const btVector3 &observer) const
Check if an intersection is occluded from an observer.
Shape model that uses the Bullet library to perform ray tracing.
BulletShapeModel()
Default constructor that creates a shape model without any internal model.
Container for cube-like labels.
Definition: Pvl.h:135
This class is used to create and store valid Isis3 targets.
Definition: Target.h:76
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.
Definition: ShapeModel.h:78
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.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
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...
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.