MCPcopy Create free account
hub / github.com/OSVR/OSVR-Core / ~DOTGraphOutput

Method ~DOTGraphOutput

apps/PathTreeExport/DOTGraphOutput.cpp:47–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 m_outputLineWithId(root.getID(), os.str());
46}
47DOTGraphOutput::~DOTGraphOutput() {
48 m_os << "digraph {\n";
49 m_os << "rankdir = LR\n";
50 auto endOfReferencedIds = end(m_referencedIds);
51
52 /// Output only the referenced nodes
53 for (auto const &idAndOutput : m_idAndOutput) {
54 if (m_referencedIds.find(idAndOutput.first) != endOfReferencedIds) {
55 m_os << idAndOutput.second << "\n";
56 }
57 }
58
59 if (m_treeShape) {
60 /// Specify the nodes that should be on the same "rank" for the tree
61 /// structure.
62 typedef uint8_t Rank;
63 std::set<Rank> ranks;
64 std::multimap<Rank, std::string> rankAndIDs;
65 for (auto const &nameNode : m_nodes) {
66 if (m_referencedIds.find(nameNode.second->getID()) ==
67 endOfReferencedIds) {
68 /// This node wasn't referenced.
69 continue;
70 }
71 Rank rank;
72 if (nameNode.first == "/") {
73 // This is the root - special
74 rank = 0;
75 } else {
76 rank = std::count(nameNode.first.begin(), nameNode.first.end(),
77 '/');
78 }
79 ranks.insert(rank);
80 rankAndIDs.insert(std::make_pair(rank, nameNode.second->getID()));
81 }
82 for (auto const rank : ranks) {
83 m_os << "{ rank=same; ";
84 for (auto const &rankAndID :
85 boost::make_iterator_range(rankAndIDs.equal_range(rank))) {
86 m_os << rankAndID.second << " ";
87 }
88 m_os << "}\n";
89 }
90 }
91 m_os << "}\n";
92}
93
94NodeInterface &DOTGraphOutput::addNode(std::string const &label,
95 std::string const &fullPath,

Callers

nothing calls this directly

Calls 5

findMethod · 0.45
getIDMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected