AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agx::MergeSplitBodyStorage Class Reference

Book keeping of a body which can be merged with other bodies. More...

#include <MergeSplitBodyStorage.h>

+ Inheritance diagram for agx::MergeSplitBodyStorage:

Public Types

typedef agx::Vector
< agx::observer_ptr
< agxCollide::Geometry > > 
GeometryObserverVector
 

Public Member Functions

 MergeSplitBodyStorage ()
 Default constructor. More...
 
 MergeSplitBodyStorage (agx::RigidBody *body)
 Constructor which associates a body to this body storage. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
MergeSplitBodyStorage * getChild (size_t nth)
 
const MergeSplitBodyStorage * getChild (size_t nth) const
 
const char * getClassName () const override
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
const
agxCollide::GeometryRefVector & 
getGeometries () const
 
agx::UInt32 getIndex () const
 This index is given at creation of this object. More...
 
size_t getNumChildren () const
 
MergeSplitBodyStorage * getParent ()
 
const MergeSplitBodyStorage * getParent () const
 
int getReferenceCount () const
 
agx::RigidBody * getRigidBody ()
 
const agx::RigidBody * getRigidBody () const
 
agxStream::StorageAgent * getStorageAgent () const override
 
AffineMatrix4x4 getTransformRelativeParent () const
 
agx::Uuid getUuid () const
 
bool hasChild (MergeSplitBodyStorage *child) const
 
bool hasChildren () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
bool isFinished () const
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
virtual void restore (agxStream::InputArchive &in) override
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object. More...
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. More...
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object. More...
 
virtual void store (agxStream::OutputArchive &out) const override
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
bool validate () const
 

Static Public Member Functions

static void addMassProperties (MergeSplitBodyStorage *targetStorage, const MergeSplitBodyStorage *sourceStorage, Real sign)
 
static agxStream::Serializable * create ()
 
static agxStream::Serializable * create (agxStream::InputArchive &)
 
static const char * getConstructClassId ()
 
static void removeMassProperties (MergeSplitBodyStorage *targetStorage, const MergeSplitBodyStorage *sourceStorage, Real sign)
 
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. More...
 
static void setRebuildThreshold (size_t numChildren, size_t numUpdates)
 Set the threshold when the inertiatensor of a parent should be completely rebuilt. More...
 
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~MergeSplitBodyStorage ()
 
void addChild (MergeSplitBodyStorage *child)
 Add a storage as a child to this storage. More...
 
void addGeometry (agxCollide::Geometry *geom)
 
void allocateObserverVector () const
 
void calculateRelativeTransform (const MergeSplitBodyStorage *parentStorage)
 Calculate and store the transform relative the parent body. More...
 
void clear ()
 Reset this storage so its not associated to any body. More...
 
void deleteUsingDeleteHandler () const
 
void followGeometry ()
 Make the body follow the first geometry in the list of geometries. More...
 
void generateUuid ()
 
agx::Frame * getFrame ()
 
const agx::Frame * getFrame () const
 
agx::RigidBody::MotionControl getMotionControl () const
 
size_t getNumUpdates ()
 
void incrementNumUpdates ()
 
bool isMerged () const
 
bool removeChild (MergeSplitBodyStorage *child)
 Remove a storage so its no longer a child of this storage. More...
 
void resetNumUpdates ()
 
void restore (bool beingErased=false)
 Restore the associated body in that it will get back all its original geometries, motioncontrol etc. More...
 
void restoreMassProperties ()
 
void setMotionControl (agx::RigidBody::MotionControl m)
 
void setParent (MergeSplitBodyStorage *parent)
 Set the pointer to the parent body of this body. More...
 
void setRigidBody (agx::RigidBody *body)
 Associate this storage with the specified body. More...
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Book keeping of a body which can be merged with other bodies.

Keep track of its children, parent bodies, original geometries belonging to this body etc.

Definition at line 35 of file MergeSplitBodyStorage.h.

Member Typedef Documentation

Constructor & Destructor Documentation

agx::MergeSplitBodyStorage::MergeSplitBodyStorage ( )

Default constructor.

agx::MergeSplitBodyStorage::MergeSplitBodyStorage ( agx::RigidBody *  body)

Constructor which associates a body to this body storage.

virtual agx::MergeSplitBodyStorage::~MergeSplitBodyStorage ( )
protectedvirtual

Member Function Documentation

