|
Isis 3 Programmer Reference
|
Go to the documentation of this file.
25 #include "BulletShapeModel.h"
32 #include "IException.h"
33 #include "Intercept.h"
36 #include "Longitude.h"
37 #include "NaifStatus.h"
39 #include "ShapeModel.h"
40 #include "SpecialPixel.h"
41 #include "Statistics.h"
42 #include "SurfacePoint.h"
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 );
void calculateSurfaceNormal()
compute the ellipsoid surface normal of the target
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.
BulletShapeModel()
Default constructor that creates a shape model without any internal model.
btVector3 normal() const
Return the local surface normal at the intersection, if an intersection exists.
BulletClosestRayCallback m_intercept
! Tolerance of occlusion check in kilometers.
This class is designed to encapsulate the concept of a Latitude.
virtual void clearSurfacePoint()
Clear the saved surface point and reset the saved intersection.
~BulletShapeModel()
Destructor.
SurfacePoint * surfaceIntersection() const
Returns the surface intersection for this ShapeModel.
bool isOccluded(const BulletClosestRayCallback &hit, const btVector3 &observer) const
Check if an intersection is occluded from an observer.
void updateShapeModel(const BulletClosestRayCallback &result)
Update shape model - carefully!!
virtual void setSurfacePoint(const SurfacePoint &surfacePoint)
Set surface intersection point.
btVector3 pointToVector(const SurfacePoint &point) const
Convert a surface point into a vector.
Bullet ray tracing callback to return all intersections along a ray's path.
std::vector< Distance > targetRadii() const
Returns the radii of the body in km.
int size() const
Returns the number of intersections found.
void setLocalNormalFromIntercept()
Set the normal vector to the intercept point normal.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Container for cube-like labels.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
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 setNormal(const std::vector< double >)
Sets the normal for the currect intersection point.
Bullet World manager maintains a proper state for target bodies.
static BulletTargetShape * load(const QString &dem, const Pvl *conf=0)
Load a DEM file into the target shape.
btVector3 point() const
Return the intersection point, if one exists.
Distance measurement, usually in meters.
This class is designed to encapsulate the concept of a Longitude.
@ Traverse
Search child objects.
@ Kilometers
The distance is being specified in kilometers.
void setTolerance(const double &tolerance)
Sets the occlusion tolerance.
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.
const BulletWorldManager & model() const
Returns a direct reference to the Bullet world that contains the target shape and can perform ray cas...
void setName(QString name)
Sets the shape name.
Contains multiple PvlContainers.
void calculateLocalNormal(QVector< double * > cornerNeighborPoints)
Compute the normal for a local region of surface points.
const BulletClosestRayCallback & hit(const int &index=0) const
Return a callback for the intersection at a given index.
void calculateDefaultNormal()
Calculate the surface normal of the ellipsoid as the default.
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.
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.
Distance localRadius(const Latitude &lat, const Longitude &lon)
Compute the radius of the body at a lat/lon point.
bool isValid() const
Checks if the callback is valid/has a valid intersection.
bool isDEM() const
Indicates that this shape model is not from a DEM.
void setHasNormal(bool status)
Sets the flag to indicate whether this ShapeModel has a surface normal.
@ Programmer
This error is for when a programmer made an API call that was illegal.
Namespace for the standard library.
bool hasValidTarget() const
Returns the status of the target.
Define shapes and provide utilities for Isis targets.
SurfacePoint makeSurfacePoint(const btVector3 &point) const
Convert a vector into a surface point.
Bullet Target Shape for planetary bodies.
void ToNaifArray(double naifOutput[3]) const
A naif array is a c-style array of size 3.
btScalar distance() const
Returns the distance from the intersection point to the beginning of the ray.
This is free and unencumbered software released into the public domain.
bool isVisible(const BulletClosestRayCallback &other, const btScalar tolerance=DBL_MAX) const
Check if the intersection in this is visible based on another callback.
double m_tolerance
! Bullet collision world that contains the representation of the body.
bool hasIntersection()
Returns intersection status.
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.
This is free and unencumbered software released into the public domain.
QVector< BulletClosestRayCallback > sortHits(const BulletAllHitsRayCallback &hits, const btVector3 &sortPoint) const
Sort the hits in an AllHitsRayCallback based on distance to a point.
Bullet ray tracing callback for closest hit on target surface.
double getTolerance() const
Returns the occlusion tolerance in kilometers.
This class is used to create and store valid Isis targets.
const double RAD2DEG
Multiplier for converting from radians to degrees.
virtual void setSurfacePoint(const SurfacePoint &surfacePoint)
Set the internal surface point.
This class defines a body-fixed surface point.
This is free and unencumbered software released into the public domain.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
std::vector< double > normal()
Returns the local surface normal at the current intersection point.
double radians() const
Convert an angle to a double.