AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
Beam.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. 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 <agxModel/BeamModel.h>
22
24
25namespace 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
80 agx::Vec3 forward,
81 agx::Vec3 worldUpAxis = agx::Vec3::Z_AXIS() );
82
91 agx::Vec3 worldUpAxis = agx::Vec3::Z_AXIS() );
92
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
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
162
170
178
183
188
197 BeamSegment* getSegment( agx::Real restLengthFromStart ) const;
198
205
210
220
227
241 agx::Vec3 localSegmentPosition,
242 agx::RigidBody* otherRb = nullptr,
243 agx::Bool adoptModelProperties = false ) const;
244
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
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
336 inline Beam* Beam::get( agx::RigidBody* rb )
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}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXMODEL_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition agx/Vector.h:34
Beam model interface requiring moment of inertia (area moment in x, y and polar moment in z),...
Definition BeamModel.h:65
Beam segment in an agxModel::Beam containing a rigid body, a constraint and is of fixed length.
Definition BeamSegment.h:37
Beam is a segmented, lumped element structure of a given length and resolution.
Definition Beam.h:42
static BeamRef restore(agxModel::BeamModel *model, agxStream::StorageStream &str)
Creates a new beam given model and restores all data from the given storage stream.
static agx::AffineMatrix4x4 calculateTransform(agx::Vec3 startPosition, agx::Vec3 forward, agx::Vec3 worldUpAxis=agx::Vec3::Z_AXIS())
Calculates the transform of a beam given start position, forward direction and world up axis the beam...
agx::LockJointRef attach(BeamSegment *segment, agx::Bool atSegmentBegin, agx::RigidBody *otherRb=nullptr, agx::Bool adoptModelProperties=false) const
Utility method to attach a given segment (of this beam) at begin or end (of the segment) to another r...
void updateProperties()
Propagate model specific properties, such as stiffness in the constraints.
agx::Vec3 getBeginPosition() const
Current begin position, in world coordinate frame, of this (initialized) beam.
static agxModel::BeamPtrVector findAll(const agxSDK::Simulation *simulation)
Finds all agxModel::Beam instances in the given simulation.
BeamSegment * getSegment(agx::Real restLengthFromStart) const
Finds the segment overlapping the given rest length from start.
Beam(BeamModel *model, agx::UInt resolution, agx::Real length)
Construct a beam given model, resolution (number of elements) and total length.
agx::Bool isInitialized() const
BeamStiffnessDamping calculateSegmentStiffnessDamping() const
Calculates per segment stiffness dependent on beam model moment of inertia, cross section area,...
static agx::Quat calculateRotation(agx::Vec3 forward, agx::Vec3 worldUpAxis=agx::Vec3::Z_AXIS())
Calculates the rotation of a beam frame given forward direction and world up axis the beam frame up a...
agx::LockJointRef attachEnd(agx::RigidBody *otherRb=nullptr, agx::Bool adoptModelProperties=false) const
Utility method to attach the last segment of this beam at end (of the segment) to another rigid body ...
agx::Vec3 getEndPosition() const
Current end position, in world coordinate frame, of this (initialized) beam.
BeamSegmentRange getConstrainedSegments() const
BeamSegmentRange getSegments() const
static Beam * find(agxSDK::Simulation *simulation, const agx::Uuid &uuid)
Find beam instance given simulation and unique id.
agx::UInt getNumSegments() const
virtual agx::Real getRestLength() const override
static Beam * find(agxSDK::Simulation *simulation, const agx::Name &name)
Find beam instance given simulation and name.
agx::LockJointRef attachBegin(agx::RigidBody *otherRb=nullptr, agx::Bool adoptModelProperties=false) const
Utility method to attach the first segment of this beam at begin (of the segment) to another rigid bo...
agx::LockJointRef attach(BeamSegment *segment, agx::Vec3 localSegmentPosition, agx::RigidBody *otherRb=nullptr, agx::Bool adoptModelProperties=false) const
Utility method to attach a given segment (of this beam) at a local segment position to another rigid ...
BeamModel * getModel() const
static BeamRef create(agx::Vec3 startPosition, agx::Vec3 endPosition, BeamModel *model, agx::UInt resolution, agx::Vec3 worldUpAxis=agx::Vec3::Z_AXIS())
Creates an initialized beam between the given start and end positions, beam model,...
agx::Bool initialize()
Initialize this beam, creating segments, constraints and assigning properties related to the model of...
static agxModel::BeamPtrVector findAll(const agxSDK::Simulation *simulation, const agx::Name &name)
Finds all beam instances given simulation and name.
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:126
Abstract base class for storing/restoring a line/drums with version control.
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:52
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition Uuid.h:42
static Vec3T Z_AXIS()
Vector containing 'raw' data.
Definition agx/Vector.h:246
Smart pointer for handling referenced counted objects.
Definition ref_ptr.h:30
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition macros.h:96
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition FlowUnit.h:37
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...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
bool Bool
Definition Integer.h:40
uint64_t UInt
Definition Integer.h:27
double Real
Definition Real.h:42
Stiffness and damping data for constraints related to beam models.