Isis 3 Programmer Reference
BulletTargetShape.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include "BulletTargetShape.h"
9 #include "BulletDskShape.h"
10 
11 #include <iostream>
12 #include <iomanip>
13 #include <numeric>
14 #include <sstream>
15 
16 #include "FileName.h"
17 #include "IException.h"
18 #include "IString.h"
19 #include "Pvl.h"
20 
21 namespace Isis {
22 
29  : m_maximumDistance(0) { }
30 
31 
38  BulletTargetShape::BulletTargetShape(btCollisionObject *btbody, const QString &name) :
39  m_name(name), m_btbody(btbody) {
41  }
42 
43 
48 
49 
55  if (m_btbody) {
56  btVector3 center;
57  m_btbody->getCollisionShape()->getBoundingSphere(center, m_maximumDistance);
58  m_maximumDistance *= 2;
59  }
60  else {
62  }
63  }
64 
65 
71  QString BulletTargetShape::name() const {
72  return ( m_name );
73  }
74 
75 
84  BulletTargetShape *BulletTargetShape::load(const QString &dem, const Pvl *conf) {
85  FileName v_file(dem);
86 
87  QString ext = v_file.extension().toLower();
88 
89  if ( "bds" == ext) return ( loadDSK(dem) );
90  if ( "cub" == ext) return ( loadCube(dem) );
91  return ( loadPC(dem) );
92  }
93 
94 
105  BulletTargetShape *BulletTargetShape::loadPC(const QString &dem, const Pvl *conf) {
106  return (0);
107  }
108 
117  BulletTargetShape *BulletTargetShape::loadDSK(const QString &dem, const Pvl *conf) {
118  return ( new BulletDskShape(dem) );
119  }
120 
130  BulletTargetShape *BulletTargetShape::loadCube(const QString &dem, const Pvl *conf) {
131  return (0);
132  }
133 
141  void BulletTargetShape::writeBullet(const QString &btName) const {
142 
143  }
144 
150  btCollisionObject *BulletTargetShape::body() const {
151  return ( m_btbody.data() );
152  }
153 
154 
156  void BulletTargetShape::setTargetBody(btCollisionObject *body) {
157  m_btbody.reset(body);
158  m_btbody->setUserPointer(this);
160  return;
161  }
162 
163  btScalar BulletTargetShape::maximumDistance() const {
164  return m_maximumDistance;
165  }
166 
167 } // namespace Isis
Isis::BulletTargetShape::~BulletTargetShape
virtual ~BulletTargetShape()
Desctructor.
Definition: BulletTargetShape.cpp:47
Isis::BulletTargetShape::m_maximumDistance
btScalar m_maximumDistance
! The Bullet collision object for the body
Definition: BulletTargetShape.h:60
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::BulletTargetShape::writeBullet
void writeBullet(const QString &btName) const
Write a serialized version of the target shape to a Bullet file.
Definition: BulletTargetShape.cpp:141
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::BulletDskShape
Bullet Target Shape for NAIF type 2 DSK models.
Definition: BulletDskShape.h:26
Isis::BulletTargetShape::setMaximumDistance
void setMaximumDistance()
Calculate and save the maximum distance across the body.
Definition: BulletTargetShape.cpp:54
Isis::BulletTargetShape::load
static BulletTargetShape * load(const QString &dem, const Pvl *conf=0)
Load a DEM file into the target shape.
Definition: BulletTargetShape.cpp:84
Isis::BulletTargetShape::loadDSK
static BulletTargetShape * loadDSK(const QString &dem, const Pvl *conf=0)
Load a DSK in Bullet.
Definition: BulletTargetShape.cpp:117
Isis::BulletTargetShape::loadCube
static BulletTargetShape * loadCube(const QString &dem, const Pvl *conf=0)
Load an ISIS cube type DEM in Bullet.
Definition: BulletTargetShape.cpp:130
Isis::BulletTargetShape::setTargetBody
void setTargetBody(btCollisionObject *body)
Set the Bullet shape object to this object instance
Definition: BulletTargetShape.cpp:156
Isis::BulletTargetShape::m_btbody
QSharedPointer< btCollisionObject > m_btbody
! The name of the body
Definition: BulletTargetShape.h:58
Isis::BulletTargetShape::name
QString name() const
Return name of the target shape.
Definition: BulletTargetShape.cpp:71
Isis::FileName::extension
QString extension() const
Returns the last extension of the file name.
Definition: FileName.cpp:178
Isis::BulletTargetShape::BulletTargetShape
BulletTargetShape()
Default empty constructor.
Definition: BulletTargetShape.cpp:28
Isis::BulletTargetShape
Bullet Target Shape for planetary bodies.
Definition: BulletTargetShape.h:33
Isis::BulletTargetShape::loadPC
static BulletTargetShape * loadPC(const QString &dem, const Pvl *conf=0)
Load a point cloud type DEM in Bullet.
Definition: BulletTargetShape.cpp:105
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::BulletTargetShape::body
btCollisionObject * body() const
Return a pointer to the Bullet target object/shape.
Definition: BulletTargetShape.cpp:150