24 #include <initializer_list>
30 #include <nlohmann/json.hpp>
31 #include <pybind11/pybind11.h>
32 #include <pybind11/stl.h>
37 namespace ActsExamples {
42 namespace py = pybind11;
43 using namespace pybind11::literals;
46 using namespace ActsExamples;
48 namespace Acts::Python {
50 auto [
m, mex] = ctx.
get(
"main",
"examples");
54 std::shared_ptr<JsonMaterialDecorator>>(
m,
55 "JsonMaterialDecorator")
58 py::arg(
"rConfig"), py::arg(
"jFileName"), py::arg(
"level"),
59 py::arg(
"clearSurfaceMaterial") =
true,
60 py::arg(
"clearVolumeMaterial") =
true);
65 py::class_<MaterialMapJsonConverter>(
m,
"MaterialMapJsonConverter")
68 py::arg(
"config"), py::arg(
"level"));
70 auto c = py::class_<MaterialMapJsonConverter::Config>(cls,
"Config")
85 py::enum_<JsonFormat>(mex,
"JsonFormat")
86 .
value(
"NoOutput", JsonFormat::NoOutput)
87 .value(
"Json", JsonFormat::Json)
88 .value(
"Cbor", JsonFormat::Cbor)
89 .value(
"All", JsonFormat::All);
95 std::shared_ptr<JsonMaterialWriter>>(mex,
99 py::arg(
"config"), py::arg(
"level"))
100 .def(
"writeMaterial", &JsonMaterialWriter::writeMaterial)
105 py::class_<JsonMaterialWriter::Config>(cls,
"Config").def(py::init<>());
117 std::shared_ptr<JsonSurfacesWriter>>(mex,
118 "JsonSurfacesWriter")
121 py::arg(
"config"), py::arg(
"level"))
126 py::class_<JsonSurfacesWriter::Config>(cls,
"Config").def(py::init<>());
142 py::class_<Acts::ProtoDetector>(mex,
"ProtoDetector")
144 nlohmann::json jDetector;
156 auto sjOptions = py::class_<ActsExamples::JsonSurfacesReader::Options>(
157 mex,
"SurfaceJsonOptions")
170 mex.def(
"writeDetectorToJson",
176 out.open(detector.
name() +
".json");
177 out << jDetector.dump(4);
183 mex.def(
"writeDetectorToJsonDetray",
199 out.open(detector.
name() +
"_detray.json");
200 out << jDetector.dump(4);
207 "readDetectorFromJson",
210 auto in = std::ifstream(fileName,
212 nlohmann::json jDetectorIn;