File indexing completed on 2025-01-18 09:27:42
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Plugins/Json/ActsJson.hpp"
0013 #include "Acts/Surfaces/SurfaceBounds.hpp"
0014
0015 #include <array>
0016 #include <cstddef>
0017 #include <memory>
0018 #include <string>
0019 #include <vector>
0020
0021 #include <nlohmann/json.hpp>
0022
0023
0024 namespace Acts {
0025 class SurfaceBounds;
0026
0027 void to_json(nlohmann::json& j, const SurfaceBounds& bounds);
0028
0029 namespace SurfaceBoundsJsonConverter {
0030
0031
0032
0033
0034 nlohmann::json toJson(const SurfaceBounds& bounds);
0035
0036
0037
0038
0039
0040
0041
0042
0043 nlohmann::json toJsonDetray(const SurfaceBounds& bounds, bool portal = false);
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 template <typename bounds_t>
0054 std::shared_ptr<const bounds_t> fromJson(const nlohmann::json& j) {
0055 const std::size_t kValues = bounds_t::BoundValues::eSize;
0056 std::array<ActsScalar, kValues> bValues{};
0057 std::vector<ActsScalar> bVector = j["values"];
0058 std::copy_n(bVector.begin(), kValues, bValues.begin());
0059 return std::make_shared<const bounds_t>(bValues);
0060 }
0061
0062 }
0063
0064
0065 NLOHMANN_JSON_SERIALIZE_ENUM(
0066 SurfaceBounds::BoundsType,
0067 {{SurfaceBounds::BoundsType::eCone, "ConeBounds"},
0068 {SurfaceBounds::BoundsType::eCylinder, "CylinderBounds"},
0069 {SurfaceBounds::BoundsType::eDiamond, "DiamondBounds"},
0070 {SurfaceBounds::BoundsType::eDisc, "RadialBounds"},
0071 {SurfaceBounds::BoundsType::eEllipse, "EllipseBounds"},
0072 {SurfaceBounds::BoundsType::eLine, "LineBounds"},
0073 {SurfaceBounds::BoundsType::eRectangle, "RectangleBounds"},
0074 {SurfaceBounds::BoundsType::eTrapezoid, "TrapezoidBounds"},
0075 {SurfaceBounds::BoundsType::eTriangle, "TriangleBounds"},
0076 {SurfaceBounds::BoundsType::eDiscTrapezoid, "DiscTrapezoidBounds"},
0077 {SurfaceBounds::BoundsType::eConvexPolygon, "ConvexPolygonBounds"},
0078 {SurfaceBounds::BoundsType::eAnnulus, "AnnulusBounds"},
0079 {SurfaceBounds::BoundsType::eBoundless, "Boundless"},
0080 {SurfaceBounds::BoundsType::eOther, "OtherBounds"}})
0081
0082 }