AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agxWire::WireController Class Reference

Overlaying object handling wires. More...

#include <WireController.h>

+ Inheritance diagram for agxWire::WireController:

Public Types

typedef agx::HashVector< agx::UInt32, agx::observer_ptr< agxWire::Wire > > IdWireContainer
 
typedef agx::Vector< SimulationObsWirePtrContainerPair > SimplifiedWiresContainer
 
typedef std::pair< agxSDK::SimulationObserver, WireParallelCallbacksHandlerRef > SimulationObsWireParallelCallbacksHandlerRefPair
 
typedef std::pair< agxSDK::SimulationObserver, WirePtrContainer > SimulationObsWirePtrContainerPair
 
enum  State { EXPLICIT_ENABLE = (1<<0) , ALL_ENABLE = (1<<1) , USE_DYNAMIC_CONTACTS = (1<<2) , DEFAULT = EXPLICIT_ENABLE }
 Internal state handling. More...
 
typedef agx::Vector< WireHandlerRef > WireHandlerContainer
 
typedef WirePtrContainer::const_iterator WireIterator
 
typedef agx::Vector< SimulationObsWireParallelCallbacksHandlerRefPair > WireParallelCallbacksHandlerContainer
 
typedef agx::SetVector< agxWire::Wire * > WirePtrContainer
 
typedef agx::Vector< WireWireSymmetricPair > WireWireContainer
 
typedef agx::SymmetricPair< agx::observer_ptr< agxWire::Wire > > WireWireSymmetricPair
 
- Public Types inherited from agx::Singleton
enum  Priority { HIGHEST_PRIORITY = 2147483647 , LOWEST_PRIORITY = 10000 , DEFAULT_PRIORITY = 1073741824 }
 Specifies the ranges of the priority which can be assigned to a singleton at the time of creation. More...
 

Public Member Functions

agxSDK::Simulation * find (agxWire::WireHandler *handler) const
 
agxWire::WireHandler * find (const agxSDK::Simulation *simulation)
 
const agxWire::WireController::WirePtrContainer & getAllWires () const
 
WireIterator getBeginWireIterator () const
 Access to all the wires.
 
bool getEnableCollisions (const agxWire::Wire *wire1, const agxWire::Wire *wire2) const
 
const WireWireContainer & getEnabledWireWirePairs () const
 Internal method.
 
agx::Bool getEnableDynamicWireContacts (const agx::RigidBody *rb) const
 
agx::Bool getEnableDynamicWireContacts (const agxCollide::Geometry *geometry) const
 
agx::Bool getEnableDynamicWireContactsGlobally () const
 
WireIterator getEndWireIterator () const
 
agx::UInt getNumWires () const
 Can be used to iterate over all wires in a script language that e.g., not support iterators.
 
agxWire::WireHandler * getOrCreateWireHandler (agxSDK::Simulation *simulation)
 
agxWire::WireParallelCallbacksHandler * getOrCreateWireParallelCallbacksHandler (agxSDK::Simulation *simulation)
 
agxWire::Wire * getWire (agx::UInt index) const
 
bool isWireWireActive () const
 
void removeParallelCallbackHandler (agxSDK::Simulation *simulation)
 Removes object.
 
bool setEnableCollisions (agxWire::Wire *wire1, agxWire::Wire *wire2, bool enable)
 Enable, or disable, collision detection and contacts between two wires.
 
agx::Bool setEnableDynamicWireContacts (agx::RigidBody *rb, agx::Bool enable)
 Enable, or disable, the use of dynamic wire contact model against this rigid body.
 
agx::Bool setEnableDynamicWireContacts (agxCollide::Geometry *geometry, agx::Bool enable)
 Enable, or disable, the use of dynamic wire contact model against this geometry.
 
void setEnableDynamicWireContactsGlobally (agx::Bool enable)
 Force all wire contacts to be dynamic.
 
- Public Member Functions inherited from agx::Singleton
 Singleton (int priority=DEFAULT_PRIORITY)
 Default constructor.
 
virtual std::string getClassName () const =0
 
int getPriority () const
 Return the shutdown priority of the singleton instance.
 
virtual void shutdown ()=0
 Implement this method to cleanup your Singleton class.
 

Static Public Member Functions

