tetgenio_to_tetmesh.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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. /// Convert a tetgenio to a tetmesh
  25. ///
  26. /// @param[in] out output of tetrahedralization
  27. /// @param[out] V #V by 3 list of mesh vertex positions
  28. /// @param[out] T #T by 4 list of mesh tet indices into V
  29. /// @param[out] F #F by 3 list of mesh triangle indices into V
  30. /// @param[out] TM #T by 1 list of material indices into R
  31. /// @param[out] R #TT list of region ID for each tetrahedron
  32. /// @param[out] N #TT by 4 list of indices neighbors for each tetrahedron ('n')
  33. /// @param[out] PT #TV list of incident tetrahedron for a vertex ('m')
  34. /// @param[out] FT #TF by 2 list of tetrahedrons sharing a triface ('nn')
  35. /// @param[out] num_regions Number of regions in output mesh
  36. ///
  37. /// \bug Assumes that out.numberoftetrahedronattributes == 1 or 0
  38. template <
  39. typename DerivedV,
  40. typename DerivedT,
  41. typename DerivedF,
  42. typename DerivedTM,
  43. typename DerivedR,
  44. typename DerivedN,
  45. typename DerivedPT,
  46. typename DerivedFT>
  47. IGL_INLINE bool tetgenio_to_tetmesh(
  48. const tetgenio & out,
  49. Eigen::PlainObjectBase<DerivedV>& V,
  50. Eigen::PlainObjectBase<DerivedT>& T,
  51. Eigen::PlainObjectBase<DerivedF>& F,
  52. Eigen::PlainObjectBase<DerivedTM>& TM,
  53. Eigen::PlainObjectBase<DerivedR>& R,
  54. Eigen::PlainObjectBase<DerivedN>& N,
  55. Eigen::PlainObjectBase<DerivedPT>& PT,
  56. Eigen::PlainObjectBase<DerivedFT>& FT,
  57. int & num_regions);
  58. }
  59. }
  60. }
  61. #ifndef IGL_STATIC_LIBRARY
  62. # include "tetgenio_to_tetmesh.cpp"
  63. #endif
  64. #endif