view_axis.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "view_axis.h"
  9. #ifndef IGL_NO_OPENGL
  10. #include "OpenGL_convenience.h"
  11. IGL_INLINE void igl::view_axis(double * x, double * y, double * z)
  12. {
  13. double mv[16];
  14. glGetDoublev(GL_MODELVIEW_MATRIX, mv);
  15. igl::view_axis(mv,x,y,z);
  16. }
  17. IGL_INLINE void igl::view_axis(const double * mv, double * x, double * y, double * z)
  18. {
  19. *x = -mv[0*4+2];
  20. *y = -mv[1*4+2];
  21. *z = -mv[2*4+2];
  22. }
  23. template <typename DerivedV>
  24. IGL_INLINE void igl::view_axis(Eigen::PlainObjectBase<DerivedV> & V)
  25. {
  26. double x,y,z;
  27. view_axis(&x,&y,&z);
  28. V(0) = x;
  29. V(1) = y;
  30. V(2) = z;
  31. }
  32. #ifdef IGL_STATIC_LIBRARY
  33. // Explicit template instanciation
  34. template void igl::view_axis<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
  35. template void igl::view_axis<Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&);
  36. #endif
  37. #endif