parse_rhs.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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 "parse_rhs.h"
  9. #include <algorithm>
  10. template <typename DerivedV>
  11. IGL_INLINE void igl::matlab::parse_rhs_double(
  12. const mxArray *prhs[],
  13. Eigen::PlainObjectBase<DerivedV> & V)
  14. {
  15. using namespace Eigen;
  16. // Use Eigen's map and cast to copy
  17. V = Map< Matrix<double,Dynamic,Dynamic> >
  18. (mxGetPr(prhs[0]),mxGetM(prhs[0]),mxGetN(prhs[0]))
  19. .cast<typename DerivedV::Scalar>();
  20. }
  21. template <typename DerivedV>
  22. IGL_INLINE void igl::matlab::parse_rhs_index(
  23. const mxArray *prhs[],
  24. Eigen::PlainObjectBase<DerivedV> & V)
  25. {
  26. parse_rhs_double(prhs,V);
  27. V.array() -= 1;
  28. }
  29. #ifdef IGL_STATIC_LIBRARY
  30. template void igl::matlab::parse_rhs_index<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
  31. template void igl::matlab::parse_rhs_index<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
  32. template void igl::matlab::parse_rhs_double<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
  33. template void igl::matlab::parse_rhs_index<Eigen::Matrix<int, -1, 3, 1, -1, 3> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
  34. template void igl::matlab::parse_rhs_double<Eigen::Matrix<double, -1, 3, 1, -1, 3> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&);
  35. #endif