static WireController * instance ()
 

Protected Member Functions

 WireController ()
 
virtual ~WireController ()
 
void onAddNotification (agxWire::Wire *wire)
 Internal method.
 
void onCreate (agxWire::Wire *wire)
 Internal method.
 
void onDelete (agxWire::Wire *wire)
 Internal method.
 
void onRemoveNotification (agxWire::Wire *wire)
 Internal method.
 
void onSimplify (agxSDK::Simulation *simulation, agxWire::Wire *wire)
 Call when the wire is simplified.
 
void onUnsimplify (agxSDK::Simulation *simulation, agxWire::Wire *wire)
 Call when the wire is unsimplified.
 
virtual void shutdown () override
 Implement this method to cleanup your Singleton class.
 
void updateId (agxWire::Wire *wire)
 Internal method.
 
- Protected Member Functions inherited from agx::Singleton
virtual ~Singleton ()
 Destructor.
 
void _shutdown ()
 

Protected Attributes

WireWireContainer m_enabledWires
 Explicitly enabled collisions pairs.
 
IdWireContainer m_idWire
 Wire unique geometry id -> wire.
 
agx::ReentrantMutex m_mutex
 
WireParallelCallbacksHandlerFactoryRef m_parallelCallbacksFactory
 
WireParallelCallbacksHandlerContainer m_parallelCallbacksHandlers
 Parallel callbacks handler, unique for each simulation.
 
SimplifiedWiresContainer m_simplifiedWires
 
agx::UInt m_state
 Current global state.
 
WireHandlerContainer m_wireHandlers
 Wire handlers, unique for each simulation.
 
WirePtrContainer m_wires
 All wires instantiated.
 

Detailed Description

Overlaying object handling wires.

This class monitors construction and deletion (and adding, removing from simulations) of wires and enables interface for enabling and disabling contacts/collision handling between wires.

Note that this class handles agxWire::Wire objects, and nothing else.

Examples how to use this class.

Example 1: agxWire::WireRef wire1 = new ... agxWire::WireRef wire2 = new ... agxWire::WireController::instance()->getEnableCollisions( wire1, wire2 ); // false - default is false. agxWire::WireController::instance()->setEnableCollisions( wire1, wire2, true );

Example 2: Loop ALL wire objects created (registered during "new agxWire::Wire"). agxWire::WireController::WireIterator it = agxWire::WireController::instance()->getBeginWireIterator(); while ( it != agxWire::WireController::instance()->getEndWireIterator() ) { const agxWire::Wire* wire = *it; Do stuff. ++it; }

Definition at line 54 of file WireController.h.

Member Typedef Documentation

◆ IdWireContainer

◆ SimplifiedWiresContainer

◆ SimulationObsWireParallelCallbacksHandlerRefPair

Definition at line 63 of file WireController.h.

◆ SimulationObsWirePtrContainerPair

◆ WireHandlerContainer

Definition at line 62 of file WireController.h.

◆ WireIterator

◆ WireParallelCallbacksHandlerContainer

◆ WirePtrContainer

◆ WireWireContainer

◆ WireWireSymmetricPair

Member Enumeration Documentation

◆ State

Internal state handling.

Test, debug and development related.

Enumerator
EXPLICIT_ENABLE 

The user must call setEnableCollisions explicitly for all pairs of wires.

ALL_ENABLE 

Collisions enabled between all pairs of wires.

USE_DYNAMIC_CONTACTS 

Make all wire contacts dynamic.

DEFAULT 

Definition at line 72 of file WireController.h.

Constructor & Destructor Documentation

◆ WireController()

agxWire::WireController::WireController ( )
protected

◆ ~WireController()

virtual agxWire::WireController::~WireController ( )
protectedvirtual

Member Function Documentation

◆ find() [1/2]

agxSDK::Simulation * agxWire::WireController::find ( agxWire::WireHandler *  handler) const
Returns
the simulation given a wire-wire handler (the handler is unique to the simulation)

◆ find() [2/2]

agxWire::WireHandler * agxWire::WireController::find ( const agxSDK::Simulation *  simulation)
Returns
wire handler given simulation (0 if none has been created)

◆ getAllWires()

const agxWire::WireController::WirePtrContainer & agxWire::WireController::getAllWires ( ) const
Returns
all created wires

