march_cube.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2021 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_MARCH_CUBE_H
  9. #define IGL_MARCH_CUBE_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <unordered_map>
  13. namespace igl
  14. {
  15. /// Process a single cube of a marching cubes grid.
  16. ///
  17. /// @param[in] GV #GV by 3 list of grid vertex positions
  18. /// @param[in] cS list of 8 scalar field values at grid corners
  19. /// @param[in] cI list of 8 indices of corners into rows of GV
  20. /// @param[in] isovalue level-set value being extracted (often 0)
  21. /// @param[in,out] V #V by 3 current list of output mesh vertex positions
  22. /// @param[in,out] n current number of mesh vertices (i.e., occupied rows in V)
  23. /// @param[in,out] F #F by 3 current list of output mesh triangle indices into rows of V
  24. /// @param[in,out] m current number of mesh triangles (i.e., occupied rows in F)
  25. /// @param[in,out] E2V current edge (GV_i,GV_j) to vertex (V_k) map
  26. ///
  27. /// Side-effects: V,n,F,m,E2V are updated to contain new vertices and faces of
  28. /// any constructed mesh elements
  29. ///
  30. template <
  31. typename DerivedGV,
  32. typename Scalar,
  33. typename Index,
  34. typename DerivedV,
  35. typename DerivedF>
  36. IGL_INLINE void march_cube(
  37. const DerivedGV & GV,
  38. const Eigen::Matrix<Scalar,8,1> & cS,
  39. const Eigen::Matrix<Index,8,1> & cI,
  40. const Scalar & isovalue,
  41. Eigen::PlainObjectBase<DerivedV> &V,
  42. Index & n,
  43. Eigen::PlainObjectBase<DerivedF> &F,
  44. Index & m,
  45. std::unordered_map<int64_t,int> & E2V);
  46. }
  47. #ifndef IGL_STATIC_LIBRARY
  48. # include "march_cube.cpp"
  49. #endif
  50. #endif