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/Detector/detail/IndexedSurfacesGenerator.hpp"
0012 #include "Acts/Geometry/Extent.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Navigation/InternalNavigation.hpp"
0015 #include "Acts/Navigation/NavigationDelegates.hpp"
0016 #include "Acts/Plugins/Json/AlgebraJsonConverter.hpp"
0017 #include "Acts/Plugins/Json/DetrayJsonHelper.hpp"
0018 #include "Acts/Plugins/Json/GridJsonConverter.hpp"
0019 #include "Acts/Plugins/Json/IndexedGridJsonHelper.hpp"
0020 #include "Acts/Utilities/Enumerate.hpp"
0021 #include "Acts/Utilities/Grid.hpp"
0022 #include "Acts/Utilities/GridAxisGenerators.hpp"
0023 #include "Acts/Utilities/Logger.hpp"
0024 #include "Acts/Utilities/TypeList.hpp"
0025 #include "Acts/Utilities/detail/AxisFwd.hpp"
0026
0027 #include <climits>
0028 #include <vector>
0029
0030 namespace Acts {
0031
0032 using namespace GridAxisGenerators;
0033
0034 namespace IndexedSurfacesJsonConverter {
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 template <typename instance_type>
0045 void convert(nlohmann::json& jIndexedSurfaces,
0046 const Experimental::InternalNavigationDelegate& delegate,
0047 bool detray, [[maybe_unused]] const instance_type& refInstance) {
0048 using GridType =
0049 typename instance_type::template grid_type<std::vector<std::size_t>>;
0050
0051 using DelegateType = Experimental::IndexedSurfacesAllPortalsNavigation<
0052 GridType, Experimental::IndexedSurfacesNavigation>;
0053 using SubDelegateType = Experimental::IndexedSurfacesNavigation<GridType>;
0054
0055
0056 const auto* instance = delegate.instance();
0057 auto castedDelegate = dynamic_cast<const DelegateType*>(instance);
0058 if (castedDelegate != nullptr) {
0059
0060 auto indexedSurfaces = std::get<SubDelegateType>(castedDelegate->updators);
0061 jIndexedSurfaces = IndexedGridJsonHelper::convertImpl<SubDelegateType>(
0062 indexedSurfaces, detray, detray);
0063 if (detray) {
0064 nlohmann::json jAccLink;
0065 jAccLink["type"] =
0066 DetrayJsonHelper::accelerationLink(indexedSurfaces.casts);
0067 jAccLink["index"] = std::numeric_limits<std::size_t>::max();
0068 jIndexedSurfaces["grid_link"] = jAccLink;
0069 }
0070 }
0071 }
0072
0073
0074
0075
0076
0077
0078 template <typename... Args>
0079 void unrollConvert(nlohmann::json& jIndexedSurfaces,
0080 const Experimental::InternalNavigationDelegate& delegate,
0081 bool detray, TypeList<Args...> ) {
0082 (convert(jIndexedSurfaces, delegate, detray, Args{}), ...);
0083 }
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 static inline nlohmann::json toJson(
0095 const Experimental::InternalNavigationDelegate& delegate,
0096 bool detray = false) {
0097
0098 nlohmann::json jIndexedSurfaces;
0099 unrollConvert(jIndexedSurfaces, delegate, detray,
0100 GridAxisGenerators::PossibleAxes{});
0101
0102 if (!jIndexedSurfaces.is_null()) {
0103 jIndexedSurfaces["type"] = "IndexedSurfaces";
0104 }
0105 return jIndexedSurfaces;
0106 }
0107
0108
0109
0110
0111
0112
0113 Experimental::InternalNavigationDelegate fromJson(
0114 const nlohmann::json& jSurfaceNavigation);
0115
0116 }
0117 }