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