loop.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Oded Stein <[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. #ifndef IGL_LOOP_H
  9. #define IGL_LOOP_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. /// Given the triangle mesh [V, F], where n_verts = V.rows(), computes
  16. /// newV and a sparse matrix S s.t. [newV, newF] is the subdivided mesh where
  17. /// newV = S*V.
  18. ///
  19. /// @param[in] n_verts an integer (number of mesh vertices)
  20. /// @param[in] F an m by 3 matrix of integers of triangle faces
  21. /// @param[out] S a sparse matrix (will become the subdivision matrix)
  22. /// @param[out] newF a matrix containing the new faces
  23. template <
  24. typename DerivedF,
  25. typename SType,
  26. typename DerivedNF>
  27. IGL_INLINE void loop(
  28. const int n_verts,
  29. const Eigen::MatrixBase<DerivedF> & F,
  30. Eigen::SparseMatrix<SType>& S,
  31. Eigen::PlainObjectBase<DerivedNF> & NF);
  32. /// Given the triangle mesh [V, F], computes number_of_subdivs steps of loop subdivision and outputs the new mesh [newV, newF]
  33. ///
  34. /// @param[in] V an n by 3 matrix of vertices
  35. /// @param[in] F an m by 3 matrix of integers of triangle faces
  36. /// @param[out] NV a matrix containing the new vertices
  37. /// @param[out] NF a matrix containing the new faces
  38. /// @param[in] number_of_subdivs an integer that specifies how many subdivision steps to do
  39. template <
  40. typename DerivedV,
  41. typename DerivedF,
  42. typename DerivedNV,
  43. typename DerivedNF>
  44. IGL_INLINE void loop(
  45. const Eigen::MatrixBase<DerivedV>& V,
  46. const Eigen::MatrixBase<DerivedF>& F,
  47. Eigen::PlainObjectBase<DerivedNV>& NV,
  48. Eigen::PlainObjectBase<DerivedNF>& NF,
  49. const int number_of_subdivs = 1);
  50. }
  51. #ifndef IGL_STATIC_LIBRARY
  52. # include "loop.cpp"
  53. #endif
  54. #endif