AGX Dynamics  2.38.0.2
PhysicalDimension.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/export.h>
20 #include <agxPowerLine/Sides.h>
22 
24 #include <agxStream/Serializable.h>
25 
26 #include <agxUtil/agxUtil.h>
27 
28 #include <agx/RigidBody.h>
29 #include <agx/agx_hash_types.h>
32 
33 #include <string>
34 
35 
36 
37 #if defined(_MSC_VER)
38 #pragma warning( push )
39 #pragma warning( disable : 4589 ) // Disable: 4589: Constructor of abstract class 'agx::FrictionModel' ignores initializer for virtual base class 'agxStream::Serializable'
40 #endif
41 
42 
43 namespace agxPowerLine
44 {
45  namespace detail
46  {
47  class ConnectionOperations;
48  class AbstractDimensionState1Dof;
49  class AbstractDimensionState3Dof;
51  }
52 }
53 
54 namespace agxPowerLine
55 {
56  class Connection;
57  class Connector;
58  class Unit;
59  class PowerLine;
60  class PowerGenerator;
61  class LookupTable;
63 
75 
76 
78  typedef std::pair<agxPowerLine::PhysicalDimension*, agxPowerLine::Side> DimensionAndSide;
79 
93  {
94  public:
95  typedef int Type;
97 
104  virtual void calculateJacobian(
106  const agx::Real ratio,
107  const size_t index) const;
108 
114  bool connect(agxPowerLine::PhysicalDimension* otherDimension, agxPowerLine::Connector* connector);
115 
116 
117 
122  virtual agx::Real getValue() const ;
123  virtual void setValue(agx::Real value);
124  virtual agx::Real getGradient() const;
125  virtual void setGradient( agx::Real value);
126  virtual agx::Real getSecondGradient() const;
127 
141  const agx::Name& getName() const;
142  void setName(const agx::Name& name);
143 
144 
151  void reserveBody();
152 
159  agx::RigidBody* getReservedBody();
160  const agx::RigidBody* getReservedBody() const;
161 
169  agx::RigidBody* getOrReserveBody();
170 
171 
175  bool hasReservedBody() const;
176 
180  const agxPowerLine::Unit* getUnit() const;
181  agxPowerLine::Unit* getUnit();
182 
187  bool isExternalBody() const;
188 
192  virtual agx::Real getMassProperty() const;
193 
197  virtual void setMassProperty(agx::Real massProperty);
198 
199 
203  virtual agx::Real getInputLoad() const;//Torque(rotational dimension), Force(translational dimension)...
204  virtual agx::Real getOutputLoad() const;//Torque(rotational dimension), Force(translational dimension)...
205 
206 
210  virtual void addLoad(agx::Real load);
211 
212 
216  virtual agx::Real getPowerIn() const;
217  virtual agx::Real getPowerOut() const;
218 
222  agxPowerLine::PhysicalDimensionMultiBodyConstraintImplementation* getConstraint(size_t outputConnection = 0) const;
223 
227  agxPowerLine::PhysicalDimensionMultiBodyConstraintImplementation* getInputConstraint(size_t inputConnection = 0) const;
228 
229  agx::Vec3 getWorldDirection() const;
230 
231  void setVelocityDamping(float damping);
232  float getVelocityDamping() const;
233 
237  virtual void renderDebug();
238 
242  virtual void clear();
243 
244  size_t getNumInputConnections() const;
245  size_t getNumOutputConnections() const;
246  size_t getNumConnections(agxPowerLine::Side side) const;
247  size_t getNumConnections() const;
248 
252  const agxPowerLine::Connection* getInputConnection(size_t inputIndex = 0) const;
253  const agxPowerLine::Connection* getOutputConnection(size_t outputIndex = 0) const;
254 
255  Connection* getOutputConnection(const Connector* connector );
256  Connection* getInputConnection(const Connector* connector );
257  Connection* getOutputConnection(const Unit* unit);
258  Connection* getInputConnection(const Unit* unit );
259 
260  const Connection* getOutputConnection(const Connector* connector ) const;
261  const Connection* getInputConnection(const Connector* connector ) const;
262  const Connection* getOutputConnection(const Unit* unit) const;
263  const Connection* getInputConnection(const Unit* unit ) const;
264 
265  const agxPowerLine::ConnectionRefVector& getOutputConnections() const;
266  const agxPowerLine::ConnectionRefVector& getInputConnections() const;
267  agxPowerLine::Connection* getInputConnection(size_t inputIndex = 0);
268  agxPowerLine::Connection* getOutputConnection(size_t outputIndex = 0);
269 
270  const agxPowerLine::ConnectionRefVector& getConnections(agxPowerLine::Side side) const;
271 
272 
273  size_t getBodyIndexIn(const RigidBodyPtrIntHashVector& bodyToIndexTable);
274 
281  const agxPowerLine::detail::DimensionState* getState() const;
282 
290  const agxPowerLine::detail::AbstractDimensionState1Dof* get1DofState() const;
291 
292 
300  const agxPowerLine::detail::AbstractDimensionState3Dof* get3DofState() const;
301 
302 
306  virtual bool store(agxStream::StorageStream& str) const;
307 
311  virtual bool restore(agxStream::StorageStream& in);
312 
313 
315  virtual void store(agxStream::OutputArchive& out) const override;
316  virtual void restore(agxStream::InputArchive& in) override;
317  void restore(agxStream::InputArchive& in, agx::RigidBody*& body, bool& externalBody);
318 
319 
320 
336  virtual std::string getTypeName() const;
337 
338 
343 
344 
367  static std::string getStaticTypeName();
368 
369  static agxPowerLine::PhysicalDimension::Type getStaticType();
370 
374  static int getNumberOfPhysicalDimensions();
375 
376 
377  protected:
379 
381  agxPowerLine::Unit* unit,
384 
385  virtual ~PhysicalDimension();
386 
393  bool restore(agxStream::StorageStream& in, const agx::Vec3* direction);
394 
395  friend class Unit;
396  friend class Connector;
397 
398  void addNotification(agxPowerLine::PowerLine* powerLine);
399  void removeNotification(agxPowerLine::PowerLine* powerLine);
400 
405  void addNotification(agxSDK::Simulation* simulation);
406 
413 
414  void removeNotification(agxSDK::Simulation* simulation);
415 
420  virtual void removeNotification(agxSDK::Simulation* simulation, agxUtil::ConstraintHolder* constraintHolder);
421 
422  bool removeInputConnection( Connection* connection );
423  bool removeOutputConnection( Connection* connection );
424 
428  void addToListOfDimensions();
429 
430  protected:
432  agxPowerLine::ConnectionRefVector& getConnectionsWritable(agxPowerLine::Side side);
433 
434  protected:
441  };
442 
449 
450 
452 }
453 
454 #if defined(_MSC_VER)
455 #pragma warning( pop )
456 #endif
agxPowerLine::PhysicalDimension::TypeVector
agx::Vector< Type > TypeVector
Definition: PhysicalDimension.h:96
DimensionState.h
agxPowerLine::LookupTableRef
agx::ref_ptr< LookupTable > LookupTableRef
Definition: PhysicalDimension.h:69
agx::Real
double Real
Definition: Real.h:42
agxPowerLine::PhysicalDimension::m_type
PhysicalDimension::Type m_type
Definition: PhysicalDimension.h:435
agxPowerLine::Side
Side
Definition: Sides.h:28
agx::Jacobian6DOFElementT
Definition: Jacobian.h:104
agx::Vector< ConnectionRef >
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:51
agxPowerLine::PowerGeneratorObserver
agx::observer_ptr< PowerGenerator > PowerGeneratorObserver
Definition: PhysicalDimension.h:67
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
agxPowerLine::PhysicalDimension::m_outputConnections
ConnectionRefVector m_outputConnections
Definition: PhysicalDimension.h:437
export.h
agxData::getType
AGXCORE_EXPORT Type * getType(const agx::String &name)
agxPowerLine::PhysicalDimensionPtrSetVector
agx::SetVector< PhysicalDimension * > PhysicalDimensionPtrSetVector
Definition: PhysicalDimension.h:446
agxUtil::ConstraintHolder
Utility class to hold custom implementations of constraints.
Definition: agxUtil.h:463
agxPowerLine::PhysicalDimensionMultiBodyConstraintImplementation
Constraint implementation for constraining a number of physical dimensions of the same type.
Definition: PowerLineConstraints.h:149
agxPowerLine::PhysicalDimension::m_inputConnections
ConnectionRefVector m_inputConnections
Definition: PhysicalDimension.h:436
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
agxPowerLine::detail::ConnectionOperations
Definition: ConnectionOperations.h:38
StepEventListener.h
agxPowerLine::PhysicalDimension
Pure virtual class.
Definition: PhysicalDimension.h:92
agxPowerLine::PhysicalDimension::Type
int Type
Definition: PhysicalDimension.h:95
agxPowerLine::PhysicalDimension::m_name
agx::Name m_name
Definition: PhysicalDimension.h:440
agx::observer_ptr< PowerGenerator >
agxPowerLine::ConnectionPtrVector
agx::Vector< ConnectionPtr > ConnectionPtrVector
Definition: PhysicalDimension.h:72
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:399
agxPowerLine::Unit
Pure virtual class.
Definition: Unit.h:71
agxPowerLine::detail::DimensionState
A DimensionState is the data carrier of a PhysicalDimension.
Definition: DimensionState.h:71
agx::ref_ptr< DimensionState >
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:125
agxPowerLine::PhysicalDimension::m_unit
Unit * m_unit
Definition: PhysicalDimension.h:438
agxPowerLine::ConstPhysicalDimensionRef
const typedef PhysicalDimensionRef ConstPhysicalDimensionRef
Definition: PhysicalDimension.h:447
agx::SetVector
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: SetVector.h:37
agxPowerLine::ConstPhysicalDimensionRefVector
agx::Vector< ConstPhysicalDimensionRef > ConstPhysicalDimensionRefVector
Definition: PhysicalDimension.h:448
agxPowerLine::PowerLine
PowerLine is the base class for a system of power transfer integrated into the rigid body simulation.
Definition: PowerLine.h:65
RegularizationParameters.h
agx_hash_types.h
agx::Name
Representation of a name string.
Definition: Name.h:32
agxPowerLine::ConnectorRef
agx::ref_ptr< Connector > ConnectorRef
Definition: Connector.h:404
agxPowerLine::ConnectorObserver
agx::observer_ptr< Connector > ConnectorObserver
Definition: PhysicalDimension.h:68
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
Serializable.h
agxPowerLine::ConnectionPtr
Connection * ConnectionPtr
Definition: PhysicalDimension.h:71
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:50
RigidBody.h
agxPowerLine::UnitPtrVector
agx::Vector< Unit * > UnitPtrVector
Definition: PhysicalDimension.h:73
agxPowerLine::PhysicalDimensionRef
agx::ref_ptr< PhysicalDimension > PhysicalDimensionRef
Definition: PhysicalDimension.h:443
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:119
agxPowerLine
agxPowerLine contains a collection of connected components that transport power across a system.
Definition: MotorUnit.h:23
ElementaryConstraint.h
agxPowerLine::Connector
Links two connections together.
Definition: Connector.h:52
agxPowerLine::PowerGeneratorRef
agx::ref_ptr< PowerGenerator > PowerGeneratorRef
Definition: PhysicalDimension.h:62
agxPowerLine::PhysicalDimensionRefVector
agx::Vector< PhysicalDimensionRef > PhysicalDimensionRefVector
Definition: PhysicalDimension.h:444
agxPowerLine::detail::AbstractDimensionState1Dof
Base class for the two one dimensional dimension state classes.
Definition: DimensionState.h:192
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agxPowerLine::detail::AbstractDimensionState3Dof
Base class for the two three dimensional dimension state classes.
Definition: DimensionState.h:336
Sides.h
agxPowerLine::Connection
Definition: PowerLineUtils.h:257
agx::Vec3T< Real >
agxPowerLine::PhysicalDimension::m_state
agxPowerLine::detail::PhysicalDimensionStateRef m_state
Definition: PhysicalDimension.h:439
agxPowerLine::RigidBodyPtrIntHashVector
agx::HashVector< agx::RigidBody *, int > RigidBodyPtrIntHashVector
Definition: PhysicalDimension.h:74
agxPowerLine::createDimensionBody
AGXMODEL_EXPORT agx::RigidBody * createDimensionBody(const agx::Name &name)
agxTerrain::Profiler::clear
AGXTERRAIN_EXPORT void clear()
agxPowerLine::ConnectionRef
agx::ref_ptr< Connection > ConnectionRef
Definition: PhysicalDimension.h:65
agx::HashVector< agx::RigidBody *, int >
agxPowerLine::ConnectionRefVector
agx::Vector< ConnectionRef > ConnectionRefVector
Definition: PhysicalDimension.h:70
agxPowerLine::PhysicalDimensionPtrVector
agx::Vector< PhysicalDimension * > PhysicalDimensionPtrVector
Definition: PhysicalDimension.h:445
agxPowerLine::DimensionAndSide
std::pair< agxPowerLine::PhysicalDimension *, agxPowerLine::Side > DimensionAndSide
Definition: PhysicalDimension.h:77
agxUtil.h