1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_INTEROP_VTK_DATA_ARRAY_HPP
12 #define BOOST_COMPUTE_INTEROP_VTK_DATA_ARRAY_HPP
14 #include <vtkDataArray.h>
15 #include <vtkDataArrayTemplate.h>
17 #include <boost/compute/system.hpp>
18 #include <boost/compute/command_queue.hpp>
19 #include <boost/compute/algorithm/copy.hpp>
20 #include <boost/compute/algorithm/copy_n.hpp>
21 #include <boost/compute/iterator/buffer_iterator.hpp>
26 /// Copies the values in \p data to \p buffer.
28 inline void vtk_copy_data_array_to_buffer(const vtkDataArray *data,
29 buffer_iterator<T> buffer,
30 command_queue &queue = system::default_queue());
34 inline void vtk_copy_data_array_to_buffer(const vtkDataArrayTemplate<T> *data,
35 buffer_iterator<T> buffer,
36 command_queue &queue = system::default_queue())
38 vtkDataArrayTemplate<T> *data_ = const_cast<vtkDataArrayTemplate<T> *>(data);
39 const T *data_ptr = static_cast<const T *>(data_->GetVoidPointer(0));
40 size_t data_size = data_->GetNumberOfComponents() * data_->GetNumberOfTuples();
41 ::boost::compute::copy_n(data_ptr, data_size, buffer, queue);
44 /// Copies the values in the range [\p first, \p last) to \p data.
46 inline void vtk_copy_buffer_to_data_array(buffer_iterator<T> first,
47 buffer_iterator<T> last,
49 command_queue &queue = system::default_queue());
53 inline void vtk_copy_buffer_to_data_array(buffer_iterator<T> first,
54 buffer_iterator<T> last,
55 vtkDataArrayTemplate<T> *data,
56 command_queue &queue = system::default_queue())
58 T *data_ptr = static_cast<T *>(data->GetVoidPointer(0));
59 ::boost::compute::copy(first, last, data_ptr, queue);
62 } // end compute namespace
63 } // end boost namespace
65 #endif // BOOST_COMPUTE_INTEROP_VTK_DATA_ARRAY_HPP