shape.cpp
Go to the documentation of this file.
1 #include "shape.h"
2 
3 #include <SemanticObjectRelations/Shapes/json.h>
4 
5 
6 namespace armarx
7 {
8 
9  semantic::data::Shape 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 semantic::fromIce(const semantic::data::Shape& shape)
17  {
18  return nlohmann::json::parse(shape.json).get<semrel::ShapePtr>();
19  }
20 
21  semantic::data::ShapeList semantic::toIce(const semrel::ShapeList& shapes)
22  {
23  semantic::data::ShapeList result;
24  result.reserve(shapes.size());
25  for (const auto& shape : shapes)
26  {
27  result.push_back(toIce(*shape));
28  }
29  return result;
30  }
31 
32  semantic::data::ShapeList semantic::toIce(const semrel::ShapeMap& shapes)
33  {
34  semantic::data::ShapeList result;
35  result.reserve(shapes.size());
36  for (const auto& [id, shape] : shapes)
37  {
38  result.push_back(toIce(*shape));
39  }
40  return result;
41  }
42 
43  semrel::ShapeList semantic::fromIce(const semantic::data::ShapeList& shapes)
44  {
45  semrel::ShapeList result;
46  result.reserve(shapes.size());
47  for (const auto& shape : shapes)
48  {
49  result.push_back(fromIce(shape));
50  }
51  return result;
52  }
53 
54 }
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:26
armarx::semantic::fromIce
semrel::AttributedGraph fromIce(const semantic::data::Graph &graph)
Definition: graph.h:30
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:28