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/Geometry/GenericCuboidVolumeBounds.hpp"
0013 #include "Acts/Geometry/VolumeBounds.hpp"
0014 #include "Acts/Plugins/Json/ActsJson.hpp"
0015
0016 #include <array>
0017 #include <cstddef>
0018 #include <memory>
0019 #include <string>
0020 #include <vector>
0021
0022 #include <nlohmann/json.hpp>
0023
0024
0025
0026 namespace Acts {
0027
0028 void to_json(nlohmann::json& j, const VolumeBounds& bounds);
0029
0030 namespace VolumeBoundsJsonConverter {
0031
0032
0033
0034
0035
0036
0037 nlohmann::json toJson(const VolumeBounds& bounds);
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 template <typename bounds_t>
0048 std::unique_ptr<bounds_t> fromJson(const nlohmann::json& jVolumeBounds) {
0049 constexpr std::size_t kValues = bounds_t::BoundValues::eSize;
0050 std::array<ActsScalar, kValues> bValues{};
0051 std::vector<ActsScalar> bVector = jVolumeBounds["values"];
0052 std::copy_n(bVector.begin(), kValues, bValues.begin());
0053 return std::make_unique<bounds_t>(bValues);
0054 }
0055
0056
0057
0058
0059
0060 std::unique_ptr<VolumeBounds> fromJson(const nlohmann::json& jVolumeBounds);
0061
0062 }
0063
0064
0065 NLOHMANN_JSON_SERIALIZE_ENUM(
0066 VolumeBounds::BoundsType,
0067 {{VolumeBounds::BoundsType::eCone, "Cone"},
0068 {VolumeBounds::BoundsType::eCuboid, "Cuboid"},
0069 {VolumeBounds::BoundsType::eCutoutCylinder, "CutoutCylinder"},
0070 {VolumeBounds::BoundsType::eCylinder, "Cylinder"},
0071 {VolumeBounds::BoundsType::eGenericCuboid, "GenericCuboid"},
0072 {VolumeBounds::BoundsType::eTrapezoid, "Trapezoid"}})
0073
0074 }