@@ -130,20 +130,14 @@ class detector {
130130 volume_descriptor<geo_obj_ids, accel_link, material_link>;
131131 using volume_container = vector_type<volume_type>;
132132
133- // / Volume finder definition: Make volume index available from track
134- // / position
135- using volume_accelerator =
136- typename metadata::template volume_accelerator<container_t >;
137-
138133 // / Detector view types
139134 // / @TODO: Switch to const_view_type always if possible
140135 using view_type = dmulti_view<dvector_view<volume_type>,
141136 typename surface_lookup_container::view_type,
142137 typename transform_container::view_type,
143138 typename mask_container::view_type,
144139 typename material_container::view_type,
145- typename accelerator_container::view_type,
146- typename volume_accelerator::view_type>;
140+ typename accelerator_container::view_type>;
147141
148142 static_assert (concepts::device_view<view_type>,
149143 " Detector view type ill-formed" );
@@ -154,8 +148,7 @@ class detector {
154148 typename transform_container::const_view_type,
155149 typename mask_container::const_view_type,
156150 typename material_container::const_view_type,
157- typename accelerator_container::const_view_type,
158- typename volume_accelerator::const_view_type>;
151+ typename accelerator_container::const_view_type>;
159152
160153 static_assert (concepts::device_view<const_view_type>,
161154 " Detector const view type ill-formed" );
@@ -167,8 +160,7 @@ class detector {
167160 typename transform_container::buffer_type,
168161 typename mask_container::buffer_type,
169162 typename material_container::buffer_type,
170- typename accelerator_container::buffer_type,
171- typename volume_accelerator::buffer_type>;
163+ typename accelerator_container::buffer_type>;
172164
173165 static_assert (concepts::device_buffer<buffer_type>,
174166 " Detector buffer type ill-formed" );
@@ -195,8 +187,7 @@ class detector {
195187 _transforms(resource),
196188 _masks(resource),
197189 _materials(resource),
198- _accelerators(resource),
199- _volume_accelerator(resource) {}
190+ _accelerators(resource) {}
200191
201192 // / Constructor from detector data view
202193 template <concepts::device_view detector_view_t >
@@ -206,8 +197,7 @@ class detector {
206197 _transforms(detray::detail::get<2 >(det_data.m_view)),
207198 _masks(detray::detail::get<3 >(det_data.m_view)),
208199 _materials(detray::detail::get<4 >(det_data.m_view)),
209- _accelerators(detray::detail::get<5 >(det_data.m_view)),
210- _volume_accelerator(detray::detail::get<6 >(det_data.m_view)) {}
200+ _accelerators(detray::detail::get<5 >(det_data.m_view)) {}
211201 // / @}
212202
213203 // / @returns a string that contains the detector name
@@ -228,13 +218,14 @@ class detector {
228218 // / @return the volume by global cartesian @param position - const access
229219 DETRAY_HOST_DEVICE
230220 inline const auto &volume (const point3_type &p) const {
231- // The 3D cylindrical volume search grid is concentric
232- const transform3_type identity{};
233- const auto loc_pos =
234- _volume_accelerator.project (identity, p, identity.translation ());
235-
236- // Only one entry per bin
237- dindex volume_index{_volume_accelerator.search (loc_pos).value ()};
221+ volume_type v_desc{};
222+ // Allow to call the volume search data structure
223+ v_desc.set_accel_link (geo_obj_ids::e_volume, 0u );
224+ tracking_volume world{v_desc, *this };
225+
226+ const dindex volume_index =
227+ world.template visit_accelerator <geo_obj_ids::e_volume,
228+ volume_search>(p);
238229 return _volumes[volume_index];
239230 }
240231
@@ -284,32 +275,20 @@ class detector {
284275 return _accelerators;
285276 }
286277
287- // / @return the volume grid - const access
288- DETRAY_HOST_DEVICE
289- inline auto get_volume_accelerator () const -> const volume_accelerator & {
290- return _volume_accelerator;
291- }
292-
293278 // / @returns view of a detector
294279 DETRAY_HOST auto get_data () -> view_type {
295- return view_type{detray::get_data (_volumes),
296- detray::get_data (_surfaces),
297- detray::get_data (_transforms),
298- detray::get_data (_masks),
299- detray::get_data (_materials),
300- detray::get_data (_accelerators),
301- detray::get_data (_volume_accelerator)};
280+ return view_type{
281+ detray::get_data (_volumes), detray::get_data (_surfaces),
282+ detray::get_data (_transforms), detray::get_data (_masks),
283+ detray::get_data (_materials), detray::get_data (_accelerators)};
302284 }
303285
304286 // / @returns const view of a detector
305287 DETRAY_HOST auto get_data () const -> const_view_type {
306- return const_view_type{detray::get_data (_volumes),
307- detray::get_data (_surfaces),
308- detray::get_data (_transforms),
309- detray::get_data (_masks),
310- detray::get_data (_materials),
311- detray::get_data (_accelerators),
312- detray::get_data (_volume_accelerator)};
288+ return const_view_type{
289+ detray::get_data (_volumes), detray::get_data (_surfaces),
290+ detray::get_data (_transforms), detray::get_data (_masks),
291+ detray::get_data (_materials), detray::get_data (_accelerators)};
313292 }
314293
315294 // / @param names maps a volume to its string representation.
@@ -345,24 +324,27 @@ class detector {
345324 return ss.str ();
346325 }
347326
348- // / Add the volume grid - move semantics
349- // /
350- // / @param v_grid the volume grid to be added
351- DETRAY_HOST
352- inline auto set_volume_accelerator (volume_accelerator &&v_grid) -> void {
353- _volume_accelerator = std::move (v_grid);
354- }
355-
356- // / Add the volume grid - copy semantics
357- // /
358- // / @param v_grid the volume grid to be added
359- DETRAY_HOST
360- inline auto set_volume_accelerator (const volume_accelerator &v_grid)
361- -> void {
362- _volume_accelerator = v_grid;
363- }
364-
365327 private:
328+ // / Volume lookup in the volume acceleration data structures
329+ struct volume_search {
330+ // /@TODO: Move this to a volume search grid type
331+ template <typename accel_group_t , typename accel_index_t >
332+ DETRAY_HOST_DEVICE inline dindex operator ()(
333+ const accel_group_t &group, const accel_index_t index,
334+ const point3_type &p) const {
335+
336+ const auto volume_accelerator = group[index];
337+
338+ // The 3D cylindrical volume search grid is concentric
339+ const transform3_type identity{};
340+ const auto loc_pos =
341+ volume_accelerator.project (identity, p, identity.translation ());
342+
343+ // Only one entry per bin
344+ return volume_accelerator.search (loc_pos).value ();
345+ }
346+ };
347+
366348 // / Contains the detector sub-volumes.
367349 volume_container _volumes;
368350
@@ -380,9 +362,6 @@ class detector {
380362
381363 // / All surface finder data structures that are used in the detector volumes
382364 accelerator_container _accelerators;
383-
384- // / Search structure for volumes
385- volume_accelerator _volume_accelerator;
386365};
387366
388367} // namespace detray
0 commit comments