moveFV.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  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 "moveFV.h"
  9. template <typename T, typename I>
  10. IGL_INLINE void igl::moveFV(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
  11. const Eigen::Matrix<I, Eigen::Dynamic, Eigen::Dynamic> &F,
  12. const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &S,
  13. Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &SV)
  14. {
  15. SV = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>::Zero(V.rows(),S.cols());
  16. Eigen::Matrix<T, Eigen::Dynamic, 1> COUNT = Eigen::Matrix<T, Eigen::Dynamic, 1>::Zero(V.rows());
  17. for (int i = 0; i <F.rows(); ++i)
  18. {
  19. for (int j = 0; j<F.cols(); ++j)
  20. {
  21. SV.row(F(i,j)) += S.row(i);
  22. COUNT[F(i,j)] ++;
  23. }
  24. }
  25. for (int i = 0; i <V.rows(); ++i)
  26. SV.row(i) /= COUNT[i];
  27. };
  28. #ifndef IGL_HEADER_ONLY
  29. // Explicit template specialization
  30. #endif