12#include "detray/io/backend/detail/grid_writer.hpp"
13#include "detray/io/backend/detail/type_info.hpp"
14#include "detray/io/backend/homogeneous_material_writer.hpp"
15#include "detray/io/frontend/payloads.hpp"
16#include "detray/material/material_slab.hpp"
27 using base_type = detail::grid_writer;
28 using grid_writer_t = base_type;
33 static constexpr std::string_view
tag =
"material_maps";
40 using base_type::base_type;
47 template <
class detector_t>
49 const std::string_view det_name) {
50 return grid_writer_t::header_to_payload(
tag, det.material_store(),
59 template <
class detector_t>
61 const detector_t& det,
const typename detector_t::name_map& ) {
62 using algebra_t =
typename detector_t::algebra_type;
67 for (
const auto& vol_desc : det.volumes()) {
73 for (
const auto& sf_desc : vol.surfaces()) {
74 if (sf_desc.index() < offset) {
75 offset = sf_desc.index();
78 const auto& mat_link = sf_desc.material();
80 if (mat_link.is_invalid() ||
81 mat_link.id() == detector_t::material::id::e_none) {
87 if (mat_link.id() == detector_t::material::id::e_material_slab) {
92 if (mat_link.id() == detector_t::material::id::e_material_rod) {
98 auto mat_converter = [&sf_desc](
const material_t& mat) {
103 grid_writer_t::to_payload(det.material_store(), mat_link,
104 vol_desc.index(), sf_desc.index() - offset,
105 grids_data, mat_converter);
Homogeneous material writer backend.
Definition homogeneous_material_writer.hpp:32
static payload_type to_payload(const detector_t &det, const typename detector_t::name_map &)
Convert the material description of a detector det into its io payload.
Definition homogeneous_material_writer.hpp:100
Material maps writer backend.
Definition material_map_writer.hpp:26
static constexpr std::string_view tag
Tag the writer as "material_map".
Definition material_map_writer.hpp:33
static auto header_to_payload(const detector_t &det, const std::string_view det_name)
Convert the header information into its payload.
Definition material_map_writer.hpp:48
detector_grids_payload< surface_material_payload, io::material_id > payload_type
Payload type that the reader processes.
Definition material_map_writer.hpp:36
static payload_type to_payload(const detector_t &det, const typename detector_t::name_map &)
Convert the material description of a detector det into its io payload.
Definition material_map_writer.hpp:60
Facade for a detray detector volume.
Definition tracking_volume.hpp:44
Check for the the presence of material rods in a detector definition.
Definition concepts.hpp:146
Check for the the presence of material slabs in a detector definition.
Definition concepts.hpp:141
The following enums are global for all detectors.
Definition concepts.hpp:18
unsigned int dindex
Default index type.
Definition indexing.hpp:18
constexpr dindex dindex_invalid
Global invalid index definition.
Definition indexing.hpp:21
A payload for the grid collections of a detector.
Definition payloads.hpp:344
Slab structure to be mapped on the mask (plane, cylinder).
Definition material_slab.hpp:25