AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agxCable/Attachment.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
19#include <agx/Referenced.h>
20#include <agx/RigidBody.h>
21
22#include <agx/Constraint.h>
23#include <agx/BallJoint.h>
24#include <agx/LockJoint.h>
25
26
27#include <agx/AffineMatrix4x4.h>
28#include <agx/Vec3.h>
29
31
32#include <agxCable/export.h>
33
34
35
36namespace agxCable
37{
38 class CableSegment;
39}
40
41
42
43namespace agxCable
44{
47
48
50 {
51 public:
56 {
58 ROTATE_TO_NODE_DIRECTION
59 };
60
61
62 template<typename T>
63 static agxCable::SegmentAttachmentRef createFromWorld(const agx::Vec3& worldPoint, agx::RigidBody* body);
64
65 template<typename T>
66 static agxCable::SegmentAttachmentRef createFromBody(const agx::Vec3& bodyPoint, agx::RigidBody* body);
67
68 template<typename T>
69 static agxCable::SegmentAttachmentRef createFromWorld(
70 const agx::AffineMatrix4x4& worldTransform, agx::RigidBody* body);
71
72 template<typename T>
73 static agxCable::SegmentAttachmentRef createFromBody(const agx::AffineMatrix4x4& bodyTransform, agx::RigidBody* body);
74
75
76 void setName( const agx::Name& name );
77 const agx::Name& getName() const;
78
80
82
84
86
88 public:
89 virtual agx::Bool initialize(agxCable::CableSegment* segment);
90
92 void store(agxStream::OutputArchive& out) const override;
93 void restore(agxStream::InputArchive& in) override;
95
96 protected:
97 SegmentAttachment(agx::RigidBody* body, agx::Frame* rbSegmentAttachmentFrame,
99
100 SegmentAttachment(const agx::Name& name, agx::RigidBody* body, agx::Frame* bodyAttachmentFrame,
101 agx::Constraint* constraint, InitializationMode initMode);
102
104
105 virtual agx::ConstraintRef createConstraint(
106 agx::RigidBodyRef body1, agx::FrameRef frame1,
107 agx::RigidBodyRef body2, agx::FrameRef frame2) const = 0;
108
109
110 protected:
111 agx::Name m_name;
112 agx::RigidBodyRef m_body;
113 agx::FrameRef m_bodyAttachmentFrame;
114 agx::ConstraintRef m_constraint;
116 };
117
118
119
120
124 template<typename T>
126 {
127 public:
135 agx::RigidBody* body, agx::Frame* rbSegmentAttachmentFrame,
137 : SegmentAttachment(body, rbSegmentAttachmentFrame, initMode)
138 {
139 }
140
141 protected:
146 : SegmentAttachment(nullptr, nullptr, agxCable::SegmentAttachment::ROTATE_TO_NODE_DIRECTION)
147 {
148 }
149
150
151 SegmentAttachmentT(const agx::Name& name, agx::RigidBody* body, agx::Frame* bodyAttachmentFrame,
153 : SegmentAttachment(name, body, bodyAttachmentFrame, constraint, initMode)
154 {
155 }
156
161
166 agx::RigidBodyRef body1, agx::FrameRef frame1,
167 agx::RigidBodyRef body2, agx::FrameRef frame2) const override
168 {
169 return new T(body1, frame1, body2, frame2);
170 }
171 };
172
173#ifdef SWIG
174%template(SegmentAttachmentBallJoint) agxCable::SegmentAttachmentT<agx::BallJoint>;
175%template(SegmentAttachmentLockJoint) agxCable::SegmentAttachmentT<agx::LockJoint>;
176#endif
177
179 {
180 public:
181 PointSegmentAttachment(agx::RigidBody* body, const agx::Vec3& relativeTranslate);
182
184 public:
185 PointSegmentAttachment(const agx::Name& name, agx::RigidBody* body, agx::Frame* bodyAttachmentFrame,
186 agx::Constraint* constraint, agxCable::SegmentAttachment::InitializationMode initMode)
187 : SegmentAttachmentT<agx::BallJoint>(name, body, bodyAttachmentFrame, constraint, initMode)
188 {
189 }
190
192 using agxCable::SegmentAttachment::restore;
194
195 protected:
198 };
199
200
201
203 {
204 public:
205 RigidSegmentAttachment(agx::RigidBody* body, const agx::Vec3& relativeTranslate);
207
208
210 public:
211 RigidSegmentAttachment(const agx::Name& name, agx::RigidBody* body, agx::Frame* bodyAttachmentFrame,
212 agx::Constraint* constraint, agxCable::SegmentAttachment::InitializationMode initMode)
213 : SegmentAttachmentT<agx::LockJoint>(name, body, bodyAttachmentFrame, constraint, initMode)
214 {
215 }
216
218 using agxCable::SegmentAttachment::restore;
220
221 protected:
224 };
225
226
227
228 template<typename T>
230 const agx::Vec3& worldPoint, agx::RigidBody* body)
231 {
232 agx::Vec3 localPoint = body != nullptr ? body->getFrame()->transformPointToLocal(worldPoint) : worldPoint;
233 return createFromBody<T>(localPoint, body);
234 }
235
236
237
238 template<typename T>
240 const agx::Vec3& bodyPoint, agx::RigidBody* body)
241 {
242 return new T(body, bodyPoint);
243 }
244
245
246
247 template<typename T>
249 const agx::AffineMatrix4x4& worldTransform, agx::RigidBody* body)
250 {
251 agx::AffineMatrix4x4 localTransform =
252 body != nullptr ? worldTransform * body->getTransform().inverse() : worldTransform;
253 return createFromBody<T>(localTransform, body);
254 }
255
256
257
258 template<typename T>
260 const agx::AffineMatrix4x4& bodyTransform, agx::RigidBody* body)
261 {
262 return new T(body, bodyTransform);
263 }
264}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
Definition: Serializable.h:221
#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
A CableSegment represents a single link of a cable.
Definition: CableSegment.h:46
PointSegmentAttachment(agx::RigidBody *body, const agx::Vec3 &relativeTranslate)
RigidSegmentAttachment(agx::RigidBody *body, const agx::Vec3 &relativeTranslate)
RigidSegmentAttachment(agx::RigidBody *body, const agx::AffineMatrix4x4 &relativeTransform)
Helper class to create give type of constraint for the different SegmentAttachments.
virtual agx::ConstraintRef createConstraint(agx::RigidBodyRef body1, agx::FrameRef frame1, agx::RigidBodyRef body2, agx::FrameRef frame2) const override
SegmentAttachmentT(agx::RigidBody *body, agx::Frame *rbSegmentAttachmentFrame, agxCable::SegmentAttachment::InitializationMode initMode)
Construct given rigid body and a relative frame.
SegmentAttachmentT()
Default constructor for serialization.
virtual ~SegmentAttachmentT()
Reference counted object, protected destructor.
SegmentAttachmentT(const agx::Name &name, agx::RigidBody *body, agx::Frame *bodyAttachmentFrame, agx::Constraint *constraint, agxCable::SegmentAttachment::InitializationMode initMode)
static agxCable::SegmentAttachmentRef createFromWorld(const agx::Vec3 &worldPoint, agx::RigidBody *body)
void setName(const agx::Name &name)
agx::Frame * getFrame() const
agx::AffineMatrix4x4 getWorldMatrix() const
const agx::Name & getName() const
InitializationMode
Each SegmentAttachment implementation controls the initialization mode.
static agxCable::SegmentAttachmentRef createFromBody(const agx::Vec3 &bodyPoint, agx::RigidBody *body)
agx::Constraint * getConstraint() const
agx::RigidBody * getRigidBody() const
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
AffineMatrix4x4T< T > inverse() const
Quick inverse, transpose rotation part, and change sign of translation part.
The base class for a constraint.
Definition: Constraint.h:89
The object defining a frame of reference and providing transformations operations.
Definition: agx/Frame.h:68
Representation of a name string.
Definition: Name.h:33
Base class providing referencing counted objects.
Definition: Referenced.h:120
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:49
const agx::AffineMatrix4x4 & getTransform() const
Current model frame transform, given in world coordinate frame.
Definition: RigidBody.h:1253
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
Contain classes for 6 DOF lumped element cables/wires/ropes.
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.