tetrahedralize.h 2.3 KB

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