◆ getBeginWireIterator()

WireController::WireIterator agxWire::WireController::getBeginWireIterator ( ) const

Access to all the wires.

getEndWireIterator() - getBeginWireIterator() == total number of wires.

Returns
begin iterator

Definition at line 355 of file WireController.h.

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

◆ getEnableCollisions()

bool agxWire::WireController::getEnableCollisions ( const agxWire::Wire *  wire1,
const agxWire::Wire *  wire2 
) const
Parameters
wire1- first wire
wire2- second wire
Returns
true if wire1 can collide with wire2 - otherwise false

◆ getEnabledWireWirePairs()

const WireWireContainer & agxWire::WireController::getEnabledWireWirePairs ( ) const

Internal method.

Pairs of wire where setEnableCollisions( ..., true ) has been called.

◆ getEnableDynamicWireContacts() [1/2]

agx::Bool agxWire::WireController::getEnableDynamicWireContacts ( const agx::RigidBody *  rb) const
Returns
true if all geometries in rb has contact model 'dynamic' - otherwise false

◆ getEnableDynamicWireContacts() [2/2]

agx::Bool agxWire::WireController::getEnableDynamicWireContacts ( const agxCollide::Geometry *  geometry) const
Returns
true if the contact model for geometry is 'dynamic' - otherwise false

◆ getEnableDynamicWireContactsGlobally()

agx::Bool agxWire::WireController::getEnableDynamicWireContactsGlobally ( ) const
Returns
true if all wire contacts are forced to be dynamic.

◆ getEndWireIterator()

WireController::WireIterator agxWire::WireController::getEndWireIterator ( ) const
Returns
end wire iterator

Definition at line 360 of file WireController.h.

◆ getNumWires()

agx::UInt agxWire::WireController::getNumWires ( ) const

Can be used to iterate over all wires in a script language that e.g., not support iterators.

Returns
the number of wire this wire controller holds

◆ getOrCreateWireHandler()

agxWire::WireHandler * agxWire::WireController::getOrCreateWireHandler ( agxSDK::Simulation *  simulation)
Returns
the wire-wire handler given a simulation (this handler is unique to the simulation)

◆ getOrCreateWireParallelCallbacksHandler()

agxWire::WireParallelCallbacksHandler * agxWire::WireController::getOrCreateWireParallelCallbacksHandler ( agxSDK::Simulation *  simulation)
Returns
the wire parallel callbacks handler given a simulation (this handler is unique to the simulation)

◆ getWire()

agxWire::Wire * agxWire::WireController::getWire ( agx::UInt  index) const
Returns
wire with index index

◆ instance()

static WireController * agxWire::WireController::instance ( )
static
Returns
instance of the object handling wire-wire collisions

◆ isWireWireActive()

bool agxWire::WireController::isWireWireActive ( ) const
Returns
true if the wire-wire framework is active (i.e., collisions enabled between at least one wire pair or state is ALL_ENABLE) - otherwise false

◆ onAddNotification()

void agxWire::WireController::onAddNotification ( agxWire::Wire *  wire)
protected

Internal method.

All wires should report themselves to this controller during addNotification.

◆ onCreate()

void agxWire::WireController::onCreate ( agxWire::Wire *  wire)
protected

Internal method.

All wires should report themselves to this controller during construction.

◆ onDelete()

void agxWire::WireController::onDelete ( agxWire::Wire *  wire)
protected

Internal method.

All wires must be removed from the controller when the destructor is called.

◆ onRemoveNotification()

void agxWire::WireController::onRemoveNotification ( agxWire::Wire *  wire)
protected

Internal method.

From removeNotification.

◆ onSimplify()

void agxWire::WireController::onSimplify ( agxSDK::Simulation *  simulation,
agxWire::Wire *  wire 
)
protected

Call when the wire is simplified.

◆ onUnsimplify()

void agxWire::WireController::onUnsimplify ( agxSDK::Simulation *  simulation,
agxWire::Wire *  wire 
)
protected

Call when the wire is unsimplified.

◆ removeParallelCallbackHandler()

void agxWire::WireController::removeParallelCallbackHandler ( agxSDK::Simulation *  simulation)

Removes object.

◆ setEnableCollisions()

