AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agxModel::Tree::Branch Class Reference

Branch is a part of the Tree, with a body and a constraint to its parent. More...

#include <Tree.h>

+ Inheritance diagram for agxModel::Tree::Branch:

Public Types

enum  MaxLoadType { TRANSLATIONAL = 0 , ROTATIONAL }
 

Public Member Functions

 Branch ()
 Default constructor.
 
 Branch (const agx::AffineMatrix4x4 &transform)
 Construct branch given transform.
 
 Branch (const agx::Vec3 &start, const agx::Vec3 &end)
 Construct branch given start- and end point in world.
 
bool addBranch (agxModel::Tree::Branch *branch)
 Add child branch to this branch.
 
 AGXSTREAM_DECLARE_SERIALIZABLE_BASE (Branch)
 
virtual agxModel::Tree::Branch * clone ()
 
virtual agx::ConstraintRef createConstraintWithParent () const
 Creates the constraint with this branch's parent.
 
agxModel::Tree::Branch * getBranch (size_t i) const
 
agx::Constraint * getConstraint () const
 
agx::Vec2 getCurrentLoad () const
 
agx::Real getCurrentRotationalLoad () const
 
agx::Real getCurrentTranslationalLoad () const
 
agx::Referenced * getCustomData () const
 
agx::Vec3 getDirection () const
 
virtual agx::Real getLength (const agxCollide::Geometry *geometry) const
 Calculates and returns an estimated length of this branch.
 
agx::Vec3 getLocalDirection () const
 
agx::Vec2 getMaxLoad () const
 
agx::Real getMaxRotationalLoad () const
 
agx::Real getMaxTranslationalLoad () const
 
size_t getNumBranches () const
 
agxModel::Tree::Branch * getParent () const
 
agx::RigidBody * getRigidBody () const
 
bool removeBranch (agxModel::Tree::Branch *branch)
 Remove a child branch.
 
bool removeBranch (size_t index)
 Remove child given index.
 
void setCustomData (agx::Referenced *customData)
 Assign custom/user data of any type.
 
void setMaxLoad (agx::Real translational, agx::Real rotational)
 Assign max load for this branch (connection at start).
 
void setMaxRotationalLoad (agx::Real maxLoad)
 Assign rotational max load for this branch.
 
void setMaxTranslationalLoad (agx::Real maxLoad)
 Assign translational max load for this branch.
 
virtual agxCollide::Shape * splitShape (agxCollide::Shape *shapeInBranch, agx::Real shapePosition, agxModel::Tree::Branch *newBranch, agx::Real &newBelowLength, agx::Real &newAboveLength)
 This branch is about to be divided into two branches (cut)!
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
- Public Member Functions inherited from agxStream::Serializable
virtual ~Serializable ()
 Destructor for normal C++ use but hidden from SWIG bindings.
 
virtual const char * getClassName () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object.
 
virtual StorageAgent * getStorageAgent () const =0
 
agx::Uuid getUuid () const
 
bool isFinished () const
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object.
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object.
 

Static Public Member Functions

static agxStream::Serializable * create (agxStream::InputArchive &)
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Public Member Functions inherited from agxStream::Serializable
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.
 

Protected Member Functions

virtual ~Branch ()
 
void setConstraint (agx::Constraint *constraint)
 Assign constraint attached at start point of this branch.
 
void setParent (agxModel::Tree::Branch *parent)
 Assign parent to this branch.
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- Protected Member Functions inherited from agxStream::Serializable
 Serializable ()
 Default constructor.
 
 Serializable (const Serializable &other)
 Copy constructor.
 
void generateUuid ()
 

Protected Attributes

BranchContainer m_branches
 
agx::ConstraintRef m_constraint
 
agx::ref_ptr< agx::Referenced > m_customData
 
agx::Vec2 m_maxLoad
 
BranchObs m_parent
 
agx::RigidBodyRef m_rb
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 

Detailed Description

Branch is a part of the Tree, with a body and a constraint to its parent.

Definition at line 55 of file agxModel/Tree.h.

Member Enumeration Documentation

◆ MaxLoadType

Enumerator
TRANSLATIONAL 
ROTATIONAL 

Definition at line 58 of file agxModel/Tree.h.

Constructor & Destructor Documentation

◆ Branch() [1/3]

agxModel::Tree::Branch::Branch ( )

Default constructor.

◆ Branch() [2/3]

agxModel::Tree::Branch::Branch ( const agx::Vec3 &  start,
const agx::Vec3 &  end 
)

