tetrahedralize.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. }
  68. }
  69. }
  70. #ifndef IGL_STATIC_LIBRARY
  71. # include "tetrahedralize.cpp"
  72. #endif
  73. #endif