sparse_voxel_grid.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 Francis Williams <francis@fwilliams.info>
  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_SPARSE_VOXEL_GRID_H
  9. #define IGL_SPARSE_VOXEL_GRID_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl {
  13. // sparse_voxel_grid( p0, scalarFunc, eps, CV, CS, CI )
  14. //
  15. // Given a point, p0, on an isosurface, construct a shell of epsilon sized cubes surrounding the surface.
  16. // These cubes can be used as the input to marching cubes.
  17. //
  18. // Input:
  19. // p0 A 3D point on the isosurface surface defined by scalarFunc(x) = 0
  20. // scalarFunc A scalar function from R^3 to R -- points which map to 0 lie
  21. // on the surface, points which are negative lie inside the surface,
  22. // and points which are positive lie outside the surface
  23. // eps The edge length of the cubes surrounding the surface
  24. // expected_number_of_cubes This pre-allocates internal data structures to speed things up
  25. // Output:
  26. // CS #cube-vertices by 1 list of scalar values at the cube vertices
  27. // CV #cube-vertices by 3 list of cube vertex positions
  28. // CI #number of cubes by 8 list of indexes into CS and CV. Each row represents a cube
  29. //
  30. template <typename DerivedP0, typename Func, typename DerivedS, typename DerivedV, typename DerivedI>
  31. IGL_INLINE void sparse_voxel_grid(const Eigen::MatrixBase<DerivedP0>& p0,
  32. const Func& scalarFunc,
  33. const double eps,
  34. const int expected_number_of_cubes,
  35. Eigen::PlainObjectBase<DerivedS>& CS,
  36. Eigen::PlainObjectBase<DerivedV>& CV,
  37. Eigen::PlainObjectBase<DerivedI>& CI);
  38. }
  39. #ifndef IGL_STATIC_LIBRARY
  40. # include "sparse_voxel_grid.cpp"
  41. #endif
  42. #endif // IGL_SPARSE_VOXEL_GRID_H