Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:40:43

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_POINTS_HPP
0012 #define BOOST_COMPUTE_INTEROP_VTK_POINTS_HPP
0013 
0014 #include <vector>
0015 
0016 #include <vtkPoints.h>
0017 
0018 #include <boost/compute/system.hpp>
0019 #include <boost/compute/command_queue.hpp>
0020 #include <boost/compute/algorithm/copy.hpp>
0021 #include <boost/compute/iterator/buffer_iterator.hpp>
0022 
0023 namespace boost {
0024 namespace compute {
0025 
0026 /// Copies \p points to \p buffer.
0027 ///
0028 /// For example, to copy from a \c vtkPoints object to a \c vector<float4_>:
0029 /// \code
0030 /// vtkPoints *points = ...
0031 /// vector<float4_> vector(points->GetNumberOfPoints(), context);
0032 /// vtk_copy_points_to_buffer(points, vector.begin(), queue);
0033 /// \endcode
0034 template<class PointType>
0035 inline void vtk_copy_points_to_buffer(const vtkPoints *points,
0036                                       buffer_iterator<PointType> buffer,
0037                                       command_queue &queue = system::default_queue())
0038 {
0039     vtkPoints *points_ = const_cast<vtkPoints *>(points);
0040 
0041     // copy points to aligned buffer
0042     std::vector<PointType> tmp(points_->GetNumberOfPoints());
0043     for(vtkIdType i = 0; i < points_->GetNumberOfPoints(); i++){
0044         double *p = points_->GetPoint(i);
0045         tmp[i] = PointType(p[0], p[1], p[2], 1);
0046     }
0047 
0048     // copy data to device
0049     copy(tmp.begin(), tmp.end(), buffer, queue);
0050 }
0051 
0052 } // end compute namespace
0053 } // end boost namespace
0054 
0055 #endif // BOOST_COMPUTE_INTEROP_VTK_POINTS_HPP