mesh_boolean.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef MESH_BOOLEAN_H
  2. #define MESH_BOOLEAN_H
  3. #include <igl/igl_inline.h>
  4. #include "MeshBooleanType.h"
  5. #include <Eigen/Core>
  6. #include <functional>
  7. namespace igl
  8. {
  9. namespace boolean
  10. {
  11. // MESH_BOOLEAN Compute boolean csg operations on "solid", consistently
  12. // oriented meshes.
  13. //
  14. // Inputs:
  15. // V #V by 3 list of vertex positions of first mesh
  16. // F #F by 3 list of triangle indices into V
  17. // U #U by 3 list of vertex positions of second mesh
  18. // G #G by 3 list of triangle indices into U
  19. // type type of boolean operation
  20. // Outputs:
  21. // W #W by 3 list of vertex positions of boolean result mesh
  22. // H #H by 3 list of triangle indices into W
  23. // J #H list of indices into [FA;FB] revealing "birth" facet
  24. //
  25. // See also: self_intersect
  26. //
  27. template <
  28. typename DerivedVA,
  29. typename DerivedFA,
  30. typename DerivedVB,
  31. typename DerivedFB,
  32. typename DerivedVC,
  33. typename DerivedFC,
  34. typename DerivedJ>
  35. IGL_INLINE void mesh_boolean(
  36. const Eigen::PlainObjectBase<DerivedVA > & VA,
  37. const Eigen::PlainObjectBase<DerivedFA > & FA,
  38. const Eigen::PlainObjectBase<DerivedVB > & VB,
  39. const Eigen::PlainObjectBase<DerivedFB > & FB,
  40. const MeshBooleanType & type,
  41. Eigen::PlainObjectBase<DerivedVC > & VC,
  42. Eigen::PlainObjectBase<DerivedFC > & FC,
  43. Eigen::PlainObjectBase<DerivedJ > & J);
  44. template <
  45. typename DerivedVA,
  46. typename DerivedFA,
  47. typename DerivedVB,
  48. typename DerivedFB,
  49. typename DerivedVC,
  50. typename DerivedFC>
  51. IGL_INLINE void mesh_boolean(
  52. const Eigen::PlainObjectBase<DerivedVA > & VA,
  53. const Eigen::PlainObjectBase<DerivedFA > & FA,
  54. const Eigen::PlainObjectBase<DerivedVB > & VB,
  55. const Eigen::PlainObjectBase<DerivedFB > & FB,
  56. const MeshBooleanType & type,
  57. Eigen::PlainObjectBase<DerivedVC > & VC,
  58. Eigen::PlainObjectBase<DerivedFC > & FC);
  59. // Inputs:
  60. // resolve_fun function handle for computing resolve of a
  61. // self-intersections of a mesh and outputting the new mesh.
  62. template <
  63. typename DerivedVA,
  64. typename DerivedFA,
  65. typename DerivedVB,
  66. typename DerivedFB,
  67. typename DerivedVC,
  68. typename DerivedFC,
  69. typename DerivedJ>
  70. IGL_INLINE void mesh_boolean(
  71. const Eigen::PlainObjectBase<DerivedVA > & VA,
  72. const Eigen::PlainObjectBase<DerivedFA > & FA,
  73. const Eigen::PlainObjectBase<DerivedVB > & VB,
  74. const Eigen::PlainObjectBase<DerivedFB > & FB,
  75. const MeshBooleanType & type,
  76. const std::function<void(
  77. const Eigen::Matrix<
  78. typename DerivedVC::Scalar,Eigen::Dynamic,3> &,
  79. const Eigen::Matrix<
  80. typename DerivedFC::Scalar,Eigen::Dynamic,3> &,
  81. Eigen::Matrix<
  82. typename DerivedVC::Scalar,Eigen::Dynamic,3> &,
  83. Eigen::Matrix<
  84. typename DerivedFC::Scalar,Eigen::Dynamic,3> &,
  85. Eigen::Matrix<
  86. typename DerivedJ::Scalar,Eigen::Dynamic,1>&)>
  87. & resolve_fun,
  88. Eigen::PlainObjectBase<DerivedVC > & VC,
  89. Eigen::PlainObjectBase<DerivedFC > & FC,
  90. Eigen::PlainObjectBase<DerivedJ > & J);
  91. }
  92. }
  93. #ifndef IGL_STATIC_LIBRARY
  94. # include "mesh_boolean.cpp"
  95. #endif
  96. #endif