AGXDynamics  2.31.1.0
agx::RigidBodyAttachment Class Reference

Constraint attachment class for agx::RigidBody. More...

#include <Attachment.h>

+ Inheritance diagram for agx::RigidBodyAttachment:

Public Types

enum  Transformed {
  U, V, N, ANCHOR_POS,
  CM_TO_ANCHOR_POS, NUM_ELEMENTS
}
 Data access enum. More...
 

Public Member Functions

 RigidBodyAttachment (agx::RigidBody *rb, agx::Frame *relFrame)
 Construct given rigid body and relative frame. More...
 
template<typename T >
T * as ()
 Unsafe version, static cast of this to T. More...
 
template<typename T >
const T * as () const
 Unsafe version, static cast of this to T. More...
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
virtual agx::Real calculateAngularSpeed (const agx::Attachment *other) const override
 
virtual agx::Real calculateDistance (const agx::Attachment *other) const override
 
virtual agx::Real calculateLinearDistance (const agx::Attachment *other) const override
 
virtual agx::Real calculateLinearSpeed (const agx::Attachment *other) const override
 
const agx::Vec3 & get (agx::Attachment::Transformed entry) const
 
virtual agx::Vec3 getAngularVelocity () const override
 
const char * getClassName () const override
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::Frame * getFrame () const
 
agx::UInt32 getIndex () const
 This index is given at creation of this object. More...
 
virtual agx::Vec3 getLinearVelocity () const override
 
agx::Vec3 getLocal (agx::Attachment::Transformed entry) const
 
int getReferenceCount () const
 
agx::RigidBody * getRigidBody () const
 
agxStream::StorageAgent * getStorageAgent () const override
 
agx::Uuid getUuid () const
 
template<typename T >
agx::Bool is () const
 
template<typename T >
Bool is () const
 
template<>
Bool is () const
 
bool isFinished () const
 
virtual agx::Bool objectDeleted () const override
 
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
 
template<typename T >
T * safeAs ()
 Dynamic cast of this to T. More...
 
template<typename T >
const T * safeAs () const
 Dynamic cast of this to T. More...
 
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 setFrame (agx::Frame *frame)
 Assign a new frame - transformed data will be updated. More...
 
void setRigidBody (agx::RigidBody *rb)
 Assign rigid body to this constraint frame. More...
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object. More...
 
virtual void store (agxStream::OutputArchive &out) const override
 
virtual void transform () override
 Transform given rigid body and frame. More...
 
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...
 
virtual agx::Bool valid () const override
 

Static Public Member Functions

static agxStream::Serializable * create ()
 
static agxStream::Serializable * create (agxStream::InputArchive &)
 
static void createAttachmentBase (const agx::Vec3d &N, agx::Vec3d &U, agx::Vec3d &V)
 Given vector N, create orthonormal base. More...
 
static void createAttachmentBase (const agx::Vec3f &N, agx::Vec3f &U, agx::Vec3f &V)
 
static const char * getConstructClassId ()
 
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. More...
 
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

 RigidBodyAttachment ()
 Protected default constructor used by restore. More...
 
virtual ~RigidBodyAttachment ()
 Reference counted object, protected destructor. More...
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
void generateUuid ()
 
void transform (const agx::AffineMatrix4x4 &cmTransform, const agx::Vec3 &cmToModel, const agx::AffineMatrix4x4 &localConstraintTransform)
 Fill Transformed data given center of mass transform and offset from model frame to center of mass frame (assumes not rotated relative each other). 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

agx::Bool m_hadValidRb
 
Mutex m_mutex
 
ObserverContainer m_observers
 
agx::RigidBodyObserver m_rb
 
AtomicValue m_refCount
 
agx::FrameRef m_relFrame
 
agx::Vec3 m_transformed [NUM_ELEMENTS]
 

Detailed Description

Constraint attachment class for agx::RigidBody.

Definition at line 207 of file Attachment.h.

Member Enumeration Documentation

◆ Transformed

Data access enum.

Enumerator
U 

Constraint attachment x-axis.

V 

Constraint attachment y-axis.

N 

Constraint attachment z-axis.

ANCHOR_POS 

Constraint attachment world position.

CM_TO_ANCHOR_POS 

Vector from center of mass (if moving) to anchor point given in world frame.

NUM_ELEMENTS 

Number of data elements.

Definition at line 42 of file Attachment.h.

Constructor & Destructor Documentation

◆ RigidBodyAttachment() [1/2]

agx::RigidBodyAttachment::RigidBodyAttachment ( agx::RigidBody *  rb,
agx::Frame *  relFrame 
)

Construct given rigid body and relative frame.

Parameters
rb- rigid body (0 if e.g., world frame or other type of static frame)
relFrame- constraint attachment frame relative rb model frame

