AGXDynamics  2.35.0.2
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:
84  static WireController* instance();
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 
121  agx::Bool setEnableDynamicWireContacts( agxCollide::Geometry* geometry, agx::Bool enable );
122 
135  agx::Bool setEnableDynamicWireContacts( agx::RigidBody* rb, agx::Bool enable );
136 
140  void setEnableDynamicWireContactsGlobally( agx::Bool enable);
141 
145  agx::Bool getEnableDynamicWireContacts( const agxCollide::Geometry* geometry ) const;
146 
150  agx::Bool getEnableDynamicWireContacts( const agx::RigidBody* rb ) const;
151 
155  agx::Bool getEnableDynamicWireContactsGlobally() const;
156 
160  agxWire::WireHandler* getOrCreateWireHandler( agxSDK::Simulation* simulation );
161 
165  agxWire::WireParallelCallbacksHandler* getOrCreateWireParallelCallbacksHandler( agxSDK::Simulation* simulation );
166 
170  void removeParallelCallbackHandler( agxSDK::Simulation* simulation );
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 
197  agx::UInt getNumWires() const;
198 
202  agxWire::Wire* getWire( agx::UInt index ) const;
203 
207  const WireWireContainer& getEnabledWireWirePairs() const;
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:
295  WireController();
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 
agxPhysics_export.h
agx::SymmetricPair
A std::pair, with both elements of the same type, and symmetric so (a, b) == (b, a)
Definition: SymmetricPair.h:31
agxWire::WireController::getEndWireIterator
WireIterator getEndWireIterator() const
Definition: WireController.h:360
agx::Vector< WireWireSymmetricPair >
Simulation.h
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
WireParallelCallbacksHandler.h
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
Wire.h
agx::SetVector< agxWire::Wire * >::const_iterator
VectorType::const_iterator const_iterator
Definition: SetVector.h:63
agxWire::WireController::WireIterator
WirePtrContainer::const_iterator WireIterator
Definition: WireController.h:58
agxWire::WireController::WireWireSymmetricPair
agx::SymmetricPair< agx::observer_ptr< agxWire::Wire > > WireWireSymmetricPair
Definition: WireController.h:59
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
agxWire::WireController::IdWireContainer
agx::HashVector< agx::UInt32, agx::observer_ptr< agxWire::Wire > > IdWireContainer
Definition: WireController.h:61
agxWire::Wire
Interface and placeholder of controllers/helpers for wires.
Definition: Wire.h:61
agxWire::WireController::SimulationObsWirePtrContainerPair
std::pair< agxSDK::SimulationObserver, WirePtrContainer > SimulationObsWirePtrContainerPair
Definition: WireController.h:64
agx::SetVector::begin
iterator begin()
Definition: SetVector.h:272
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agx::shutdown
void AGXPHYSICS_EXPORT shutdown()
Shutdown agx.
agx::SetVector< agxWire::Wire * >
agxWire::WireController::SimplifiedWiresContainer
agx::Vector< SimulationObsWirePtrContainerPair > SimplifiedWiresContainer
Definition: WireController.h:66
agxWire
Implements a Wire model with adaptive resolution.
Definition: MergedBody.h:39
agxWire::WireController::WireHandlerContainer
agx::Vector< WireHandlerRef > WireHandlerContainer
Definition: WireController.h:62
agx::Singleton
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:30
agxWire::WireController::State
State
Internal state handling.
Definition: WireController.h:72
agxWire::WireController::SimulationObsWireParallelCallbacksHandlerRefPair
std::pair< agxSDK::SimulationObserver, WireParallelCallbacksHandlerRef > SimulationObsWireParallelCallbacksHandlerRefPair
Definition: WireController.h:63
agxWire::WireController::WirePtrContainer
agx::SetVector< agxWire::Wire * > WirePtrContainer
Definition: WireController.h:57
agxUtil::setEnableCollisions
AGXPHYSICS_EXPORT bool setEnableCollisions(agx::RigidBody *rb1, agx::RigidBody *rb2, bool enable)
Enable or disable the collision between all geometries in RigidBody rb1 and RigidBody rb2.
agxCollide::Geometry
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
agxWire::WireController::WireParallelCallbacksHandlerContainer
agx::Vector< SimulationObsWireParallelCallbacksHandlerRefPair > WireParallelCallbacksHandlerContainer
Definition: WireController.h:65
agx::GraphNode::State
State
Definition: GraphNode.h:39
agx::UInt
uint32_t UInt
Definition: Integer.h:34
agx::ReentrantMutex
std::recursive_mutex ReentrantMutex
Definition: Object.h:49
agxCollide
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Definition: ContactForceFilterParticipant.h:22
agx::Bool
bool Bool
Definition: Integer.h:48
Singleton.h
agxWire::WireController::WireWireContainer
agx::Vector< WireWireSymmetricPair > WireWireContainer
Definition: WireController.h:60
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
WireHandler.h
agx::UInt32
uint32_t UInt32
Definition: Integer.h:40
agx::HashVector
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: HashVector.h:40
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agxWire::WireController
Overlaying object handling wires.
Definition: WireController.h:54