File indexing completed on 2026-10-18 08:42:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #pragma once
0017
0018
0019 #include "detray/definitions/detail/qualifiers.hpp"
0020 #include "detray/definitions/geometry.hpp"
0021 #include "detray/definitions/indexing.hpp"
0022 #include "detray/definitions/units.hpp"
0023 #include "detray/geometry/identifier.hpp"
0024 #include "detray/geometry/mask.hpp"
0025
0026 namespace detray {
0027
0028 template <typename algebra_t, typename shape_t, typename material_t,
0029 typename nav_link_t>
0030 class external_surface {
0031 public:
0032 using transform3_type = dtransform3D<algebra_t>;
0033 using mask_type = detray::mask<shape_t, algebra_t, nav_link_t>;
0034 using material_type = material_t;
0035
0036 using navigation_link = nav_link_t;
0037
0038
0039 constexpr external_surface() = default;
0040
0041
0042
0043
0044
0045
0046
0047
0048 DETRAY_HOST_DEVICE
0049 constexpr external_surface(const transform3_type& trf, const mask_type& mask,
0050 const material_type& material, const dindex volume,
0051 const surface_id sf_id)
0052 : m_transform{trf},
0053 m_mask(mask),
0054 m_material(material),
0055 m_barcode{geometry::identifier{}.set_volume(volume).set_id(sf_id)} {}
0056
0057
0058
0059
0060
0061
0062
0063
0064 DETRAY_HOST_DEVICE
0065 constexpr external_surface(transform3_type&& trf, mask_type&& mask,
0066 material_type&& material, const dindex volume,
0067 const surface_id sf_id)
0068 : m_transform{std::move(trf)},
0069 m_mask(std::move(mask)),
0070 m_material(std::move(material)),
0071 m_barcode{geometry::identifier{}.set_volume(volume).set_id(sf_id)} {}
0072
0073
0074
0075
0076 DETRAY_HOST_DEVICE
0077 constexpr auto operator==(const external_surface& rhs) const -> bool {
0078 return (m_barcode == rhs.m_barcode);
0079 }
0080
0081
0082 DETRAY_HOST_DEVICE
0083 auto set_barcode(const geometry::identifier bcd) -> void { m_barcode = bcd; }
0084
0085
0086 DETRAY_HOST_DEVICE
0087 constexpr auto barcode() const -> geometry::identifier { return m_barcode; }
0088
0089
0090 DETRAY_HOST_DEVICE
0091 constexpr auto identifier() const -> geometry::identifier {
0092 return m_barcode;
0093 }
0094
0095
0096 DETRAY_HOST_DEVICE
0097 explicit operator geometry::identifier() const { return m_barcode; }
0098
0099
0100 DETRAY_HOST_DEVICE
0101 auto set_id(const surface_id new_id) -> void { m_barcode.set_id(new_id); }
0102
0103
0104 DETRAY_HOST_DEVICE
0105 constexpr auto id() const -> surface_id { return m_barcode.id(); }
0106
0107
0108 DETRAY_HOST_DEVICE
0109 auto set_volume(const dindex new_idx) -> void {
0110 m_barcode.set_volume(new_idx);
0111 }
0112
0113
0114 DETRAY_HOST_DEVICE
0115 constexpr auto volume() const -> dindex { return m_barcode.volume(); }
0116
0117
0118 DETRAY_HOST_DEVICE
0119 auto set_index(const dindex new_idx) -> void { m_barcode.set_index(new_idx); }
0120
0121
0122 DETRAY_HOST_DEVICE
0123 constexpr auto index() const -> dindex { return m_barcode.index(); }
0124
0125
0126
0127
0128 DETRAY_HOST_DEVICE
0129 void set_transform(const transform3_type& trf) { m_transform = trf; }
0130
0131
0132 DETRAY_HOST_DEVICE
0133 constexpr auto transform() const -> const transform3_type& {
0134 return m_transform;
0135 }
0136
0137
0138
0139
0140 DETRAY_HOST_DEVICE
0141 void set_mask(const mask_type m) { m_mask = m; }
0142
0143
0144 DETRAY_HOST_DEVICE
0145 constexpr auto mask() const -> const mask_type& { return m_mask; }
0146
0147
0148
0149
0150 DETRAY_HOST_DEVICE
0151 void set_material(const material_type& offset) { m_material.shift(offset); }
0152
0153
0154 DETRAY_HOST_DEVICE
0155 constexpr auto material() -> material_type& { return m_material; }
0156
0157
0158 DETRAY_HOST_DEVICE
0159 constexpr auto material() const -> const material_type& { return m_material; }
0160
0161
0162 DETRAY_HOST_DEVICE
0163 constexpr auto has_material() const -> bool { return false; }
0164
0165
0166 DETRAY_HOST_DEVICE
0167 constexpr auto is_sensitive() const -> bool {
0168 return m_barcode.id() == surface_id::e_sensitive;
0169 }
0170
0171
0172 DETRAY_HOST_DEVICE
0173 constexpr auto is_portal() const -> bool {
0174 return m_barcode.id() == surface_id::e_portal;
0175 }
0176
0177
0178 DETRAY_HOST_DEVICE
0179 constexpr auto is_passive() const -> bool {
0180 return m_barcode.id() == surface_id::e_passive;
0181 }
0182
0183 private:
0184
0185 transform3_type m_transform{};
0186
0187 mask_type m_mask{};
0188
0189 material_type m_material{};
0190
0191 geometry::identifier m_barcode{};
0192 };
0193
0194 }