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_POINTS_HPP
12 #define BOOST_COMPUTE_INTEROP_VTK_POINTS_HPP
16 #include <vtkPoints.h>
18 #include <boost/compute/system.hpp>
19 #include <boost/compute/command_queue.hpp>
20 #include <boost/compute/algorithm/copy.hpp>
21 #include <boost/compute/iterator/buffer_iterator.hpp>
26 /// Copies \p points to \p buffer.
28 /// For example, to copy from a \c vtkPoints object to a \c vector<float4_>:
30 /// vtkPoints *points = ...
31 /// vector<float4_> vector(points->GetNumberOfPoints(), context);
32 /// vtk_copy_points_to_buffer(points, vector.begin(), queue);
34 template<class PointType>
35 inline void vtk_copy_points_to_buffer(const vtkPoints *points,
36 buffer_iterator<PointType> buffer,
37 command_queue &queue = system::default_queue())
39 vtkPoints *points_ = const_cast<vtkPoints *>(points);
41 // copy points to aligned buffer
42 std::vector<PointType> tmp(points_->GetNumberOfPoints());
43 for(vtkIdType i = 0; i < points_->GetNumberOfPoints(); i++){
44 double *p = points_->GetPoint(i);
45 tmp[i] = PointType(p[0], p[1], p[2], 1);
48 // copy data to device
49 copy(tmp.begin(), tmp.end(), buffer, queue);
52 } // end compute namespace
53 } // end boost namespace
55 #endif // BOOST_COMPUTE_INTEROP_VTK_POINTS_HPP