per_vertex_attribute_smoothing.cpp 791 B

1234567891011121314151617181920212223
  1. #include "per_vertex_attribute_smoothing.h"
  2. #include <vector>
  3. template <typename DerivedV, typename DerivedF>
  4. IGL_INLINE void igl::per_vertex_attribute_smoothing(
  5. const Eigen::PlainObjectBase<DerivedV>& Ain,
  6. const Eigen::PlainObjectBase<DerivedF>& F,
  7. Eigen::PlainObjectBase<DerivedV> & Aout)
  8. {
  9. std::vector<double> denominator(Ain.rows(), 0);
  10. Aout = Eigen::PlainObjectBase<DerivedV>::Zero(Ain.rows(), Ain.cols());
  11. for (int i = 0; i < F.rows(); ++i) {
  12. for (int j = 0; j < 3; ++j) {
  13. int j1 = (j + 1) % 3;
  14. int j2 = (j + 2) % 3;
  15. Aout.row(F(i, j)) += Ain.row(F(i, j1)) + Ain.row(F(i, j2));
  16. denominator[F(i, j)] += 2;
  17. }
  18. }
  19. for (int i = 0; i < Ain.rows(); ++i)
  20. Aout.row(i) /= denominator[i];
  21. }