File indexing completed on 2026-07-16 08:08:36
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Geometry/GeometryContext.hpp"
0010 #include "Acts/Utilities/Logger.hpp"
0011 #include "ActsPlugins/Json/JsonMaterialDecorator.hpp"
0012 #include "ActsPlugins/Json/JsonSurfacesReader.hpp"
0013 #include "ActsPlugins/Json/MaterialMapJsonConverter.hpp"
0014 #include "ActsPython/Utilities/Helpers.hpp"
0015 #include "ActsPython/Utilities/Macros.hpp"
0016
0017 #include <memory>
0018 #include <string>
0019
0020 #include <pybind11/pybind11.h>
0021 #include <pybind11/stl.h>
0022
0023 namespace py = pybind11;
0024 using namespace pybind11::literals;
0025
0026 using namespace Acts;
0027 using namespace ActsPython;
0028 using namespace ActsExamples;
0029
0030 PYBIND11_MODULE(ActsPluginsPythonBindingsJson, json) {
0031 {
0032 py::class_<JsonMaterialDecorator, IMaterialDecorator,
0033 std::shared_ptr<JsonMaterialDecorator>>(json,
0034 "JsonMaterialDecorator")
0035 .def(py::init<const MaterialMapJsonConverter::Config&,
0036 const std::string&, Logging::Level, bool, bool>(),
0037 py::arg("rConfig"), py::arg("jFileName"), py::arg("level"),
0038 py::arg("clearSurfaceMaterial") = true,
0039 py::arg("clearVolumeMaterial") = true);
0040 }
0041
0042 {
0043 auto cls =
0044 py::class_<MaterialMapJsonConverter>(json, "MaterialMapJsonConverter")
0045 .def(py::init<const MaterialMapJsonConverter::Config&,
0046 Logging::Level>(),
0047 py::arg("config"), py::arg("level"));
0048
0049 auto c = py::class_<MaterialMapJsonConverter::Config>(cls, "Config")
0050 .def(py::init<>());
0051 ACTS_PYTHON_STRUCT(c, context, processSensitives, processApproaches,
0052 processRepresenting, processBoundaries, processVolumes,
0053 processDenseVolumes, processNonMaterial);
0054 }
0055
0056 {
0057 auto sjOptions =
0058 py::class_<JsonSurfacesReader::Options>(json, "SurfaceJsonOptions")
0059 .def(py::init<>());
0060 ACTS_PYTHON_STRUCT(sjOptions, inputFile, jsonEntryPath);
0061
0062 json.def("readSurfaceHierarchyMapFromJson",
0063 JsonSurfacesReader::readHierarchyMap);
0064
0065 json.def("readSurfaceVectorFromJson", JsonSurfacesReader::readVector);
0066
0067 py::class_<JsonDetectorElement, SurfacePlacementBase,
0068 std::shared_ptr<JsonDetectorElement>>(json,
0069 "JsonDetectorElement")
0070 .def("surface", [](JsonDetectorElement& self) {
0071 return self.surface().getSharedPtr();
0072 });
0073
0074 json.def("readDetectorElementsFromJson",
0075 JsonSurfacesReader::readDetectorElements);
0076 }
0077 }