AGX Dynamics  2.38.0.2
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 #pragma once
18 
19 #include <agxModel/export.h>
20 #include <agx/Constraint.h>
21 
22 namespace agx
23 {
24  class RigidBody;
25 }
26 
27 namespace agxPowerLine
28 {
29  class PowerLine;
30  class PhysicalDimension;
31  class Connector;
32  class Unit;
33 
36 
41 }
42 
43 namespace agxUtil
44 {
45  class ConstraintHolder;
46 }
47 
48 namespace agxPowerLine
49 {
50 
53 
54 
59  {
60  public:
61 
62  SubGraph();
63 
68  void setName(const agx::Name& name);
69 
73  const agx::Name& getName() const;
74 
75  SubGraph* getEnclosingGraph();
76  const SubGraph* getEnclosingGraph() const;
77 
81  SubGraph* getRootEnclosingGraph();
82 
86  const SubGraph* getRootEnclosingGraph() const;
87 
88  Unit* getEnclosingUnit();
89  const Unit* getEnclosingUnit() const;
90 
91  Connector* getEnclosingConnector();
92  const Connector* getEnclosingConnector() const;
93 
97  bool isEnclosedWithin(const SubGraph* component) const;
98 
103  virtual void getConnectorsRecursive(ConnectorPtrVector& connectors);
104 
109  virtual void getUnitsRecursive(UnitPtrVector& units);
110 
111 
112  // Methods called by the rest of the PowerLine frame work.
113  public:
114 
115  virtual bool addNotification(agxSDK::Simulation* simulation) = 0;
116 
117  virtual void prepareForStore();
118  virtual void prepareForRestore();
119 
120 
121  const agxPowerLine::UnitRefVector& getInternalUnits() const;
122  const agxPowerLine::ConnectorRefVector& getInternalConnectors() const;
123  virtual bool removeNotification(agxUtil::ConstraintHolder* holder, agxSDK::Simulation* simulation) = 0;
124 
125 
126  void spreadPowerLineToGraph();
127 
138  virtual bool preUpdate(agx::Real timeStep);
139  virtual bool postUpdate(agx::Real timeStep);
140 
144  virtual bool store(agxStream::StorageStream& str) const;
145 
149  virtual bool restore(agxStream::StorageStream& str);
150 
152  virtual void restore(agxStream::InputArchive& in) override;
153  virtual void store(agxStream::OutputArchive& out) const override;
154 
155  protected:
156  virtual ~SubGraph();
157 
158  void addInternalUnit(agxPowerLine::Unit* unit);
159  void addInternalConnector(agxPowerLine::Connector* connector);
160 
161  void removeInternalUnit(agxPowerLine::Unit* unit);
162  void removeInternalConnector(agxPowerLine::Connector* connector);
163 
164  agx::Bool replaceInternalUnit(agxPowerLine::Unit* oldUnit, agxPowerLine::Unit* newUnit);
165 
166  protected:
172  };
173 }
agx::Real
double Real
Definition: Real.h:42
agxPowerLine::SubGraph::m_name
agx::Name m_name
Definition: SubGraph.h:171
agxPowerLine::SubGraph::m_powerLine
PowerLine * m_powerLine
Definition: SubGraph.h:170
agxPowerLine::SubGraph
Definition: SubGraph.h:58
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:169
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:168
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:399
agxPowerLine::Unit
Pure virtual class.
Definition: Unit.h:71
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:125
agxPowerLine::UnitRef
agx::ref_ptr< Unit > UnitRef
Definition: Connector.h:45
agxPowerLine::UnitRefVector
agx::Vector< UnitRef > UnitRefVector
Definition: Connector.h:46
agxPowerLine::PowerLine
PowerLine is the base class for a system of power transfer integrated into the rigid body simulation.
Definition: PowerLine.h:65
agx::Name
Representation of a name string.
Definition: Name.h:32
agxPowerLine::ConnectorRefVector
agx::Vector< ConnectorRef > ConnectorRefVector
Definition: Connector.h:405
agxPowerLine::ConnectorRef
agx::ref_ptr< Connector > ConnectorRef
Definition: Connector.h:404
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:167
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:50
agxPowerLine::UnitPtrVector
agx::Vector< Unit * > UnitPtrVector
Definition: PhysicalDimension.h:73
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:119
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
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:52
agx::Bool
bool Bool
Definition: Integer.h:40
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agxPowerLine::ConnectorPtrVector
agx::Vector< Connector * > ConnectorPtrVector
Definition: Connector.h:401
agxUtil
The agxUtil namespace contain classes and methods for utility functionality.
Definition: CylindricalJoint.h:20