Simbody  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Body.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_BODY_H_
2 #define SimTK_SIMBODY_BODY_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm) *
6  * -------------------------------------------------------------------------- *
7  * This is part of the SimTK biosimulation toolkit originating from *
8  * Simbios, the NIH National Center for Physics-Based Simulation of *
9  * Biological Structures at Stanford, funded under the NIH Roadmap for *
10  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11  * *
12  * Portions copyright (c) 2007-13 Stanford University and the Authors. *
13  * Authors: Michael Sherman *
14  * Contributors: *
15  * *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
17  * not use this file except in compliance with the License. You may obtain a *
18  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19  * *
20  * Unless required by applicable law or agreed to in writing, software *
21  * distributed under the License is distributed on an "AS IS" BASIS, *
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23  * See the License for the specific language governing permissions and *
24  * limitations under the License. *
25  * -------------------------------------------------------------------------- */
26 
32 #include "SimTKcommon.h"
35 
36 #include <cassert>
37 
38 namespace SimTK {
39 
40 class DecorativeGeometry;
41 
42 //==============================================================================
43 // BODY
44 //==============================================================================
56 public:
58 Body() : rep(0) { }
60 ~Body();
63 Body(const Body& source);
66 Body& operator=(const Body& source);
67 
72 Body(const MassProperties& massProps);
73 
78 Body& setDefaultRigidBodyMassProperties(const MassProperties&);
79 
83 const MassProperties& getDefaultRigidBodyMassProperties() const;
84 
91 int addDecoration(const Transform& X_BD, const DecorativeGeometry& geometry);
92 
95 int addDecoration(const DecorativeGeometry& geometry)
96 { return addDecoration(Transform(), geometry); }
97 
101 int getNumDecorations() const;
102 
106 const DecorativeGeometry& getDecoration(int i) const;
107 
113 DecorativeGeometry& updDecoration(int i) const;
114 
120 int addContactSurface(const Transform& X_BS,
121  const ContactSurface& shape);
122 
126 { return addContactSurface(Transform(), shape); }
127 
130 int getNumContactSurfaces() const;
133 const ContactSurface& getContactSurface(int i) const;
136 const Transform& getContactSurfaceTransform(int i) const;
140 ContactSurface& updContactSurface(int i);
144 Transform& updContactSurfaceTransform(int i);
145 
146 // These are the built-in Body types.
147 class Ground; // infinitely massive
148 class Massless; // just a reference frame
149 class Particle; // point mass only; com=0; no inertia
150 class Linear; // point masses along a line; scalar inertia
151 class Rigid; // general rigid body
152 class Deformable; // base class for bodies with internal deformation coords
153 
154 bool isOwnerHandle() const;
155 bool isEmptyHandle() const;
156 
157 // Internal use only
158 class BodyRep; // local subclass
159 explicit Body(class BodyRep* r) : rep(r) { }
160 bool hasRep() const {return rep!=0;}
161 const BodyRep& getRep() const {assert(rep); return *rep;}
162 BodyRep& updRep() const {assert(rep); return *rep;}
163 void setRep(BodyRep& r) {assert(!rep); rep = &r;}
164 
165 protected:
166 class BodyRep* rep;
167 };
168 
169 
170 
171 //==============================================================================
172 // BODY::RIGID
173 //==============================================================================
177 public:
180  Rigid();
183  explicit Rigid(const MassProperties&);
184 
187  return *this;
188  }
189 
190  class RigidRep; // local subclass
192 private:
193  RigidRep& updRep();
194  const RigidRep& getRep() const;
195 };
196 
197 
198 
199 
200 //==============================================================================
201 // BODY::LINEAR
202 //==============================================================================
207 public:
208  Linear(); // default mass properties (1,Vec3(0),Inertia(1,1,0))
209  explicit Linear(const MassProperties&);
210 
213  return *this;
214  }
215 
216  class LinearRep; // local subclass
218 private:
219  LinearRep& updRep();
220  const LinearRep& getRep() const;
221 };
222 
223 
224 // Particles aren't yet supported, so hide this in Doxygen.
226 //==============================================================================
227 // BODY::PARTICLE
228 //==============================================================================
232 class SimTK_SIMBODY_EXPORT Body::Particle : public Body {
233 public:
234  Particle(); // default mass properties (1,Vec3(0),Inertia(0))
235  explicit Particle(const Real& mass);
236 
237  Particle& setDefaultRigidBodyMassProperties(const MassProperties& m) {
239  return *this;
240  }
241 
242  class ParticleRep; // local subclass
243  SimTK_PIMPL_DOWNCAST(Particle, Body);
244 private:
245  ParticleRep& updRep();
246  const ParticleRep& getRep() const;
247 };
252 //==============================================================================
253 // BODY::MASSLESS
254 //==============================================================================
258 public:
259  Massless();
260 
261  class MasslessRep; // local subclass
263 private:
264  MasslessRep& updRep();
265  const MasslessRep& getRep() const;
266 };
267 
268 
269 
270 //==============================================================================
271 // BODY::GROUND
272 //==============================================================================
276 public:
277  Ground();
278 
279  class GroundRep; // local subclass
281 private:
282  GroundRep& updRep();
283  const GroundRep& getRep() const;
284 };
285 
286 } // namespace SimTK
287 
288 #endif // SimTK_SIMBODY_BODY_H_
289 
290 
291 
#define SimTK_PIMPL_DOWNCAST(Derived, Parent)
Similar to the above but for private implementation abstract classes, that is, abstract class hierarc...
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:564
Declares ContactMaterial and ContactSurface classes.
Body()
Default constructor creates an empty Body handle.
Definition: Body.h:58
This is a Body representing something immobile, of effectively infinite mass and inertia, that cannot be modified to be anything else.
Definition: Body.h:275
The Body class represents a reference frame that can be used to describe mass properties and geometry...
Definition: Body.h:55
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
A general rigid body.
Definition: Body.h:176
const BodyRep & getRep() const
Definition: Body.h:161
Linear & setDefaultRigidBodyMassProperties(const MassProperties &m)
Definition: Body.h:211
Every Simbody header and source file should include this header before any other Simbody header...
SimTK_Real Real
This is the default compiled-in floating point type for SimTK, either float or double.
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:577
class BodyRep * rep
Definition: Body.h:166
Body(class BodyRep *r)
Definition: Body.h:159
Includes internal headers providing declarations for the basic SimTK Core classes, including Simmatrix.
int addContactSurface(const ContactSurface &shape)
Convenience method for when the contact surface is to be placed at the body frame.
Definition: Body.h:125
This is a Body that is constitutively massless (and inertialess); meaning that no amount of fiddling ...
Definition: Body.h:257
bool hasRep() const
Definition: Body.h:160
int addDecoration(const DecorativeGeometry &geometry)
Convenience method for when the decorative geometry is to be placed at the body frame.
Definition: Body.h:95
This class contains the mass, center of mass, and unit inertia matrix of a rigid body B...
Definition: MassProperties.h:85
This is a rigid body in the shape of a line, which is inherently inertialess about its axis...
Definition: Body.h:206
Body & setDefaultRigidBodyMassProperties(const MassProperties &)
Every type of Body should provide an initial set of rigid body mass properties defined at Topology st...
This is the client-side interface to an implementation-independent representation of "Decorations" su...
Definition: DecorativeGeometry.h:86
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:72
This class combines a piece of ContactGeometry with a ContactMaterial to make an object suitable for ...
Definition: ContactSurface.h:332
void setRep(BodyRep &r)
Definition: Body.h:163
Rigid & setDefaultRigidBodyMassProperties(const MassProperties &m)
Definition: Body.h:185
BodyRep & updRep() const
Definition: Body.h:162
Transform_< Real > Transform
Definition: Transform.h:44