275 T* getComponent()
const;
315 using Assembly::addNotification;
316 using Assembly::removeNotification;
477 T* getSegment(
agx::Real restLengthFromStart )
const;
484 T* findSegment(
const agx::Vec3& worldPoint )
const;
489 template<
typename ObjT>
501 template<
typename T,
typename ObjT>
530 void trigger( SimulationEvent simulationEvent );
531 void addGroup(
const IdData& group );
532 void removeGroup(
const IdData& group );
533 agx::Bool hasGroup(
const IdData& group )
const;
536 friend class
agx::InternalData;
540 agx::Referenced* getInternalData() const;
545 void setInternalData(
agx::Referenced* data );
549 agx::Uuid m_uniqueId;
550 agx::Uuid m_disabledCollisionsId;
552 agx::MaterialRef m_material;
553 IdDataContainer m_externallyAddedGroups;
555 agx::Vec3 m_linearVelocityDamping;
556 agx::Vec3 m_angularVelocityDamping;
557 agx::ref_ptr<
agx::Referenced> m_internalData;
563 auto data = LinkedStructureObjectData::get<LinkedStructureObjectData>( rb );
564 return data !=
nullptr && data->linkedStructure !=
nullptr ? data->linkedStructure->template asSafe<T>() :
nullptr;
570 return LinkedStructure::getT<T>(
const_cast<agx::RigidBody*
>( rb ) );
574 T* LinkedStructure::getComponent()
const
576 for (
auto component : m_components ) {
577 auto typed = component->template asSafe<T>();
578 if ( typed !=
nullptr )
590 inline agx::UInt LinkedStructure::getNumSegments()
const
592 return m_segments.
size();
606 getSegmentIterator<T>( endIndex ) );
612 return m_segments[ index ];
616 T* LinkedStructure::getSegment(
agx::Real restLengthFromStart )
const
618 if ( m_segments.empty() )
621 if ( restLengthFromStart <= 0.0 )
622 return m_segments.front()->template as<T>();
624 agx::Real restLengthAlongStructure = 0.0;
625 for (
auto segment : this->
template getSegments<T>() ) {
626 if ( restLengthAlongStructure + segment->getLength() < restLengthFromStart )
627 restLengthAlongStructure += segment->getLength();
629 return segment->template as<T>();
632 return m_segments.back()->template as<T>();
636 T* LinkedStructure::findSegment(
const agx::Vec3 &worldPoint )
const
638 auto [point, segment] = findPointAndSegment( worldPoint );
639 return segment->template as<T>();
645 auto index = getSegmentIndex( rb );
647 m_segments[ index ] :
653 auto data = getData( rb );
654 return data !=
nullptr && data->segment !=
nullptr && data->linkedStructure ==
this ?
655 data->segment->getIndex() :
665 template<
typename T,
typename ObjT>
668 auto segment = this->getSegment( rb );
669 if ( segment ==
nullptr )
671 return getSegmentIterator<T>( segment->getIndex(), boundaryless );
676 auto data = LinkedStructureObjectData::get<LinkedStructureObjectData>( rb );
679 return data !=
nullptr && ( data->linkedStructure ==
this || data->linkedStructure == nullptr ) ?
686 return m_internalData;
#define AGX_DECLARE_POINTER_TYPES(type)
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXPHYSICS_EXPORT
The geometry representation used by the collision detection engine.
Collection of geometry group names and id's.
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints,...
Optionally unbounded linked structure segment iterator object to iterate segments in a SegmentStructu...
Segment range object for linked structure.
Segment object in a linked structure.
Base implementation of a component (e.g., specific functionality) in linked structures.
Basic implementation of any structure where bodies are linked/constrained together in a well defined ...
LinkedStructure()
Hidden default constructor.
virtual void setMaterial(agx::Material *material)
Assign material to all segments in this linked structure.
virtual void removeGroup(agx::UInt32 id)
Remove group id from all segments in this linked structure.
virtual agx::Real findRestLengthTo(const agx::Vec3 &worldPoint) const
Given any world point, find a center point on this structure that is closest to the given worldPoint ...
virtual agxCollide::GroupIdCollection findGroupIdCollection() const
static const LinkedStructure * get(const agx::RigidBody *body)
virtual void onSetEnableCollisions(agxCollide::Geometry *geometry, agx::Bool enable)
Called when collision state changed for given geometry.
virtual void setLinearVelocityDamping(const agx::Vec3 &linearVelocityDamping)
Assigns linear velocity damping to all segments in this linked structure.
virtual void onLastStep()
Called on simulation last step event - after user lastStep.
virtual agx::Bool getEnableCollisions(const agxCollide::Geometry *geometry) const
virtual void removeGroup(const agx::Name &name)
Remove group name from all segments in this linked structure.
virtual void addGroup(agx::UInt32 id)
Add group id to all segments in this linked structure.
virtual agx::Bool rebind()
Make the current relative positions of all nodes the rest state.
virtual agx::Bool removeComponent(agxSDK::LinkedStructureComponent *component)
Remove an added component from this linked structure.
virtual agx::Bool getEnableCollisions(const agx::RigidBody *rb) const
virtual void onAddNotification(agxSDK::Simulation *simulation)
Called when addNotification is executed when this linked structure is added to the simulation.
virtual void onPreStep()
Called on simulation pre step event - after user preStep.
static const LinkedStructure * get(const agxCollide::Geometry *geometry)
virtual agx::Vec3 findPoint(agx::Real restLengthFromStart) const
Finds center point on this structure given rest length from the start.
virtual void onGroupRemove(const IdData &group)
Called when an existing group has been removed.
virtual void onRemoveNotification(agxSDK::Simulation *simulation)
Called when removeNotification is executed when this linked structure is removed from the simulation.
virtual agx::Bool addComponent(agxSDK::LinkedStructureComponent *component)
Add new component to this linked structure.
virtual void setEnableCollisions(agxCollide::Geometry *geometry, agx::Bool enable)
Enable/disable collisions between the geometry and all segments of this linked structure.
virtual agx::Real getCurrentLength() const
Calculates and returns the total length of this linked structure, at current state.
void removeNotification(agxSDK::Simulation *simulation) final override
Called when this linked structure is added to the simulation.
agxSDK::LinkedStructureComponent * getComponent(const agx::Name &name) const
static LinkedStructure * get(agx::RigidBody *body)
virtual agx::Real getRestLength() const
Calculates and returns the total length of this linked structure, at rest.
virtual agx::Real findCurrentLength(agx::Real restLengthFromStart) const
Calculates the current length of a given rest length.
virtual ~LinkedStructure()
Reference counted object - protected destructor.
virtual void setEnableCollisions(agx::RigidBody *rb, agx::Bool enable)
Enable/disable collisions between the rigid body and all segments of this linked structure.
virtual void onPostStep()
Called on simulation post step event - after user postStep.
std::tuple< agx::Vec3, LinkedSegment * > findPointAndSegment(const agx::Vec3 &worldPoint) const
virtual agx::UInt32 getDisabledCollisionGroupId() const
virtual agx::Real getRestVolume() const
Calculates and returns the total volume of this linked structure, at rest.
agxSDK::LinkedSegmentRange< agxSDK::LinkedSegment > segments()
void add(LinkedSegment *segment)
Add segment to this linked structure.
virtual agx::Bool hasGroup(agx::UInt32 id) const
virtual agx::Real findRestLength(agx::Real currentLengthFromStart) const
Calculates the rest length of a given current length from start.
virtual void addGroup(const agx::Name &name)
Add group name to all segments in this linked structure.
virtual void onPostIntegrate()
Called on simulation post integrate event - when transforms has been updated given current velocities...
virtual agx::Real findRestLengthTo(const agxSDK::LinkedSegment *segment) const
Finds rest length to the start of the given segment.
virtual agx::Bool hasGroup(const agx::Name &name) const
virtual void onPreCollideStep()
Called on simulation pre-collide step event - after user preCollide.
virtual agx::UInt32 getUniqueId() const
virtual agx::Vec3 getAngularVelocityDamping() const
static LinkedStructure * get(agxCollide::Geometry *geometry)
virtual void setAngularVelocityDamping(const agx::Vec3 &angularVelocityDamping)
Assigns angular velocity damping to all segments in this linked structure.
virtual agx::Material * getMaterial() const
virtual agx::Vec3 findPoint(const agx::Vec3 &worldPoint) const
Given any world point, find a center point on this structure that is closest to the given worldPoint.
virtual void onGroupAdd(const IdData &group)
Called when a new group has been added.
LinkedSegment * getSegment(const ObjT *rb) const
void addNotification(agxSDK::Simulation *simulation) final override
Called when this linked structure is added to the simulation.
virtual void onMaterialNew()
Called when a new material has been assigned.
virtual agx::Real getMass() const
Calculates and returns the total mass of this linked structure.
virtual agx::Vec3 getLinearVelocityDamping() const
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Main material class which acts as a holder of a Surface Material and a Bulk material.
Representation of a name string.
Base class providing referencing counted objects.
The rigid body class, combining a geometric model and a frame of reference.
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
Connection back from bodies, constraints etc.
Group id 'union' of int id and name id.
IdData(agx::UInt32 id)
Construct group given int id where name == "".
IdData(const agx::Name &name)
Construct group given name where id == agx::InvalidIndex.
IdData()
Default constructor, group id is invalid with id == agx::InvalidIndex and name == "".