NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
tgModel Class Reference

#include <tgModel.h>

Inherits tgTaggable.

Inherited by BaseSpineModelLearning, BuildTestModel, ConnectorTestModel, ContactTestModel, FlemonsSpineModel, Hilbert2DModel, NestedStructureTestModel, NestedStructureTestModel, PrismModel, RBStringTest, SingleRibModel, SingleRibModel, StructureTestModel, T6Model, tgBaseString, and tgRod.

Collaboration diagram for tgModel:

Public Member Functions

 tgModel ()
 
 tgModel (const tgTags &tags)
 
 tgModel (std::string space_separated_tags)
 
virtual ~tgModel ()
 
virtual void setup (tgWorld &world)
 
virtual void teardown ()
 
virtual void step (double dt)
 
virtual void onVisit (const tgModelVisitor &r) const
 
void addChild (tgModel *pChild)
 
virtual std::string toString (std::string prefix="") const
 
template<typename T >
std::vector< T * > find (const tgTagSearch &tagSearch)
 
template<typename T >
std::vector< T * > find (const std::string &tagSearch)
 
std::vector< tgModel * > getDescendants () const
 
void addTags (const std::string &space_separated_tags)
 
void addTags (const tgTags &tags)
 
bool hasTag (const std::string tag) const
 
bool hasAllTags (std::string tags)
 
bool hasAnyTags (const std::string tags)
 
bool hasNoTags ()
 
tgTagsgetTags ()
 
const tgTagsgetTags () const
 
void setTags (tgTags tags)
 
std::string getTagStr (std::string delim=" ") const
 

Detailed Description

A root-level model is a Tensegrity. It can contain sub-models. The Composite design pattern is used for the sub-models.

Definition at line 44 of file tgModel.h.

Constructor & Destructor Documentation

tgModel::tgModel ( )

The default constructor. Primarily used within the tgCreator for compounded objects and subclasses of tgModel

Definition at line 32 of file tgModel.cpp.

tgModel::tgModel ( const tgTags tags)

Constructor for a model with tags, used within tgCreator for things that are already tagged

Parameters
[in]tgTags,tagsfor the tgTaggable parent class

Definition at line 38 of file tgModel.cpp.

tgModel::tgModel ( std::string  space_separated_tags)

Constructor for sace seperated tags

Parameters
[in]space_seperated_tags,tagsfor the tgTaggable parent class

Definition at line 44 of file tgModel.cpp.

tgModel::~tgModel ( )
virtual

Destructor. Deletes the children, if they weren't already deleted by teardown()

Definition at line 50 of file tgModel.cpp.

Member Function Documentation

void tgModel::addChild ( tgModel pChild)

Add a sub-model to this model. The model takes ownership of the child sub-model and is responsible for deallocating it.

Parameters
[in,out]pChilda pointer to a sub-model
Exceptions
std::invalid_argumentis pChild is NULL, this object, or already a descendant
Todo:
Make sure that every child appears no more than once in the tree.

Definition at line 126 of file tgModel.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T >
std::vector<T*> tgModel::find ( const tgTagSearch tagSearch)
inline

Get a vector of descendants sorted by type and a tagsearch. Useful for pulling out muscle groups, or similar.

Parameters
[in]tagSearch,atagSearch that contains the desired tags
Returns
a std::vector of pointers to members that match the tag search and typename T

Definition at line 129 of file tgModel.h.

Here is the call graph for this function:

template<typename T >
std::vector<T*> tgModel::find ( const std::string &  tagSearch)
inline

Get a vector of descendants sorted by type and a tagsearch. Useful for pulling out muscle groups, or similar.

Parameters
[in]tagSearch,astd::string& that contains the desired tags
Returns
a std::vector of pointers to members that match the tag search and typename T

Definition at line 142 of file tgModel.h.

Here is the call graph for this function:

std::vector< tgModel * > tgModel::getDescendants ( ) const

Return a std::vector of const pointers to all sub-models.

Todo:
examine whether this should be public, and perhaps create a read only version
Returns
a std::vector of const pointers all sub-models.
Todo:
Unnecessary copying can be avoided by pasing the result collection in the recursive step.

Definition at line 174 of file tgModel.cpp.

Here is the call graph for this function:

void tgModel::onVisit ( const tgModelVisitor r) const
virtual

Call tgModelVisitor::render() on self and all descendants.

Parameters
[in,out]ra reference to a tgModelVisitor

Reimplemented in ConnectorTestModel, BuildTestModel, tgLinearString, and tgRod.

Definition at line 109 of file tgModel.cpp.

Here is the call graph for this function:

void tgModel::setup ( tgWorld world)
virtual

Setup takes a tgWorld and passes it to any children for their own setup functions. All subclasses should call this at the appropriate time (usually end of setup) within their own setup function.

Parameters
[in]world- the tgWorld the models will exist in.

Reimplemented in tgBaseString, NestedStructureTestModel, tgRBString, tgLinearString, PrismModel, SingleRibModel, SingleRibModel, T6Model, Hilbert2DModel, RBStringTest, ContactTestModel, StructureTestModel, BaseSpineModelLearning, ConnectorTestModel, TetraSpineLearningModel, BuildTestModel, FlemonsSpineModelLearningCL, FlemonsSpineModelLearning, RibModel, and FlemonsSpineModel.

Definition at line 62 of file tgModel.cpp.

void tgModel::step ( double  dt)
virtual

Advance the simulation.

Parameters
[in]dtthe number of seconds since the previous call; std::invalid_argument is thrown if dt is not positive
Exceptions
std::invalid_argumentif dt is not positive
Note
This is not necessarily const for every child.

Reimplemented in NestedStructureTestModel, tgBaseString, ConnectorTestModel, BuildTestModel, ContactTestModel, StructureTestModel, tgLinearString, PrismModel, NestedStructureTestModel, tgRBString, T6Model, RBStringTest, BaseSpineModelLearning, TetraSpineLearningModel, FlemonsSpineModelLearningCL, FlemonsSpineModelLearning, RibModel, and FlemonsSpineModel.

Definition at line 86 of file tgModel.cpp.

Here is the call graph for this function:

void tgModel::teardown ( )
virtual
std::string tgModel::toString ( std::string  prefix = "") const
virtual

Returns the tag names of this model and its children

Parameters
[in]prefixa string to append to
Returns
the original string with this model and its children's tags appended

Definition at line 156 of file tgModel.cpp.

Here is the caller graph for this function:


The documentation for this class was generated from the following files: