AGX Dynamics  2.35.0.1
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 
75 
88 
101 
106 
107 
119 
124 
135 
142 
143 
148 
156  virtual agx::Real getRestLength() const override;
157 
165  virtual agx::Real getCurrentLength() const override;
166 
174 
181 
186 
192 
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 
228 
229 
234 
236 
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 
269 
276 
282 
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 }
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#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
#define AGXCABLE_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
Class controlling material properties of one or more cables.
A CableSegment represents a single link of a cable.
Definition: CableSegment.h:46
A model of a cable using a lumped elements model.
Definition: Cable.h:44
static agx::StringVector getAvailableLibraryProperties()
Returns a vector with all the named CableProperties that were found in the Material Library.
agx::Real getResolution() const
Returns the resolution of the cable, measured in units of length per segment.
static Cable * find(agxSDK::Simulation *simulation, const agx::Uuid &uuid)
This method will do a linear search in Simulation and return a pointer to the specified Cable.
agxCable::CableProperties * getCableProperties() const
Return the cable properties for this cable.
agxCable::CableIterator begin() const
Returns an iterator that walks over the segments of the cable.
static agxCable::Cable * getCableForGeometry(agxCollide::Geometry *geometry)
agxCable::RouteInitializationReport getInitializationReport() const
agxCable::CableIterator end() const
Returns an iterator pointing one-past the last segment.
agx::UInt getNumSegments() const
Returns the number of segments in the cable.
static agxCable::Cable * asCable(agxSDK::Assembly *assembly)
static agxCable::CablePtrVector getAll(agxSDK::Simulation *simulation)
Collect all Cables in the given simulation.
agx::Bool add(agxCable::RoutingNode *node)
Add the given cable node to the end of the cable.
agxCable::CableIterator begin()
virtual agx::Real getCurrentLength() const override
Get the current length of the cable, including any stretching.
static Cable * find(agxSDK::Simulation *simulation, const agx::Name &name)
This method will do a linear search in Simulation and return a pointer to the specified Cable.
bool attach(agxCable::CableIterator segment, agx::RigidBody *body, const agx::Vec3 &relativeTranslate)
Attach the given segment to the given rigid body using a BallJoint that lets the cable rotate freely ...
bool attach(agxCable::CableIterator segment, agx::RigidBody *body, const agx::AffineMatrix4x4 &relativeTransform)
Attach the given segment to the given rigid body using a LockJoint.
void setCableProperties(agxCable::CableProperties *cableProperties)
Set the cable properties object used by this cable.
agxCable::CableIterator findLast() const
Returns an iterator pointing to the last segment.
static const agxCable::Cable * getCableForBody(const agx::RigidBody *body)
static agxCable::Cable * getCableForBody(agx::RigidBody *body)
virtual agx::Real getRestLength() const override
Get the rest length of the cable.
agxCable::CableIterator end()
static agxCable::CablePtrVector findAll(agxSDK::Simulation *simulation, const agx::Name &name)
This method will do a linear search in Simulation and return a vector with pointers to all matching C...
agxCable::RouteInitializationReport tryInitialize(agx::Real maxError)
Make a dry-run with a specified maximum allowed routing error.
agxCable::SegmentRange getSegments() const
Cable(agx::Real radius, agxCable::HomogeneousSegmentsRoute *routingAlgorithm)
Create a new cable using the given routing algorithm.
Cable(agx::Real radius, agx::Real resolutionPerUnitLength)
Create a new cable with the given radius and resolution.
static const agxCable::Cable * getCableForGeometry(const agxCollide::Geometry *geometry)
agxCable::RouteInitializationReport tryInitialize()
Make a dry-run of the cable initialization.
agx::Real getRadius() const
bool loadLibraryProperties(const agx::String &name)
Load named CableProperties from the Material Library for the current Cable.
An ordered collection of agxCable::Node objects that has been added to a particular cable.
Definition: Route.h:41
Base class for route nodes that defines the path and some behavior of a cable.
Definition: agxCable/Node.h:37
The geometry representation used by the collision detection engine.
Definition: Geometry.h:93
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints,...
Definition: Assembly.h:67
Optionally unbounded linked structure segment iterator object to iterate segments in a SegmentStructu...
Segment range object for linked structure.
Basic implementation of any structure where bodies are linked/constrained together in a well defined ...
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
Representation of a name string.
Definition: Name.h:33
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:42
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
Contain classes for 6 DOF lumped element cables/wires/ropes.
AGXCABLE_EXPORT agxCable::CableIterator end(const agxCable::Cable &cable)
AGXCABLE_EXPORT agxCable::CableIterator begin(const agxCable::Cable &cable)
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
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
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:40
bool Bool
Definition: Integer.h:48
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42