remesh_along_isoline.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 Alec Jacobson <[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_REMESH_ALONG_ISOLINE_H
  9. #define IGL_REMESH_ALONG_ISOLINE_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. /// Given a triangle mesh and a scalar field, remesh so that a given isovalue
  16. /// of the scalar field follows (new) edges of the output mesh. Effectively
  17. /// running "marching triangles" on mesh, but not in any coherent order. The
  18. /// output mesh should be as manifold as the input.
  19. ///
  20. /// @param[in] V #V by dim list of mesh vertex positions
  21. /// @param[in] F #F by 3 list of mesh triangle indices into V
  22. /// @param[in] S #V by 1 list of scalar field
  23. /// @param[in] val value of S to remesh along
  24. /// @param[out] U #U by dim list of mesh vertex positions #U>=#V
  25. /// @param[out] G #G by 3 list of mesh triangle indices into U, #G>=#F
  26. /// @param[out] SU #U list of scalar field values over new mesh
  27. /// @param[out] J #G list of indices into F revealing birth triangles
  28. /// @param[out] BC #U by #V sparse matrix of barycentric coordinates so that U = BC*V
  29. /// @param[out] L #G list of bools whether scalar field in triangle below or above val
  30. template <
  31. typename DerivedV,
  32. typename DerivedF,
  33. typename DerivedS,
  34. typename DerivedU,
  35. typename DerivedG,
  36. typename DerivedJ,
  37. typename BCtype,
  38. typename DerivedSU,
  39. typename DerivedL>
  40. IGL_INLINE void remesh_along_isoline(
  41. const Eigen::MatrixBase<DerivedV> & V,
  42. const Eigen::MatrixBase<DerivedF> & F,
  43. const Eigen::MatrixBase<DerivedS> & S,
  44. const typename DerivedS::Scalar val,
  45. Eigen::PlainObjectBase<DerivedU> & U,
  46. Eigen::PlainObjectBase<DerivedG> & G,
  47. Eigen::PlainObjectBase<DerivedSU> & SU,
  48. Eigen::PlainObjectBase<DerivedJ> & J,
  49. Eigen::SparseMatrix<BCtype> & BC,
  50. Eigen::PlainObjectBase<DerivedL> & L);
  51. /// \overload
  52. /// @param[in] n number of vertices (#V)
  53. template <
  54. typename DerivedF,
  55. typename DerivedS,
  56. typename DerivedG,
  57. typename DerivedJ,
  58. typename BCtype,
  59. typename DerivedSU,
  60. typename DerivedL>
  61. IGL_INLINE void remesh_along_isoline(
  62. const int n,
  63. const Eigen::MatrixBase<DerivedF> & F,
  64. const Eigen::MatrixBase<DerivedS> & S,
  65. const typename DerivedS::Scalar val,
  66. Eigen::PlainObjectBase<DerivedG> & G,
  67. Eigen::PlainObjectBase<DerivedSU> & SU,
  68. Eigen::PlainObjectBase<DerivedJ> & J,
  69. Eigen::SparseMatrix<BCtype> & BC,
  70. Eigen::PlainObjectBase<DerivedL> & L);
  71. }
  72. #ifndef IGL_STATIC_LIBRARY
  73. # include "remesh_along_isoline.cpp"
  74. #endif
  75. #endif