void agx::MergeSplitBodyStorage::addChild ( MergeSplitBodyStorage *  child)
protected

Add a storage as a child to this storage.

void agx::MergeSplitBodyStorage::addGeometry ( agxCollide::Geometry *  geom)
protected
static void agx::MergeSplitBodyStorage::addMassProperties ( MergeSplitBodyStorage *  targetStorage,
const MergeSplitBodyStorage *  sourceStorage,
Real  sign 
)
static
void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
void agx::MergeSplitBodyStorage::calculateRelativeTransform ( const MergeSplitBodyStorage *  parentStorage)
protected

Calculate and store the transform relative the parent body.

void agx::MergeSplitBodyStorage::clear ( )
protected

Reset this storage so its not associated to any body.

static agxStream::Serializable* agx::MergeSplitBodyStorage::create ( agxStream::InputArchive &  )
inlinestatic

Definition at line 53 of file MergeSplitBodyStorage.h.

static agxStream::Serializable* agx::MergeSplitBodyStorage::create ( )
inlinestatic

Definition at line 53 of file MergeSplitBodyStorage.h.

void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
void agx::MergeSplitBodyStorage::followGeometry ( )
protected

Make the body follow the first geometry in the list of geometries.

void agxStream::Serializable::generateUuid ( )
protectedinherited
MergeSplitBodyStorage* agx::MergeSplitBodyStorage::getChild ( size_t  nth)
Returns
a pointer to the nth child, nullptr if there are no children of this index.
const MergeSplitBodyStorage* agx::MergeSplitBodyStorage::getChild ( size_t  nth) const
Returns
a pointer to the nth child, nullptr if there are no children of this index.
const char* agx::MergeSplitBodyStorage::getClassName ( ) const
inlineoverridevirtual
Returns
the class name of this class.

Reimplemented from agxStream::Serializable.

Definition at line 53 of file MergeSplitBodyStorage.h.

static const char* agx::MergeSplitBodyStorage::getConstructClassId ( )
inlinestatic

Definition at line 53 of file MergeSplitBodyStorage.h.

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
bool agxStream::Serializable::getEnableSerialization ( ) const
inherited
Returns
true if serialization is enabled for this object

Definition at line 273 of file Serializable.h.

bool agxStream::Serializable::getEnableUuidGeneration ( )
inherited
Returns
true if Uuid:s should be generated for each new Serializable object
agx::Frame * agx::MergeSplitBodyStorage::getFrame ( )
inlineprotected
Returns
a pointer to this body storages frame

Definition at line 222 of file MergeSplitBodyStorage.h.

const agx::Frame * agx::MergeSplitBodyStorage::getFrame ( ) const
inlineprotected

Definition at line 227 of file MergeSplitBodyStorage.h.

const agxCollide::GeometryRefVector& agx::MergeSplitBodyStorage::getGeometries ( ) const
Returns
a const reference to the vector of geometries associated to this body storage.
agx::UInt32 agxStream::Serializable::getIndex ( ) const
inherited

This index is given at creation of this object.

It is guaranteed to be unique for the lifetime of this library instance. As long as the application is running. This value is not serialized or restored. A new object will always get a new index no matter how it is created.

Returns
an instance index of this object. This is unique for the lifetime of this library instance.

Definition at line 247 of file Serializable.h.

agx::RigidBody::MotionControl agx::MergeSplitBodyStorage::getMotionControl ( ) const
inlineprotected

Definition at line 232 of file MergeSplitBodyStorage.h.

size_t agx::MergeSplitBodyStorage::getNumChildren ( ) const
inline
Returns
the number of children this body storage has

Definition at line 217 of file MergeSplitBodyStorage.h.

References agx::SetVector< DataT, HashT >::size().

size_t agx::MergeSplitBodyStorage::getNumUpdates ( )
inlineprotected

Definition at line 207 of file MergeSplitBodyStorage.h.

MergeSplitBodyStorage * agx::MergeSplitBodyStorage::getParent ( )
inline
Returns
a pointer to a parent MergeSplitBodyStorage

Definition at line 212 of file MergeSplitBodyStorage.h.

const MergeSplitBodyStorage * agx::MergeSplitBodyStorage::getParent ( ) const
inline
Returns
a pointer to a parent MergeSplitBodyStorage

Definition at line 213 of file MergeSplitBodyStorage.h.

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
agx::RigidBody * agx::MergeSplitBodyStorage::getRigidBody ( )
inline
Returns
a pointer to the associated body

