march_cube.h 1.8 KB

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