AGX Dynamics  2.37.3.2
Beam.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 <agxModel/BeamModel.h>
20 #include <agxModel/BeamSegment.h>
22 
23 #include <agxSDK/LinkedStructure.h>
24 
25 namespace agxModel
26 {
29 
42  {
43  public:
65  static BeamRef create( agx::Vec3 startPosition,
66  agx::Vec3 endPosition,
67  BeamModel* model,
68  agx::UInt resolution,
69  agx::Vec3 worldUpAxis = agx::Vec3::Z_AXIS() );
70 
79  static agx::AffineMatrix4x4 calculateTransform( agx::Vec3 startPosition,
80  agx::Vec3 forward,
81  agx::Vec3 worldUpAxis = agx::Vec3::Z_AXIS() );
82 
90  static agx::Quat calculateRotation( agx::Vec3 forward,
91  agx::Vec3 worldUpAxis = agx::Vec3::Z_AXIS() );
92 
103  static BeamRef restore( agxModel::BeamModel* model, agxStream::StorageStream& str );
104 
109  static Beam* get( agx::RigidBody* rb );
110 
115  static const Beam* get( const agx::RigidBody* rb );
116 
123  static Beam* find( agxSDK::Simulation* simulation, const agx::Name& name );
124 
131  static Beam* find( agxSDK::Simulation* simulation, const agx::Uuid& uuid );
132 
138  static agxModel::BeamPtrVector findAll( const agxSDK::Simulation* simulation );
139 
146  static agxModel::BeamPtrVector findAll( const agxSDK::Simulation* simulation, const agx::Name& name );
147 
148  public:
156  Beam( BeamModel* model, agx::UInt resolution, agx::Real length );
157 
161  BeamModel* getModel() const;
162 
169  agx::Vec3 getBeginPosition() const;
170 
177  agx::Vec3 getEndPosition() const;
178 
182  BeamSegmentRange getSegments() const;
183 
187  agx::UInt getNumSegments() const;
188 
197  BeamSegment* getSegment( agx::Real restLengthFromStart ) const;
198 
204  BeamSegmentRange getConstrainedSegments() const;
205 
209  agx::Bool isInitialized() const;
210 
219  agx::Bool initialize();
220 
226  void updateProperties();
227 
240  agx::LockJointRef attach( BeamSegment* segment,
241  agx::Vec3 localSegmentPosition,
242  agx::RigidBody* otherRb = nullptr,
243  agx::Bool adoptModelProperties = false ) const;
244 
257  agx::LockJointRef attach( BeamSegment* segment,
258  agx::Bool atSegmentBegin,
259  agx::RigidBody* otherRb = nullptr,
260  agx::Bool adoptModelProperties = false ) const;
261 
272  agx::LockJointRef attachBegin( agx::RigidBody* otherRb = nullptr, agx::Bool adoptModelProperties = false ) const;
273 
284  agx::LockJointRef attachEnd( agx::RigidBody* otherRb = nullptr, agx::Bool adoptModelProperties = false ) const;
285 
291  BeamStiffnessDamping calculateSegmentStiffnessDamping() const;
292 
293  public:
297  virtual agx::Real getRestLength() const override;
298 
299  public:
301 
303 
304  virtual void storeLightData( agxStream::StorageStream& str ) const override;
305  virtual void restoreLightData( agxStream::StorageStream& str ) override;
306 
307  protected:
308  Beam();
309  virtual ~Beam();
310 
311  virtual void onAddNotification( agxSDK::Simulation* simulation ) override;
312  virtual void onRemoveNotification( agxSDK::Simulation* simulation ) override;
313 
314  virtual void onPreStep() override;
315 
316  private:
317  enum StateEnum : agx::UInt32
318  {
319  INITIALIZED = 1 << 0,
320  };
321  using State = agx::BitState<StateEnum, agx::UInt32>;
322 
323  private:
324  agx::Bool validateMembersAndWarn( agx::String context ) const;
325  void restoreLightData( agxStream::StorageStream& str, agx::Bool& valid );
326 
328 
329  private:
330  BeamModelRef m_model;
331  agx::UInt m_resolution;
332  agx::Real m_length;
333  State m_state;
334  };
335 
337  {
338  return LinkedStructure::getT<Beam>( rb );
339  }
340 
341  inline const Beam* Beam::get( const agx::RigidBody* rb )
342  {
343  return LinkedStructure::getT<Beam>( rb );
344  }
345 }
Stiffness and damping data for constraints related to beam models.
Basic implementation of any structure where bodies are linked/constrained together in a well defined ...
Beam segment in an agxModel::Beam containing a rigid body, a constraint and is of fixed length...
Definition: BeamSegment.h:36
bool Bool
Definition: Integer.h:48
Segment range object for linked structure.
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:363
Beam is a segmented, lumped element structure of a given length and resolution.
Definition: Beam.h:41
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Representation of a name string.
Definition: Name.h:32
static Vec3T Z_AXIS()
Definition: Vec3Template.h:783
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
Beam model interface requiring moment of inertia (area moment in x, y and polar moment in z)...
Definition: BeamModel.h:64
uint32_t UInt
Definition: Integer.h:34
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
#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
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
AGXBRICK_EXPORT bool isInitialized()
static Beam * get(agx::RigidBody *rb)
Definition: Beam.h:336
#define AGXMODEL_EXPORT
double Real
Definition: Real.h:42
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
uint32_t UInt32
Definition: Integer.h:40
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97