infinite_cost_stopping_condition.cpp 1.6 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 "infinite_cost_stopping_condition.h"
  9. IGL_INLINE void igl::infinite_cost_stopping_condition(
  10. const decimate_cost_and_placement_callback & cost_and_placement,
  11. decimate_stopping_condition_callback & stopping_condition)
  12. {
  13. stopping_condition =
  14. [&cost_and_placement]
  15. (
  16. const Eigen::MatrixXd & V,
  17. const Eigen::MatrixXi & F,
  18. const Eigen::MatrixXi & E,
  19. const Eigen::VectorXi & EMAP,
  20. const Eigen::MatrixXi & EF,
  21. const Eigen::MatrixXi & EI,
  22. const igl::min_heap< std::tuple<double,int,int> > & ,/*Q*/
  23. const Eigen::VectorXi & EQ,
  24. const Eigen::MatrixXd & /*C*/,
  25. const int e,
  26. const int /*e1*/,
  27. const int /*e2*/,
  28. const int /*f1*/,
  29. const int /*f2*/)->bool
  30. {
  31. // e was (just) collapsed.
  32. if(EQ(e) == -1) { return false; }
  33. Eigen::RowVectorXd p;
  34. double cost;
  35. cost_and_placement(e,V,F,E,EMAP,EF,EI,cost,p);
  36. return std::isinf(cost);
  37. };
  38. }
  39. IGL_INLINE igl::decimate_stopping_condition_callback
  40. igl::infinite_cost_stopping_condition(
  41. const decimate_cost_and_placement_callback & cost_and_placement)
  42. {
  43. decimate_stopping_condition_callback stopping_condition;
  44. infinite_cost_stopping_condition(cost_and_placement,stopping_condition);
  45. return stopping_condition;
  46. }