5#include <SimoxUtility/algorithm/string.h>
8#include <ArmarXCore/interface/core/BasicVectorTypes.h>
17 {OVERRIDE_MATERIAL,
"Override_Material"},
22 {ORIGINAL,
"Original"},
23 {COLLISION,
"Collision"},
24 {OVERRIDE_COLOR,
"Override_Color"},
30 j[
"x"] = coloredPoint.x;
31 j[
"y"] = coloredPoint.y;
32 j[
"z"] = coloredPoint.z;
33 j[
"color"] = coloredPoint.color;
40 coloredPoint.x = j.at(
"x");
41 coloredPoint.y = j.at(
"y");
42 coloredPoint.z = j.at(
"z");
43 coloredPoint.color = j.at(
"color");
50 j[
"length"] = arrow.length;
51 j[
"width"] = arrow.width;
58 arrow.length = j.at(
"length");
59 arrow.width = j.at(
"width");
66 j[
"radius"] = arrowCircle.radius;
67 j[
"completion"] = arrowCircle.completion;
68 j[
"width"] = arrowCircle.width;
75 arrowCircle.radius = j.at(
"radius");
76 arrowCircle.completion = j.at(
"completion");
77 arrowCircle.width = j.at(
"width");
91 box.size = j.at(
"size").get<armarx::Vector3f>();
98 j[
"height"] = cylinder.height;
99 j[
"radius"] = cylinder.radius;
106 cylinder.height = j.at(
"height");
107 cylinder.radius = j.at(
"radius");
114 j[
"height"] = cylindroid.height;
115 j[
"axisLengths"] = cylindroid.axisLengths;
116 j[
"curvature"] = cylindroid.curvature;
123 cylindroid.height = j.at(
"height");
124 cylindroid.axisLengths = j.at(
"axisLengths").get<armarx::Vector2f>();
125 cylindroid.curvature = j.at(
"curvature").get<armarx::Vector2f>();
132 j[
"from"] = line.from;
134 j[
"lineWidth"] = line.lineWidth;
141 line.from = j.at(
"from").get<armarx::Vector3f>();
142 line.to = j.at(
"to").get<armarx::Vector3f>();
143 line.lineWidth = j.at(
"lineWidth").get<
float>();
150 j[
"# Vertices"] = mesh.vertices.size();
151 j[
"# Colors"] = mesh.colors.size();
152 j[
"# Faces"] = mesh.faces.size();
169 j[
"transparency"] = pointCloud.transparency;
170 j[
"pointSizeInPixels"] = pointCloud.pointSizeInPixels;
172 std::size_t numPoints = pointCloud.points.size() /
sizeof(ColoredPoint);
173 j[
"# Points"] = numPoints;
176 ColoredPoint
const* begin = (ColoredPoint
const*)pointCloud.points.data();
177 ColoredPoint
const* end = begin + std::min(std::size_t(10), numPoints);
178 j[
"Points[0:10]"] = ColoredPointList(begin, end);
185 pointCloud.transparency = j.at(
"transparency");
186 pointCloud.pointSizeInPixels = j.at(
"pointSizeInPixels");
193 j[
"lineColor"] = polygon.lineColor;
195 j[
"lineWidth"] = polygon.lineWidth;
196 j[
"points"] = polygon.points;
203 polygon.lineColor = j.at(
"lineColor");
204 polygon.lineWidth = j.at(
"lineWidth");
205 polygon.points = j.at(
"points").get<std::vector<armarx::Vector3f>>();
224 j[
"points"] = path.points;
231 path.points = j.at(
"points").get<armarx::Vector3fSeq>();
238 j[
"radius"] = sphere.radius;
245 sphere.radius = j.at(
"radius");
252 j[
"axisLengths"] = ellipsoid.axisLengths;
253 j[
"curvature"] = ellipsoid.curvature;
260 ellipsoid.axisLengths = j.at(
"axisLengths");
261 ellipsoid.curvature = j.at(
"curvature");
268 j[
"text"] = text.text;
275 text.text = j.at(
"text");
283 std::vector<std::string> flag_names;
284 for (
int flag :
names.values())
286 if (drawStyle == flag
289 flag_names.push_back(
names.to_name(flag));
292 return simox::alg::join(flag_names,
" | ");
298 bool trim_elements =
true;
299 std::vector<std::string>
split = simox::alg::split(flagString,
"|", trim_elements);
301 for (
auto& s :
split)
303 flag |=
names.from_name(s);
313 j[
"project"] =
object.project;
314 j[
"filename"] =
object.filename;
317 std::to_string(
object.drawStyle) +
")";
325 object.project = j.at(
"project");
326 object.filename = j.at(
"filename");
334 j[
"project"] = robot.project;
335 j[
"filename"] = robot.filename;
336 j[
"jointValues"] = robot.jointValues;
346 robot.project = j.at(
"project");
347 robot.filename = j.at(
"filename");
348 robot.jointValues = j.at(
"jointValues").get<armarx::StringFloatDictionary>();
356 j[
"pose"] =
grid.pose;
357 j[
"resolution"] =
grid.resolution;
358 j[
"sizeX"] =
grid.sizeX;
359 j[
"sizeY"] =
grid.sizeY;
363 if (!
grid.colors.empty())
365 const std::size_t numPointsSelection = std::min<std::size_t>(10,
grid.colors.size());
367 const auto begin =
grid.colors.begin();
368 const auto end = begin + numPointsSelection;
370 j[
"Colors[0:10]"] = ::armarx::viz::data::ColorSeq(begin, end);
378 grid.pose = j.at(
"pose");
379 grid.resolution = j.at(
"resolution");
380 grid.sizeX = j.at(
"sizeX");
381 grid.sizeY = j.at(
"sizeY");
382 j.at(
"colors").get_to(
grid.colors);
const simox::meta::IntEnumNames names
int from_flag_names(const std::string &flagString)
std::string to_flag_names(const int drawStyle)
const simox::meta::IntEnumNames names
void to_json(nlohmann::json &j, RecordingBatchHeader const &batch)
void from_json(nlohmann::json const &j, RecordingBatchHeader &batch)
void from_json_base(const nlohmann::json &j, data::Element &value)
void to_json_base(nlohmann::json &j, const data::Element &element)
This file is part of ArmarX.
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)