shape.cpp
Go to the documentation of this file.
1 #include "shape.h"
2 
3 #include <SemanticObjectRelations/Shapes/json.h>
4 
5 namespace armarx
6 {
7 
8  semantic::data::Shape
9  semantic::toIce(const semrel::Shape& shape)
10  {
11  semantic::data::Shape result;
12  result.json = nlohmann::json(shape).dump();
13  return result;
14  }
15 
16  semrel::ShapePtr
17  semantic::fromIce(const semantic::data::Shape& shape)
18  {
19  return nlohmann::json::parse(shape.json).get<semrel::ShapePtr>();
20  }
21 
22  semantic::data::ShapeList
23  semantic::toIce(const semrel::ShapeList& shapes)
24  {
25  semantic::data::ShapeList result;
26  result.reserve(shapes.size());
27  for (const auto& shape : shapes)
28  {
29  result.push_back(toIce(*shape));
30  }
31  return result;
32  }
33 
34  semantic::data::ShapeList
35  semantic::toIce(const semrel::ShapeMap& shapes)
36  {
37  semantic::data::ShapeList result;
38  result.reserve(shapes.size());
39  for (const auto& [id, shape] : shapes)
40  {
41  result.push_back(toIce(*shape));
42  }
43  return result;
44  }
45 
46  semrel::ShapeList
47  semantic::fromIce(const semantic::data::ShapeList& shapes)
48  {
49  semrel::ShapeList result;
50  result.reserve(shapes.size());
51  for (const auto& shape : shapes)
52  {
53  result.push_back(fromIce(shape));
54  }
55  return result;
56  }
57 
58 } // namespace armarx
shape.h
armarx::semantic::toIce
data::Graph toIce(const semrel::AttributedGraph &input)
Definition: graph.cpp:15
armarx::toIce
void toIce(std::map< IceKeyT, IceValueT > &iceMap, const boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:15
armarx::fromIce
void fromIce(const std::map< IceKeyT, IceValueT > &iceMap, boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:27
armarx::semantic::fromIce
semrel::AttributedGraph fromIce(const semantic::data::Graph &graph)
Definition: graph.h:31
shapes
MiscLib::Vector< std::pair< MiscLib::RefCountPtr< PrimitiveShape >, size_t > > shapes
Definition: ReadMe.txt:92
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27