marching_tets.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 Francis Williams <francis@fwilliams.info>
  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_MARCHING_TETS_H
  9. #define IGL_MARCHING_TETS_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Sparse>
  13. namespace igl {
  14. // marching_tets( TV, TT, S, isovalue, SV, SF, J, BC)
  15. //
  16. // performs the marching tetrahedra algorithm on a tet mesh defined by TV and
  17. // TT with scalar values defined at each vertex in TV. The output is a
  18. // triangle mesh approximating the isosurface coresponding to the value
  19. // isovalue.
  20. //
  21. // Input:
  22. // TV #tet_vertices x 3 array -- The vertices of the tetrahedral mesh
  23. // TT #tets x 4 array -- The indexes of each tet in the tetrahedral mesh
  24. // S #tet_vertices x 1 array -- The values defined on each tet vertex
  25. // isovalue scalar -- The isovalue of the level set we want to compute
  26. //
  27. // Output:
  28. // SV #SV x 3 array -- The vertices of the output level surface mesh
  29. // SF #SF x 3 array -- The face indexes of the output level surface mesh
  30. // J #SF list of indices into TT revealing which tet each face comes from
  31. // BC #SV x #TV list of barycentric coordinates so that SV = BC*TV
  32. template <typename DerivedTV,
  33. typename DerivedTT,
  34. typename DerivedS,
  35. typename DerivedSV,
  36. typename DerivedSF,
  37. typename DerivedJ,
  38. typename BCType>
  39. IGL_INLINE void marching_tets(
  40. const Eigen::PlainObjectBase<DerivedTV>& TV,
  41. const Eigen::PlainObjectBase<DerivedTT>& TT,
  42. const Eigen::PlainObjectBase<DerivedS>& S,
  43. double isovalue,
  44. Eigen::PlainObjectBase<DerivedSV>& SV,
  45. Eigen::PlainObjectBase<DerivedSF>& SF,
  46. Eigen::PlainObjectBase<DerivedJ>& J,
  47. Eigen::SparseMatrix<BCType>& BC);
  48. // marching_tets( TV, TT, S, SV, SF, J, BC)
  49. //
  50. // Performs the marching tetrahedra algorithm on a tet mesh defined by TV and
  51. // TT with scalar values defined at each vertex in TV. The output is a
  52. // triangle mesh approximating the isosurface coresponding to an isovalue of 0.
  53. //
  54. // Input:
  55. // TV #tet_vertices x 3 array -- The vertices of the tetrahedral mesh
  56. // TT #tets x 4 array -- The indexes of each tet in the tetrahedral mesh
  57. // S #tet_vertices x 1 array -- The values defined on each tet vertex
  58. // isovalue scalar -- The isovalue of the level set we want to compute
  59. //
  60. // Output:
  61. // SV #SV x 3 array -- The vertices of the output level surface mesh
  62. // SF #SF x 3 array -- The face indexes of the output level surface mesh
  63. // J #SF list of indices into TT revealing which tet each face comes from
  64. // BC #SV x #TV list of barycentric coordinates so that SV = BC*TV
  65. template <typename DerivedTV,
  66. typename DerivedTT,
  67. typename DerivedS,
  68. typename DerivedSV,
  69. typename DerivedSF,
  70. typename DerivedJ,
  71. typename BCType>
  72. IGL_INLINE void marching_tets(
  73. const Eigen::PlainObjectBase<DerivedTV>& TV,
  74. const Eigen::PlainObjectBase<DerivedTT>& TT,
  75. const Eigen::PlainObjectBase<DerivedS>& S,
  76. Eigen::PlainObjectBase<DerivedSV>& SV,
  77. Eigen::PlainObjectBase<DerivedSF>& SF,
  78. Eigen::PlainObjectBase<DerivedJ>& J,
  79. Eigen::SparseMatrix<BCType>& BC) {
  80. return igl::marching_tets(TV, TT, S, 0.0, SV, SF, J, BC);
  81. }
  82. // marching_tets( TV, TT, S, isovalue, SV, SF, J)
  83. //
  84. // performs the marching tetrahedra algorithm on a tet mesh defined by TV and
  85. // TT with scalar values defined at each vertex in TV. The output is a
  86. // triangle mesh approximating the isosurface coresponding to the value
  87. // isovalue.
  88. //
  89. // Input:
  90. // TV #tet_vertices x 3 array -- The vertices of the tetrahedral mesh
  91. // TT #tets x 4 array -- The indexes of each tet in the tetrahedral mesh
  92. // S #tet_vertices x 1 array -- The values defined on each tet vertex
  93. // isovalue scalar -- The isovalue of the level set we want to compute
  94. //
  95. // Output:
  96. // SV #SV x 3 array -- The vertices of the output level surface mesh
  97. // SF #SF x 3 array -- The face indexes of the output level surface mesh
  98. // J #SF list of indices into TT revealing which tet each face comes from
  99. template <typename DerivedTV,
  100. typename DerivedTT,
  101. typename DerivedS,
  102. typename DerivedSV,
  103. typename DerivedSF,
  104. typename DerivedJ>
  105. IGL_INLINE void marching_tets(
  106. const Eigen::PlainObjectBase<DerivedTV>& TV,
  107. const Eigen::PlainObjectBase<DerivedTT>& TT,
  108. const Eigen::PlainObjectBase<DerivedS>& S,
  109. double isovalue,
  110. Eigen::PlainObjectBase<DerivedSV>& SV,
  111. Eigen::PlainObjectBase<DerivedSF>& SF,
  112. Eigen::PlainObjectBase<DerivedJ>& J) {
  113. Eigen::SparseMatrix<double> _BC;
  114. return igl::marching_tets(TV, TT, S, isovalue, SV, SF, J, _BC);
  115. }
  116. // marching_tets( TV, TT, S, isovalue, SV, SF, BC)
  117. //
  118. // performs the marching tetrahedra algorithm on a tet mesh defined by TV and
  119. // TT with scalar values defined at each vertex in TV. The output is a
  120. // triangle mesh approximating the isosurface coresponding to the value
  121. // isovalue.
  122. //
  123. // Input:
  124. // TV #tet_vertices x 3 array -- The vertices of the tetrahedral mesh
  125. // TT #tets x 4 array -- The indexes of each tet in the tetrahedral mesh
  126. // S #tet_vertices x 1 array -- The values defined on each tet vertex
  127. // isovalue scalar -- The isovalue of the level set we want to compute
  128. //
  129. // Output:
  130. // SV #SV x 3 array -- The vertices of the output level surface mesh
  131. // SF #SF x 3 array -- The face indexes of the output level surface mesh
  132. // BC #SV x #TV list of barycentric coordinates so that SV = BC*TV
  133. template <typename DerivedTV,
  134. typename DerivedTT,
  135. typename DerivedS,
  136. typename DerivedSV,
  137. typename DerivedSF,
  138. typename BCType>
  139. IGL_INLINE void marching_tets(
  140. const Eigen::PlainObjectBase<DerivedTV>& TV,
  141. const Eigen::PlainObjectBase<DerivedTT>& TT,
  142. const Eigen::PlainObjectBase<DerivedS>& S,
  143. double isovalue,
  144. Eigen::PlainObjectBase<DerivedSV>& SV,
  145. Eigen::PlainObjectBase<DerivedSF>& SF,
  146. Eigen::SparseMatrix<BCType>& BC) {
  147. Eigen::VectorXi _J;
  148. return igl::marching_tets(TV, TT, S, isovalue, SV, SF, _J, BC);
  149. }
  150. // marching_tets( TV, TT, S, isovalue, SV, SF)
  151. //
  152. // performs the marching tetrahedra algorithm on a tet mesh defined by TV and
  153. // TT with scalar values defined at each vertex in TV. The output is a
  154. // triangle mesh approximating the isosurface coresponding to the value
  155. // isovalue.
  156. //
  157. // Input:
  158. // TV #tet_vertices x 3 array -- The vertices of the tetrahedral mesh
  159. // TT #tets x 4 array -- The indexes of each tet in the tetrahedral mesh
  160. // S #tet_vertices x 1 array -- The values defined on each tet vertex
  161. // isovalue scalar -- The isovalue of the level set we want to compute
  162. //
  163. // Output:
  164. // SV #SV x 3 array -- The vertices of the output level surface mesh
  165. // SF #SF x 3 array -- The face indexes of the output level surface mesh
  166. template <typename DerivedTV,
  167. typename DerivedTT,
  168. typename DerivedS,
  169. typename DerivedSV,
  170. typename DerivedSF>
  171. IGL_INLINE void marching_tets(
  172. const Eigen::PlainObjectBase<DerivedTV>& TV,
  173. const Eigen::PlainObjectBase<DerivedTT>& TT,
  174. const Eigen::PlainObjectBase<DerivedS>& S,
  175. double isovalue,
  176. Eigen::PlainObjectBase<DerivedSV>& SV,
  177. Eigen::PlainObjectBase<DerivedSF>& SF) {
  178. Eigen::VectorXi _J;
  179. Eigen::SparseMatrix<double> _BC;
  180. return igl::marching_tets(TV, TT, S, isovalue, SV, SF, _J, _BC);
  181. }
  182. }
  183. #ifndef IGL_STATIC_LIBRARY
  184. # include "marching_tets.cpp"
  185. #endif
  186. #endif // IGL_MARCHING_TETS_H