bone_parents.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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 "bone_parents.h"
  9. template <typename DerivedBE, typename DerivedP>
  10. IGL_INLINE void igl::bone_parents(
  11. const Eigen::PlainObjectBase<DerivedBE>& BE,
  12. Eigen::PlainObjectBase<DerivedP>& P)
  13. {
  14. P.resize(BE.rows(),1);
  15. // Stupid O(n²) version
  16. for(int e = 0;e<BE.rows();e++)
  17. {
  18. P(e) = -1;
  19. for(int f = 0;f<BE.rows();f++)
  20. {
  21. if(BE(e,0) == BE(f,1))
  22. {
  23. P(e) = f;
  24. }
  25. }
  26. }
  27. }
  28. #ifdef IGL_STATIC_LIBRARY
  29. template void igl::bone_parents<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
  30. #endif