• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
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
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10 
11 #ifndef BOOST_COMPUTE_INTEROP_VTK_DATA_ARRAY_HPP
12 #define BOOST_COMPUTE_INTEROP_VTK_DATA_ARRAY_HPP
13 
14 #include <vtkDataArray.h>
15 #include <vtkDataArrayTemplate.h>
16 
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>
22 
23 namespace boost {
24 namespace compute {
25 
26 /// Copies the values in \p data to \p buffer.
27 template<class T>
28 inline void vtk_copy_data_array_to_buffer(const vtkDataArray *data,
29                                           buffer_iterator<T> buffer,
30                                           command_queue &queue = system::default_queue());
31 
32 /// \internal_
33 template<class T>
vtk_copy_data_array_to_buffer(const vtkDataArrayTemplate<T> * data,buffer_iterator<T> buffer,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())
37 {
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);
42 }
43 
44 /// Copies the values in the range [\p first, \p last) to \p data.
45 template<class T>
46 inline void vtk_copy_buffer_to_data_array(buffer_iterator<T> first,
47                                           buffer_iterator<T> last,
48                                           vtkDataArray *data,
49                                           command_queue &queue = system::default_queue());
50 
51 /// \internal_
52 template<class T>
vtk_copy_buffer_to_data_array(buffer_iterator<T> first,buffer_iterator<T> last,vtkDataArrayTemplate<T> * data,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())
57 {
58     T *data_ptr = static_cast<T *>(data->GetVoidPointer(0));
59     ::boost::compute::copy(first, last, data_ptr, queue);
60 }
61 
62 } // end compute namespace
63 } // end boost namespace
64 
65 #endif // BOOST_COMPUTE_INTEROP_VTK_DATA_ARRAY_HPP
66