tetgenio_to_tetmesh.h 2.0 KB

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