5 #include <SimoxUtility/json.h>
6 #include <VirtualRobot/ManipulationObject.h>
10 #include <SemanticObjectRelations/Shapes.h>
11 #include <SemanticObjectRelations/Shapes/json.h>
15 JsonSimoxShapeSerializer::JsonSimoxShapeSerializer(
17 classSegment(classSegment)
26 j[
"class"] =
object.objectClassName;
27 j[
"instance"] =
object.object->getName();
28 j[
"entityId"] =
object.entityId;
34 const std::string objectClassName = j.at(
"class").get<std::string>();
36 VirtualRobot::ManipulationObjectPtr manipulationObject;
39 std::optional<memoryx::ObjectClassWrapper> objectClass =
40 classSegment->getClass(objectClassName);
43 const std::string instance = j.at(
"instance").get<std::string>();
44 manipulationObject = objectClass->manipulationObject->clone(instance);
48 object = SimoxObjectShape(manipulationObject, objectClassName);
50 object.entityId = j.at(
"entityId");
54 JsonSimoxShapeSerializer::registerSerializer(
55 const std::shared_ptr<JsonSimoxShapeSerializer>& instance,
58 semrel::json::ShapeSerializers::registerSerializer<SimoxObjectShape>(
59 [instance](nlohmann::json& j,
const SimoxObjectShape&
object)
60 { instance->to_json(j,
object); },
61 [instance](
const nlohmann::json& j, SimoxObjectShape& object)
62 { instance->from_json(j,
object); },