matrix4x4.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef BOOST_COMPUTE_INTEROP_VTK_MATRIX4X4_HPP
  11. #define BOOST_COMPUTE_INTEROP_VTK_MATRIX4X4_HPP
  12. #include <vtkMatrix4x4.h>
  13. #include <boost/compute/types/fundamental.hpp>
  14. namespace boost {
  15. namespace compute {
  16. /// Converts a \c vtkMatrix4x4 to a \c float16_.
  17. inline float16_ vtk_matrix4x4_to_float16(const vtkMatrix4x4 *matrix)
  18. {
  19. float16_ result;
  20. for(int i = 0; i < 4; i++){
  21. for(int j = 0; j < 4; j++){
  22. result[i*4+j] = matrix->GetElement(i, j);
  23. }
  24. }
  25. return result;
  26. }
  27. /// Converts a \c vtkMatrix4x4 to a \c double16_;
  28. inline double16_ vtk_matrix4x4_to_double16(const vtkMatrix4x4 *matrix)
  29. {
  30. double16_ result;
  31. std::memcpy(&result, matrix->Element, 16 * sizeof(double));
  32. return result;
  33. }
  34. } // end compute namespace
  35. } // end boost namespace
  36. #endif // BOOST_COMPUTE_INTEROP_VTK_MATRIX4X4_HPP