AGXDynamics  2.35.0.3
Cable.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 <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 }
agxCable::SegmentAttachment
Definition: able/Attachment.h:49
CableProperties.h
LinkedStructure.h
agx::Real
double Real
Definition: Real.h:42
export.h
agx::Vector< AgXString< std::string > >
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
agx::AffineMatrix4x4T< Real >
agxCable
Contain classes for 6 DOF lumped element cables/wires/ropes.
Definition: able/Attachment.h:36
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
agxCable::Cable
A model of a cable using a lumped elements model.
Definition: Cable.h:43
AGXSTREAM_DECLARE_SERIALIZABLE
#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
agx::VectorPOD
Vector containing 'raw' data.
Definition: Vector.h:245
AGXCABLE_EXPORT
#define AGXCABLE_EXPORT
Definition: agxCable/export.h:41
agxStream::in
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
agxCable::end
AGXCABLE_EXPORT agxCable::CableIterator end(const agxCable::Cable &cable)
AGX_DECLARE_VECTOR_TYPES
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
agxSDK::Assembly
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints,...
Definition: Assembly.h:66
agx::ref_ptr< HomogeneousSegmentsRoute >
Route.h
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agxSDK::LinkedStructure
Basic implementation of any structure where bodies are linked/constrained together in a well defined ...
Definition: LinkedStructure.h:35
agxCollide::Geometry
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
agx::Name
Representation of a name string.
Definition: Name.h:32
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
agx::GraphNode::State
State
Definition: GraphNode.h:39
agxCable::CableProperties
Class controlling material properties of one or more cables.
Definition: CableProperties.h:35
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agx::UInt
uint32_t UInt
Definition: Integer.h:34
agx::Bool
bool Bool
Definition: Integer.h:48
CableIterator.h
agxCable::CableSegment
A CableSegment represents a single link of a cable.
Definition: CableSegment.h:45
agxCable::HomogeneousSegmentsRoute
An ordered collection of agxCable::Node objects that has been added to a particular cable.
Definition: Route.h:40
agx::AgXString< std::string >
agxCable::RouteInitializationReport
Definition: RouteInitializationReport.h:28
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
agx::Vec3T< Real >
agxSDK::LinkedSegmentRange
Segment range object for linked structure.
Definition: LinkedSegmentRange.h:27
agx::Uuid
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
agxSDK::LinkedSegmentIterator
Optionally unbounded linked structure segment iterator object to iterate segments in a SegmentStructu...
Definition: LinkedSegmentIterator.h:28
agxCable::begin
AGXCABLE_EXPORT agxCable::CableIterator begin(const agxCable::Cable &cable)
agx::UInt32
uint32_t UInt32
Definition: Integer.h:40
agxCable::RoutingNode
Base class for route nodes that defines the path and some behavior of a cable.
Definition: agxCable/Node.h:36