21 #include <nlohmann/json.hpp>
29 namespace SurfaceBoundsJsonConverter {
53 template <
typename bounds_t>
54 std::shared_ptr<const bounds_t>
fromJson(
const nlohmann::json&
j) {
55 const size_t kValues = bounds_t::BoundValues::eSize;
56 std::array<ActsScalar, kValues> bValues{};
57 std::vector<ActsScalar> bVector = j[
"values"];
58 std::copy_n(bVector.begin(), kValues, bValues.begin());
59 return std::make_shared<const bounds_t>(bValues);
65 NLOHMANN_JSON_SERIALIZE_ENUM(
67 {{SurfaceBounds::BoundsType::eCone,
"ConeBounds"},
68 {SurfaceBounds::BoundsType::eCylinder,
"CylinderBounds"},
69 {SurfaceBounds::BoundsType::eDiamond,
"DiamondBounds"},
70 {SurfaceBounds::BoundsType::eDisc,
"RadialBounds"},
71 {SurfaceBounds::BoundsType::eEllipse,
"EllipseBounds"},
72 {SurfaceBounds::BoundsType::eLine,
"LineBounds"},
73 {SurfaceBounds::BoundsType::eRectangle,
"RectangleBounds"},
74 {SurfaceBounds::BoundsType::eTrapezoid,
"TrapezoidBounds"},
75 {SurfaceBounds::BoundsType::eTriangle,
"TriangleBounds"},
76 {SurfaceBounds::BoundsType::eDiscTrapezoid,
"DiscTrapezoidBounds"},
77 {SurfaceBounds::BoundsType::eConvexPolygon,
"ConvexPolygonBounds"},
78 {SurfaceBounds::BoundsType::eAnnulus,
"AnnulusBounds"},
79 {SurfaceBounds::BoundsType::eBoundless,
"Boundless"},
80 {SurfaceBounds::BoundsType::eOther,
"OtherBounds"}})