AGX Dynamics  2.37.3.2
WireImpactController.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 <agx/agxPhysics_export.h>
21 
23 
25 
26 
27 #define WIRE_IMPACT_EPSILON ((double)1E-6)
28 
29 
30 namespace agx
31 {
32  class DebugRendererCache;
33 }
34 
35 namespace agxCollide
36 {
37  class Box;
38  class Cylinder;
39  class Mesh;
40 }
41 
42 namespace agxWire
43 {
44  // Forward declarations
45  class WireGeometryController;
46 
48 
49 
50  namespace NodeInvalidFlag
51  {
53  enum Enum { VALID = 0, VALID_CIRCLE_CONTACT, INVALID_PLANE_ANGLE_OR_SAME_EDGE_TEST, INVALID_PASSED_EDGE_TEST, INVALID_PENETRATION_DEPTH_TOO_LARGE, INVALID_SAME_EDGE_TEST, INVALID };
54  }
56 
57  // Small class used to render contact points handled by this controller
58  class WireImpactRenderer : public agxSDK::StepEventListener
59  {
60  public:
61  WireImpactRenderer();
62 
63  virtual void preCollide( const agx::TimeStamp& /*t*/ )
64  {
66  m_clnPND.clear( ContactWireNodeRefPointNormalDepthTable::MAINTAIN_BUFFER );
67  m_wires.clear();
68  }
69 
70  void add( const agxCollide::GeometryContact* geometryContact, bool used = true );
71  void add( const agxCollide::ContactPoint& point, bool used = true );
72  void add( const agxCollide::ContactPoint& point, NodeInvalidFlag::Enum renderFlag );
73  void add( ContactNode* cln );
74  void add( const agx::Vec3& p1, const agx::Vec3& p2, const agx::Vec3& color );
75  void changeRenderFlag( ContactNode* cln, NodeInvalidFlag::Enum renderFlag );
76 
77  void render( agxRender::RenderManager *mgr ) const;
78 
79  protected:
80  virtual ~WireImpactRenderer() {}
81 
82  private:
83  struct PointNormalDepth
84  {
85  PointNormalDepth() : depth( 0 ), renderFlag( NodeInvalidFlag::VALID ) {}
86  PointNormalDepth( agx::Real d, const agx::Vec3& n, const agx::Vec3& p, NodeInvalidFlag::Enum flag )
87  : depth( d ), normal( n ), point( p ), renderFlag( flag ) {}
88  agx::Real depth;
89  agx::Vec3 normal;
90  agx::Vec3 point;
91  NodeInvalidFlag::Enum renderFlag;
92  };
93  typedef agx::HashTable< ContactNodeRef, PointNormalDepth > ContactWireNodeRefPointNormalDepthTable;
94 
95  ContactWireNodeRefPointNormalDepthTable m_clnPND;
97  agx::Vector< agx::Vec3 > m_colors;
99  agx::Vector< std::string > m_descriptions;
100  };
101 
102  typedef agx::ref_ptr< WireImpactRenderer > WireImpactRendererRef;
103 
109  class AGXPHYSICS_EXPORT WireImpactController : public agx::Referenced
110  {
111  public:
112  WireImpactController();
113 
117  virtual void addNotification();
118 
122  virtual void removeNotification();
123 
129  void setWire( WireDistanceCompositeConstraint* wire, WireGeometryController* geometryController );
130 
135  virtual bool handleGeometryContact( agxCollide::GeometryContact* geometryContact );
136 
137 
138  protected:
142  virtual ~WireImpactController();
143 
144 
149  bool handleWire( agxCollide::GeometryContact* geometryContact, agxCollide::Geometry* otherGeometry );
150 
154  agxSDK::SimulationProxy* getSimulationProxy() const;
155 
156  protected:
157  friend class WireOldContactController;
158 
159  protected:
161  WireGeometryController* m_geometryController;
162  };
163 
164  typedef agx::ref_ptr< WireImpactController > WireImpactControllerRef;
165 
166  inline agxSDK::SimulationProxy* WireImpactController::getSimulationProxy() const
167  {
168  return m_wire != nullptr ? m_wire->getSimulationProxy() : nullptr;
169  }
170 }
171 
173 
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Definition: observer_ptr.h:60
This namespace consists of a set of classes for handling geometric intersection tests including boole...
A contact between two geometries.
Definition: Contacts.h:270
#define AGXPHYSICS_EXPORT
agx::Real TimeStamp
Definition: TimeStamp.h:26
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc...
Base class providing referencing counted objects.
Definition: Referenced.h:119
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
Templated vector class.
Definition: Vector.h:52
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Implements a Wire model with adaptive resolution.
Definition: MergedBody.h:39
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
A contact point in a contact data.
Definition: Contacts.h:55
Interface class used by internal objects running in parallel.
double Real
Definition: Real.h:42
Inheritance with partial specialization due to bug with ref_ptr containers.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97