AGX Dynamics  2.35.0.1
WireController.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agxWire/Wire.h>
20 #include <agxWire/WireHandler.h>
22 
23 #include <agxSDK/Simulation.h>
24 
25 #include <agx/agxPhysics_export.h>
26 #include <agx/Singleton.h>
27 
28 namespace agxWire
29 {
55  {
56  public:
63  typedef std::pair< agxSDK::SimulationObserver, WireParallelCallbacksHandlerRef > SimulationObsWireParallelCallbacksHandlerRefPair;
64  typedef std::pair< agxSDK::SimulationObserver, WirePtrContainer > SimulationObsWirePtrContainerPair;
67 
68  public:
72  enum State
73  {
74  EXPLICIT_ENABLE = (1<<0),
75  ALL_ENABLE = (1<<1),
76  USE_DYNAMIC_CONTACTS = (1<<2),
77  DEFAULT = EXPLICIT_ENABLE
78  };
79 
80  public:
85 
90  bool isWireWireActive() const;
91 
100  bool setEnableCollisions( agxWire::Wire* wire1, agxWire::Wire* wire2, bool enable );
101 
107  bool getEnableCollisions( const agxWire::Wire* wire1, const agxWire::Wire* wire2 ) const;
108 
122 
136 
141 
146 
151 
156 
160  agxWire::WireHandler* getOrCreateWireHandler( agxSDK::Simulation* simulation );
161 
165  agxWire::WireParallelCallbacksHandler* getOrCreateWireParallelCallbacksHandler( agxSDK::Simulation* simulation );
166 
171 
175  agxWire::WireHandler* find( const agxSDK::Simulation* simulation );
176 
180  agxSDK::Simulation* find( agxWire::WireHandler* handler ) const;
181 
186  WireIterator getBeginWireIterator() const;
187 
191  WireIterator getEndWireIterator() const;
192 
198 
202  agxWire::Wire* getWire( agx::UInt index ) const;
203 
208 
210 
211 
215  agxWire::Wire* findWire(agx::UInt32 id) const;
216 
221  agxWire::Wire* findWire(const agxCollide::Geometry* geometry) const;
222 
226  bool add(agxSDK::Simulation* simulation, agxWire::WireHandler* wireHandler);
227 
231  bool remove(agxWire::WireHandler* wireHandler);
232 
236  agx::UInt getStateMask() const;
237 
241  void setStateMask( agx::UInt stateMask );
242 
247  void addState( State state );
248 
253  void removeState( State state );
254 
259  agx::Bool hasState( State state ) const;
260 
264  const agxWire::WireController::IdWireContainer& getIdWireContainer() const;
265 
269  agxWire::WireController::WirePtrContainer getSimplifiedWires(const agxSDK::Simulation* simulation) const;
270 
274  void registerParallelHandlerFactory(agxWire::WireParallelCallbacksHandlerFactory* factory);
275 
279  agxWire::WireParallelCallbacksHandlerFactory* getParallelHandlerFactory() const;
280 
284  agx::ReentrantMutex& getMutex();
285 
287 
291  const agxWire::WireController::WirePtrContainer& getAllWires() const;
292 
293 
294  protected:
296  virtual ~WireController();
297 
298  virtual void shutdown() override;
299 
300  friend class Wire;
301  friend class WireGeometryController;
302  friend class WireSimplifyController;
303 
307  void onCreate( agxWire::Wire* wire );
308 
312  void onAddNotification( agxWire::Wire* wire );
313 
317  void onDelete( agxWire::Wire* wire );
318 
322  void onRemoveNotification( agxWire::Wire* wire );
323 
327  void updateId( agxWire::Wire* wire );
328 
332  void onSimplify( agxSDK::Simulation* simulation, agxWire::Wire* wire );
333 
337  void onUnsimplify( agxSDK::Simulation* simulation, agxWire::Wire* wire );
338 
339  SINGLETON_CLASSNAME_METHOD();
340 
341  protected:
343  WireWireContainer m_enabledWires;
344  IdWireContainer m_idWire;
345  WireHandlerContainer m_wireHandlers;
346  WireParallelCallbacksHandlerFactoryRef m_parallelCallbacksFactory;
347  WireParallelCallbacksHandlerContainer m_parallelCallbacksHandlers;
348  SimplifiedWiresContainer m_simplifiedWires;
349  agx::UInt m_state;
350  agx::ReentrantMutex m_mutex;
351  private:
352  static WireController* s_instance;
353  };
354 
356  {
357  return m_wires.begin();
358  }
359 
361  {
362  return m_wires.end();
363  }
364 }
365 
#define AGXPHYSICS_EXPORT
The geometry representation used by the collision detection engine.
Definition: Geometry.h:93
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
Overlaying object handling wires.
agx::Vector< SimulationObsWirePtrContainerPair > SimplifiedWiresContainer
void setEnableDynamicWireContactsGlobally(agx::Bool enable)
Force all wire contacts to be dynamic.
agxWire::WireHandler * getOrCreateWireHandler(agxSDK::Simulation *simulation)
agx::HashVector< agx::UInt32, agx::observer_ptr< agxWire::Wire > > IdWireContainer
agxWire::WireHandler * find(const agxSDK::Simulation *simulation)
static WireController * instance()
agx::SymmetricPair< agx::observer_ptr< agxWire::Wire > > WireWireSymmetricPair
State
Internal state handling.
const WireWireContainer & getEnabledWireWirePairs() const
Internal method.
agx::Vector< WireWireSymmetricPair > WireWireContainer
agx::Vector< WireHandlerRef > WireHandlerContainer
agxSDK::Simulation * find(agxWire::WireHandler *handler) const
agx::Bool getEnableDynamicWireContactsGlobally() const
std::pair< agxSDK::SimulationObserver, WireParallelCallbacksHandlerRef > SimulationObsWireParallelCallbacksHandlerRefPair
agx::UInt getNumWires() const
Can be used to iterate over all wires in a script language that e.g., not support iterators.
agx::Bool setEnableDynamicWireContacts(agxCollide::Geometry *geometry, agx::Bool enable)
Enable, or disable, the use of dynamic wire contact model against this geometry.
agx::Bool setEnableDynamicWireContacts(agx::RigidBody *rb, agx::Bool enable)
Enable, or disable, the use of dynamic wire contact model against this rigid body.
WireIterator getEndWireIterator() const
bool getEnableCollisions(const agxWire::Wire *wire1, const agxWire::Wire *wire2) const
bool isWireWireActive() const
agx::SetVector< agxWire::Wire * > WirePtrContainer
agx::Bool getEnableDynamicWireContacts(const agx::RigidBody *rb) const
agx::Vector< SimulationObsWireParallelCallbacksHandlerRefPair > WireParallelCallbacksHandlerContainer
agxWire::Wire * getWire(agx::UInt index) 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 getEnableDynamicWireContacts(const agxCollide::Geometry *geometry) const
std::pair< agxSDK::SimulationObserver, WirePtrContainer > SimulationObsWirePtrContainerPair
WirePtrContainer::const_iterator WireIterator
agxWire::WireParallelCallbacksHandler * getOrCreateWireParallelCallbacksHandler(agxSDK::Simulation *simulation)
Interface and placeholder of controllers/helpers for wires.
Definition: Wire.h:62
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: HashVector.h:41
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
iterator begin()
Definition: SetVector.h:272
VectorType::const_iterator const_iterator
Definition: SetVector.h:63
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:31
A std::pair, with both elements of the same type, and symmetric so (a, b) == (b, a)
Definition: SymmetricPair.h:32
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
#define AGX_FORCE_INLINE
Definition: macros.h:58
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
Implements a Wire model with adaptive resolution.
Definition: MergedBody.h:40
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:40
bool Bool
Definition: Integer.h:48
uint32_t UInt
Definition: Integer.h:34
void AGXPHYSICS_EXPORT shutdown()
Shutdown agx.
std::recursive_mutex ReentrantMutex
Definition: Object.h:49