barycenter.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233
  1. #include "barycenter.h"
  2. template <
  3. typename DerivedV,
  4. typename DerivedF,
  5. typename DerivedBC>
  6. IGL_INLINE void igl::barycenter(
  7. const Eigen::PlainObjectBase<DerivedV> & V,
  8. const Eigen::PlainObjectBase<DerivedF> & F,
  9. Eigen::PlainObjectBase<DerivedBC> & BC)
  10. {
  11. BC.setZero(F.rows(),V.cols());
  12. // Loop over faces
  13. for(int i = 0;i<F.rows();i++)
  14. {
  15. // loop around face
  16. for(int j = 0;j<F.cols();j++)
  17. {
  18. // Accumulate
  19. BC.row(i) += V.row(F(i,j));
  20. }
  21. // average
  22. BC.row(i) /= double(F.cols());
  23. }
  24. }
  25. #ifndef IGL_HEADER_ONLY
  26. // Explicit instanciation
  27. template void igl::barycenter<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 4, 0, -1, 4> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 4, 0, -1, 4> >&);
  28. template void igl::barycenter<Eigen::Matrix<double, -1, 4, 0, -1, 4>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 4, 0, -1, 4> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 4, 0, -1, 4> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 4, 0, -1, 4> >&);
  29. template void igl::barycenter<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
  30. template void igl::barycenter<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
  31. #endif