◆ RigidBodyAttachment() [2/2]

agx::RigidBodyAttachment::RigidBodyAttachment ( )
protected

Protected default constructor used by restore.

◆ ~RigidBodyAttachment()

virtual agx::RigidBodyAttachment::~RigidBodyAttachment ( )
protectedvirtual

Reference counted object, protected destructor.

Member Function Documentation

◆ allocateObserverVector()

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited

◆ as() [1/2]

template<typename T >
T * agx::Attachment::as ( )
inherited

Unsafe version, static cast of this to T.

See also
safeAs
Returns
this attachment as subclass using static cast

Definition at line 486 of file Attachment.h.

References agxAssert.

◆ as() [2/2]

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

Unsafe version, static cast of this to T.

See also
safeAs
Returns
this attachment as subclass using static cast

Definition at line 505 of file Attachment.h.

References agxAssert.

◆ asSafe() [1/2]

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

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

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

◆ asSafe() [2/2]

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

◆ calculateAngularSpeed()

virtual agx::Real agx::RigidBodyAttachment::calculateAngularSpeed ( const agx::Attachment *  other) const
overridevirtual
Returns
relative speed about world z-axis of this attachment

Reimplemented from agx::Attachment.

◆ calculateDistance()

virtual agx::Real agx::RigidBodyAttachment::calculateDistance ( const agx::Attachment *  other) const
overridevirtual
Returns
the distance between this and the other attachment
See also
calculateLinearDistance

Reimplemented from agx::Attachment.

◆ calculateLinearDistance()

virtual agx::Real agx::RigidBodyAttachment::calculateLinearDistance ( const agx::Attachment *  other) const
overridevirtual
Returns
the projected (along this attachments world z-axis) distance between this and the other attachment

Reimplemented from agx::Attachment.

◆ calculateLinearSpeed()

virtual agx::Real agx::RigidBodyAttachment::calculateLinearSpeed ( const agx::Attachment *  other) const
overridevirtual
Returns
relative speed along world z-axis of this attachment

Reimplemented from agx::Attachment.

◆ create() [1/2]

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

Definition at line 275 of file Attachment.h.

◆ create() [2/2]

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

Definition at line 275 of file Attachment.h.

◆ createAttachmentBase() [1/2]

static void agx::Attachment::createAttachmentBase ( const agx::Vec3d &  N,
agx::Vec3d &  U,
agx::Vec3d &  V 
)
staticinherited

Given vector N, create orthonormal base.

Parameters
N- in vector (a.k.a. z axis)
U- out vector (a.k.a. x axis)
V- out vector (a.k.a. y axis)

Referenced by agx::OrientedFrictionModelImpl< agx::ScaleBoxFrictionModel >::calculateTangentPlane().

◆ createAttachmentBase() [2/2]

static void agx::Attachment::createAttachmentBase ( const agx::Vec3f &  N,
agx::Vec3f &  U,
agx::Vec3f &  V 
)
staticinherited

◆ deleteUsingDeleteHandler()

void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited

◆ generateUuid()

void agxStream::Serializable::generateUuid ( )
protectedinherited

◆ get()

const Vec3 & agx::Attachment::get ( agx::Attachment::Transformed  entry) const
inherited
Returns
the transformed data

Definition at line 463 of file Attachment.h.

◆ getAngularVelocity()

virtual agx::Vec3 agx::RigidBodyAttachment::getAngularVelocity ( ) const
overridevirtual
Returns
linear velocity of this attachment given in world frame

Reimplemented from agx::Attachment.

◆ getClassName()

const char* agx::RigidBodyAttachment::getClassName ( ) const
inlineoverridevirtual
Returns
the class name of this class.

Reimplemented from agx::Attachment.

Definition at line 275 of file Attachment.h.

◆ getConstructClassId()

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

Definition at line 275 of file Attachment.h.

◆ getDeleteHandler()

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.

◆ getEnableSerialization()

bool agxStream::Serializable::getEnableSerialization ( ) const
inherited
Returns
true if serialization is enabled for this object

Definition at line 273 of file Serializable.h.

◆ getEnableUuidGeneration()

bool agxStream::Serializable::getEnableUuidGeneration ( )
inherited
Returns
true if Uuid:s should be generated for each new Serializable object

◆ getFrame()

Frame * agx::Attachment::getFrame ( ) const
inherited
Returns
the frame

Definition at line 468 of file Attachment.h.

◆ getIndex()

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.

◆ getLinearVelocity()

virtual agx::Vec3 agx::RigidBodyAttachment::getLinearVelocity ( ) const
overridevirtual
Returns
linear velocity of this attachment given in world frame

Reimplemented from agx::Attachment.

