tetrahedralized_grid.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2020 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_TETRAHEDRALIZED_GRID_H
  9. #define IGL_TETRAHEDRALIZED_GRID_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Types of tetrahedralizations of a cubical cell
  15. enum TetrahedralizedGripType
  16. {
  17. /// 1 cube → 5 tets
  18. TETRAHEDRALIZED_GRID_TYPE_5 = 0,
  19. /// 1 cube → 6 tets with rotatonal symmetry
  20. TETRAHEDRALIZED_GRID_TYPE_6_ROTATIONAL = 1,
  21. /// Total number of tetrahedralization types
  22. NUM_TETRAHEDRALIZED_GRID_TYPE = 2
  23. };
  24. /// Construct vertices of a regular grid, suitable for input to
  25. /// `igl::marching_tets`
  26. ///
  27. /// @param[in] nx number of grid vertices in x direction
  28. /// @param[in] ny number of grid vertices in y direction
  29. /// @param[in] nz number of grid vertices in z direction
  30. /// @param[in] type type of tetrahedralization of cube to use
  31. /// @param[out] GV nx*ny*nz by 3 list of grid vertex positions
  32. /// @param[out] GT (nx-1)*(ny-1)*(nz-1)*k by 4 list of tetrahedron indices into rows of
  33. /// V, where k is the number of tets per cube (dependent on type)
  34. ///
  35. /// \see triangulated_grid, quad_grid
  36. template <
  37. typename DerivedGV,
  38. typename DerivedGT>
  39. IGL_INLINE void tetrahedralized_grid(
  40. const int nx,
  41. const int ny,
  42. const int nz,
  43. const TetrahedralizedGripType type,
  44. Eigen::PlainObjectBase<DerivedGV> & GV,
  45. Eigen::PlainObjectBase<DerivedGT> & GT);
  46. /// \overload
  47. /// @param[in] side 3-long list {nx,ny,nz} see above
  48. template <
  49. typename Derivedside,
  50. typename DerivedGT>
  51. IGL_INLINE void tetrahedralized_grid(
  52. const Eigen::MatrixBase<Derivedside> & side,
  53. const TetrahedralizedGripType type,
  54. Eigen::PlainObjectBase<DerivedGT> & GT);
  55. }
  56. #ifndef IGL_STATIC_LIBRARY
  57. # include "tetrahedralized_grid.cpp"
  58. #endif
  59. #endif