barycentric_interpolation.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2020 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 "barycentric_interpolation.h"
  9. #include "parallel_for.h"
  10. template <
  11. typename DerivedD,
  12. typename DerivedF,
  13. typename DerivedB,
  14. typename DerivedI,
  15. typename DerivedX>
  16. IGL_INLINE void igl::barycentric_interpolation(
  17. const Eigen::MatrixBase<DerivedD> & D,
  18. const Eigen::MatrixBase<DerivedF> & F,
  19. const Eigen::MatrixBase<DerivedB> & B,
  20. const Eigen::MatrixBase<DerivedI> & I,
  21. Eigen::PlainObjectBase<DerivedX> & X)
  22. {
  23. assert(B.rows() == I.size());
  24. assert(F.cols() == B.cols());
  25. X.setZero(B.rows(),D.cols());
  26. // should use parallel_for
  27. //for(int i = 0;i<X.rows();i++)
  28. parallel_for(X.rows(),[&X,&B,&D,&F,&I](const int i)
  29. {
  30. for(int j = 0;j<F.cols();j++)
  31. {
  32. X.row(i) += B(i,j) * D.row(F(I(i),j));
  33. }
  34. },1000);
  35. }
  36. #ifdef IGL_STATIC_LIBRARY
  37. // Explicit template instantiation
  38. // generated by autoexplicit.sh
  39. template void igl::barycentric_interpolation<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::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
  40. #endif