Simbody 3.7
Loading...
Searching...
No Matches
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
38namespace SimTK {
39
40class DecorativeGeometry;
41
42//==============================================================================
43// BODY
44//==============================================================================
56public:
58Body() : rep(0) { }
63Body(const Body& source);
66Body& operator=(const Body& source);
67
72Body(const MassProperties& massProps);
73
79
84
93int addDecoration(const Transform& X_BD, const DecorativeGeometry& geometry);
94
98{ return addDecoration(Transform(), geometry); }
99
104
109
116
125 const ContactSurface& shape);
126
130{ return addContactSurface(Transform(), shape); }
131
149
150// These are the built-in Body types.
151class Ground; // infinitely massive
152class Massless; // just a reference frame
153class Particle; // point mass only; com=0; no inertia
154class Linear; // point masses along a line; scalar inertia
155class Rigid; // general rigid body
156class Deformable; // base class for bodies with internal deformation coords
157
158bool isOwnerHandle() const;
159bool isEmptyHandle() const;
160
161// Internal use only
162class BodyRep; // local subclass
163explicit Body(class BodyRep* r) : rep(r) { }
164bool hasRep() const {return rep!=0;}
165const BodyRep& getRep() const {assert(rep); return *rep;}
166BodyRep& updRep() const {assert(rep); return *rep;}
167void setRep(BodyRep& r) {assert(!rep); rep = &r;}
168
169protected:
170class BodyRep* rep;
171};
172
173
174
175//==============================================================================
176// BODY::RIGID
177//==============================================================================
181public:
187 explicit Rigid(const MassProperties&);
188
190 (void)Body::setDefaultRigidBodyMassProperties(m);
191 return *this;
192 }
193
194 class RigidRep; // local subclass
196private:
197 RigidRep& updRep();
198 const RigidRep& getRep() const;
199};
200
201
202
203
204//==============================================================================
205// BODY::LINEAR
206//==============================================================================
211public:
212 Linear(); // default mass properties (1,Vec3(0),Inertia(1,1,0))
213 explicit Linear(const MassProperties&);
214
216 (void)Body::setDefaultRigidBodyMassProperties(m);
217 return *this;
218 }
219
220 class LinearRep; // local subclass
222private:
223 LinearRep& updRep();
224 const LinearRep& getRep() const;
225};
226
227
228// Particles aren't yet supported, so hide this in Doxygen.
230//==============================================================================
231// BODY::PARTICLE
232//==============================================================================
236class SimTK_SIMBODY_EXPORT Body::Particle : public Body {
237public:
238 Particle(); // default mass properties (1,Vec3(0),Inertia(0))
239 explicit Particle(const Real& mass);
240
241 Particle& setDefaultRigidBodyMassProperties(const MassProperties& m) {
242 (void)Body::setDefaultRigidBodyMassProperties(m);
243 return *this;
244 }
245
246 class ParticleRep; // local subclass
247 SimTK_PIMPL_DOWNCAST(Particle, Body);
248private:
249 ParticleRep& updRep();
250 const ParticleRep& getRep() const;
251};
256//==============================================================================
257// BODY::MASSLESS
258//==============================================================================
262public:
264
265 class MasslessRep; // local subclass
267private:
268 MasslessRep& updRep();
269 const MasslessRep& getRep() const;
270};
271
272
273
274//==============================================================================
275// BODY::GROUND
276//==============================================================================
280public:
282
283 class GroundRep; // local subclass
285private:
286 GroundRep& updRep();
287 const GroundRep& getRep() const;
288};
289
290} // namespace SimTK
291
292#endif // SimTK_SIMBODY_BODY_H_
293
294
295
Declares ContactMaterial and ContactSurface classes.
#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:593
Includes internal headers providing declarations for the basic SimTK Core classes,...
Every Simbody header and source file should include this header before any other Simbody header.
#define SimTK_SIMBODY_EXPORT
Definition Simbody/include/simbody/internal/common.h:68
This is a Body representing something immobile, of effectively infinite mass and inertia,...
Definition Body.h:279
SimTK_PIMPL_DOWNCAST(Ground, Body)
This is a rigid body in the shape of a line, which is inherently inertialess about its axis.
Definition Body.h:210
Linear & setDefaultRigidBodyMassProperties(const MassProperties &m)
Definition Body.h:215
Linear(const MassProperties &)
SimTK_PIMPL_DOWNCAST(Linear, Body)
This is a Body that is constitutively massless (and inertialess); meaning that no amount of fiddling ...
Definition Body.h:261
SimTK_PIMPL_DOWNCAST(Massless, Body)
A general rigid body.
Definition Body.h:180
Rigid & setDefaultRigidBodyMassProperties(const MassProperties &m)
Definition Body.h:189
Rigid()
Construct a rigid body with default mass properties which are (1,Vec3(0),Inertia(1,...
SimTK_PIMPL_DOWNCAST(Rigid, Body)
Rigid(const MassProperties &)
Construct a rigid body with the given mass properties; any set of mass properties is allowed since th...
The Body class represents a reference frame that can be used to describe mass properties and geometry...
Definition Body.h:55
Body & operator=(const Body &source)
Copy assignment is a deep copy; the original object is deleted if this is the owner,...
Body(const MassProperties &massProps)
This is a default conversion from MassProperties to Body.
bool isOwnerHandle() const
int addContactSurface(const ContactSurface &shape)
Convenience method for when the contact surface is to be placed at the body frame.
Definition Body.h:129
Body(const Body &source)
Copy constructor is a deep copy; the new Body is separate from the source Body.
const BodyRep & getRep() const
Definition Body.h:165
Transform & updContactSurfaceTransform(int i)
Get a writable reference to the Transform specifying the placement of the i'th contact surface on thi...
int getNumContactSurfaces() const
Obtain the number of contact surfaces ns attached to this Body.
const Transform & getContactSurfaceTransform(int i) const
Get the Transform specifying the placement of the i'th contact surface on this Body.
Body & setDefaultRigidBodyMassProperties(const MassProperties &)
Every type of Body should provide an initial set of rigid body mass properties defined at Topology st...
void setRep(BodyRep &r)
Definition Body.h:167
const ContactSurface & getContactSurface(int i) const
Get a reference to the i'th contact surface on this body; be sure to get the Transform also.
int addDecoration(const Transform &X_BD, const DecorativeGeometry &geometry)
Add a piece of decorative geometry fixed at some pose on this Body.
Body(class BodyRep *r)
Definition Body.h:163
bool isEmptyHandle() const
ContactSurface & updContactSurface(int i)
Get write access to the i'th unique contact surface owned by this Body.
bool hasRep() const
Definition Body.h:164
const MassProperties & getDefaultRigidBodyMassProperties() const
Get the default (that is, Topology stage) mass properties for this Body.
int addContactSurface(const Transform &X_BS, const ContactSurface &shape)
Create a new ContactSurface on a body and place it using the indicated Transform.
int addDecoration(const DecorativeGeometry &geometry)
Convenience method for when the decorative geometry is to be placed at the body frame.
Definition Body.h:97
BodyRep & updRep() const
Definition Body.h:166
class BodyRep * rep
Definition Body.h:170
DecorativeGeometry & updDecoration(int i) const
Get a writable reference to the i'th piece of DecorativeGeometry that was added to this Body,...
~Body()
Destroy the handle and the body if this is the owner.
const DecorativeGeometry & getDecoration(int i) const
Get a read-only reference to the i'th piece of DecorativeGeometry that was added to this Body,...
Body()
Default constructor creates an empty Body handle.
Definition Body.h:58
int getNumDecorations() const
Obtain a count nd of how many pieces of DecorativeGeometry have been attached to this Body.
This class combines a piece of ContactGeometry with a ContactMaterial to make an object suitable for ...
Definition ContactSurface.h:342
This is the client-side interface to an implementation-independent representation of "Decorations" su...
Definition DecorativeGeometry.h:86
This class contains the mass, center of mass, and unit inertia matrix of a rigid body B.
Definition MassProperties.h:1363
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition Assembler.h:37
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:606