Construct branch given start- and end point in world.

The rigid body model frame will be located at start, and rotated so that z-axis points toward end.

Parameters
start- start position, in world, for this branch
end- end position, in world, for this branch

◆ Branch() [3/3]

agxModel::Tree::Branch::Branch ( const agx::AffineMatrix4x4 &  transform)

Construct branch given transform.

The rigid body will initially have this transform, i.e., this is the model frame during initialize.

Parameters
transform- model frame transform

◆ ~Branch()

virtual agxModel::Tree::Branch::~Branch ( )
protectedvirtual

Member Function Documentation

◆ addBranch()

bool agxModel::Tree::Branch::addBranch ( agxModel::Tree::Branch *  branch)

Add child branch to this branch.

This branch will be parent to branch and later attached to it with a constraint.

Parameters
branch- child branch
Returns
true if add was successful - otherwise false (e.g., loops)

◆ AGXSTREAM_DECLARE_SERIALIZABLE_BASE()

agxModel::Tree::Branch::AGXSTREAM_DECLARE_SERIALIZABLE_BASE ( Branch  )

◆ clone()

virtual agxModel::Tree::Branch * agxModel::Tree::Branch::clone ( )
virtual
Returns
clone of this branch

Reimplemented in agxModel::Deformable1DNode.

◆ create()

static agxStream::Serializable * agxModel::Tree::Branch::create ( agxStream::InputArchive &  )
inlinestatic

Definition at line 238 of file agxModel/Tree.h.

◆ createConstraintWithParent()

virtual agx::ConstraintRef agxModel::Tree::Branch::createConstraintWithParent ( ) const
virtual

Creates the constraint with this branch's parent.

Default is lock joint along this branch direction.

Note
It's not defined to call this method if the parent is the root.

Reimplemented in agxModel::Deformable1DNode.

◆ getBranch()

agxModel::Tree::Branch * agxModel::Tree::Branch::getBranch ( size_t  i) const
Returns
child branch i

◆ getConstraint()

agx::Constraint * agxModel::Tree::Branch::getConstraint ( ) const
Returns
the constraint of this branch

◆ getCurrentLoad()

agx::Vec2 agxModel::Tree::Branch::getCurrentLoad ( ) const
Returns
both translational and rotational load (current) (index with Branch::TRANSLATIONAL and Branch::ROTATIONAL)

◆ getCurrentRotationalLoad()

agx::Real agxModel::Tree::Branch::getCurrentRotationalLoad ( ) const
Returns
current rotational load in this branch

◆ getCurrentTranslationalLoad()

agx::Real agxModel::Tree::Branch::getCurrentTranslationalLoad ( ) const
Returns
current translational load in this branch

◆ getCustomData()

agx::Referenced * agxModel::Tree::Branch::getCustomData ( ) const
Returns
the custom data assigned to this branch (0 if none)

◆ getDirection()

agx::Vec3 agxModel::Tree::Branch::getDirection ( ) const
Returns
direction of this branch

◆ getLength()

virtual agx::Real agxModel::Tree::Branch::getLength ( const agxCollide::Geometry *  geometry) const
virtual

Calculates and returns an estimated length of this branch.

Default this method can estimate the length of the first shape in geometry of shape types: agxCollide::Shape::CYLINDER and agxCollide::Shape::CAPSULE.

Returns
the length, or at least estimated length, of this branch

Reimplemented in agxModel::Deformable1DNode.

◆ getLocalDirection()

agx::Vec3 agxModel::Tree::Branch::getLocalDirection ( ) const
Returns
the local direction of this branch

◆ getMaxLoad()

agx::Vec2 agxModel::Tree::Branch::getMaxLoad ( ) const
Returns
both translational and rotational max load (index with Branch::TRANSLATIONAL and Branch::ROTATIONAL)

◆ getMaxRotationalLoad()

agx::Real agxModel::Tree::Branch::getMaxRotationalLoad ( ) const
Returns
rotational max load for this branch

◆ getMaxTranslationalLoad()

agx::Real agxModel::Tree::Branch::getMaxTranslationalLoad ( ) const
Returns
translational max load for this branch

◆ getNumBranches()

size_t agxModel::Tree::Branch::getNumBranches ( ) const
Returns
the number of child branches for this branch

◆ getParent()

agxModel::Tree::Branch * agxModel::Tree::Branch::getParent ( ) const
Returns
parent branch to this branch