◆ getLocal()

agx::Vec3 agx::Attachment::getLocal ( agx::Attachment::Transformed  entry) const
inherited
Returns
the local data

◆ getReferenceCount()

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.

◆ getRigidBody()

RigidBody * agx::RigidBodyAttachment::getRigidBody ( ) const
Returns
the rigid body

Definition at line 522 of file Attachment.h.

◆ getStorageAgent()

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

Reimplemented from agx::Attachment.

Definition at line 275 of file Attachment.h.

◆ getUuid()

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

Definition at line 268 of file Serializable.h.

Referenced by agxSDK::UuidHashCollisionFilter::match().

◆ is() [1/3]

template<typename T >
agx::Bool agx::Attachment::is ( ) const
inherited
Returns
true if this object is of type T

◆ is() [2/3]

template<typename T >
Bool agx::Attachment::is ( ) const
inherited

Definition at line 474 of file Attachment.h.

◆ is() [3/3]

template<>
Bool agx::Attachment::is ( ) const
inherited

Definition at line 480 of file Attachment.h.

◆ isFinished()

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.

References AGX_FORCE_INLINE.

◆ objectDeleted()

virtual agx::Bool agx::RigidBodyAttachment::objectDeleted ( ) const
overridevirtual
Returns
true if the rigid body or the frame has been deleted

Reimplemented from agx::Attachment.

◆ reference()

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.

◆ restore()

virtual void agx::RigidBodyAttachment::restore ( agxStream::InputArchive &  in)
overridevirtual

Reimplemented from agx::Attachment.

◆ safeAs() [1/2]

template<typename T >
T * agx::Attachment::safeAs ( )
inherited

Dynamic cast of this to T.

Returns
this attachment as subclass using dynamic cast

Definition at line 499 of file Attachment.h.

◆ safeAs() [2/2]

template<typename T >
const T * agx::Attachment::safeAs ( ) const
inherited

Dynamic cast of this to T.

Returns
this attachment as subclass using dynamic cast

Definition at line 517 of file Attachment.h.

◆ setDeleteHandler()

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

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

◆ setEnableSerialization()

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.

◆ setEnableUuidGeneration()

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.

◆ setFinished()

void agxStream::Serializable::setFinished ( )
inherited

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

◆ setFrame()

void agx::Attachment::setFrame ( agx::Frame *  frame)
inherited

Assign a new frame - transformed data will be updated.

Parameters
frame- new frame

◆ setRigidBody()

void agx::RigidBodyAttachment::setRigidBody ( agx::RigidBody *  rb)

Assign rigid body to this constraint frame.

Note
The actual constraint will not know about this change unless it's handled explicitly.
Parameters
rb- new rigid body

◆ setUuid()

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!

◆ store()

virtual void agx::RigidBodyAttachment::store ( agxStream::OutputArchive &  out) const
overridevirtual

Reimplemented from agx::Attachment.

◆ transform() [1/2]

void agx::Attachment::transform ( const agx::AffineMatrix4x4 &  cmTransform,
const agx::Vec3 &  cmToModel,
const agx::AffineMatrix4x4 &  localConstraintTransform 
)
protectedinherited

Fill Transformed data given center of mass transform and offset from model frame to center of mass frame (assumes not rotated relative each other).

Parameters
cmTransform- world transform of the center of mass frame
cmToModel- in local coordinates, vector from center of mass frame to model frame
localConstraintTransform- transform of the local constraint frame

◆ transform() [2/2]

virtual void agx::RigidBodyAttachment::transform ( )
overridevirtual

Transform given rigid body and frame.

Reimplemented from agx::Attachment.

◆ unreference()

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.

Referenced by agxData::EntityRef< ContactMaterialPtr >::~EntityRef().

◆ unreference_nodelete()

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.

◆ valid()

virtual agx::Bool agx::RigidBodyAttachment::valid ( ) const
overridevirtual
Returns
true if the current configuration is valid

Reimplemented from agx::Attachment.

◆ ValidateCast()

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

Member Data Documentation

◆ m_hadValidRb

agx::Bool agx::RigidBodyAttachment::m_hadValidRb
protected

Definition at line 290 of file Attachment.h.

◆ m_mutex

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

◆ m_observers

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

◆ m_rb

agx::RigidBodyObserver agx::RigidBodyAttachment::m_rb
protected

Definition at line 289 of file Attachment.h.

◆ m_refCount

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

◆ m_relFrame

agx::FrameRef agx::Attachment::m_relFrame
protectedinherited

Definition at line 199 of file Attachment.h.

◆ m_transformed

agx::Vec3 agx::Attachment::m_transformed[NUM_ELEMENTS]
protectedinherited

Definition at line 198 of file Attachment.h.


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