Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:01

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_INTEROP_VTK_DATA_ARRAY_HPP
0012 #define BOOST_COMPUTE_INTEROP_VTK_DATA_ARRAY_HPP
0013 
0014 #include <vtkDataArray.h>
0015 #include <vtkDataArrayTemplate.h>
0016 
0017 #include <boost/compute/system.hpp>
0018 #include <boost/compute/command_queue.hpp>
0019 #include <boost/compute/algorithm/copy.hpp>
0020 #include <boost/compute/algorithm/copy_n.hpp>
0021 #include <boost/compute/iterator/buffer_iterator.hpp>
0022 
0023 namespace boost {
0024 namespace compute {
0025 
0026 /// Copies the values in \p data to \p buffer.
0027 template<class T>
0028 inline void vtk_copy_data_array_to_buffer(const vtkDataArray *data,
0029                                           buffer_iterator<T> buffer,
0030                                           command_queue &queue = system::default_queue());
0031 
0032 /// \internal_
0033 template<class T>
0034 inline void vtk_copy_data_array_to_buffer(const vtkDataArrayTemplate<T> *data,
0035                                           buffer_iterator<T> buffer,
0036                                           command_queue &queue = system::default_queue())
0037 {
0038     vtkDataArrayTemplate<T> *data_ = const_cast<vtkDataArrayTemplate<T> *>(data);
0039     const T *data_ptr = static_cast<const T *>(data_->GetVoidPointer(0));
0040     size_t data_size = data_->GetNumberOfComponents() * data_->GetNumberOfTuples();
0041     ::boost::compute::copy_n(data_ptr, data_size, buffer, queue);
0042 }
0043 
0044 /// Copies the values in the range [\p first, \p last) to \p data.
0045 template<class T>
0046 inline void vtk_copy_buffer_to_data_array(buffer_iterator<T> first,
0047                                           buffer_iterator<T> last,
0048                                           vtkDataArray *data,
0049                                           command_queue &queue = system::default_queue());
0050 
0051 /// \internal_
0052 template<class T>
0053 inline void vtk_copy_buffer_to_data_array(buffer_iterator<T> first,
0054                                           buffer_iterator<T> last,
0055                                           vtkDataArrayTemplate<T> *data,
0056                                           command_queue &queue = system::default_queue())
0057 {
0058     T *data_ptr = static_cast<T *>(data->GetVoidPointer(0));
0059     ::boost::compute::copy(first, last, data_ptr, queue);
0060 }
0061 
0062 } // end compute namespace
0063 } // end boost namespace
0064 
0065 #endif // BOOST_COMPUTE_INTEROP_VTK_DATA_ARRAY_HPP