◆ getRigidBody()

agx::RigidBody * agxModel::Tree::Branch::getRigidBody ( ) const
Returns
the rigid body of this branch

◆ removeBranch() [1/2]

bool agxModel::Tree::Branch::removeBranch ( agxModel::Tree::Branch *  branch)

Remove a child branch.

Parent will be set to 0 for branch.

Parameters
branch- child branch
Returns
true if the branch was successfully removed

◆ removeBranch() [2/2]

bool agxModel::Tree::Branch::removeBranch ( size_t  index)

Remove child given index.

Parent will be set to 0 for branch at index.

Parameters
index- index of branch to remove
Returns
true if the branch, at index, was successfully removed

◆ setConstraint()

void agxModel::Tree::Branch::setConstraint ( agx::Constraint *  constraint)
protected

Assign constraint attached at start point of this branch.

Parameters
constraint- constraint attached at start point of this branch

◆ setCustomData()

void agxModel::Tree::Branch::setCustomData ( agx::Referenced *  customData)

Assign custom/user data of any type.

Only constraint is that the class inherits agx::Referenced for easier memory managment.

Parameters
customData- custom/user data for this branch

◆ setMaxLoad()

void agxModel::Tree::Branch::setMaxLoad ( agx::Real  translational,
agx::Real  rotational 
)

Assign max load for this branch (connection at start).

Maximum load is divided into two parts, translational and rotational, units force. When/if the constraint exceeds one of these values an event is fired.

Parameters
translational- translational max load, unit force (default: infinity = disabled)
rotational- rotational max load, unit force (default: infinity = disabled)

◆ setMaxRotationalLoad()

void agxModel::Tree::Branch::setMaxRotationalLoad ( agx::Real  maxLoad)

Assign rotational max load for this branch.

Parameters
maxLoad- rotational max load, unit force (default: infinity = disabled)

◆ setMaxTranslationalLoad()

void agxModel::Tree::Branch::setMaxTranslationalLoad ( agx::Real  maxLoad)

Assign translational max load for this branch.

Parameters
maxLoad- translational max load, unit force (default: infinity = disabled)

◆ setParent()

void agxModel::Tree::Branch::setParent ( agxModel::Tree::Branch *  parent)
protected

Assign parent to this branch.

Parameters
parent- parent branch

◆ splitShape()

virtual agxCollide::Shape * agxModel::Tree::Branch::splitShape ( agxCollide::Shape *  shapeInBranch,
agx::Real  shapePosition,
agxModel::Tree::Branch *  newBranch,
agx::Real &  newBelowLength,
agx::Real &  newAboveLength 
)
virtual

This branch is about to be divided into two branches (cut)!

Split a shape in this branch (shapeInBranch is part of a geometry of this branch rigid body) at a distance along the shape. Creates a new shape and also returns the new length from start to shapePosition, newBelowLength, and new length from newBelowLength to end, newAboveLength. The new shape will belong to newBranch after this call.

Default this method supports shape types: agxCollide::Shape::CYLINDER and agxCollide::Shape::CAPSULE.

Parameters
shapeInBranch- a shape in a geometry in this branch rigid body
shapePosition- a distance along shapeInBranch y-axis (because normally cylinder or capsule)
newBranch- the branch the new shape will belong to
[out]newBelowLength- new length of this branch (along y-axis)
[out]newAboveLength- new length of the new shape
Returns
a new shape where the length of the new shape should be round newAboveLength of length

Reimplemented in agxModel::Deformable1DNode.

Member Data Documentation

◆ m_branches

BranchContainer agxModel::Tree::Branch::m_branches
protected

Definition at line 258 of file agxModel/Tree.h.

◆ m_constraint

agx::ConstraintRef agxModel::Tree::Branch::m_constraint
protected

Definition at line 262 of file agxModel/Tree.h.

◆ m_customData

agx::ref_ptr< agx::Referenced > agxModel::Tree::Branch::m_customData
protected

Definition at line 259 of file agxModel/Tree.h.

◆ m_maxLoad

agx::Vec2 agxModel::Tree::Branch::m_maxLoad
protected

Definition at line 263 of file agxModel/Tree.h.

◆ m_parent

BranchObs agxModel::Tree::Branch::m_parent
protected

Definition at line 257 of file agxModel/Tree.h.

◆ m_rb

agx::RigidBodyRef agxModel::Tree::Branch::m_rb
protected

Definition at line 261 of file agxModel/Tree.h.


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