tetrahedralize.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_COPYLEFT_TETGEN_TETRAHEDRALIZE_H
  9. #define IGL_COPYLEFT_TETGEN_TETRAHEDRALIZE_H
  10. #include "../../igl_inline.h"
  11. #include <vector>
  12. #include <string>
  13. #include <Eigen/Core>
  14. #ifndef TETLIBRARY
  15. #define TETLIBRARY
  16. #endif
  17. #include "tetgen.h" // Defined REAL
  18. namespace igl
  19. {
  20. namespace copyleft
  21. {
  22. namespace tetgen
  23. {
  24. // Mesh the interior of a surface mesh (V,F) using tetgen
  25. //
  26. // Inputs:
  27. // V #V by 3 vertex position list
  28. // F #F list of polygon face indices into V (0-indexed)
  29. // switches string of tetgen options (See tetgen documentation) e.g.
  30. // "pq1.414a0.01" tries to mesh the interior of a given surface with
  31. // quality and area constraints
  32. // "" will mesh the convex hull constrained to pass through V (ignores F)
  33. // Outputs:
  34. // TV #V by 3 vertex position list
  35. // TT #T by 4 list of tet face indices
  36. // TF #F by 3 list of triangle face indices
  37. // Returns status:
  38. // 0 success
  39. // 1 tetgen threw exception
  40. // 2 tetgen did not crash but could not create any tets (probably there are
  41. // holes, duplicate faces etc.)
  42. // -1 other error
  43. IGL_INLINE int tetrahedralize(
  44. const std::vector<std::vector<REAL > > & V,
  45. const std::vector<std::vector<int> > & F,
  46. const std::string switches,
  47. std::vector<std::vector<REAL > > & TV,
  48. std::vector<std::vector<int > > & TT,
  49. std::vector<std::vector<int> > & TF);
  50. // Wrapper with Eigen types
  51. // Templates:
  52. // DerivedV real-value: i.e. from MatrixXd
  53. // DerivedF integer-value: i.e. from MatrixXi
  54. template <
  55. typename DerivedV,
  56. typename DerivedF,
  57. typename DerivedTV,
  58. typename DerivedTT,
  59. typename DerivedTF>
  60. IGL_INLINE int tetrahedralize(
  61. const Eigen::PlainObjectBase<DerivedV>& V,
  62. const Eigen::PlainObjectBase<DerivedF>& F,
  63. const std::string switches,
  64. Eigen::PlainObjectBase<DerivedTV>& TV,
  65. Eigen::PlainObjectBase<DerivedTT>& TT,
  66. Eigen::PlainObjectBase<DerivedTF>& TF);
  67. // Mesh the interior of a surface mesh (V,F) using tetgen
  68. //
  69. // Inputs:
  70. // V #V by 3 vertex position list
  71. // F #F list of polygon face indices into V (0-indexed)
  72. // M #V list of markers for vertices
  73. // switches string of tetgen options (See tetgen documentation) e.g.
  74. // "pq1.414a0.01" tries to mesh the interior of a given surface with
  75. // quality and area constraints
  76. // "" will mesh the convex hull constrained to pass through V (ignores F)
  77. // Outputs:
  78. // TV #V by 3 vertex position list
  79. // TT #T by 4 list of tet face indices
  80. // TF #F by 3 list of triangle face indices
  81. // TM #V list of markers for vertices
  82. // Returns status:
  83. // 0 success
  84. // 1 tetgen threw exception
  85. // 2 tetgen did not crash but could not create any tets (probably there are
  86. // holes, duplicate faces etc.)
  87. // -1 other error
  88. IGL_INLINE int tetrahedralize(
  89. const std::vector<std::vector<REAL > > & V,
  90. const std::vector<std::vector<int> > & F,
  91. const std::vector<int> & VM,
  92. const std::vector<int> & FM,
  93. const std::string switches,
  94. std::vector<std::vector<REAL > > & TV,
  95. std::vector<std::vector<int > > & TT,
  96. std::vector<std::vector<int> > & TF,
  97. std::vector<int> & TM);
  98. // Wrapper with Eigen types
  99. // Templates:
  100. // DerivedV real-value: i.e. from MatrixXd
  101. // DerivedF integer-value: i.e. from MatrixXi
  102. template <
  103. typename DerivedV,
  104. typename DerivedF,
  105. typename DerivedVM,
  106. typename DerivedFM,
  107. typename DerivedTV,
  108. typename DerivedTT,
  109. typename DerivedTF,
  110. typename DerivedTM>
  111. IGL_INLINE int tetrahedralize(
  112. const Eigen::PlainObjectBase<DerivedV>& V,
  113. const Eigen::PlainObjectBase<DerivedF>& F,
  114. const Eigen::PlainObjectBase<DerivedVM>& VM,
  115. const Eigen::PlainObjectBase<DerivedFM>& FM,
  116. const std::string switches,
  117. Eigen::PlainObjectBase<DerivedTV>& TV,
  118. Eigen::PlainObjectBase<DerivedTT>& TT,
  119. Eigen::PlainObjectBase<DerivedTF>& TF,
  120. Eigen::PlainObjectBase<DerivedTM>& TM);
  121. }
  122. }
  123. }
  124. #ifndef IGL_STATIC_LIBRARY
  125. # include "tetrahedralize.cpp"
  126. #endif
  127. #endif