deform_skeleton.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "deform_skeleton.h"
  2. void igl::deform_skeleton(
  3. const Eigen::MatrixXd & C,
  4. const Eigen::MatrixXi & BE,
  5. const std::vector<
  6. Eigen::Affine3d,Eigen::aligned_allocator<Eigen::Affine3d> > & vA,
  7. Eigen::MatrixXd & CT,
  8. Eigen::MatrixXi & BET)
  9. {
  10. using namespace Eigen;
  11. assert(BE.rows() == (int)vA.size());
  12. CT.resize(2*BE.rows(),C.cols());
  13. BET.resize(BE.rows(),2);
  14. for(int e = 0;e<BE.rows();e++)
  15. {
  16. BET(e,0) = 2*e;
  17. BET(e,1) = 2*e+1;
  18. Affine3d a = vA[e];
  19. Vector3d c0 = C.row(BE(e,0));
  20. Vector3d c1 = C.row(BE(e,1));
  21. CT.row(2*e) = a * c0;
  22. CT.row(2*e+1) = a * c1;
  23. }
  24. }
  25. IGL_INLINE void igl::deform_skeleton(
  26. const Eigen::MatrixXd & C,
  27. const Eigen::MatrixXi & BE,
  28. const Eigen::MatrixXd & T,
  29. Eigen::MatrixXd & CT,
  30. Eigen::MatrixXi & BET)
  31. {
  32. using namespace Eigen;
  33. //assert(BE.rows() == (int)vA.size());
  34. CT.resize(2*BE.rows(),C.cols());
  35. BET.resize(BE.rows(),2);
  36. for(int e = 0;e<BE.rows();e++)
  37. {
  38. BET(e,0) = 2*e;
  39. BET(e,1) = 2*e+1;
  40. Affine3d a;
  41. a.matrix() = T.block(e*4,0,4,3).transpose();
  42. Vector3d c0 = C.row(BE(e,0));
  43. Vector3d c1 = C.row(BE(e,1));
  44. CT.row(2*e) = a * c0;
  45. CT.row(2*e+1) = a * c1;
  46. }
  47. }