AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
Unit.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. 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/export.h>
24
27
28#include <agxUtil/agxUtil.h>
29
30#include <agx/RigidBody.h>
32
33
34namespace agxPowerLine
35{
36 /************************************************************************/
37 /*
38 The agxPowerLine::PowerLine implementation is the base for energy transportation
39 in a 1D physical system.
40
41 The energy is stored in units connected by connectors. Each unit can have a set of both
42 in and out connections, representing different physical dimensions.
43
44 The physical dimensions can either be dynamically solved or be represented as
45 a kinematic calculator that uses a lookup table to calculate its current state
46 given the surrounding units. It could affect the power produced in its dynamically
47 solved parent, or the state of gradient for that parent.(For example a look up table
48 working as a gear box for a drive train will affect the torque and RPM of the
49 incoming shaft. Since it has no shaft of its own it will convert the parent shaft )
50 */
51 /************************************************************************/
52 class Unit;
53 class Traverser;
62
63
65
66
72 {
73 public:
78
82 virtual bool isValid() const;
83
87 virtual bool isConnected(agxPowerLine::Unit* otherUnit) const;
88
90
97
103 virtual bool connect(agxPowerLine::Connector* connector);
104
112 virtual bool connect(
113 agxPowerLine::Side mySide,
114 agxPowerLine::Side connectorSide,
115 agxPowerLine::Connector* connector);
116
121 virtual bool connect(agxPowerLine::Unit* otherUnit);
122
123 virtual bool connect(
124 agxPowerLine::Side mySide,
125 agxPowerLine::Side otherSide,
126 agxPowerLine::Unit* other);
127
128
129
130 virtual bool disconnect(agxPowerLine::Unit* unit);
131
133
134
135
136 // Methods called by the rest of the PowerLine/Hydraulics frame work.
137 public:
144
150
153
164
165
169 virtual size_t getNumConnectableDimensions(Side side) const;
170
171
176 void getOwnConnectedUnits(UnitPtrSetVector& unitSet, bool startFromCleanUnitSet = true) const;
177 void getOwnConnectedUnits(UnitPtrSetVector& unitSet, agxPowerLine::Side side, bool startFromCleanUnitSet = true) const;
178
185
186
193
194
201
207
213
214 /*
215 Functions called by static functions. Do NOT use them.
216 */
217
218
221
228 virtual bool addNotification(agxSDK::Simulation* simulation) override;
229 virtual bool removeNotification(agxUtil::ConstraintHolder* constraintHolder, agxSDK::Simulation* simulation) override;
231
232
233 agxPowerLine::PowerLine* getPowerLine() const;
234
236 bool hasConnector( const Connector* connector ) const;
237
238
241 size_t getNumConnections() const;
242
252 size_t getConnectors(const agxPowerLine::Unit* unit, agxPowerLine::ConnectorPtrVector& result);
253 size_t getInputConnectors(const agxPowerLine::Unit* unit, agxPowerLine::ConnectorPtrVector& result);
254 size_t getOutputConnectors(const agxPowerLine::Unit* unit, agxPowerLine::ConnectorPtrVector& result);
255
256 size_t getConnectors(agxPowerLine::ConnectorPtrVector& result) const;
257 size_t getInputConnectors(agxPowerLine::ConnectorPtrVector& result) const;
258 size_t getOutputConnectors(agxPowerLine::ConnectorPtrVector& result) const;
259
260
261 Connector* getFirstInputConnector(const agxPowerLine::Unit* unit) const;
262 Connector* getFirstOutputConnector(const agxPowerLine::Unit* unit) const;
263
264 agxPowerLine::Side getSide(const Connector* connector) const;
265
266
267 bool getIgnoreForStoreRestoreStream() const;
268
269
270 virtual bool postStore(agxStream::StorageStream& str) const;
271
272 virtual bool postRestore(agxStream::StorageStream& str);
273
277 virtual bool store(agxStream::StorageStream& str) const override;
278
282 virtual bool restore(agxStream::StorageStream& str) override;
283
284 void spreadRootToGraph();
285
286 agxPowerLine::Unit* getRoot() const;
287
288 void setRoot(agxPowerLine::Unit* root);
289
290 virtual bool vetoConnect(agxPowerLine::Connector* connector) const;
291
293 virtual void store(agxStream::OutputArchive& out) const override;
294 virtual void restore(agxStream::InputArchive& in) override;
295
296 protected:
297 virtual ~Unit();
298
302 friend class Traverser;
303 friend class GraphTraverser;
304 friend class PowerLine;
305 friend class Actuator;
306 friend class Connector;
307
311 virtual bool hasValidInputConnection() const;
312
316 void setPowerLine(PowerLine* powerLine);
317
318 bool activateDimension( PhysicalDimension* dimension );
319
320 void restorePre46(agxStream::InputArchive& in);
321
322 protected:
324
325 agx::observer_ptr<agx::RigidBody> m_attachBody;
326
327 bool m_ignoreMeForStoreRestoreStream;
328
329 agxPowerLine::Unit* m_rootUnit;
330 };
331
332 typedef agx::ref_ptr< Unit > UnitRef;
333}
#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
#define AGXMODEL_EXPORT
Abstract base class for connecting a agxPowerLine::Unit to an ordinary constraint such as a Hinge or ...
Definition: Actuator.h:47
Links two connections together.
Definition: Connector.h:53
PowerLine is the base class for a system of power transfer integrated into the rigid body simulation.
Definition: PowerLine.h:66
Pure virtual class.
Definition: Unit.h:72
virtual bool connect(agxPowerLine::Side mySide, agxPowerLine::Side connectorSide, agxPowerLine::Connector *connector)
Connect the unit to a connector, specifying the side of each.
virtual size_t getNumConnectableDimensions(Side side) const
agxPowerLine::PhysicalDimension * getConnectableInputDimension(agxPowerLine::PhysicalDimension::Type type)
virtual bool disconnect(agxPowerLine::Unit *unit)
virtual bool connect(agxPowerLine::Unit *otherUnit)
Connect the unit to another unit.
void addNotification(agxPowerLine::PowerLine *powerLine)
void removeNotification(agxPowerLine::PowerLine *powerLine)
void getOwnConnectedUnits(UnitPtrSetVector &unitSet, bool startFromCleanUnitSet=true) const
Constructs the set of Units connected to this Unit's own dimensions.
agxPowerLine::PhysicalDimension * getConnectableOutputDimension(agxPowerLine::PhysicalDimension::Type type)
void getConnectedUnits(UnitPtrSetVector &result, agxPowerLine::Side side)
agx::String buildDimensionsName() const
agxPowerLine::PhysicalDimensionRefVector & getDimensions()
Unit()
Constructor.
size_t getNumActiveDimensions() const
The number of non-null PhysicalDimension in this Unit, not including internal Units.
const agxPowerLine::PhysicalDimensionRefVector & getDimensions() const
void attach(agx::RigidBody *body)
Define which body in the simulation this Unit is attached to.
virtual void getConnectableDimensionTypes(agxPowerLine::PhysicalDimension::TypeVector &types, agxPowerLine::Side side) const
agxPowerLine::PhysicalDimension * getActiveDimension(size_t index)
virtual bool isValid() const
const agxPowerLine::PhysicalDimension * getDimension(agxPowerLine::PhysicalDimension::Type type) const
virtual agxPowerLine::DimensionAndSide getConnectableDimension(agxPowerLine::PhysicalDimension::Type type, agxPowerLine::Side side)
agxPowerLine::PhysicalDimension * getDimension(agxPowerLine::PhysicalDimension::Type type)
virtual bool isConnected(agxPowerLine::Unit *otherUnit) const
virtual bool connect(agxPowerLine::Side mySide, agxPowerLine::Side otherSide, agxPowerLine::Unit *other)
virtual bool connect(agxPowerLine::Connector *connector)
Connect the unit to a connector.
const agxPowerLine::PhysicalDimension * getActiveDimension(size_t index) const
void getOwnConnectedUnits(UnitPtrSetVector &unitSet, agxPowerLine::Side side, bool startFromCleanUnitSet=true) const
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: agx/HashSet.h:670
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:49
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
agxPowerLine contains a collection of connected components that transport power across a system.
Definition: MotorUnit.h:24
agx::SetVector< Unit * > UnitPtrSetVector
Definition: Connector.h:40
agx::Vector< UnitRef > UnitRefVector
Definition: Connector.h:46
agx::Vector< std::pair< agxPowerLine::PhysicalDimension *, agxPowerLine::Side > > DimensionSideVector
Definition: Unit.h:64
agx::HashSet< UnitRef > UnitRefSet
Definition: Unit.h:59
std::pair< agxPowerLine::PhysicalDimension *, agxPowerLine::Side > DimensionAndSide
agx::Vector< ConnectorRef > ConnectorRefVector
Definition: Connector.h:405
agx::ref_ptr< Unit > UnitRef
Definition: Connector.h:45
agx::Vector< Connector * > ConnectorPtrVector
Definition: Connector.h:401
agx::SetVector< UnitRef > UnitRefSetVector
Definition: Unit.h:60
agx::Vector< agx::observer_ptr< Unit > > UnitObsVector
Definition: Unit.h:56
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 agxUtil namespace contain classes and methods for utility functionality.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.