36 toJson(j, std::get<0>(surface), std::get<2>(surface));
37 to_json(j, std::get<1>(surface).
get());
46 const std::shared_ptr<const Acts::Surface>&
surface) {
52 const std::shared_ptr<const Acts::Surface>& surface,
58 const nlohmann::json& j) {
60 auto sType = j[
"type"].get<Surface::SurfaceType>();
63 std::shared_ptr<Surface> mutableSf =
nullptr;
68 case Surface::SurfaceType::Plane:
70 case SurfaceBounds::BoundsType::eEllipse:
71 mutableSf = surfaceFromJsonT<PlaneSurface, EllipseBounds>(
j);
73 case SurfaceBounds::BoundsType::eRectangle:
74 mutableSf = surfaceFromJsonT<PlaneSurface, RectangleBounds>(
j);
76 case SurfaceBounds::BoundsType::eTrapezoid:
77 mutableSf = surfaceFromJsonT<PlaneSurface, TrapezoidBounds>(
j);
80 case SurfaceBounds::BoundsType::eBoundless:
81 mutableSf = surfaceFromJsonT<PlaneSurface, void>(
j);
84 throw std::invalid_argument(
"Invalid bounds type " +
86 " for plane surface");
90 case Surface::SurfaceType::Disc:
92 case SurfaceBounds::BoundsType::eAnnulus:
93 mutableSf = surfaceFromJsonT<DiscSurface, AnnulusBounds>(
j);
95 case SurfaceBounds::BoundsType::eDisc:
96 mutableSf = surfaceFromJsonT<DiscSurface, RadialBounds>(
j);
98 case SurfaceBounds::BoundsType::eDiscTrapezoid:
99 mutableSf = surfaceFromJsonT<DiscSurface, DiscTrapezoidBounds>(
j);
102 throw std::invalid_argument(
"Invalid bounds type " +
104 " for disc surface");
108 case Surface::SurfaceType::Cylinder:
109 mutableSf = surfaceFromJsonT<CylinderSurface, CylinderBounds>(
j);
112 case Surface::SurfaceType::Cone:
113 mutableSf = surfaceFromJsonT<ConeSurface, ConeBounds>(
j);
116 case Surface::SurfaceType::Straw:
117 mutableSf = surfaceFromJsonT<StrawSurface, LineBounds>(
j);
120 case Surface::SurfaceType::Perigee:
121 mutableSf = Surface::makeShared<PerigeeSurface>(
125 throw std::invalid_argument(
"Invalid surface type " +
129 throw_assert(mutableSf,
"Could not create surface from json");
132 mutableSf->assignGeometryId(geoID);
134 if (j.find(
"material") != j.end() and not j[
"material"].empty()) {
137 std::shared_ptr<const ISurfaceMaterial> sharedSurfaceMaterial(
139 mutableSf->assignSurfaceMaterial(sharedSurfaceMaterial);
148 nlohmann::json jSurface;
149 const auto& sBounds = surface.
bounds();
152 jSurface[
"transform"] =
154 jSurface[
"type"] = surface.
type();
167 nlohmann::json jSurface;
168 const auto& sBounds = surface.
bounds();
171 jSurface[
"transform"] =
176 jSurface[
"mask"] = jMask;
178 jSurface[
"barcode"] = 0;