AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxWire::WireController Class Referenceabstract

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
 
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...
 
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 Member Functions

agxWire::WireHandler * find (const agxSDK::Simulation *simulation)
 
agxSDK::Simulation * find (agxWire::WireHandler *handler) const
 
const
agxWire::WireController::WirePtrContainer & 
getAllWires () const
 
WireIterator getBeginWireIterator () const
 Access to all the wires. More...
 
virtual std::string getClassName () const =0
 
bool getEnableCollisions (const agxWire::Wire *wire1, const agxWire::Wire *wire2) const
 
const WireWireContainer & getEnabledWireWirePairs () const
 Internal method. More...
 
agx::Bool getEnableDynamicWireContacts (const agxCollide::Geometry *geometry) const
 
agx::Bool getEnableDynamicWireContacts (const agx::RigidBody *rb) 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. More...
 
agxWire::WireHandler * getOrCreateWireHandler (agxSDK::Simulation *simulation)
 
agxWire::WireParallelCallbacksHandler * getOrCreateWireParallelCallbacksHandler (agxSDK::Simulation *simulation)
 
int getPriority () const
 Return the shutdown priority of the singleton instance. More...
 
agxWire::Wire * getWire (agx::UInt index) const
 
bool isWireWireActive () const
 
void removeParallelCallbackHandler (agxSDK::Simulation *simulation)
 Removes object. More...
 
bool setEnableCollisions (agxWire::Wire *wire1, agxWire::Wire *wire2, bool enable)
 Enable, or disable, collision detection and contacts between two wires. More...
 
agx::Bool setEnableDynamicWireContacts (agxCollide::Geometry *geometry, agx::Bool enable)
 Enable, or disable, the use of dynamic wire contact model against this geometry. More...
 
agx::Bool setEnableDynamicWireContacts (agx::RigidBody *rb, agx::Bool enable)
 Enable, or disable, the use of dynamic wire contact model against this rigid body. More...
 
void setEnableDynamicWireContactsGlobally (agx::Bool enable)
 Force all wire contacts to be dynamic. More...
 

Static Public Member Functions

static WireController * instance ()
 

Protected Member Functions

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

Protected Attributes

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

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

Definition at line 63 of file WireController.h.

Definition at line 62 of file WireController.h.

Member Enumeration Documentation

enum agx::Singleton::Priority
inherited

Specifies the ranges of the priority which can be assigned to a singleton at the time of creation.

Enumerator
HIGHEST_PRIORITY 

The highest priority that can be given to a singleton.

LOWEST_PRIORITY 

The lowest priority that can be given to a singleton.

DEFAULT_PRIORITY 

The default priority given to a singleton.

Definition at line 35 of file Singleton.h.

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

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

Member Function Documentation

void agx::Singleton::_shutdown ( )
protectedinherited
agxWire::WireHandler* agxWire::WireController::find ( const agxSDK::Simulation *  simulation)
Returns
wire handler given simulation (0 if none has been created)
agxSDK::Simulation* agxWire::WireController::find ( agxWire::WireHandler *  handler) const
Returns
the simulation given a wire-wire handler (the handler is unique to the simulation)
const agxWire::WireController::WirePtrContainer& agxWire::WireController::getAllWires ( ) const
Returns
all created wires
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().

virtual std::string agx::Singleton::getClassName ( ) const
pure virtualinherited
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
const WireWireContainer& agxWire::WireController::getEnabledWireWirePairs ( ) const

Internal method.

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

agx::Bool agxWire::WireController::getEnableDynamicWireContacts ( const agxCollide::Geometry *  geometry) const
Returns
true if the contact model for geometry is 'dynamic' - otherwise false
agx::Bool agxWire::WireController::getEnableDynamicWireContacts ( const agx::RigidBody *  rb) const
Returns
true if all geometries in rb has contact model 'dynamic' - otherwise false
agx::Bool agxWire::WireController::getEnableDynamicWireContactsGlobally ( ) const
Returns
true if all wire contacts are forced to be dynamic.
WireController::WireIterator agxWire::WireController::getEndWireIterator ( ) const
Returns
end wire iterator

Definition at line 360 of file WireController.h.

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
agxWire::WireHandler* agxWire::WireController::getOrCreateWireHandler ( agxSDK::Simulation *  simulation)
Returns
the wire-wire handler given a simulation (this handler is unique to the simulation)
agxWire::WireParallelCallbacksHandler* agxWire::WireController::getOrCreateWireParallelCallbacksHandler ( agxSDK::Simulation *  simulation)
Returns
the wire parallel callbacks handler given a simulation (this handler is unique to the simulation)
int agx::Singleton::getPriority ( ) const
inherited

Return the shutdown priority of the singleton instance.

agxWire::Wire* agxWire::WireController::getWire ( agx::UInt  index) const
Returns
wire with index index
static WireController* agxWire::WireController::instance ( )
static
Returns
instance of the object handling wire-wire collisions
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
void agxWire::WireController::onAddNotification ( agxWire::Wire *  wire)
protected

Internal method.

All wires should report themselves to this controller during addNotification.

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

Internal method.

All wires should report themselves to this controller during construction.

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

Internal method.

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

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

Internal method.

From removeNotification.

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

Call when the wire is simplified.

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

Call when the wire is unsimplified.

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

Removes object.

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
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
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
void agxWire::WireController::setEnableDynamicWireContactsGlobally ( agx::Bool  enable)

Force all wire contacts to be dynamic.

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

Implement this method to cleanup your Singleton class.

Reimplemented from agx::Singleton.

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

Internal method.

Updates identification number for a wire.

Member Data Documentation

WireWireContainer agxWire::WireController::m_enabledWires
protected

Explicitly enabled collisions pairs.

Definition at line 343 of file WireController.h.

IdWireContainer agxWire::WireController::m_idWire
protected

Wire unique geometry id -> wire.

Definition at line 344 of file WireController.h.

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

Definition at line 350 of file WireController.h.

WireParallelCallbacksHandlerFactoryRef agxWire::WireController::m_parallelCallbacksFactory
protected

Definition at line 346 of file WireController.h.

WireParallelCallbacksHandlerContainer agxWire::WireController::m_parallelCallbacksHandlers
protected

Parallel callbacks handler, unique for each simulation.

Definition at line 347 of file WireController.h.

SimplifiedWiresContainer agxWire::WireController::m_simplifiedWires
protected

Definition at line 348 of file WireController.h.

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

Current global state.

Definition at line 349 of file WireController.h.

WireHandlerContainer agxWire::WireController::m_wireHandlers
protected

Wire handlers, unique for each simulation.

Definition at line 345 of file WireController.h.

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: