max_faces_stopping_condition.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 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 "max_faces_stopping_condition.h"
  9. IGL_INLINE void igl::max_faces_stopping_condition(
  10. int & m,
  11. const int orig_m,
  12. const int max_m,
  13. decimate_stopping_condition_callback & stopping_condition)
  14. {
  15. stopping_condition =
  16. [orig_m,max_m,&m](
  17. const Eigen::MatrixXd &,
  18. const Eigen::MatrixXi &,
  19. const Eigen::MatrixXi &,
  20. const Eigen::VectorXi &,
  21. const Eigen::MatrixXi &,
  22. const Eigen::MatrixXi &,
  23. const igl::min_heap< std::tuple<double,int,int> > & ,
  24. const Eigen::VectorXi & ,
  25. const Eigen::MatrixXd &,
  26. const int,
  27. const int,
  28. const int,
  29. const int f1,
  30. const int f2)->bool
  31. {
  32. // Only subtract if we're collapsing a real face
  33. if(f1 < orig_m) m-=1;
  34. if(f2 < orig_m) m-=1;
  35. return m<=(int)max_m;
  36. };
  37. }
  38. IGL_INLINE igl::decimate_stopping_condition_callback
  39. igl::max_faces_stopping_condition(
  40. int & m,
  41. const int orig_m,
  42. const int max_m)
  43. {
  44. decimate_stopping_condition_callback stopping_condition;
  45. max_faces_stopping_condition(m,orig_m,max_m,stopping_condition);
  46. return stopping_condition;
  47. }