AGXDynamics  2.31.1.0
Cable.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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 
277 
279  public:
282 
283  protected:
285  Cable();
286 
287  virtual ~Cable();
288 
290  agxCable::HomogeneousSegmentsRoute* getRoute() const;
291 
292  protected:
293  virtual void onAddNotification(agxSDK::Simulation* simulation) override;
294  virtual void onPreStep() override;
295  virtual void onPostStep() override;
296 
297  private:
298  friend class CableSegment;
299  void onAttachmentAdded(agxCable::CableSegment* segment, agxCable::SegmentAttachment* attachment);
300 
301  private:
303  void restoreFromLinkedCable(agxStream::InputArchive& in);
304 
306  void restoreFromDeformable1D(agxStream::InputArchive& in);
307 
308  private:
309  enum StateEnum : agx::UInt32
310  {
311  INITIALIZED = 1 << 0, // After add notification and route successfully initialized.
312  };
313  using State = agx::BitState<StateEnum, agx::UInt32>;
314 
315 
316  private:
317  agx::Real m_radius;
318 
319  agxCable::HomogeneousSegmentsRouteRef m_initializationRoute;
320  agxCable::RouteInitializationReport m_initializationReport;
321 
322  agxCable::CablePropertiesRef m_properties;
323 
324  State m_state;
325  };
326 
327 
328  // Needed by for-each loops.
331 }
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:248
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)
AGX_DECLARE_VECTOR_TYPES(CollisionGroupFilter)
The geometry representation used by the collision detection engine.
Definition: Geometry.h:88
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
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:52
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:206
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:121
double Real
Definition: Real.h:42
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:102
#define AGXCABLE_EXPORT
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:101
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints, geometries.
Definition: Assembly.h:73