AGXDynamics  2.35.0.3
SubGraph.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 
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
agx::Real
double Real
Definition: Real.h:42
agxPowerLine::SubGraph::m_name
agx::Name m_name
Definition: SubGraph.h:173
agxPowerLine::SubGraph::m_powerLine
PowerLine * m_powerLine
Definition: SubGraph.h:172
agxPowerLine::SubGraph
Definition: SubGraph.h:60
agx::Vector
Templated vector class.
Definition: Vector.h:52
agxStream::out
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.
Definition: OutputArchive.h:412
agxStream::Serializable
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
export.h
Constraint.h
agxUtil::ConstraintHolder
Utility class to hold custom implementations of constraints.
Definition: agxUtil.h:463
agxPowerLine::SubGraph::m_internalConnectors
ConnectorRefVector m_internalConnectors
Definition: SubGraph.h:171
agxStream::StorageStream
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE
#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
agxPowerLine::SubGraph::m_internalUnits
UnitRefVector m_internalUnits
Definition: SubGraph.h:170
agx::observer_ptr< SubGraph >
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
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
AGX_DECLARE_VECTOR_TYPES
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
agx::ref_ptr< Connector >
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agxPowerLine::UnitRef
agx::ref_ptr< Unit > UnitRef
Definition: InverseDynamics.h:63
agxPowerLine::UnitRefVector
agx::Vector< UnitRef > UnitRefVector
Definition: InverseDynamics.h:64
agxPowerLine::PowerLine
PowerLine is the base class for a system of power transfer integrated into the rigid body simulation.
Definition: PowerLine.h:70
agx::Name
Representation of a name string.
Definition: Name.h:32
agxPowerLine::ConnectorRefVector
agx::Vector< ConnectorRef > ConnectorRefVector
Definition: Connector.h:406
agxPowerLine::ConnectorRef
agx::ref_ptr< Connector > ConnectorRef
Definition: Connector.h:405
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
agxPowerLine::SubGraph::m_enclosingGraph
SubGraphObserver m_enclosingGraph
Definition: SubGraph.h:169
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
agxPowerLine::UnitPtrVector
agx::Vector< Unit * > UnitPtrVector
Definition: PhysicalDimension.h:74
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agxPowerLine
agxPowerLine contains a collection of connected components that transport power across a system.
Definition: MotorUnit.h:23
agxPowerLine::Connector
Links two connections together.
Definition: Connector.h:53
agx::Bool
bool Bool
Definition: Integer.h:48
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agxPowerLine::ConnectorPtrVector
agx::Vector< Connector * > ConnectorPtrVector
Definition: Connector.h:402
agxUtil
The agxUtil namespace contain classes and methods for utility functionality.
Definition: CylindricalJoint.h:22