half_space_box.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef IGL_COPYLEFT_CGAL_HALF_SPACE_BOX_H
  2. #define IGL_COPYLEFT_CGAL_HALF_SPACE_BOX_H
  3. #include "../../igl_inline.h"
  4. #include <Eigen/Core>
  5. #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
  6. #include <CGAL/Plane_3.h>
  7. namespace igl
  8. {
  9. namespace copyleft
  10. {
  11. namespace cgal
  12. {
  13. // Construct a mesh of box (BV,BF) so that it contains the intersection of
  14. // the half-space under the plane (P) and the bounding box of V, and does not
  15. // contain any of the half-space above (P).
  16. //
  17. // Inputs:
  18. // P plane so that normal points away from half-space
  19. // V #V by 3 list of vertex positions
  20. // Outputs:
  21. // BV #BV by 3 list of box vertex positions
  22. // BF #BF b3 list of box triangle indices into BV
  23. template <typename DerivedV>
  24. IGL_INLINE void half_space_box(
  25. const CGAL::Plane_3<CGAL::Epeck> & P,
  26. const Eigen::PlainObjectBase<DerivedV> & V,
  27. Eigen::Matrix<CGAL::Epeck::FT,8,3> & BV,
  28. Eigen::Matrix<int,12,3> & BF);
  29. // Inputs:
  30. // p 3d point on plane
  31. // n 3d vector of normal of plane pointing away from inside
  32. // V #V by 3 list of vertex positions
  33. // Outputs:
  34. // BV #BV by 3 list of box vertex positions
  35. // BF #BF b3 list of box triangle indices into BV
  36. template <typename Derivedp, typename Derivedn, typename DerivedV>
  37. IGL_INLINE void half_space_box(
  38. const Eigen::PlainObjectBase<Derivedp> & p,
  39. const Eigen::PlainObjectBase<Derivedn> & n,
  40. const Eigen::PlainObjectBase<DerivedV> & V,
  41. Eigen::Matrix<CGAL::Epeck::FT,8,3> & BV,
  42. Eigen::Matrix<int,12,3> & BF);
  43. // Inputs:
  44. // equ plane equation: a*x+b*y+c*z + d = 0
  45. // V #V by 3 list of vertex positions
  46. // Outputs:
  47. // BV #BV by 3 list of box vertex positions
  48. // BF #BF b3 list of box triangle indices into BV
  49. template <typename Derivedequ, typename DerivedV>
  50. IGL_INLINE void half_space_box(
  51. const Eigen::PlainObjectBase<Derivedequ> & equ,
  52. const Eigen::PlainObjectBase<DerivedV> & V,
  53. Eigen::Matrix<CGAL::Epeck::FT,8,3> & BV,
  54. Eigen::Matrix<int,12,3> & BF);
  55. }
  56. }
  57. }
  58. #ifndef IGL_STATIC_LIBRARY
  59. # include "half_space_box.cpp"
  60. #endif
  61. #endif