tetrahedralize.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_TETGEN_TETRAHEDRALIZE_H
  9. #define IGL_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 tetgen
  21. {
  22. // Mesh the interior of a surface mesh (V,F) using tetgen
  23. //
  24. // Inputs:
  25. // V #V by 3 vertex position list
  26. // F #F list of polygon face indices into V (0-indexed)
  27. // switches string of tetgen options (See tetgen documentation) e.g.
  28. // "pq1.414a0.01" tries to mesh the interior of a given surface with
  29. // quality and area constraints
  30. // "" will mesh the convex hull constrained to pass through V (ignores F)
  31. // Outputs:
  32. // TV #V by 3 vertex position list
  33. // TT #T by 4 list of tet face indices
  34. // TF #F by 3 list of triangle face indices
  35. // Returns status:
  36. // 0 success
  37. // 1 tetgen threw exception
  38. // 2 tetgen did not crash but could not create any tets (probably there are
  39. // holes, duplicate faces etc.)
  40. // -1 other error
  41. IGL_INLINE int tetrahedralize(
  42. const std::vector<std::vector<REAL > > & V,
  43. const std::vector<std::vector<int> > & F,
  44. const std::string switches,
  45. std::vector<std::vector<REAL > > & TV,
  46. std::vector<std::vector<int > > & TT,
  47. std::vector<std::vector<int> > & TF);
  48. // Wrapper with Eigen types
  49. // Templates:
  50. // DerivedV real-value: i.e. from MatrixXd
  51. // DerivedF integer-value: i.e. from MatrixXi
  52. template <
  53. typename DerivedV,
  54. typename DerivedF,
  55. typename DerivedTV,
  56. typename DerivedTT,
  57. typename DerivedTF>
  58. IGL_INLINE int tetrahedralize(
  59. const Eigen::PlainObjectBase<DerivedV>& V,
  60. const Eigen::PlainObjectBase<DerivedF>& F,
  61. const std::string switches,
  62. Eigen::PlainObjectBase<DerivedTV>& TV,
  63. Eigen::PlainObjectBase<DerivedTT>& TT,
  64. Eigen::PlainObjectBase<DerivedTF>& TF);
  65. }
  66. }
  67. #ifndef IGL_STATIC_LIBRARY
  68. # include "tetrahedralize.cpp"
  69. #endif
  70. #endif