average_onto_faces.cpp 1.2 KB

123456789101112131415161718192021222324252627
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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 "average_onto_faces.h"
  9. template <typename DerivedF, typename DerivedS, typename DerivedSF>
  10. IGL_INLINE void igl::average_onto_faces(
  11. const Eigen::MatrixBase<DerivedF> & F,
  12. const Eigen::MatrixBase<DerivedS> & S,
  13. Eigen::PlainObjectBase<DerivedSF> & SF)
  14. {
  15. SF.setConstant(F.rows(),S.cols(),0);
  16. for (int i = 0; i <F.rows(); ++i)
  17. for (int j = 0; j<F.cols(); ++j)
  18. SF.row(i) += S.row(F(i,j));
  19. SF.array() /= F.cols();
  20. }
  21. #ifdef IGL_STATIC_LIBRARY
  22. // Explicit template instantiation
  23. // generated by autoexplicit.sh
  24. template void igl::average_onto_faces<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
  25. #endif