AGX Dynamics  2.37.3.2
Cable.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 <agxSDK/LinkedStructure.h>
20 
21 #include <agxCable/export.h>
23 #include <agxCable/CableIterator.h>
24 #include <agxCable/Route.h>
25 
26 namespace agxSDK
27 {
28  class Simulation;
29 }
30 
31 namespace agxCable
32 {
33  class RoutingNode;
34 
35 
38 
44  {
45  public:
46 
59  Cable(agx::Real radius, agx::Real resolutionPerUnitLength);
60 
61 
74  Cable(agx::Real radius, agxCable::HomogeneousSegmentsRoute* routingAlgorithm);
75 
88 
100  agxCable::RouteInitializationReport tryInitialize();
101 
105  agxCable::RouteInitializationReport getInitializationReport() const;
106 
107 
118  agxCable::RouteInitializationReport tryInitialize(agx::Real maxError);
119 
123  agxCable::SegmentRange getSegments() const;
124 
134  agx::UInt getNumSegments() const;
135 
141  agx::Real getResolution() const;
142 
143 
147  agx::Real getRadius() const;
148 
156  virtual agx::Real getRestLength() const override;
157 
165  virtual agx::Real getCurrentLength() const override;
166 
174 
181 
185  agxCable::CableIterator findLast() const;
186 
191  agxCable::CableProperties* getCableProperties() const;
192 
198  void setCableProperties(agxCable::CableProperties* cableProperties);
199 
210  bool attach(agxCable::CableIterator segment, agx::RigidBody* body, const agx::Vec3& relativeTranslate);
211 
224  bool attach(agxCable::CableIterator segment, agx::RigidBody* body, const agx::AffineMatrix4x4& relativeTransform);
225 
226 
227  static agxCable::Cable* asCable(agxSDK::Assembly* assembly);
228 
229 
233  static agxCable::Cable* getCableForGeometry(agxCollide::Geometry* geometry);
234 
235  static const agxCable::Cable* getCableForGeometry(const agxCollide::Geometry* geometry);
236 
240  static agxCable::Cable* getCableForBody(agx::RigidBody* body);
241  static const agxCable::Cable* getCableForBody(const agx::RigidBody* body);
242 
250  static Cable* find(agxSDK::Simulation* simulation, const agx::Name& name);
251 
259  static Cable* find(agxSDK::Simulation* simulation, const agx::Uuid& uuid);
260 
268  static agxCable::CablePtrVector findAll(agxSDK::Simulation* simulation, const agx::Name& name);
269 
275  static agxCable::CablePtrVector getAll(agxSDK::Simulation* simulation);
276 
281  bool loadLibraryProperties(const agx::String& name);
282 
287  static agx::StringVector getAvailableLibraryProperties();
288 
289 
291  public:
294 
295  protected:
297  Cable();
298 
299  virtual ~Cable();
300 
302  agxCable::HomogeneousSegmentsRoute* getRoute() const;
303 
304  protected:
305  virtual void onAddNotification(agxSDK::Simulation* simulation) override;
306  virtual void onPreStep() override;
307  virtual void onPostStep() override;
308 
309  private:
310  friend class CableSegment;
311  void onAttachmentAdded(agxCable::CableSegment* segment, agxCable::SegmentAttachment* attachment);
312 
313  private:
315  void restoreFromLinkedCable(agxStream::InputArchive& in);
316 
318  void restoreFromDeformable1D(agxStream::InputArchive& in);
319 
320  private:
321  enum StateEnum : agx::UInt32
322  {
323  INITIALIZED = 1 << 0, // After add notification and route successfully initialized.
324  };
325  using State = agx::BitState<StateEnum, agx::UInt32>;
326 
327 
328  private:
329  agx::Real m_radius;
330 
331  agxCable::HomogeneousSegmentsRouteRef m_initializationRoute;
332  agxCable::RouteInitializationReport m_initializationReport;
333 
334  agxCable::CablePropertiesRef m_properties;
335 
336  State m_state;
337  };
338 
339 
340  // Needed by for-each loops.
343 }
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:400
Basic implementation of any structure where bodies are linked/constrained together in a well defined ...
bool Bool
Definition: Integer.h:48
Segment range object for linked structure.
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
An ordered collection of agxCable::Node objects that has been added to a particular cable...
Definition: Route.h:40
Representation of a name string.
Definition: Name.h:32
AGXCABLE_EXPORT agxCable::CableIterator end(const agxCable::Cable &cable)
AGXCABLE_EXPORT agxCable::CableIterator begin(const agxCable::Cable &cable)
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
A model of a cable using a lumped elements model.
Definition: Cable.h:43
Class controlling material properties of one or more cables.
Contain classes for 6 DOF lumped element cables/wires/ropes.
uint32_t UInt
Definition: Integer.h:34
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
A CableSegment represents a single link of a cable.
Definition: CableSegment.h:45
Base class for route nodes that defines the path and some behavior of a cable.
Definition: agxCable/Node.h:36
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
Optionally unbounded linked structure segment iterator object to iterate segments in a SegmentStructu...
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
double Real
Definition: Real.h:42
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
uint32_t UInt32
Definition: Integer.h:40
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define AGXCABLE_EXPORT
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints, geometries.
Definition: Assembly.h:66