loop.h 2.0 KB

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