tetrahedralize.h 2.2 KB

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