remesh_along_isoline.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 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_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. // Inputs:
  21. // V #V by dim list of mesh vertex positions
  22. // F #F by 3 list of mesh triangle indices into V
  23. // S #V by 1 list of scalar field
  24. // val value of S to remesh along
  25. // Outputs:
  26. // U #U by dim list of mesh vertex positions #U>=#V
  27. // G #G by 3 list of mesh triangle indices into U, #G>=#F
  28. // SU #U list of scalar field values over new mesh
  29. // J #G list of indices into F revealing birth triangles
  30. // BC #U by #V sparse matrix of barycentric coordinates so that U = BC*V
  31. // L #G list of bools whether scalar field in triangle below or above val
  32. template <
  33. typename DerivedV,
  34. typename DerivedF,
  35. typename DerivedS,
  36. typename DerivedU,
  37. typename DerivedG,
  38. typename DerivedJ,
  39. typename BCtype,
  40. typename DerivedSU,
  41. typename DerivedL>
  42. IGL_INLINE void remesh_along_isoline(
  43. const Eigen::MatrixBase<DerivedV> & V,
  44. const Eigen::MatrixBase<DerivedF> & F,
  45. const Eigen::MatrixBase<DerivedS> & S,
  46. const typename DerivedS::Scalar val,
  47. Eigen::PlainObjectBase<DerivedU> & U,
  48. Eigen::PlainObjectBase<DerivedG> & G,
  49. Eigen::PlainObjectBase<DerivedSU> & SU,
  50. Eigen::PlainObjectBase<DerivedJ> & J,
  51. Eigen::SparseMatrix<BCtype> & BC,
  52. Eigen::PlainObjectBase<DerivedL> & L);
  53. // Input:
  54. // n number of vertices (#V)
  55. template <
  56. typename DerivedF,
  57. typename DerivedS,
  58. typename DerivedG,
  59. typename DerivedJ,
  60. typename BCtype,
  61. typename DerivedSU,
  62. typename DerivedL>
  63. IGL_INLINE void remesh_along_isoline(
  64. const int n,
  65. const Eigen::MatrixBase<DerivedF> & F,
  66. const Eigen::MatrixBase<DerivedS> & S,
  67. const typename DerivedS::Scalar val,
  68. Eigen::PlainObjectBase<DerivedG> & G,
  69. Eigen::PlainObjectBase<DerivedSU> & SU,
  70. Eigen::PlainObjectBase<DerivedJ> & J,
  71. Eigen::SparseMatrix<BCtype> & BC,
  72. Eigen::PlainObjectBase<DerivedL> & L);
  73. }
  74. #ifndef IGL_STATIC_LIBRARY
  75. # include "remesh_along_isoline.cpp"
  76. #endif
  77. #endif