AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
DotGraphWriter.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
9having been advised so by Algoryx Simulation AB for a time limited evaluation,
10or having purchased a valid 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 <agx/Referenced.h>
20#include <agx/HashTable.h>
22
23namespace agxPowerLine
24{
25 class PowerLine;
26
28
29
31 {
32 public:
33 DotGraphWriter(const char* rotRateQuantity = "rad/s", const char* transRateQuantity = "m/s");
34
35 void registerQuantity(const char* dimensionName, const char* quantityName);
36
37 bool writeDimensionsGraph(const agx::String& filename, const PowerLine* powerline);
38 bool writeDimensionsGraph(const agx::String& filename, const agxPowerLine::Unit* startUnit);
40
41 //bool writeUnitGraph(const char* filename, agxPowerLine::PowerLine* powerline);
42
43 // Each Physical Dimension and Connector belong to a Sub Graph. This struct
44 // keeps track of those relationships. We only track top-level Sub Graphs,
45 // so any nesting is flattened when this is being built.
46 struct SeenSubGraph {
48 // These contain indices pointing into m_seenDimensions and m_seenConnectors.
51
52 SeenSubGraph(const SubGraph* inSubGraph)
53 : subGraph {inSubGraph}
54 {
55 if (subGraph->is<Unit>())
56 {
57 // Most Units have only 1 Physical Dimension.
58 dimensions.reserve(1);
59 }
60 }
61 };
62
63 protected:
64 virtual ~DotGraphWriter() {}
65
66 private:
67 void clear();
68 bool writeDimensionsGraph(const agx::String& filename);
69 void visitDimensionConnections( const agxPowerLine::ConnectionRefVector& connections );
70 void visitConnectorDimensions( const agxPowerLine::ConnectionRefVector& connections );
71 struct SeenSubGraph& getSeenRootSubGraph(const SubGraph* subGraph);
72
73 private:
74 typedef agx::HashTable<agx::String, agx::String> QuantitiesTable;
75 QuantitiesTable m_quantities;
76
77
78 typedef agx::Vector<const PhysicalDimension*> DimensionVector;
79 typedef agx::Vector<const Connector*> ConnectorVector;
80
81 typedef agx::Vector<SeenSubGraph> SeenSubGraphVector;
82 SeenSubGraphVector m_seenSubGraphs;
83
84 // The index of each dimension and connector in these vectors determines it's
85 // ID within the DOT graph. Each dimension and connector may only be represented
86 // once.
87 DimensionVector m_seenDimensions;
88 ConnectorVector m_seenConnectors;
89
90 typedef agx::HashTable<const SubGraph*, size_t> SubGraphToIndexTable;
91 typedef agx::HashTable<const PhysicalDimension*, size_t> DimensionToIndexTable;
92 typedef agx::HashTable<const Connector*, size_t> ConnectorToIndexTable;
93
94 // The index of each unit, dimension and connector is kept in these hash tables.
95 SubGraphToIndexTable m_subGraphToIndexTable;
96 DimensionToIndexTable m_dimensionToIndexTable;
97 ConnectorToIndexTable m_connectorToIndexTable;
98
99 typedef agx::Vector<const Unit*> UnitVector;
100 UnitVector m_queue;
101 };
102}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXMODEL_EXPORT
DotGraphWriter(const char *rotRateQuantity="rad/s", const char *transRateQuantity="m/s")
bool writeDimensionsGraph(const agx::String &filename, const PowerLine *powerline)
void registerQuantity(const char *dimensionName, const char *quantityName)
bool writeDimensionsGraph(const agx::String &filename, const agxPowerLine::Unit *startUnit)
bool writeDimensionsGraph(const agx::String &filename, const UnitPtrPowerLinePtrHashVector &roots)
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
void reserve(size_t size)
Reserve capacity in the hash set.
Definition: agx/HashSet.h:455
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: agx/HashSet.h:670
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: HashVector.h:41
Inheritance with partial specialization due to bug with ref_ptr containers.
Base class providing referencing counted objects.
Definition: Referenced.h:120
bool is() const
Subclass test.
agxPowerLine contains a collection of connected components that transport power across a system.
Definition: MotorUnit.h:24
SeenSubGraph(const SubGraph *inSubGraph)