36 const std::vector<const Acts::Experimental::DetectorVolume*>&
volumes) {
37 auto candidate = std::find(volumes.begin(), volumes.end(), volume);
38 if (candidate != volumes.end()) {
47 const std::vector<const Experimental::DetectorVolume*>&
detectorVolumes,
48 const std::vector<const Experimental::Portal*>& portals,
50 nlohmann::json jVolume;
51 jVolume[
"name"] = volume.
name();
56 nlohmann::json jSurfaces;
62 jVolume[
"surfaces"] = jSurfaces;
64 nlohmann::json jSurfacesDelegate =
66 jVolume[
"surface_navigation"] = jSurfacesDelegate;
69 nlohmann::json jVolumes;
72 jVolumes.push_back(
toJson(gctx, *
v, detectorVolumes, portals, options));
74 jVolume[
"volumes"] = jVolumes;
77 nlohmann::json jPortals;
78 if (not portals.empty()) {
79 for (
const auto*
p : volume.
portals()) {
80 auto it = std::find(portals.begin(), portals.end(),
p);
81 if (
it != portals.end()) {
84 throw std::runtime_error(
"Portal not found in the list of portals");
87 jVolume[
"portal_links"] = jPortals;
89 for (
const auto&
p : volume.
portals()) {
92 jPortals.push_back(jPortal);
94 jVolume[
"portals"] = jPortals;
101 const std::vector<const Experimental::DetectorVolume*>&
detectorVolumes,
103 nlohmann::json jVolume;
104 jVolume[
"name"] = volume.
name();
111 if (volumeBoundsType == VolumeBounds::BoundsType::eCylinder) {
112 jVolume[
"type"] = 0
u;
113 }
else if (volumeBoundsType == VolumeBounds::BoundsType::eCuboid) {
114 jVolume[
"type"] = 4
u;
116 throw std::runtime_error(
"Unsupported volume bounds type");
120 int vIndex = findVolume(&volume, detectorVolumes);
121 jVolume[
"index"] = vIndex;
124 nlohmann::json jSurfaces;
125 for (
const auto&
s : volume.
surfaces()) {
129 jSurfaces.push_back(jSurface);
134 auto orientedSurfaces =
139 auto jPortalSurfaces =
140 (
toJsonDetray(gctx, *
p, ip, volume, orientedSurfaces, detectorVolumes,
142 std::for_each(jPortalSurfaces.begin(), jPortalSurfaces.end(),
143 [&](
auto& jSurface) { jSurfaces.push_back(jSurface); });
145 jVolume[
"surfaces"] = jSurfaces;
150 std::shared_ptr<Acts::Experimental::DetectorVolume>
152 const nlohmann::json& jVolume) {
158 auto jSurfaces = jVolume[
"surfaces"];
159 auto jVolumes = jVolume[
"volumes"];
164 if (jSurfaces.empty() and jVolumes.empty()) {
165 return Experimental::DetectorVolumeFactory::construct(
170 std::vector<std::shared_ptr<Surface>> surfaces;
171 for (
const auto& js : jSurfaces) {
175 std::vector<std::shared_ptr<Experimental::DetectorVolume>>
volumes;
176 for (
const auto& jv : jVolumes) {
180 auto jSurfaceNavigation = jVolume[
"surface_navigation"];
182 return Experimental::DetectorVolumeFactory::construct(