Simbody
|
This is a concrete subsystem which can apply arbitrary forces to a MultibodySystem. More...
#include <GeneralForceSubsystem.h>
Public Member Functions | |
GeneralForceSubsystem () | |
GeneralForceSubsystem (MultibodySystem &) | |
ForceIndex | adoptForce (Force &force) |
Attach a new force to this subsystem. | |
int | getNumForces () const |
Get the number of force elements which have been added to this Subsystem. | |
const Force & | getForce (ForceIndex index) const |
Get a const reference to a force element by index. | |
Force & | updForce (ForceIndex index) |
Get a writable reference to a force element by index. | |
bool | isForceDisabled (const State &state, ForceIndex index) const |
Find out whether a particular force element contained in this subsystem is currently disabled in the given state. | |
void | setForceIsDisabled (State &state, ForceIndex index, bool shouldBeDisabled) const |
Disable or enable a particular force element contained in this subsystem. | |
const MultibodySystem & | getMultibodySystem () const |
Every Subsystem is owned by a System; a GeneralForceSubsystem expects to be owned by a MultibodySystem. |
This is a concrete subsystem which can apply arbitrary forces to a MultibodySystem.
Each force element is represented by a Force object. For example, to add a spring between two bodies, you would write
GeneralForceSubsystem forces(system); // ... Force::TwoPointLinearSpring(forces, body1, station1, body2, station2, k, x0);
SimTK::GeneralForceSubsystem::GeneralForceSubsystem | ( | ) |
SimTK::GeneralForceSubsystem::GeneralForceSubsystem | ( | MultibodySystem & | ) | [explicit] |
ForceIndex SimTK::GeneralForceSubsystem::adoptForce | ( | Force & | force | ) |
Attach a new force to this subsystem.
The subsystem takes over ownership of the force, leaving the passed in handle as a reference to it. This is normally called by the Force handle constructor.
force | A writable reference to a Force handle whose referenced force element is not yet owned by any subsystem. We will take over ownership of the ForceImpl implementation objected referenced by the handle, bumping the reference count and leaving the reference in place so that the original handle can continue to be used to reference and modify the force element. |
int SimTK::GeneralForceSubsystem::getNumForces | ( | ) | const |
Get the number of force elements which have been added to this Subsystem.
Legal ForceIndex values range from 0 to getNumForces()-1.
const Force& SimTK::GeneralForceSubsystem::getForce | ( | ForceIndex | index | ) | const |
Get a const reference to a force element by index.
Force& SimTK::GeneralForceSubsystem::updForce | ( | ForceIndex | index | ) |
Get a writable reference to a force element by index.
bool SimTK::GeneralForceSubsystem::isForceDisabled | ( | const State & | state, |
ForceIndex | index | ||
) | const |
Find out whether a particular force element contained in this subsystem is currently disabled in the given state.
void SimTK::GeneralForceSubsystem::setForceIsDisabled | ( | State & | state, |
ForceIndex | index, | ||
bool | shouldBeDisabled | ||
) | const |
Disable or enable a particular force element contained in this subsystem.
This can usually be done more conveniently through the Force handle's disable() and enable() methods. Note that although force elements are normally enabled when created, it is possible that the force element will have been constructed to be disabled by default in which case it must be explicitly enabled.
const MultibodySystem& SimTK::GeneralForceSubsystem::getMultibodySystem | ( | ) | const |
Every Subsystem is owned by a System; a GeneralForceSubsystem expects to be owned by a MultibodySystem.
This method returns a const reference to the containing MultibodySystem and will throw an exception if there is no containing System or it is not a MultibodySystem.