progressive_hulls_cost_and_placement.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #ifndef IGL_COPYLEFT_PROGRESSIVE_HULLS_COST_AND_PLACEMENT_H
  9. #define IGL_COPYLEFT_PROGRESSIVE_HULLS_COST_AND_PLACEMENT_H
  10. #include <Eigen/Core>
  11. #include "../igl_inline.h"
  12. namespace igl
  13. {
  14. namespace copyleft
  15. {
  16. // A "cost and placement" compatible with `igl::decimate` implementing the
  17. // "progressive hulls" algorithm in "Silhouette clipping" [Sander et al.
  18. // 2000]. This implementation fixes an issue that the original linear
  19. // program becomes unstable for flat patches by introducing a small
  20. // quadratic energy term pulling the collapsed edge toward its midpoint.
  21. // This function is not really meant to be called directly but rather
  22. // passed to `igl::decimate` as a handle.
  23. //
  24. // Inputs:
  25. // e index of edge to be collapsed
  26. // V #V by 3 list of vertex positions
  27. // F #F by 3 list of faces indices into V
  28. // E #E by 3 list of edges indices into V
  29. // EMAP #F*3 list of indices into E, mapping each directed edge to unique
  30. // unique edge in E
  31. // EF #E by 2 list of edge flaps, EF(e,0)=f means e=(i-->j) is the edge of
  32. // F(f,:) opposite the vth corner, where EI(e,0)=v. Similarly EF(e,1) "
  33. // e=(j->i)
  34. // EI #E by 2 list of edge flap corners (see above).
  35. // Outputs:
  36. // cost cost of collapsing edge e
  37. // p position to place collapsed vertex
  38. //
  39. IGL_INLINE void progressive_hulls_cost_and_placement(
  40. const int e,
  41. const Eigen::MatrixXd & V,
  42. const Eigen::MatrixXi & F,
  43. const Eigen::MatrixXi & E,
  44. const Eigen::VectorXi & EMAP,
  45. const Eigen::MatrixXi & EF,
  46. const Eigen::MatrixXi & EI,
  47. double & cost,
  48. Eigen::RowVectorXd & p);
  49. }
  50. }
  51. #ifndef IGL_STATIC_LIBRARY
  52. # include "progressive_hulls_cost_and_placement.cpp"
  53. #endif
  54. #endif