sparse_voxel_grid.h 1.9 KB

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