]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/compute/include/boost/compute/interop/vtk/points.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / interop / vtk / points.hpp
CommitLineData
7c673cae
FG
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_POINTS_HPP
12#define BOOST_COMPUTE_INTEROP_VTK_POINTS_HPP
13
14#include <vector>
15
16#include <vtkPoints.h>
17
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>
22
23namespace boost {
24namespace compute {
25
26/// Copies \p points to \p buffer.
27///
28/// For example, to copy from a \c vtkPoints object to a \c vector<float4_>:
29/// \code
30/// vtkPoints *points = ...
31/// vector<float4_> vector(points->GetNumberOfPoints(), context);
32/// vtk_copy_points_to_buffer(points, vector.begin(), queue);
33/// \endcode
34template<class PointType>
35inline void vtk_copy_points_to_buffer(const vtkPoints *points,
36 buffer_iterator<PointType> buffer,
37 command_queue &queue = system::default_queue())
38{
39 vtkPoints *points_ = const_cast<vtkPoints *>(points);
40
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);
46 }
47
48 // copy data to device
49 copy(tmp.begin(), tmp.end(), buffer, queue);
50}
51
52} // end compute namespace
53} // end boost namespace
54
55#endif // BOOST_COMPUTE_INTEROP_VTK_POINTS_HPP