AGX Dynamics  2.35.0.1
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 
105 
110 
115 
120 
122 
123 
124  public:
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 
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 
247  };
248 
253  {
254  public:
261  RigidNodeAttachment( agx::RigidBody* rb, const agx::Vec3& relPosition );
262 
270 
272 
273  protected:
278 
283  };
284 
289  {
290  public:
297  RotatingNodeAttachment( agx::RigidBody* rb, const agx::Vec3& relPosition );
298 
305 
307 
308  protected:
313 
318  };
319 
324  {
325  public:
332  SlidingNodeAttachment( agx::RigidBody* rb, const agx::Vec3& relPosition );
333 
340 
342 
343  protected:
348 
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
#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 AGXMODEL_EXPORT
Special node implementation of segments in e.g., a Deformable1D object.
Helper class to create give type of constraint for the different attachments.
virtual agx::ConstraintRef createConstraint(agx::RigidBodyRef rb1, agx::FrameRef f1, agx::RigidBodyRef rb2, agx::FrameRef f2) const override
NodeAttachmentT(agx::RigidBody *rb, agx::Frame *rbAttachmentFrame, agxModel::NodeAttachment::InitializationMode initMode)
Construct given rigid body and a relative frame.
NodeAttachmentT()
Default constructor for serialization.
virtual ~NodeAttachmentT()
Reference counted object, protected destructor.
Base class for attachments to Deformable1D nodes.
agx::AffineMatrix4x4 getWorldMatrix() const
InitializationMode
Each attachment implementation controls the initialization mode.
agx::RigidBody * getRigidBody() const
virtual agx::Bool initialize(agxModel::Deformable1DNode *node)
Initializes constraint.
agx::Constraint * getConstraint() const
virtual ~NodeAttachment()
Reference counted object, protected destructor.
void setName(const agx::String &name)
Name this attachment, e.g., to find this attachment using agxModel::Node::getAttachment( const agx::S...
void store(agxStream::OutputArchive &out) const override
Serialization store.
static agxModel::NodeAttachmentRef createFromWorld(agx::Vec3 worldPoint, agx::RigidBody *rb)
Creates an node attachment given a point in world frame.
const agx::String & getName() const
virtual agx::ConstraintRef createConstraint(agx::RigidBodyRef rb1, agx::FrameRef f1, agx::RigidBodyRef rb2, agx::FrameRef f2) const =0
Create the attachment constraint.
InitializationMode getInitMode() const
agx::Frame * getFrame() const
virtual void storeLightData(agxStream::StorageStream &str) const override
Store structural independent data to stream.
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agxModel::NodeAttachment)
static agxModel::NodeAttachmentRef createFromBody(agx::Vec3 bodyPoint, agx::RigidBody *rb)
Creates an node attachment given a point in rb local frame.
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore structural independent data from stream.
NodeAttachment(agx::RigidBody *rb, agx::Frame *rbAttachmentFrame, agxModel::NodeAttachment::InitializationMode initMode)
Construct given rigid body and a relative frame.
void restore(agxStream::InputArchive &in) override
Serialization restore.
Node attachment using ball joint, i.e., the node will rotate about this attachment.
virtual ~PointNodeAttachment()
Reference counted object, protected destructor.
PointNodeAttachment()
Default constructor for serialization.
PointNodeAttachment(agx::RigidBody *rb, const agx::Vec3 &relPosition)
Construct given rigid body and relative (to rigid body) position.
Node attachment using lock joint, i.e., the node cannot move relative to this attachment.
RigidNodeAttachment(agx::RigidBody *rb, const agx::AffineMatrix4x4 &relTransform)
Construct given rigid body and relative (to rigid body) transform.
virtual ~RigidNodeAttachment()
Reference counted object, protected destructor.
RigidNodeAttachment()
Default constructor for serialization.
RigidNodeAttachment(agx::RigidBody *rb, const agx::Vec3 &relPosition)
Construct given rigid body and relative (to rigid body) position.
Node attachment using hinge joint, i.e., the node can rotate about this attachment.
RotatingNodeAttachment()
Default constructor for serialization.
virtual ~RotatingNodeAttachment()
Reference counted object, protected destructor.
RotatingNodeAttachment(agx::RigidBody *rb, const agx::AffineMatrix4x4 &relTransform)
Construct given rigid body and relative transform.
RotatingNodeAttachment(agx::RigidBody *rb, const agx::Vec3 &relPosition)
Construct given rigid body and relative position.
Node attachment using prismatic joint, i.e., the node can slide along this attachment.
SlidingNodeAttachment(agx::RigidBody *rb, const agx::AffineMatrix4x4 &relTransform)
Construct given rigid body and relative transform.
SlidingNodeAttachment(agx::RigidBody *rb, const agx::Vec3 &relPosition)
Construct given rigid body and relative position.
SlidingNodeAttachment()
Default constructor for serialization.
virtual ~SlidingNodeAttachment()
Reference counted object, protected destructor.
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:52
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:49
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
agx::Vec3 transformPointToLocal(const agx::Vec3 &pointWorld) const
Transform point from the world coordinate frame to this frame.
Definition: agx/Frame.h:626
Base class providing referencing counted objects.
Definition: Referenced.h:114
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
const agx::AffineMatrix4x4 & getTransform() const
Current model frame transform, given in world coordinate frame.
Definition: RigidBody.h:1633
agx::Frame * getFrame()
Returns the model frame containing model the transformation and utilities to manipulate position,...
Definition: RigidBody.h:1484
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:37
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
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.
bool Bool
Definition: Integer.h:48