AGX Dynamics  2.37.2.0
SubGraph.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 
18 #ifndef AGXPOWERLINE_SUB_GRAPH_ROUTER_H
19 #define AGXPOWERLINE_SUB_GRAPH_ROUTER_H
20 
21 #include <agxModel/export.h>
22 #include <agx/Constraint.h>
23 
24 namespace agx
25 {
26  class RigidBody;
27 }
28 
29 namespace agxPowerLine
30 {
31  class PowerLine;
32  class PhysicalDimension;
33  class Connector;
34  class Unit;
35 
38 
43 }
44 
45 namespace agxUtil
46 {
47  class ConstraintHolder;
48 }
49 
50 namespace agxPowerLine
51 {
52 
55 
56 
61  {
62  public:
63 
64  SubGraph();
65 
70  void setName(const agx::Name& name);
71 
75  const agx::Name& getName() const;
76 
77  SubGraph* getEnclosingGraph();
78  const SubGraph* getEnclosingGraph() const;
79 
83  SubGraph* getRootEnclosingGraph();
84 
88  const SubGraph* getRootEnclosingGraph() const;
89 
90  Unit* getEnclosingUnit();
91  const Unit* getEnclosingUnit() const;
92 
93  Connector* getEnclosingConnector();
94  const Connector* getEnclosingConnector() const;
95 
99  bool isEnclosedWithin(const SubGraph* component) const;
100 
105  virtual void getConnectorsRecursive(ConnectorPtrVector& connectors);
106 
111  virtual void getUnitsRecursive(UnitPtrVector& units);
112 
113 
114  // Methods called by the rest of the PowerLine frame work.
115  public:
116 
117  virtual bool addNotification(agxSDK::Simulation* simulation) = 0;
118 
119  virtual void prepareForStore();
120  virtual void prepareForRestore();
121 
122 
123  const agxPowerLine::UnitRefVector& getInternalUnits() const;
124  const agxPowerLine::ConnectorRefVector& getInternalConnectors() const;
125  virtual bool removeNotification(agxUtil::ConstraintHolder* holder, agxSDK::Simulation* simulation) = 0;
126 
127 
128  void spreadPowerLineToGraph();
129 
140  virtual bool preUpdate(agx::Real timeStep);
141  virtual bool postUpdate(agx::Real timeStep);
142 
146  virtual bool store(agxStream::StorageStream& str) const;
147 
151  virtual bool restore(agxStream::StorageStream& str);
152 
154  virtual void restore(agxStream::InputArchive& in) override;
155  virtual void store(agxStream::OutputArchive& out) const override;
156 
157  protected:
158  virtual ~SubGraph();
159 
160  void addInternalUnit(agxPowerLine::Unit* unit);
161  void addInternalConnector(agxPowerLine::Connector* connector);
162 
163  void removeInternalUnit(agxPowerLine::Unit* unit);
164  void removeInternalConnector(agxPowerLine::Connector* connector);
165 
166  agx::Bool replaceInternalUnit(agxPowerLine::Unit* oldUnit, agxPowerLine::Unit* newUnit);
167 
168  protected:
174  };
175 
176 
177 }
178 
179 #endif
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
Utility class to hold custom implementations of constraints.
Definition: agxUtil.h:463
SubGraphObserver m_enclosingGraph
Definition: SubGraph.h:169
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...
bool Bool
Definition: Integer.h:48
Pure virtual class.
Definition: Unit.h:72
PowerLine * m_powerLine
Definition: SubGraph.h:172
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
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
agx::Vector< Connector * > ConnectorPtrVector
Definition: Connector.h:402
Base class providing referencing counted objects.
Definition: Referenced.h:119
Templated vector class.
Definition: Vector.h:52
agx::Vector< UnitRef > UnitRefVector
agx::ref_ptr< Unit > UnitRef
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agx::Vector< ConnectorRef > ConnectorRefVector
Definition: Connector.h:406
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
UnitRefVector m_internalUnits
Definition: SubGraph.h:170
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
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
#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
double Real
Definition: Real.h:42
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
PowerLine is the base class for a system of power transfer integrated into the rigid body simulation...
Definition: PowerLine.h:70
ConnectorRefVector m_internalConnectors
Definition: SubGraph.h:171
The agxUtil namespace contain classes and methods for utility functionality.