tetgenio_to_tetmesh.h 1.9 KB

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