tetrahedralize.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef IGL_TETRAHEDRALIZE_H
  2. #define IGL_TETRAHEDRALIZE_H
  3. #include "../igl_inline.h"
  4. #include <vector>
  5. #include <string>
  6. #include <Eigen/Core>
  7. #define TETLIBRARY
  8. #include "tetgen.h" // Defined REAL
  9. namespace igl
  10. {
  11. // Mesh the interior of a surface mesh (V,F) using tetgen
  12. //
  13. // Inputs:
  14. // V #V by 3 vertex position list
  15. // F #F list of polygon face indices into V (0-indexed)
  16. // switches string of tetgen options (See tetgen documentation) e.g.
  17. // "pq1.414a0.01" tries to mesh the interior of a given surface with
  18. // quality and area constraints
  19. // "" will mesh the convex hull constrained to pass through V (ignores F)
  20. // Outputs:
  21. // TV #V by 3 vertex position list
  22. // TT #T by 4 list of tet face indices
  23. // TF #F by 3 list of trianlge face indices
  24. // Returns status:
  25. // 0 success
  26. // 1 tetgen threw exception
  27. // 2 tetgen did not crash but could not create any tets (probably there are
  28. // holes, duplicate faces etc.)
  29. // -1 other error
  30. IGL_INLINE int tetrahedralize(
  31. const std::vector<std::vector<REAL > > & V,
  32. const std::vector<std::vector<int> > & F,
  33. const std::string switches,
  34. std::vector<std::vector<REAL > > & TV,
  35. std::vector<std::vector<int > > & TT,
  36. std::vector<std::vector<int> > & TF);
  37. // Wrapper with Eigen types
  38. // Templates:
  39. // DerivedV real-value: i.e. from MatrixXd
  40. // DerivedF integer-value: i.e. from MatrixXi
  41. template <
  42. typename DerivedV,
  43. typename DerivedF,
  44. typename DerivedTV,
  45. typename DerivedTT,
  46. typename DerivedTF>
  47. IGL_INLINE int tetrahedralize(
  48. const Eigen::PlainObjectBase<DerivedV>& V,
  49. const Eigen::PlainObjectBase<DerivedF>& F,
  50. const std::string switches,
  51. Eigen::PlainObjectBase<DerivedTV>& TV,
  52. Eigen::PlainObjectBase<DerivedTT>& TT,
  53. Eigen::PlainObjectBase<DerivedTF>& TF);
  54. }
  55. #ifdef IGL_HEADER_ONLY
  56. # include "tetrahedralize.cpp"
  57. #endif
  58. #endif