1818#include < vector>
1919
2020template <typename T>
21- struct ArborX ::AccessTraits<std::vector<T>>
21+ struct PointCloud
2222{
23- static std::size_t size (std::vector<T> const &v) { return v.size (); }
24- static T const &get (std::vector<T> const &v, std::size_t i) { return v[i]; }
23+ std::vector<T> data;
24+ };
25+
26+ template <typename T>
27+ struct ArborX ::AccessTraits<PointCloud<T>>
28+ {
29+ static std::size_t size (PointCloud<T> const &cloud)
30+ {
31+ return cloud.data .size ();
32+ }
33+ static T const &get (PointCloud<T> const &cloud, std::size_t i)
34+ {
35+ return cloud.data [i];
36+ }
2537 using memory_space = Kokkos::HostSpace;
2638};
2739
@@ -40,17 +52,17 @@ int main(int argc, char *argv[])
4052 return Point{rd (), rd (), rd ()};
4153 });
4254
55+ PointCloud<Point> point_cloud{points};
56+
4357 // Pass directly the vector of points to use the access traits defined above
44- ArborX::BoundingVolumeHierarchy bvh{
45- Kokkos::DefaultHostExecutionSpace{},
46- ArborX::Experimental::attach_indices (points)};
58+ ArborX::BoundingVolumeHierarchy bvh{Kokkos::DefaultHostExecutionSpace{},
59+ point_cloud};
4760
4861 // As a supported alternative, wrap the vector in an unmanaged View
4962 bvh = ArborX::BoundingVolumeHierarchy{
5063 Kokkos::DefaultHostExecutionSpace{},
51- ArborX::Experimental::attach_indices (
52- Kokkos::View<Point *, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>{
53- points.data (), points.size ()})};
64+ Kokkos::View<Point *, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>{
65+ points.data (), points.size ()}};
5466
5567 return 0 ;
5668}
0 commit comments