tetgenio_to_tetmesh.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 <unordered_map>
  17. #include <Eigen/Core>
  18. namespace igl
  19. {
  20. namespace copyleft
  21. {
  22. namespace tetgen
  23. {
  24. // Extract a tetrahedral mesh from a tetgenio object
  25. // Inputs:
  26. // out tetgenio output object
  27. // Outputs:
  28. // V #V by 3 vertex position list
  29. // T #T by 4 list of tetrahedra indices into V
  30. // F #F by 3 list of marked facets
  31. // Returns true on success, false on error
  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. std::vector<std::vector<int> > & F);
  37. IGL_INLINE bool tetgenio_to_tetmesh(
  38. const tetgenio & out,
  39. std::vector<std::vector<REAL > > & V,
  40. std::vector<std::vector<int> > & T);
  41. // Wrapper with Eigen types
  42. // Templates:
  43. // DerivedV real-value: i.e. from MatrixXd
  44. // DerivedT integer-value: i.e. from MatrixXi
  45. template <typename DerivedV, typename DerivedT, typename DerivedF>
  46. IGL_INLINE bool tetgenio_to_tetmesh(
  47. const tetgenio & out,
  48. Eigen::PlainObjectBase<DerivedV>& V,
  49. Eigen::PlainObjectBase<DerivedT>& T,
  50. Eigen::PlainObjectBase<DerivedF>& F);
  51. template <typename DerivedV, typename DerivedT>
  52. IGL_INLINE bool tetgenio_to_tetmesh(
  53. const tetgenio & out,
  54. Eigen::PlainObjectBase<DerivedV>& V,
  55. Eigen::PlainObjectBase<DerivedT>& T);
  56. // Extract a tetrahedral mesh from a tetgenio object
  57. // Inputs:
  58. // out tetgenio output object
  59. // Outputs:
  60. // V #V by 3 vertex position list
  61. // T #T by 4 list of tetrahedra indices into V
  62. // F #F by 3 list of marked facets
  63. // R #T list of region IDs for tetrahedra
  64. // N #T by 2 list of neighbors for each tetrahedron
  65. // PT #V list of incident tetrahedron for each vertex
  66. // FT #F by 2 list of tetrahedra sharing each face
  67. // nR number of regions in output mesh
  68. // Returns true on success, false on error
  69. IGL_INLINE bool tetgenio_to_tetmesh(
  70. const tetgenio & out,
  71. std::vector<std::vector<REAL > > & V,
  72. std::vector<std::vector<int> > & T,
  73. std::vector<std::vector<int> > & F,
  74. std::vector<std::vector<REAL> > & R,// region marks for tetrahedrons
  75. std::vector<std::vector<int > > &N, // neighborlist per tet
  76. std::vector<std::vector<int > > &PT, // Point to tet list per point
  77. std::vector<std::vector<int > > &FT, // face to tet list
  78. size_t & nR); // number of regions
  79. }
  80. }
  81. }
  82. #ifndef IGL_STATIC_LIBRARY
  83. # include "tetgenio_to_tetmesh.cpp"
  84. #endif
  85. #endif