AGX Dynamics  2.37.3.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 #ifndef AGXPOWERLINE_PHYSICAL_DIMENSION_H
18 #define AGXPOWERLINE_PHYSICAL_DIMENSION_H
19 
20 #include <agxModel/export.h>
21 #include <agxPowerLine/Sides.h>
23 
25 #include <agxStream/Serializable.h>
26 
27 #include <agxUtil/agxUtil.h>
28 
29 #include <agx/RigidBody.h>
30 #include <agx/agx_hash_types.h>
33 
34 #include <string>
35 
36 
37 
38 #if defined(_MSC_VER)
39 #pragma warning( push )
40 #pragma warning( disable : 4589 ) // Disable: 4589: Constructor of abstract class 'agx::FrictionModel' ignores initializer for virtual base class 'agxStream::Serializable'
41 #endif
42 
43 
44 namespace agxPowerLine
45 {
46  namespace detail
47  {
48  class ConnectionOperations;
49  class AbstractDimensionState1Dof;
50  class AbstractDimensionState3Dof;
52  }
53 }
54 
55 namespace agxPowerLine
56 {
57  class Connection;
58  class Connector;
59  class Unit;
60  class PowerLine;
61  class PowerGenerator;
62  class LookupTable;
64 
76 
77 
79  typedef std::pair<agxPowerLine::PhysicalDimension*, agxPowerLine::Side> DimensionAndSide;
80 
94  {
95  public:
96  typedef int Type;
98 
105  virtual void calculateJacobian(
107  const agx::Real ratio,
108  const size_t index) const;
109 
115  bool connect(agxPowerLine::PhysicalDimension* otherDimension, agxPowerLine::Connector* connector);
116 
117 
118 
123  virtual agx::Real getValue() const ;
124  virtual void setValue(agx::Real value);
125  virtual agx::Real getGradient() const;
126  virtual void setGradient( agx::Real value);
127  virtual agx::Real getSecondGradient() const;
128 
142  const agx::Name& getName() const;
143  void setName(const agx::Name& name);
144 
145 
152  void reserveBody();
153 
160  agx::RigidBody* getReservedBody();
161  const agx::RigidBody* getReservedBody() const;
162 
170  agx::RigidBody* getOrReserveBody();
171 
172 
176  bool hasReservedBody() const;
177 
181  const agxPowerLine::Unit* getUnit() const;
182  agxPowerLine::Unit* getUnit();
183 
188  bool isExternalBody() const;
189 
193  virtual agx::Real getMassProperty() const;
194 
198  virtual void setMassProperty(agx::Real massProperty);
199 
200 
204  virtual agx::Real getInputLoad() const;//Torque(rotational dimension), Force(translational dimension)...
205  virtual agx::Real getOutputLoad() const;//Torque(rotational dimension), Force(translational dimension)...
206 
207 
211  virtual void addLoad(agx::Real load);
212 
213 
217  virtual agx::Real getPowerIn() const;
218  virtual agx::Real getPowerOut() const;
219 
223  agxPowerLine::PhysicalDimensionMultiBodyConstraintImplementation* getConstraint(size_t outputConnection = 0) const;
224 
228  agxPowerLine::PhysicalDimensionMultiBodyConstraintImplementation* getInputConstraint(size_t inputConnection = 0) const;
229 
230  agx::Vec3 getWorldDirection() const;
231 
232  void setVelocityDamping(float damping);
233  float getVelocityDamping() const;
234 
238  virtual void renderDebug();
239 
243  virtual void clear();
244 
245  size_t getNumInputConnections() const;
246  size_t getNumOutputConnections() const;
247  size_t getNumConnections(agxPowerLine::Side side) const;
248  size_t getNumConnections() const;
249 
253  const agxPowerLine::Connection* getInputConnection(size_t inputIndex = 0) const;
254  const agxPowerLine::Connection* getOutputConnection(size_t outputIndex = 0) const;
255 
256  Connection* getOutputConnection(const Connector* connector );
257  Connection* getInputConnection(const Connector* connector );
258  Connection* getOutputConnection(const Unit* unit);
259  Connection* getInputConnection(const Unit* unit );
260 
261  const Connection* getOutputConnection(const Connector* connector ) const;
262  const Connection* getInputConnection(const Connector* connector ) const;
263  const Connection* getOutputConnection(const Unit* unit) const;
264  const Connection* getInputConnection(const Unit* unit ) const;
265 
266  const agxPowerLine::ConnectionRefVector& getOutputConnections() const;
267  const agxPowerLine::ConnectionRefVector& getInputConnections() const;
268  agxPowerLine::Connection* getInputConnection(size_t inputIndex = 0);
269  agxPowerLine::Connection* getOutputConnection(size_t outputIndex = 0);
270 
271  const agxPowerLine::ConnectionRefVector& getConnections(agxPowerLine::Side side) const;
272 
273 
274  size_t getBodyIndexIn(const RigidBodyPtrIntHashVector& bodyToIndexTable);
275 
282  const agxPowerLine::detail::DimensionState* getState() const;
283 
291  const agxPowerLine::detail::AbstractDimensionState1Dof* get1DofState() const;
292 
293 
301  const agxPowerLine::detail::AbstractDimensionState3Dof* get3DofState() const;
302 
303 
307  virtual bool store(agxStream::StorageStream& str) const;
308 
312  virtual bool restore(agxStream::StorageStream& in);
313 
314 
316  virtual void store(agxStream::OutputArchive& out) const override;
317  virtual void restore(agxStream::InputArchive& in) override;
318  void restore(agxStream::InputArchive& in, agx::RigidBody*& body, bool& externalBody);
319 
320 
321 
337  virtual std::string getTypeName() const;
338 
339 
344 
345 
368  static std::string getStaticTypeName();
369 
370  static agxPowerLine::PhysicalDimension::Type getStaticType();
371 
375  static int getNumberOfPhysicalDimensions();
376 
377 
378  protected:
380 
382  agxPowerLine::Unit* unit,
385 
386  virtual ~PhysicalDimension();
387 
394  bool restore(agxStream::StorageStream& in, const agx::Vec3* direction);
395 
396  friend class Unit;
397  friend class Connector;
398 
399  void addNotification(agxPowerLine::PowerLine* powerLine);
400  void removeNotification(agxPowerLine::PowerLine* powerLine);
401 
406  void addNotification(agxSDK::Simulation* simulation);
407 
414 
415  void removeNotification(agxSDK::Simulation* simulation);
416 
421  virtual void removeNotification(agxSDK::Simulation* simulation, agxUtil::ConstraintHolder* constraintHolder);
422 
423  bool removeInputConnection( Connection* connection );
424  bool removeOutputConnection( Connection* connection );
425 
429  void addToListOfDimensions();
430 
431  protected:
433  agxPowerLine::ConnectionRefVector& getConnectionsWritable(agxPowerLine::Side side);
434 
435  protected:
437  ConnectionRefVector m_inputConnections;
438  ConnectionRefVector m_outputConnections;
442  };
443 
448  typedef const PhysicalDimensionRef ConstPhysicalDimensionRef;
450 
451 
453 }
454 
455 #if defined(_MSC_VER)
456 #pragma warning( pop )
457 #endif
458 
459 
460 #endif // AGXMODEL_PHYSICAL_DIMENSION_H
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
Links two connections together.
Definition: Connector.h:53
AGXTERRAIN_EXPORT void clear()
AGXCORE_EXPORT Type * getType(const agx::String &name)
const PhysicalDimensionRef ConstPhysicalDimensionRef
Utility class to hold custom implementations of constraints.
Definition: agxUtil.h:463
agxPowerLine::detail::PhysicalDimensionStateRef m_state
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...
ConnectionRefVector m_inputConnections
agx::SetVector< PhysicalDimension * > PhysicalDimensionPtrSetVector
agx::Vector< PhysicalDimension * > PhysicalDimensionPtrVector
Constraint implementation for constraining a number of physical dimensions of the same type...
Pure virtual class.
Definition: Unit.h:72
agx::Vector< ConnectionPtr > ConnectionPtrVector
agx::observer_ptr< PowerGenerator > PowerGeneratorObserver
Representation of a name string.
Definition: Name.h:32
agxPowerLine contains a collection of connected components that transport power across a system...
Definition: MotorUnit.h:23
ConnectionRefVector m_outputConnections
Base class providing referencing counted objects.
Definition: Referenced.h:119
A DimensionState is the data carrier of a PhysicalDimension.
agx::observer_ptr< Connector > ConnectorObserver
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
agx::Vector< ConstPhysicalDimensionRef > ConstPhysicalDimensionRefVector
Connection * ConnectionPtr
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
agx::Vector< Unit * > UnitPtrVector
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
agx::ref_ptr< Connector > ConnectorRef
Definition: Connector.h:405
agx::HashVector< agx::RigidBody *, int > RigidBodyPtrIntHashVector
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
Return a value of y given any value of x.
AGXMODEL_EXPORT agx::RigidBody * createDimensionBody(const agx::Name &name)
#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
std::pair< agxPowerLine::PhysicalDimension *, agxPowerLine::Side > DimensionAndSide
#define AGXMODEL_EXPORT
agx::ref_ptr< PhysicalDimension > PhysicalDimensionRef
double Real
Definition: Real.h:42
agx::Vector< ConnectionRef > ConnectionRefVector
PowerLine is the base class for a system of power transfer integrated into the rigid body simulation...
Definition: PowerLine.h:70
agx::ref_ptr< LookupTable > LookupTableRef
agx::ref_ptr< PowerGenerator > PowerGeneratorRef
agx::Vector< PhysicalDimensionRef > PhysicalDimensionRefVector
Base class for the two one dimensional dimension state classes.
PhysicalDimension::Type m_type
Will generate power by adding a load to a physical dimension.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: SetVector.h:37
agx::ref_ptr< Connection > ConnectionRef
Base class for the two three dimensional dimension state classes.