parse_rhs.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. #include "parse_rhs.h"
  2. #include <algorithm>
  3. template <typename DerivedV>
  4. IGL_INLINE void igl::parse_rhs_double(
  5. const mxArray *prhs[],
  6. Eigen::PlainObjectBase<DerivedV> & V)
  7. {
  8. using namespace std;
  9. // set number of mesh vertices
  10. const int n = mxGetM(prhs[0]);
  11. // set vertex position pointers
  12. double * Vp = mxGetPr(prhs[0]);
  13. const int dim = mxGetN(prhs[0]);
  14. V.resize(n,dim);
  15. copy(Vp,Vp+n*dim,&V.data()[0]);
  16. }
  17. template <typename DerivedV>
  18. IGL_INLINE void igl::parse_rhs_index(
  19. const mxArray *prhs[],
  20. Eigen::PlainObjectBase<DerivedV> & V)
  21. {
  22. parse_rhs_double(prhs,V);
  23. V.array() -= 1;
  24. }
  25. #ifdef IGL_STATIC_LIBRARY
  26. template void igl::parse_rhs_index<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
  27. template void igl::parse_rhs_index<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
  28. template void igl::parse_rhs_double<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
  29. #endif