@@ -131,20 +131,14 @@ class detector {
131131 volume_descriptor<geo_obj_ids, accel_link, material_link>;
132132 using volume_container = vector_type<volume_type>;
133133
134- // / Volume finder definition: Make volume index available from track
135- // / position
136- using volume_accelerator =
137- typename metadata::template volume_accelerator<container_t >;
138-
139134 // / Detector view types
140135 // / @TODO: Switch to const_view_type always if possible
141136 using view_type = dmulti_view<dvector_view<volume_type>,
142137 typename surface_lookup_container::view_type,
143138 typename transform_container::view_type,
144139 typename mask_container::view_type,
145140 typename material_container::view_type,
146- typename accelerator_container::view_type,
147- typename volume_accelerator::view_type>;
141+ typename accelerator_container::view_type>;
148142
149143 static_assert (concepts::device_view<view_type>,
150144 " Detector view type ill-formed" );
@@ -155,8 +149,7 @@ class detector {
155149 typename transform_container::const_view_type,
156150 typename mask_container::const_view_type,
157151 typename material_container::const_view_type,
158- typename accelerator_container::const_view_type,
159- typename volume_accelerator::const_view_type>;
152+ typename accelerator_container::const_view_type>;
160153
161154 static_assert (concepts::device_view<const_view_type>,
162155 " Detector const view type ill-formed" );
@@ -168,8 +161,7 @@ class detector {
168161 typename transform_container::buffer_type,
169162 typename mask_container::buffer_type,
170163 typename material_container::buffer_type,
171- typename accelerator_container::buffer_type,
172- typename volume_accelerator::buffer_type>;
164+ typename accelerator_container::buffer_type>;
173165
174166 static_assert (concepts::device_buffer<buffer_type>,
175167 " Detector buffer type ill-formed" );
@@ -196,8 +188,7 @@ class detector {
196188 _transforms(resource),
197189 _masks(resource),
198190 _materials(resource),
199- _accelerators(resource),
200- _volume_accelerator(resource) {}
191+ _accelerators(resource) {}
201192
202193 // / Constructor from detector data view
203194 template <concepts::device_view detector_view_t >
@@ -207,8 +198,7 @@ class detector {
207198 _transforms(detray::detail::get<2 >(det_data.m_view)),
208199 _masks(detray::detail::get<3 >(det_data.m_view)),
209200 _materials(detray::detail::get<4 >(det_data.m_view)),
210- _accelerators(detray::detail::get<5 >(det_data.m_view)),
211- _volume_accelerator(detray::detail::get<6 >(det_data.m_view)) {}
201+ _accelerators(detray::detail::get<5 >(det_data.m_view)) {}
212202 // / @}
213203
214204 // / @returns a string that contains the detector name
@@ -231,13 +221,14 @@ class detector {
231221 // / @return the volume by global cartesian @param position - const access
232222 DETRAY_HOST_DEVICE
233223 inline const auto &volume (const point3_type &p) const {
234- // The 3D cylindrical volume search grid is concentric
235- const transform3_type identity{};
236- const auto loc_pos =
237- _volume_accelerator.project (identity, p, identity.translation ());
238-
239- // Only one entry per bin
240- dindex volume_index{_volume_accelerator.search (loc_pos).value ()};
224+ volume_type v_desc{};
225+ // Allow to call the volume search data structure
226+ v_desc.set_accel_link (geo_obj_ids::e_volume, 0u );
227+ tracking_volume world{v_desc, *this };
228+
229+ const dindex volume_index =
230+ world.template visit_accelerator <geo_obj_ids::e_volume,
231+ volume_search>(p);
241232 return _volumes[volume_index];
242233 }
243234
@@ -287,48 +278,20 @@ class detector {
287278 return _accelerators;
288279 }
289280
290- // / @return the volume grid - const access
291- DETRAY_HOST_DEVICE
292- inline auto get_volume_accelerator () const -> const volume_accelerator & {
293- return _volume_accelerator;
294- }
295-
296281 // / @returns view of a detector
297282 DETRAY_HOST auto get_data () -> view_type {
298- return view_type{detray::get_data (_volumes),
299- detray::get_data (_surfaces),
300- detray::get_data (_transforms),
301- detray::get_data (_masks),
302- detray::get_data (_materials),
303- detray::get_data (_accelerators),
304- detray::get_data (_volume_accelerator)};
283+ return view_type{
284+ detray::get_data (_volumes), detray::get_data (_surfaces),
285+ detray::get_data (_transforms), detray::get_data (_masks),
286+ detray::get_data (_materials), detray::get_data (_accelerators)};
305287 }
306288
307289 // / @returns const view of a detector
308290 DETRAY_HOST auto get_data () const -> const_view_type {
309- return const_view_type{detray::get_data (_volumes),
310- detray::get_data (_surfaces),
311- detray::get_data (_transforms),
312- detray::get_data (_masks),
313- detray::get_data (_materials),
314- detray::get_data (_accelerators),
315- detray::get_data (_volume_accelerator)};
316- }
317- // / Add the volume grid - move semantics
318- // /
319- // / @param v_grid the volume grid to be added
320- DETRAY_HOST
321- inline auto set_volume_accelerator (volume_accelerator &&v_grid) -> void {
322- _volume_accelerator = std::move (v_grid);
323- }
324-
325- // / Add the volume grid - copy semantics
326- // /
327- // / @param v_grid the volume grid to be added
328- DETRAY_HOST
329- inline auto set_volume_accelerator (const volume_accelerator &v_grid)
330- -> void {
331- _volume_accelerator = v_grid;
291+ return const_view_type{
292+ detray::get_data (_volumes), detray::get_data (_surfaces),
293+ detray::get_data (_transforms), detray::get_data (_masks),
294+ detray::get_data (_materials), detray::get_data (_accelerators)};
332295 }
333296
334297 private:
@@ -340,6 +303,26 @@ class detector {
340303 return os;
341304 }
342305
306+ // / Volume lookup in the volume acceleration data structures
307+ struct volume_search {
308+ // /@TODO: Move this to a volume search grid type
309+ template <typename accel_group_t , typename accel_index_t >
310+ DETRAY_HOST_DEVICE inline dindex operator ()(
311+ const accel_group_t &group, const accel_index_t index,
312+ const point3_type &p) const {
313+
314+ const auto volume_accelerator = group[index];
315+
316+ // The 3D cylindrical volume search grid is concentric
317+ const transform3_type identity{};
318+ const auto loc_pos =
319+ volume_accelerator.project (identity, p, identity.translation ());
320+
321+ // Only one entry per bin
322+ return volume_accelerator.search (loc_pos).value ();
323+ }
324+ };
325+
343326 // / Contains the detector sub-volumes.
344327 volume_container _volumes;
345328
@@ -357,9 +340,6 @@ class detector {
357340
358341 // / All surface finder data structures that are used in the detector volumes
359342 accelerator_container _accelerators;
360-
361- // / Search structure for volumes
362- volume_accelerator _volume_accelerator;
363343};
364344
365345} // namespace detray
0 commit comments