Definition at line 209 of file MergeSplitBodyStorage.h.

const agx::RigidBody * agx::MergeSplitBodyStorage::getRigidBody ( ) const
inline
Returns
a pointer to the associated body

Definition at line 210 of file MergeSplitBodyStorage.h.

agxStream::StorageAgent* agx::MergeSplitBodyStorage::getStorageAgent ( ) const
inlineoverridevirtual
Returns
the storage agent

Implements agxStream::Serializable.

Definition at line 53 of file MergeSplitBodyStorage.h.

AffineMatrix4x4 agx::MergeSplitBodyStorage::getTransformRelativeParent ( ) const
inline

Definition at line 215 of file MergeSplitBodyStorage.h.

agx::Uuid agxStream::Serializable::getUuid ( ) const
inherited
Returns
a unique id for this instance.

Definition at line 268 of file Serializable.h.

bool agx::MergeSplitBodyStorage::hasChild ( MergeSplitBodyStorage *  child) const
Returns
true if the specified storage is a child of this
bool agx::MergeSplitBodyStorage::hasChildren ( ) const
inline
Returns
true if this storage has children

Definition at line 237 of file MergeSplitBodyStorage.h.

References agx::SetVector< DataT, HashT >::size().

void agx::MergeSplitBodyStorage::incrementNumUpdates ( )
inlineprotected

Definition at line 203 of file MergeSplitBodyStorage.h.

template<typename T >
bool agx::Referenced::is ( ) const
inherited
bool agxStream::Serializable::isFinished ( ) const
inherited
Returns
true if this class is restored correctly and should not be deleted during destruction of an Archive.

Definition at line 252 of file Serializable.h.

bool agx::MergeSplitBodyStorage::isMerged ( ) const
inlineprotected
Returns
true if this body is merged into a superbody

Definition at line 201 of file MergeSplitBodyStorage.h.

void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

bool agx::MergeSplitBodyStorage::removeChild ( MergeSplitBodyStorage *  child)
protected

Remove a storage so its no longer a child of this storage.

static void agx::MergeSplitBodyStorage::removeMassProperties ( MergeSplitBodyStorage *  targetStorage,
const MergeSplitBodyStorage *  sourceStorage,
Real  sign 
)
static
void agx::MergeSplitBodyStorage::resetNumUpdates ( )
inlineprotected

Definition at line 205 of file MergeSplitBodyStorage.h.

virtual void agx::MergeSplitBodyStorage::restore ( agxStream::InputArchive &  in)
overridevirtual
void agx::MergeSplitBodyStorage::restore ( bool  beingErased = false)
protected

Restore the associated body in that it will get back all its original geometries, motioncontrol etc.

void agx::MergeSplitBodyStorage::restoreMassProperties ( )
protected
static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agxStream::Serializable::setEnableSerialization ( bool  flag)
inherited

Set to false to disable serialization of this object.

It will just be ignored during serialization (writing). It is still possible to restore TO this object.

static void agxStream::Serializable::setEnableUuidGeneration ( bool  flag)
staticinherited

Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.

void agxStream::Serializable::setFinished ( )
inherited

Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.

void agx::MergeSplitBodyStorage::setMotionControl ( agx::RigidBody::MotionControl  m)
protected
void agx::MergeSplitBodyStorage::setParent ( MergeSplitBodyStorage *  parent)
protected

Set the pointer to the parent body of this body.

static void agx::MergeSplitBodyStorage::setRebuildThreshold ( size_t  numChildren,
size_t  numUpdates 
)
static

Set the threshold when the inertiatensor of a parent should be completely rebuilt.

Parameters
numChildren- If a parent has less children than numChildren, rebuild the whole tensor
numUpdates- If a parent has been incrementally recalculated more than numUpdates, rebuild the whole tensor
void agx::MergeSplitBodyStorage::setRigidBody ( agx::RigidBody *  body)
protected

Associate this storage with the specified body.

Stores information about motioncontrol, associated geometries etc.

void agxStream::Serializable::setUuid ( const agx::Uuid &  uuid)
inherited

Explicitly set a Uuid on a serializable object.

Use this method with great care, as it can result in non-unique identifiers in the system!

virtual void agx::MergeSplitBodyStorage::store ( agxStream::OutputArchive &  out) const
overridevirtual
void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

bool agx::MergeSplitBodyStorage::validate ( ) const
template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.


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