File indexing completed on 2025-01-18 09:30:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_INTEROP_VTK_BOUNDS_HPP
0012 #define BOOST_COMPUTE_INTEROP_VTK_BOUNDS_HPP
0013
0014 #include <vector>
0015 #include <iterator>
0016
0017 #include <boost/compute/system.hpp>
0018 #include <boost/compute/command_queue.hpp>
0019 #include <boost/compute/algorithm/copy_n.hpp>
0020 #include <boost/compute/algorithm/reduce.hpp>
0021 #include <boost/compute/container/array.hpp>
0022
0023 namespace boost {
0024 namespace compute {
0025
0026
0027
0028
0029
0030
0031 template<class PointIterator>
0032 inline void vtk_compute_bounds(PointIterator first,
0033 PointIterator last,
0034 double bounds[6],
0035 command_queue &queue = system::default_queue())
0036 {
0037 typedef typename std::iterator_traits<PointIterator>::value_type T;
0038
0039 const context &context = queue.get_context();
0040
0041
0042 array<T, 2> extrema(context);
0043 reduce(first, last, extrema.begin() + 0, min<T>(), queue);
0044 reduce(first, last, extrema.begin() + 1, max<T>(), queue);
0045
0046
0047 std::vector<T> buffer(2);
0048 copy_n(extrema.begin(), 2, buffer.begin(), queue);
0049
0050
0051 bounds[0] = buffer[0][0]; bounds[1] = buffer[1][0];
0052 bounds[2] = buffer[0][1]; bounds[3] = buffer[1][1];
0053 bounds[4] = buffer[0][2]; bounds[5] = buffer[1][2];
0054 }
0055
0056 }
0057 }
0058
0059 #endif