bool agxWire::WireController::setEnableCollisions ( agxWire::Wire *  wire1,
agxWire::Wire *  wire2,
bool  enable 
)

Enable, or disable, collision detection and contacts between two wires.

By default collisions are disabled.

Parameters
wire1- first wire
wire2- second wire
enable- true to enable collisions between wire1 and wire2 - false to disable
Returns
true if the new state was accepted - otherwise false

◆ setEnableDynamicWireContacts() [1/2]

agx::Bool agxWire::WireController::setEnableDynamicWireContacts ( agx::RigidBody *  rb,
agx::Bool  enable 
)

Enable, or disable, the use of dynamic wire contact model against this rigid body.

Note
This method will add the WIRE_DYNAMIC_CONTACTS_GROUP group to the geometries in the given rigid body, and contacts between geometries with the WIRE_DYNAMIC_CONTACTS_GROUP group and wire lump spheres - are by definition disabled.
The geometries will not be 'remembered' after this call. I.e., the changes made to the geometry by calling this method with enable == true can only be reverted when this method is called with the same geometry and enable == false.
Parameters
rb- rigid body with geometries to change wire contact model on
enable- true to use the dynamics contact model, false to use the default contact model
Returns
true if the desired state was accepted / successful - otherwise false

◆ setEnableDynamicWireContacts() [2/2]

agx::Bool agxWire::WireController::setEnableDynamicWireContacts ( agxCollide::Geometry *  geometry,
agx::Bool  enable 
)

Enable, or disable, the use of dynamic wire contact model against this geometry.

Note
This method will add the WIRE_DYNAMIC_CONTACTS_GROUP group to the geometry, and contacts between geometries with the WIRE_DYNAMIC_CONTACTS_GROUP group and wire lump spheres - are by definition disabled.
This geometry will not be 'remembered' after this call. I.e., the changes made to the geometry by calling this method with enable == true can only be reverted when this method is called with the same geometry and enable == false.
Parameters
geometry- geometry to change wire contact model on
enable- true to use the dynamics contact model, false to use the default contact model
Returns
true if the desired state was accepted / successful - otherwise false

◆ setEnableDynamicWireContactsGlobally()

void agxWire::WireController::setEnableDynamicWireContactsGlobally ( agx::Bool  enable)

Force all wire contacts to be dynamic.

◆ shutdown()

virtual void agxWire::WireController::shutdown ( )
overrideprotectedvirtual

Implement this method to cleanup your Singleton class.

Implements agx::Singleton.

◆ updateId()

void agxWire::WireController::updateId ( agxWire::Wire *  wire)
protected

Internal method.

Updates identification number for a wire.

Member Data Documentation

◆ m_enabledWires

WireWireContainer agxWire::WireController::m_enabledWires
protected

Explicitly enabled collisions pairs.

Definition at line 343 of file WireController.h.

◆ m_idWire

IdWireContainer agxWire::WireController::m_idWire
protected

Wire unique geometry id -> wire.

Definition at line 344 of file WireController.h.

◆ m_mutex

agx::ReentrantMutex agxWire::WireController::m_mutex
protected

Definition at line 350 of file WireController.h.

◆ m_parallelCallbacksFactory

WireParallelCallbacksHandlerFactoryRef agxWire::WireController::m_parallelCallbacksFactory
protected

Definition at line 346 of file WireController.h.

◆ m_parallelCallbacksHandlers

WireParallelCallbacksHandlerContainer agxWire::WireController::m_parallelCallbacksHandlers
protected

Parallel callbacks handler, unique for each simulation.

Definition at line 347 of file WireController.h.

◆ m_simplifiedWires

SimplifiedWiresContainer agxWire::WireController::m_simplifiedWires
protected

Definition at line 348 of file WireController.h.

◆ m_state

agx::UInt agxWire::WireController::m_state
protected

Current global state.

Definition at line 349 of file WireController.h.

◆ m_wireHandlers

WireHandlerContainer agxWire::WireController::m_wireHandlers
protected

Wire handlers, unique for each simulation.

Definition at line 345 of file WireController.h.

◆ m_wires

WirePtrContainer agxWire::WireController::m_wires
protected

All wires instantiated.

Definition at line 342 of file WireController.h.


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