AGX Dynamics  2.35.0.1
PhysicalDimension.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 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;
63  class PhysicalDimensionMultiBodyConstraintImplementation;
64 
76 
77 
78  class PhysicalDimension;
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 
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 
162 
171 
172 
176  bool hasReservedBody() const;
177 
181  const agxPowerLine::Unit* getUnit() const;
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 
224 
229 
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;
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 
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 
270 
272 
273 
274  size_t getBodyIndexIn(const RigidBodyPtrIntHashVector& bodyToIndexTable);
275 
283 
292 
293 
302 
303 
307  virtual bool store(agxStream::StorageStream& str) const;
308 
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 
371 
376 
377 
378  protected:
380 
382  agxPowerLine::Unit* unit,
385 
387 
394  bool restore(agxStream::StorageStream& in, const agx::Vec3* direction);
395 
396  friend class Unit;
397  friend class Connector;
398 
401 
407 
414 
416 
421  virtual void removeNotification(agxSDK::Simulation* simulation, agxUtil::ConstraintHolder* constraintHolder);
422 
423  bool removeInputConnection( Connection* connection );
424  bool removeOutputConnection( Connection* connection );
425 
430 
431  protected:
434 
435  protected:
442  };
443 
450 
451 
453 }
454 
455 #if defined(_MSC_VER)
456 #pragma warning( pop )
457 #endif
458 
459 
460 #endif // AGXMODEL_PHYSICAL_DIMENSION_H
#define AGXMODEL_EXPORT
Links two connections together.
Definition: Connector.h:54
Constraint implementation for constraining a number of physical dimensions of the same type.
static std::string getStaticTypeName()
Returns the dimension type name of PhysicalDimension.
const agxPowerLine::Unit * getUnit() const
Returns pointer to the Unit that contains this dimension.
agxPowerLine::Connection * getInputConnection(size_t inputIndex=0)
size_t getNumOutputConnections() const
virtual void calculateJacobian(agx::Jacobian6DOFElement *G, const agx::Real ratio, const size_t index) const
Calculates jacobian for a physical dimension.
agxPowerLine::detail::AbstractDimensionState1Dof * get1DofState()
Access the DimensionState as a 1-dimensional state.
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agxPowerLine::PhysicalDimension)
size_t getNumConnections(agxPowerLine::Side side) const
virtual agx::Real getPowerOut() const
agxPowerLine::PhysicalDimension::Type getType() const
returns the PhysicalDimension::Type of this dimension
Connection * getInputConnection(const Connector *connector)
agxPowerLine::detail::AbstractDimensionState3Dof * get3DofState()
Access the DimensionState as a 3-dimensional state.
virtual void store(agxStream::OutputArchive &out) const override
virtual void addLoad(agx::Real load)
Add a load to the dimension.
void addToListOfDimensions()
Add to singleton that controls the different types of physical dimensions.
virtual agx::Real getInputLoad() const
return the load in/out
bool removeInputConnection(Connection *connection)
void addNotification(agxPowerLine::PowerLine *powerLine)
void removeNotification(agxSDK::Simulation *simulation)
virtual agx::Real getValue() const
Physical properties of the dimension.
const Connection * getInputConnection(const Connector *connector) const
void restore(agxStream::InputArchive &in, agx::RigidBody *&body, bool &externalBody)
const agxPowerLine::ConnectionRefVector & getOutputConnections() const
virtual void clear()
Clear all reference pointers.
size_t getNumInputConnections() const
PhysicalDimension::Type m_type
agxPowerLine::PhysicalDimensionMultiBodyConstraintImplementation * getConstraint(size_t outputConnection=0) const
static int getNumberOfPhysicalDimensions()
agxPowerLine::ConnectionRefVector & getConnectionsWritable(agxPowerLine::Side side)
const agxPowerLine::detail::AbstractDimensionState1Dof * get1DofState() const
bool removeOutputConnection(Connection *connection)
const agxPowerLine::ConnectionRefVector & getInputConnections() const
ConnectionRefVector m_inputConnections
ConnectionRefVector m_outputConnections
virtual void restore(agxStream::InputArchive &in) override
agxPowerLine::PhysicalDimensionMultiBodyConstraintImplementation * getInputConstraint(size_t inputConnection=0) const
const agx::RigidBody * getReservedBody() const
void addNotification(agxSDK::Simulation *simulation)
Called when the Unit owning this PhysicalDimension is added to a simulation.
agxPowerLine::detail::DimensionState * getState()
Provides direct access to the underlying DimensionState.
const agxPowerLine::detail::AbstractDimensionState3Dof * get3DofState() const
virtual void setGradient(agx::Real value)
bool connect(agxPowerLine::PhysicalDimension *otherDimension, agxPowerLine::Connector *connector)
Connect to another dimension for possible power transfer.
agx::Vec3 getWorldDirection() const
virtual agx::Real getSecondGradient() const
Connection * getInputConnection(const Unit *unit)
const Connection * getOutputConnection(const Unit *unit) const
agxPowerLine::Unit * getUnit()
const agxPowerLine::Connection * getOutputConnection(size_t outputIndex=0) const
virtual void setValue(agx::Real value)
agx::RigidBody * getOrReserveBody()
Return a body that is guaranteed to not be shared with any other PhysicalDimension.
const agxPowerLine::Connection * getInputConnection(size_t inputIndex=0) const
Traversing helper functions.
PhysicalDimension(agxPowerLine::Unit *unit, agxPowerLine::PhysicalDimension::Type type, agxPowerLine::detail::DimensionState *state)
const agxPowerLine::detail::DimensionState * getState() const
virtual std::string getTypeName() const
Returns the dimension type name of this PhysicalDimension instance.
bool restore(agxStream::StorageStream &in, const agx::Vec3 *direction)
Some serialization versions stored the dimension axis direction in classes deriving from PhysicalDime...
agx::RigidBody * getReservedBody()
Return a body that is guaranteed to not be shared with any other PhysicalDimension.
void setName(const agx::Name &name)
virtual void setMassProperty(agx::Real massProperty)
Set the mass property of the dimension.
Connection * getOutputConnection(const Unit *unit)
agxPowerLine::detail::PhysicalDimensionStateRef m_state
virtual void renderDebug()
Implement this to render Your physical dimension.
const Connection * getOutputConnection(const Connector *connector) const
virtual bool store(agxStream::StorageStream &str) const
Stores internal data into stream.
static agxPowerLine::PhysicalDimension::Type getStaticType()
virtual agx::Real getGradient() const
void reserveBody()
Ensure that this PhysicalDimension does not share it's body with any other PhysicalDimension.
virtual bool restore(agxStream::StorageStream &in)
Restores internal data from stream.
bool isExternalBody() const
Return true if the body that defines the dimension was given to the Power- Line, false if the body wa...
size_t getBodyIndexIn(const RigidBodyPtrIntHashVector &bodyToIndexTable)
agxPowerLine::Connection * getOutputConnection(size_t outputIndex=0)
const agxPowerLine::ConnectionRefVector & getConnections(agxPowerLine::Side side) const
const agx::Name & getName() const
Returns the name of this PhysicalDimension instance.
const Connection * getInputConnection(const Unit *unit) const
Connection * getOutputConnection(const Connector *connector)
virtual void removeNotification(agxSDK::Simulation *simulation, agxUtil::ConstraintHolder *constraintHolder)
Remove the PhysicalDimension from the simulation.
virtual agx::Real getMassProperty() const
returns the mass property of the dimension body.
virtual agx::Real getOutputLoad() const
void removeNotification(agxPowerLine::PowerLine *powerLine)
virtual agx::Real getPowerIn() const
return the power in/out
void setVelocityDamping(float damping)
PowerLine is the base class for a system of power transfer integrated into the rigid body simulation.
Definition: PowerLine.h:71
Pure virtual class.
Definition: Unit.h:73
Base class for the two one dimensional dimension state classes.
Base class for the two three dimensional dimension state classes.
A DimensionState is the data carrier of a PhysicalDimension.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
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
Utility class to hold custom implementations of constraints.
Definition: agxUtil.h:464
Representation of a name string.
Definition: Name.h:33
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
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: SetVector.h:38
agxPowerLine contains a collection of connected components that transport power across a system.
Definition: MotorUnit.h:24
agx::HashVector< agx::RigidBody *, int > RigidBodyPtrIntHashVector
agx::observer_ptr< Connector > ConnectorObserver
agx::Vector< PhysicalDimension * > PhysicalDimensionPtrVector
agx::SetVector< PhysicalDimension * > PhysicalDimensionPtrSetVector
std::pair< agxPowerLine::PhysicalDimension *, agxPowerLine::Side > DimensionAndSide
agx::Vector< ConnectionPtr > ConnectionPtrVector
Connection * ConnectionPtr
const PhysicalDimensionRef ConstPhysicalDimensionRef
agx::ref_ptr< LookupTable > LookupTableRef
agx::Vector< ConstPhysicalDimensionRef > ConstPhysicalDimensionRefVector
agx::ref_ptr< PhysicalDimension > PhysicalDimensionRef
agx::ref_ptr< PowerGenerator > PowerGeneratorRef
agx::ref_ptr< Connection > ConnectionRef
agx::ref_ptr< Connector > ConnectorRef
Definition: Connector.h:405
agx::Vector< PhysicalDimensionRef > PhysicalDimensionRefVector
agx::Vector< Unit * > UnitPtrVector
AGXMODEL_EXPORT agx::RigidBody * createDimensionBody(const agx::Name &name)
agx::observer_ptr< PowerGenerator > PowerGeneratorObserver
agx::Vector< ConnectionRef > ConnectionRefVector
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.
double Real
Definition: Real.h:42