Body.h
Go to the documentation of this file.00001 #ifndef SimTK_SIMBODY_BODY_H_
00002 #define SimTK_SIMBODY_BODY_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00040 #include "SimTKcommon.h"
00041 #include "simbody/internal/common.h"
00042 #include "simbody/internal/ContactSurface.h"
00043
00044 #include <cassert>
00045
00046 namespace SimTK {
00047
00048 class DecorativeGeometry;
00049
00050
00051
00052
00063 class SimTK_SIMBODY_EXPORT Body {
00064 public:
00066 Body() : rep(0) { }
00068 ~Body();
00071 Body(const Body& source);
00074 Body& operator=(const Body& source);
00075
00080 Body(const MassProperties& massProps);
00081
00086 Body& setDefaultRigidBodyMassProperties(const MassProperties&);
00090 const MassProperties& getDefaultRigidBodyMassProperties() const;
00091
00095 Body& addDecoration(const Transform& X_BD, const DecorativeGeometry&);
00096
00099 int getNumDecorations() const;
00100
00103 const DecorativeGeometry& getDecoration(int n) const;
00104
00107 DecorativeGeometry& updDecoration(int n);
00108
00111 Body& addContactSurface(const Transform& X_BS,
00112 const ContactSurface& shape);
00113
00116 int getNumContactSurfaces() const;
00119 const ContactSurface& getContactSurface(int n) const;
00122 const Transform& getContactSurfaceTransform(int n) const;
00126 ContactSurface& updContactSurface(int n);
00130 Transform& updContactSurfaceTransform(int n);
00131
00132
00133 class Ground;
00134 class Massless;
00135 class Particle;
00136 class Linear;
00137 class Rigid;
00138 class Deformable;
00139
00140 bool isOwnerHandle() const;
00141 bool isEmptyHandle() const;
00142
00143
00144 class BodyRep;
00145 explicit Body(class BodyRep* r) : rep(r) { }
00146 bool hasRep() const {return rep!=0;}
00147 const BodyRep& getRep() const {assert(rep); return *rep;}
00148 BodyRep& updRep() const {assert(rep); return *rep;}
00149 void setRep(BodyRep& r) {assert(!rep); rep = &r;}
00150
00151 protected:
00152 class BodyRep* rep;
00153 };
00154
00155
00156
00157
00158
00159
00162 class SimTK_SIMBODY_EXPORT Body::Rigid : public Body {
00163 public:
00166 Rigid();
00169 explicit Rigid(const MassProperties&);
00170
00171 Rigid& addDecoration(const Transform& X_BD, const DecorativeGeometry& g) {
00172 (void)Body::addDecoration(X_BD,g);
00173 return *this;
00174 }
00175 Rigid& setDefaultRigidBodyMassProperties(const MassProperties& m) {
00176 (void)Body::setDefaultRigidBodyMassProperties(m);
00177 return *this;
00178 }
00179
00180 class RigidRep;
00181 SimTK_PIMPL_DOWNCAST(Rigid, Body);
00182 private:
00183 RigidRep& updRep();
00184 const RigidRep& getRep() const;
00185 };
00186
00187
00188
00189
00190
00191
00192
00196 class SimTK_SIMBODY_EXPORT Body::Linear : public Body {
00197 public:
00198 Linear();
00199 explicit Linear(const MassProperties&);
00200
00201 Linear& addDecoration(const Transform& X_BD, const DecorativeGeometry& g) {
00202 (void)Body::addDecoration(X_BD,g);
00203 return *this;
00204 }
00205 Linear& setDefaultRigidBodyMassProperties(const MassProperties& m) {
00206 (void)Body::setDefaultRigidBodyMassProperties(m);
00207 return *this;
00208 }
00209
00210 class LinearRep;
00211 SimTK_PIMPL_DOWNCAST(Linear, Body);
00212 private:
00213 LinearRep& updRep();
00214 const LinearRep& getRep() const;
00215 };
00216
00217
00218
00219
00220
00221
00225 class SimTK_SIMBODY_EXPORT Body::Particle : public Body {
00226 public:
00227 Particle();
00228 explicit Particle(const Real& mass);
00229
00230 Particle& addDecoration(const Transform& X_BD, const DecorativeGeometry& g) {
00231 (void)Body::addDecoration(X_BD,g);
00232 return *this;
00233 }
00234 Particle& setDefaultRigidBodyMassProperties(const MassProperties& m) {
00235 (void)Body::setDefaultRigidBodyMassProperties(m);
00236 return *this;
00237 }
00238
00239 class ParticleRep;
00240 SimTK_PIMPL_DOWNCAST(Particle, Body);
00241 private:
00242 ParticleRep& updRep();
00243 const ParticleRep& getRep() const;
00244 };
00245
00246
00247
00248
00249
00250
00253 class SimTK_SIMBODY_EXPORT Body::Massless : public Body {
00254 public:
00255 Massless();
00256
00257 Massless& addDecoration(const Transform& X_BD, const DecorativeGeometry& g) {
00258 (void)Body::addDecoration(X_BD,g);
00259 return *this;
00260 }
00261
00262 class MasslessRep;
00263 SimTK_PIMPL_DOWNCAST(Massless, Body);
00264 private:
00265 MasslessRep& updRep();
00266 const MasslessRep& getRep() const;
00267 };
00268
00269
00270
00271
00272
00273
00276 class SimTK_SIMBODY_EXPORT Body::Ground : public Body {
00277 public:
00278 Ground();
00279
00280 Ground& addDecoration(const Transform& X_BD, const DecorativeGeometry& g) {
00281 (void)Body::addDecoration(X_BD,g);
00282 return *this;
00283 }
00284
00285 class GroundRep;
00286 SimTK_PIMPL_DOWNCAST(Ground, Body);
00287 private:
00288 GroundRep& updRep();
00289 const GroundRep& getRep() const;
00290 };
00291
00292 }
00293
00294 #endif // SimTK_SIMBODY_BODY_H_
00295
00296
00297