tetgenio_to_tetmesh.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_TETGENIO_TO_TETMESH_H
  9. #define IGL_COPYLEFT_TETGEN_TETGENIO_TO_TETMESH_H
  10. #include "../../igl_inline.h"
  11. #ifndef TETLIBRARY
  12. #define TETLIBRARY
  13. #endif
  14. #include "tetgen.h" // Defined tetgenio, REAL
  15. #include <vector>
  16. #include <Eigen/Core>
  17. namespace igl
  18. {
  19. namespace copyleft
  20. {
  21. namespace tetgen
  22. {
  23. // Extract a tetrahedral mesh from a tetgenio object
  24. // Inputs:
  25. // out tetgenio output object
  26. // Outputs:
  27. // V #V by 3 vertex position list
  28. // T #T by 4 list of tetrahedra indices into V
  29. // F #F by 3 list of marked facets
  30. // Returns true on success, false on error
  31. IGL_INLINE bool tetgenio_to_tetmesh(
  32. const tetgenio & out,
  33. std::vector<std::vector<REAL > > & V,
  34. std::vector<std::vector<int> > & T,
  35. std::vector<std::vector<int> > & F);
  36. IGL_INLINE bool tetgenio_to_tetmesh(
  37. const tetgenio & out,
  38. std::vector<std::vector<REAL > > & V,
  39. std::vector<std::vector<int> > & T);
  40. // Wrapper with Eigen types
  41. // Templates:
  42. // DerivedV real-value: i.e. from MatrixXd
  43. // DerivedT integer-value: i.e. from MatrixXi
  44. template <typename DerivedV, typename DerivedT, typename DerivedF>
  45. IGL_INLINE bool tetgenio_to_tetmesh(
  46. const tetgenio & out,
  47. Eigen::PlainObjectBase<DerivedV>& V,
  48. Eigen::PlainObjectBase<DerivedT>& T,
  49. Eigen::PlainObjectBase<DerivedF>& F);
  50. template <typename DerivedV, typename DerivedT>
  51. IGL_INLINE bool tetgenio_to_tetmesh(
  52. const tetgenio & out,
  53. Eigen::PlainObjectBase<DerivedV>& V,
  54. Eigen::PlainObjectBase<DerivedT>& T);
  55. }
  56. }
  57. }
  58. #ifndef IGL_STATIC_LIBRARY
  59. # include "tetgenio_to_tetmesh.cpp"
  60. #endif
  61. #endif