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