File indexing completed on 2025-08-06 08:10:49
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Io/Json/JsonSurfacesReader.hpp"
0010
0011 #include "Acts/Geometry/GeometryIdentifier.hpp"
0012 #include "Acts/Plugins/Json/ActsJson.hpp"
0013 #include "Acts/Plugins/Json/GeometryHierarchyMapJsonConverter.hpp"
0014 #include "Acts/Plugins/Json/SurfaceJsonConverter.hpp"
0015 #include "Acts/Surfaces/Surface.hpp"
0016
0017 #include <fstream>
0018 #include <iostream>
0019
0020 namespace ActsExamples {
0021
0022 Acts::GeometryHierarchyMap<std::shared_ptr<Acts::Surface>>
0023 JsonSurfacesReader::read(const JsonSurfacesReader::Options& options) {
0024
0025 nlohmann::json j;
0026 std::ifstream in(options.inputFile);
0027 in >> j;
0028 in.close();
0029
0030 using SurfaceHierachyMap =
0031 Acts::GeometryHierarchyMap<std::shared_ptr<Acts::Surface>>;
0032 using GeometryIdHelper = Acts::GeometryHierarchyMapJsonConverter<bool>;
0033 std::vector<SurfaceHierachyMap::InputElement> surfaceElements;
0034
0035
0036 nlohmann::json jSurfaces = j;
0037 for (const auto& jep : options.jsonEntryPath) {
0038 jSurfaces = jSurfaces[jep];
0039 }
0040
0041
0042 surfaceElements.reserve(jSurfaces.size());
0043 for (const auto& jSurface : jSurfaces) {
0044
0045 Acts::GeometryIdentifier geoId =
0046 GeometryIdHelper::decodeIdentifier(jSurface);
0047 auto surface = Acts::SurfaceJsonConverter::fromJson(jSurface["value"]);
0048 surfaceElements.emplace_back(geoId, surface);
0049 }
0050 return SurfaceHierachyMap(std::move(surfaceElements));
0051 }
0052
0053 }