AGXDynamics  2.35.0.3
PowerLine.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
9 having been advised so by Algoryx Simulation AB for a time limited evaluation,
10 or having purchased a 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_POWER_LINE_H
18 #define AGXPOWERLINE_POWER_LINE_H
19 
20 
21 
22 
23 #include <agxModel/export.h>
24 #include <agxPowerLine/Unit.h>
25 
27 #include <agxStream/Serializable.h>
29 
30 #include <agxUtil/agxUtil.h>
31 
32 #include <agx/RigidBody.h>
33 #include <agx/Singleton.h>
35 
39 
40 #include <agxSDK/Assembly.h>
41 
42 
43 #include <agx/HashVector.h>
44 
45 
46 
47 
48 #define POWER_LINE_DEBUG 0
49 
50 
51 namespace agxPowerLine
52 {
53 
54  class Actuator;
55  class PowerLinesHandler;
57 
61 
66 
71  {
72  public:
73  public:
74 
75  PowerLine();
76 
77  public:
82  int getDimensionType(std::string name);
83 
87  void createConstraintHolder();
88 
92  agxUtil::ConstraintHolder* getConstraintHolder() const;
93 
99  void setAddUnitsOnConnect(agx::Bool addOnConnect);
100  agx::Bool getAddUnitsOnConnect() const;
101 
106  void getRoots(agxPowerLine::UnitPtrPowerLinePtrHashVector& units) const;
107 
108 
109 
119  bool setSource(agxPowerLine::Unit* source);
120  bool setSource(agxPowerLine::SubGraph* source);
121 
125  const agxPowerLine::Unit* getSource() const;
126  agxPowerLine::Unit* getSource();
135  bool add(agxPowerLine::Unit* component);
136  bool add(agxPowerLine::SubGraph* component);
137  bool remove(agxPowerLine::SubGraph* component);
138 
139  size_t getNumUnits() const;
140  size_t getNumConnectors() const;
141 
148  Unit* getUnit(const agx::Name& name);
149 
156  const Unit* getUnit(const agx::Name& name) const;
157 
162  void setSolveType( agx::Constraint::SolveType solveType );
163 
167  agx::Constraint::SolveType getSolveType( ) const;
168 
169 
170  void insertSubGraphRouterTemporary(SubGraph* router);
171 
172  void insertConnectorTemporary( Connector* connector );
173 
174  void collectConstraintsToHolder();
175 
180  bool writeDimensionsGraph(const agx::String& path) const;
181  bool writeDimensionsGraph(const char* path) const;
182 
183 
184  const agxPowerLine::UnitRefSetVector& getUnits() const;
185  const agxPowerLine::ConnectorRefSet& getConnectors() const;
186 
187  virtual void addNotification(agxSDK::Simulation* simulation) override;
188  virtual void removeNotification(agxSDK::Simulation* simulation) override;
189 
193  virtual void addNotification(agxSDK::Assembly*) override {}
199  virtual void removeNotification(agxSDK::Assembly*) override {}
200  agxPowerLine::SlotMapper* getSlotMapper();
201 
210  virtual bool store(agxStream::StorageStream& str) const;
211 
221  virtual bool restore(agxStream::StorageStream& str);
222 
224 
225  static bool renderDebug();
226 
233  static agxPowerLine::PowerLine* find(agxSDK::Simulation* simulation, const agx::Name& name);
234 
241  static agxPowerLine::PowerLine* find(agxSDK::Assembly* assembly, const agx::Name& name);
242 
249  static PowerLinePtrVector findAll( const agxSDK::Simulation* simulation, const agx::Name& name );
250 
256  static PowerLinePtrVector findAll( const agxSDK::Simulation* simulation );
257 
258  public:
259  bool removeSubGraph(agxPowerLine::SubGraph* component);
260  bool removeUnit(agxPowerLine::Unit* unit);
261  bool removeConnector(agxPowerLine::Connector* connector);
262 
263  bool pointAddConnector(agxPowerLine::Connector* connector);
264  bool pointAddUnit(agxPowerLine::Unit* unit);
265  bool pointReplace( agxPowerLine::Unit* oldUnit, agxPowerLine::Unit* newUnit );
266 
267  bool cacheAdd(agxPowerLine::SubGraph* component);
268  bool cacheRemove(agxPowerLine::SubGraph* component);
269  bool hasCachedOperations() const;
270  void clearAddRemoveCache(ConnectorPtrVector& addedConnectors, UnitPtrVector& addedUnits);
271 
272  protected:
273 
274  friend class PowerLinesHandler;
275 
276  virtual ~PowerLine();
277 
278  bool traverseUnits(bool (*callback)(agxPowerLine::Unit*));
279  bool traverseDimensions(bool (*callback)(agxPowerLine::PhysicalDimension*));
280  bool traverseConnectors(bool (*callback)(agxPowerLine::Connector*));
281 
282  virtual void initialize();
283 
284  void pre(agx::Real time);
285  void post(agx::Real time);
286 
287  void prepareConstraintDimensions();
288 
289  bool preUpdateGraph();
290 
291  protected:
292  void restorePre46(agxStream::InputArchive& in);
293 
298  void setUnitPowerLine(agxPowerLine::Unit* unit);
299 
300 
301 
302  private:
303  bool shouldRenderDebug();
304 
305  protected:
308 
310 
312 
314 
316 
318 
321 
325  };
326 }
327 
328 
329 // AGXMODEL_POWER_LINE_H
330 #endif
agxPowerLine::PowerLine::m_cachedAdds
agxPowerLine::SubGraphRefVector m_cachedAdds
Definition: PowerLine.h:322
agxPowerLine::PowerLine::m_cacheAddsAndRemoves
bool m_cacheAddsAndRemoves
Definition: PowerLine.h:324
agxPowerLine::UnitPtrPowerLinePtrHashVector
agx::HashVector< agxPowerLine::Unit *, agxPowerLine::PowerLine * > UnitPtrPowerLinePtrHashVector
Definition: PowerLine.h:60
agxPowerLine::PowerLine::m_slotMapper
agxPowerLine::SlotMapperRef m_slotMapper
Definition: PowerLine.h:309
agx::Real
double Real
Definition: Real.h:42
agxPowerLine::PowerLine::removeNotification
virtual void removeNotification(agxSDK::Assembly *) override
Called when this assembly is removed from another assembly.
Definition: PowerLine.h:199
agxPowerLine::PowerLine::m_cachedRemoves
agxPowerLine::SubGraphRefVector m_cachedRemoves
Definition: PowerLine.h:323
agxPowerLine::SubGraph
Definition: SubGraph.h:60
agx::Vector< PowerLineRef >
agxPowerLine::PowerLine::m_solveType
agx::Constraint::SolveType m_solveType
Definition: PowerLine.h:317
Unit.h
agxPowerLine::PowerLine::addNotification
virtual void addNotification(agxSDK::Assembly *) override
Called when this assembly is added to another assembly.
Definition: PowerLine.h:193
export.h
HashVector.h
agxUtil::ConstraintHolder
Utility class to hold custom implementations of constraints.
Definition: agxUtil.h:463
TranslationalDimension.h
agxPowerLine::PowerLineRef
agx::ref_ptr< PowerLine > PowerLineRef
Definition: InverseDynamics.h:67
Assembly.h
agxStream::StorageStream
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
StepEventListener.h
agxPowerLine::PhysicalDimension
Pure virtual class.
Definition: PhysicalDimension.h:93
agxPowerLine::PowerLinesHandler
A PowerLinesHandler is a collection of PowerLines that are part of the same agxSDK::Simulation.
Definition: PowerLineController.h:42
AGXSTREAM_DECLARE_SERIALIZABLE
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
agx::VectorPOD
Vector containing 'raw' data.
Definition: Vector.h:245
agx::observer_ptr< PowerLine >
agxPowerLine::PowerLine::m_tempRouterHashVector
SubGraphRouterBoolHashVector m_tempRouterHashVector
Definition: PowerLine.h:319
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:400
agxPowerLine::Unit
Pure virtual class.
Definition: Unit.h:72
agxPowerLine::PowerLine::m_tempConnectorHashVector
ConnectorBoolHashVector m_tempConnectorHashVector
Definition: PowerLine.h:320
agxSDK::Assembly
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints,...
Definition: Assembly.h:66
agxPowerLine::PowerLineObsPtr
agx::observer_ptr< PowerLine > PowerLineObsPtr
Definition: PowerLine.h:62
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agx::SetVector< UnitRef >
agxPowerLine::PowerLine::m_connectors
agxPowerLine::ConnectorRefSet m_connectors
Definition: PowerLine.h:307
agxPowerLine::SubGraphRouterBoolHashVector
agx::HashVector< agxPowerLine::SubGraph *, bool > SubGraphRouterBoolHashVector
Definition: PowerLine.h:59
agxPowerLine::PowerLine
PowerLine is the base class for a system of power transfer integrated into the rigid body simulation.
Definition: PowerLine.h:70
agxPowerLine::PowerLineRefVector
agx::Vector< PowerLineRef > PowerLineRefVector
Definition: InverseDynamics.h:68
agxPowerLine::PowerLine::m_addOnConnect
bool m_addOnConnect
Definition: PowerLine.h:315
agxPowerLine::PowerLineCollector
PowerLineTraverser that stores the nodes it visits.
Definition: PowerLineTraverser.h:186
agxPowerLine::ConnectorBoolHashVector
agx::HashVector< agxPowerLine::Connector *, bool > ConnectorBoolHashVector
Definition: PowerLine.h:56
agx::Name
Representation of a name string.
Definition: Name.h:32
agxPowerLine::SlotMapper
The SlotMapper is reponsible for mapping one dimensional dimension states to slots in the RigidBodies...
Definition: SlotMapper.h:51
Serializable.h
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
RigidBody.h
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:53
agx::Bool
bool Bool
Definition: Integer.h:48
Singleton.h
agxPowerLine::PowerLine::m_units
agxPowerLine::UnitRefSetVector m_units
Definition: PowerLine.h:306
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agxPowerLine::getDimensionType
AGXMODEL_EXPORT agxPowerLine::PhysicalDimension::Type getDimensionType(const std::string &dimensionName)
agx::Constraint::SolveType
SolveType
Specifies in what solvers the constraint will be solved.
Definition: Constraint.h:92
agx::AgXString< std::string >
RotationalDimension.h
agxPowerLine::PowerLine::m_constraintHolder
agxUtil::ConstraintHolderRef m_constraintHolder
Definition: PowerLine.h:313
agx::HashVector< agxPowerLine::Connector *, bool >
StorageStream.h
agxPowerLine::PowerLinePtrVector
agx::VectorPOD< PowerLine * > PowerLinePtrVector
Definition: PowerLine.h:64
agxPowerLine::PowerLine::m_parentBody
agx::observer_ptr< agx::RigidBody > m_parentBody
Definition: PowerLine.h:311
agxSDK::Assembly::removeNotification
virtual void removeNotification(agxSDK::Simulation *)
Called when this assembly is removed from a simulation.
Definition: Assembly.h:618
SlotMapper.h
agxUtil.h
agxSDK::Assembly::addNotification
virtual void addNotification(agxSDK::Simulation *)
Called when this assembly is added to a simulation (given that it not already is in the simulation).
Definition: Assembly.h:613