planarize_quad_mesh.h 1.9 KB

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