box_faces.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2025 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_BOX_FACES_H
  9. #define IGL_BOX_FACES_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Geometry>
  13. namespace igl
  14. {
  15. /// Compute the quad faces of an axis-aligned bounding box) shrunk by a given
  16. /// factor.
  17. ///
  18. /// @param[in] box Axis-aligned bounding box
  19. /// @param[in] shrink Factor by which to shrink the box
  20. /// @param[out] P #P by 3 list of vertex positions
  21. /// @param[out] Q #Q by 4 list of triangle indices into rows of P
  22. template <typename DerivedV, typename DerivedQ>
  23. IGL_INLINE void box_faces(
  24. const Eigen::AlignedBox<typename DerivedV::Scalar,3> & box,
  25. const typename DerivedV::Scalar shrink,
  26. Eigen::PlainObjectBase<DerivedV> & P,
  27. Eigen::PlainObjectBase<DerivedQ> & Q);
  28. // Forward declaration
  29. template <typename DerivedV, int DIM> class AABB;
  30. /// Compute the quad faces of a tree of axis-aligned bounding boxes.
  31. ///
  32. /// @param[in] tree Tree of axis-aligned bounding boxes
  33. /// @param[out] P #P by 3 list of vertex positions
  34. /// @param[out] Q #Q by 4 list of triangle indices into rows of P
  35. /// @param[out] D #Q list of tree depths (0==root)
  36. template <
  37. typename DerivedV,
  38. typename DerivedP,
  39. typename DerivedQ,
  40. typename DerivedD >
  41. IGL_INLINE void box_faces(
  42. const igl::AABB<DerivedV,3> & tree,
  43. Eigen::PlainObjectBase<DerivedP> & P,
  44. Eigen::PlainObjectBase<DerivedQ> & Q,
  45. Eigen::PlainObjectBase<DerivedD> & D);
  46. }
  47. #ifndef IGL_STATIC_LIBRARY
  48. # include "box_faces.cpp"
  49. #endif
  50. #endif