25 #include <SemanticObjectRelations/Shapes/Shape.h>
26 #include <SimoxUtility/color/cmaps.h>
28 #include <RobotAPI/libraries/armem/aron/MemoryID.aron.generated.h>
53 int shapeIDCounter = 0;
55 graph.attrib().initialMemoryID =
memoryID;
58 std::map<armarx::armem::MemoryID, int> shapeIDs;
59 std::vector<std::tuple<int, int, std::pair<std::string, bool>>> edges;
60 std::vector<armarx::armem::MemoryID> currentLevel{
memoryID};
61 std::vector<armarx::armem::MemoryID> nextLevel;
64 shapeIDs[
memoryID] = shapeIDCounter++;
66 while (!currentLevel.empty())
73 graph.addVertex(semrel::ShapeID{shapeIDs[vertID]}, vert);
83 ARMARX_WARNING <<
"Could not extract Aron data and type from memory object.";
86 auto [aronData, aronType] = objectAndType.value();
88 auto ids = getMemoryIDs(aronData, aronType);
89 for (
const auto& ref : ids)
91 if (!ref.second.hasMemoryName())
96 nowhere.
depth = depth + 1;
97 int nowhereID = shapeIDCounter++;
98 graph.addVertex(semrel::ShapeID{nowhereID}, nowhere);
100 shapeIDs[vertID], nowhereID, std::make_pair(ref.first,
true));
104 if (shapeIDs.find(ref.second) == shapeIDs.end())
106 shapeIDs[ref.second] = shapeIDCounter++;
107 nextLevel.push_back(ref.second);
110 shapeIDs[vertID], shapeIDs[ref.second], std::make_pair(ref.first,
false));
113 currentLevel = std::move(nextLevel);
118 for (
const auto& [vert1, vert2, edgeProps] : edges)
123 graph.addEdge(semrel::ShapeID{vert1}, semrel::ShapeID{vert2}, memEdge);
130 for (
auto vertex : graph.vertices())
132 maxDepth =
std::max(maxDepth, vertex.attrib().depth);
135 simox::ColorMap cmap = simox::color::cmaps::GnBu();
136 cmap.set_vlimits(0, maxDepth + 1);
137 for (
auto vertex : graph.vertices())
148 std::map<std::string, armarx::armem::MemoryID>