AGXDynamics  2.35.0.2
Deformable1DAttachment.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 #ifndef AGXMODEL_DEFORMABLE1DATTACHMENT_H
18 #define AGXMODEL_DEFORMABLE1DATTACHMENT_H
19 
20 #include <agxModel/export.h>
21 
22 #include <agx/LockJoint.h>
23 #include <agx/BallJoint.h>
24 #include <agx/Hinge.h>
25 #include <agx/Prismatic.h>
26 
27 namespace agxModel
28 {
29  class Deformable1DNode;
30 
32 
37  {
38  public:
43  {
45  ROTATE_TO_NODE_DIRECTION
46  };
47 
48  public:
56  template< typename T >
57  static agxModel::NodeAttachmentRef createFromWorld( agx::Vec3 worldPoint, agx::RigidBody* rb );
58 
66  template< typename T >
67  static agxModel::NodeAttachmentRef createFromBody( agx::Vec3 bodyPoint, agx::RigidBody* rb );
68 
76  template< typename T >
77  static agxModel::NodeAttachmentRef createFromWorld( agx::AffineMatrix4x4 worldTransform, agx::RigidBody* rb );
78 
86  template< typename T >
87  static agxModel::NodeAttachmentRef createFromBody( agx::AffineMatrix4x4 bodyTransform, agx::RigidBody* rb );
88 
89  public:
94  void setName( const agx::String& name );
95 
99  const agx::String& getName() const;
100 
104  agx::Frame* getFrame() const;
105 
109  agx::Constraint* getConstraint() const;
110 
114  agx::RigidBody* getRigidBody() const;
115 
119  agx::AffineMatrix4x4 getWorldMatrix() const;
120 
121  InitializationMode getInitMode() const;
122 
123 
124  public:
128  virtual agx::Bool initialize(agxModel::Deformable1DNode* node);
129 
131 
135  virtual void storeLightData( agxStream::StorageStream& str ) const override;
136 
140  virtual void restoreLightData( agxStream::StorageStream& str ) override;
141 
142  protected:
150 
154  void store( agxStream::OutputArchive& out ) const override;
155 
159  void restore( agxStream::InputArchive& in ) override;
160 
161  protected:
165  virtual ~NodeAttachment();
166 
170  virtual agx::ConstraintRef createConstraint( agx::RigidBodyRef rb1, agx::FrameRef f1, agx::RigidBodyRef rb2, agx::FrameRef f2 ) const = 0;
171 
172  protected:
178  };
179 
183  template< typename T >
185  {
186  public:
193  NodeAttachmentT( agx::RigidBody* rb, agx::Frame* rbAttachmentFrame, agxModel::NodeAttachment::InitializationMode initMode ) : NodeAttachment( rb, rbAttachmentFrame, initMode ) {}
194 
195  protected:
200 
204  virtual ~NodeAttachmentT() {}
205 
210  {
211  return new T( rb1, f1, rb2, f2 );
212  }
213  };
214 
215 #ifdef SWIG
216  %template(NodeAttachmentTBallJoint) agxModel::NodeAttachmentT<agx::BallJoint>;
217  %template(NodeAttachmentTLockJoint) agxModel::NodeAttachmentT<agx::LockJoint>;
218  %template(NodeAttachmentTHinge) agxModel::NodeAttachmentT<agx::Hinge>;
219  %template(NodeAttachmentTPrismatic) agxModel::NodeAttachmentT<agx::Prismatic>;
220 #endif
221 
226  {
227  public:
233  PointNodeAttachment( agx::RigidBody* rb, const agx::Vec3& relPosition );
234 
236 
237  protected:
242 
246  virtual ~PointNodeAttachment();
247  };
248 
253  {
254  public:
261  RigidNodeAttachment( agx::RigidBody* rb, const agx::Vec3& relPosition );
262 
269  RigidNodeAttachment( agx::RigidBody* rb, const agx::AffineMatrix4x4& relTransform );
270 
272 
273  protected:
278 
282  virtual ~RigidNodeAttachment();
283  };
284 
289  {
290  public:
297  RotatingNodeAttachment( agx::RigidBody* rb, const agx::Vec3& relPosition );
298 
304  RotatingNodeAttachment( agx::RigidBody* rb, const agx::AffineMatrix4x4& relTransform );
305 
307 
308  protected:
313 
317  virtual ~RotatingNodeAttachment();
318  };
319 
324  {
325  public:
332  SlidingNodeAttachment( agx::RigidBody* rb, const agx::Vec3& relPosition );
333 
339  SlidingNodeAttachment( agx::RigidBody* rb, const agx::AffineMatrix4x4& relTransform );
340 
342 
343  protected:
348 
352  virtual ~SlidingNodeAttachment();
353  };
354 
355  template< typename T >
357  {
358  return createFromBody< T >( (rb != nullptr ? rb->getFrame()->transformPointToLocal( worldPoint ) : worldPoint), rb );
359  }
360 
361  template< typename T >
363  {
364  return new T( rb, bodyPoint );
365  }
366 
367  template< typename T >
369  {
370  return createFromBody< T >( (rb != nullptr ? worldTransform * rb->getTransform().inverse() : worldTransform), rb );
371  }
372 
373  template< typename T >
375  {
376  return new T( rb, bodyTransform );
377  }
378 }
379 
380 #endif // AGXMODEL_DEFORMABLE1DATTACHMENT_H
agxModel::NodeAttachment::ROTATE_TO_NODE_DIRECTION
@ ROTATE_TO_NODE_DIRECTION
Definition: Deformable1DAttachment.h:45
agxModel
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
Hinge.h
agxModel::NodeAttachmentT::~NodeAttachmentT
virtual ~NodeAttachmentT()
Reference counted object, protected destructor.
Definition: Deformable1DAttachment.h:204
agxStream::out
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
Definition: OutputArchive.h:412
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
agxStream::Serializable
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
export.h
agx::AffineMatrix4x4T< Real >
agx::Frame::transformPointToLocal
agx::Vec3 transformPointToLocal(const agx::Vec3 &pointWorld) const
Transform point from the world coordinate frame to this frame.
Definition: Frame.h:626
agxStream::StorageStream
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE
#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
agxModel::RotatingNodeAttachment
Node attachment using hinge joint, i.e., the node can rotate about this attachment.
Definition: Deformable1DAttachment.h:288
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
agxModel::NodeAttachment::m_constraint
agx::ConstraintRef m_constraint
Definition: Deformable1DAttachment.h:176
Prismatic.h
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
agx::RigidBody::getTransform
const agx::AffineMatrix4x4 & getTransform() const
Current model frame transform, given in world coordinate frame.
Definition: RigidBody.h:1633
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agxModel::NodeAttachment::InitializationMode
InitializationMode
Each attachment implementation controls the initialization mode.
Definition: Deformable1DAttachment.h:42
agxModel::NodeAttachment
Base class for attachments to Deformable1D nodes.
Definition: Deformable1DAttachment.h:36
agxModel::NodeAttachment::m_rbAttachmentFrame
agx::FrameRef m_rbAttachmentFrame
Definition: Deformable1DAttachment.h:175
agxModel::NodeAttachment::m_rb
agx::RigidBodyRef m_rb
Definition: Deformable1DAttachment.h:174
agxModel::NodeAttachmentT::createConstraint
virtual agx::ConstraintRef createConstraint(agx::RigidBodyRef rb1, agx::FrameRef f1, agx::RigidBodyRef rb2, agx::FrameRef f2) const override
Definition: Deformable1DAttachment.h:209
agxModel::NodeAttachment::createFromWorld
static agxModel::NodeAttachmentRef createFromWorld(agx::Vec3 worldPoint, agx::RigidBody *rb)
Creates an node attachment given a point in world frame.
Definition: Deformable1DAttachment.h:356
LockJoint.h
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
agxModel::RigidNodeAttachment
Node attachment using lock joint, i.e., the node cannot move relative to this attachment.
Definition: Deformable1DAttachment.h:252
agxModel::SlidingNodeAttachment
Node attachment using prismatic joint, i.e., the node can slide along this attachment.
Definition: Deformable1DAttachment.h:323
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
agxModel::NodeAttachment::m_name
agx::String m_name
Definition: Deformable1DAttachment.h:173
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agxModel::NodeAttachmentT
Helper class to create give type of constraint for the different attachments.
Definition: Deformable1DAttachment.h:184
agx::Bool
bool Bool
Definition: Integer.h:48
agx::Constraint
The base class for a constraint.
Definition: Constraint.h:88
agxModel::NodeAttachment::createFromBody
static agxModel::NodeAttachmentRef createFromBody(agx::Vec3 bodyPoint, agx::RigidBody *rb)
Creates an node attachment given a point in rb local frame.
Definition: Deformable1DAttachment.h:362
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agx::AgXString< std::string >
agx::AffineMatrix4x4T::inverse
AffineMatrix4x4T< T > inverse() const
Quick inverse, transpose rotation part, and change sign of translation part.
Definition: AffineMatrix4x4.h:455
agxModel::NodeAttachmentT::NodeAttachmentT
NodeAttachmentT(agx::RigidBody *rb, agx::Frame *rbAttachmentFrame, agxModel::NodeAttachment::InitializationMode initMode)
Construct given rigid body and a relative frame.
Definition: Deformable1DAttachment.h:193
agx::RigidBody::getFrame
agx::Frame * getFrame()
Returns the model frame containing model the transformation and utilities to manipulate position,...
Definition: RigidBody.h:1484
agx::Vec3T< Real >
agxModel::PointNodeAttachment
Node attachment using ball joint, i.e., the node will rotate about this attachment.
Definition: Deformable1DAttachment.h:225
agxModel::Deformable1DNode
Special node implementation of segments in e.g., a Deformable1D object.
Definition: Deformable1DNode.h:36
agxModel::NodeAttachment::m_initMode
InitializationMode m_initMode
Definition: Deformable1DAttachment.h:177
agx::Frame
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
agxModel::NodeAttachment::USE_RELATIVE_TRANSFORM
@ USE_RELATIVE_TRANSFORM
Definition: Deformable1DAttachment.h:44
BallJoint.h
agxModel::NodeAttachmentT::NodeAttachmentT
NodeAttachmentT()
Default constructor for serialization.
Definition: Deformable1DAttachment.h:199