intersect_with_half_space.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef IGL_COPYLEFT_CGAL_INTERSECT_WITH_HALF_SPACE_H
  2. #define IGL_COPYLEFT_CGAL_INTERSECT_WITH_HALF_SPACE_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. // Intersect a PWN mesh with a half-space. Point on plane, normal pointing
  14. // outward.
  15. //
  16. // Inputs:
  17. // V #V by 3 list of mesh vertex positions
  18. // p 3d point on plane
  19. // n 3d vector of normal of plane pointing away from inside
  20. // Outputs:
  21. // VC #VC by 3 list of vertex positions of boolean result mesh
  22. // FC #FC by 3 list of triangle indices into VC
  23. // J #FC list of indices into [F;F.rows()+[1;2]] revealing "birth"
  24. // facet
  25. template <
  26. typename DerivedV,
  27. typename DerivedF,
  28. typename Derivedp,
  29. typename Derivedn,
  30. typename DerivedVC,
  31. typename DerivedFC,
  32. typename DerivedJ>
  33. IGL_INLINE bool intersect_with_half_space(
  34. const Eigen::PlainObjectBase<DerivedV > & V,
  35. const Eigen::PlainObjectBase<DerivedF > & F,
  36. const Eigen::PlainObjectBase<Derivedp > & p,
  37. const Eigen::PlainObjectBase<Derivedn > & n,
  38. Eigen::PlainObjectBase<DerivedVC > & VC,
  39. Eigen::PlainObjectBase<DerivedFC > & FC,
  40. Eigen::PlainObjectBase<DerivedJ > & J);
  41. // Intersect a PWN mesh with a half-space. Plane equation.
  42. //
  43. // Inputs:
  44. // V #V by 3 list of mesh vertex positions
  45. // equ plane equation: P(x,y,z) = a*x+b*y+c*z + d = 0, P(x,y,z) < 0 is
  46. // _inside_.
  47. // Outputs:
  48. // VC #VC by 3 list of vertex positions of boolean result mesh
  49. // FC #FC by 3 list of triangle indices into VC
  50. // J #FC list of indices into [F;F.rows()+[1;2]] revealing "birth" facet
  51. template <
  52. typename DerivedV,
  53. typename DerivedF,
  54. typename Derivedequ,
  55. typename DerivedVC,
  56. typename DerivedFC,
  57. typename DerivedJ>
  58. IGL_INLINE bool intersect_with_half_space(
  59. const Eigen::PlainObjectBase<DerivedV > & V,
  60. const Eigen::PlainObjectBase<DerivedF > & F,
  61. const Eigen::PlainObjectBase<Derivedequ > & equ,
  62. Eigen::PlainObjectBase<DerivedVC > & VC,
  63. Eigen::PlainObjectBase<DerivedFC > & FC,
  64. Eigen::PlainObjectBase<DerivedJ > & J);
  65. // Intersect a PWN mesh with a half-space. CGAL Plane.
  66. //
  67. // Inputs:
  68. // V #V by 3 list of mesh vertex positions
  69. // P plane
  70. // Outputs:
  71. // VC #VC by 3 list of vertex positions of boolean result mesh
  72. // FC #FC by 3 list of triangle indices into VC
  73. // J #FC list of indices into [F;F.rows()+[1;2]] revealing "birth" facet
  74. template <
  75. typename DerivedV,
  76. typename DerivedF,
  77. typename DerivedVC,
  78. typename DerivedFC,
  79. typename DerivedJ>
  80. IGL_INLINE bool intersect_with_half_space(
  81. const Eigen::PlainObjectBase<DerivedV > & V,
  82. const Eigen::PlainObjectBase<DerivedF > & F,
  83. const CGAL::Plane_3<CGAL::Epeck> & P,
  84. Eigen::PlainObjectBase<DerivedVC > & VC,
  85. Eigen::PlainObjectBase<DerivedFC > & FC,
  86. Eigen::PlainObjectBase<DerivedJ > & J);
  87. }
  88. }
  89. }
  90. #ifndef IGL_STATIC_LIBRARY
  91. # include "intersect_with_half_space.cpp"
  92. #endif
  93. #endif