planarize_quad_mesh.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef IGL_PLANARIZE_QUAD_MESH_H
  2. #define IGL_PLANARIZE_QUAD_MESH_H
  3. #include "igl_inline.h"
  4. #include <Eigen/Core>
  5. namespace igl
  6. {
  7. // Planarizes a given quad mesh using the algorithm described in the paper
  8. // "Shape-Up: Shaping Discrete Geometry with Projections" by S. Bouaziz,
  9. // M. Deuss, Y. Schwartzburg, T. Weise, M. Pauly, Computer Graphics Forum,
  10. // Volume 31, Issue 5, August 2012, p. 1657-1667
  11. // (http://dl.acm.org/citation.cfm?id=2346802).
  12. // The algorithm iterates between projecting each quad to its closest planar
  13. // counterpart and stitching those quads together via a least squares
  14. // optimization. It stops whenever all quads' non-planarity is less than a
  15. // given threshold (suggested value: 0.01), or a maximum number of iterations
  16. // is reached.
  17. // Inputs:
  18. // Vin #V by 3 eigen Matrix of mesh vertex 3D positions
  19. // F #F by 4 eigen Matrix of face (quad) indices
  20. // maxIter maximum numbers of iterations
  21. // threshold minimum allowed threshold for non-planarity
  22. // Output:
  23. // Vout #V by 3 eigen Matrix of planar mesh vertex 3D positions
  24. //
  25. template <typename DerivedV, typename DerivedF>
  26. IGL_INLINE void planarize_quad_mesh(const Eigen::PlainObjectBase<DerivedV> &Vin,
  27. const Eigen::PlainObjectBase<DerivedF> &F,
  28. const int maxIter,
  29. const double &threshold,
  30. Eigen::PlainObjectBase<DerivedV> &Vout);
  31. }
  32. #ifndef IGL_STATIC_LIBRARY
  33. # include "planarize_quad_mesh.cpp"
  34. #endif
  35. #endif