mesh_boolean.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
  4. // Qingnan Zhou <qnzhou@gmail.com>
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla Public License
  7. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  8. // obtain one at http://mozilla.org/MPL/2.0/.
  9. //
  10. #ifndef IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_H
  11. #define IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_H
  12. #include "../../igl_inline.h"
  13. #include "MeshBooleanType.h"
  14. #include <Eigen/Core>
  15. #include <functional>
  16. namespace igl
  17. {
  18. namespace copyleft
  19. {
  20. namespace boolean
  21. {
  22. template <
  23. typename DerivedVA,
  24. typename DerivedFA,
  25. typename DerivedVB,
  26. typename DerivedFB,
  27. typename WindingNumberOp,
  28. typename IsInsideFunc,
  29. typename ResolveFunc,
  30. typename DerivedVC,
  31. typename DerivedFC,
  32. typename DerivedJ>
  33. IGL_INLINE void per_face_winding_number_binary_operation(
  34. const Eigen::PlainObjectBase<DerivedVA> & VA,
  35. const Eigen::PlainObjectBase<DerivedFA> & FA,
  36. const Eigen::PlainObjectBase<DerivedVB> & VB,
  37. const Eigen::PlainObjectBase<DerivedFB> & FB,
  38. const WindingNumberOp& wind_num_op,
  39. const IsInsideFunc& is_inside,
  40. const ResolveFunc& resolve_fun,
  41. Eigen::PlainObjectBase<DerivedVC > & VC,
  42. Eigen::PlainObjectBase<DerivedFC > & FC,
  43. Eigen::PlainObjectBase<DerivedJ > & J);
  44. // MESH_BOOLEAN Compute boolean csg operations on "solid",
  45. // consistently
  46. // oriented meshes.
  47. //
  48. // Inputs:
  49. // VA #VA by 3 list of vertex positions of first mesh
  50. // FA #FA by 3 list of triangle indices into VA
  51. // VB #VB by 3 list of vertex positions of second mesh
  52. // FB #FB by 3 list of triangle indices into VB
  53. // type type of boolean operation
  54. // resolve_fun function handle for computing resolve of a
  55. // self-intersections of a mesh and outputting the new mesh.
  56. // Outputs:
  57. // VC #VC by 3 list of vertex positions of boolean result mesh
  58. // FC #FC by 3 list of triangle indices into VC
  59. // J #FC list of indices into [FA;FB] revealing "birth" facet
  60. //
  61. // See also: mesh_boolean_cork, intersect_other,
  62. // remesh_self_intersections
  63. //
  64. template <
  65. typename DerivedVA,
  66. typename DerivedFA,
  67. typename DerivedVB,
  68. typename DerivedFB,
  69. typename ResolveFunc,
  70. typename DerivedVC,
  71. typename DerivedFC,
  72. typename DerivedJ>
  73. IGL_INLINE void mesh_boolean(
  74. const Eigen::PlainObjectBase<DerivedVA > & VA,
  75. const Eigen::PlainObjectBase<DerivedFA > & FA,
  76. const Eigen::PlainObjectBase<DerivedVB > & VB,
  77. const Eigen::PlainObjectBase<DerivedFB > & FB,
  78. const MeshBooleanType & type,
  79. const ResolveFunc& resolve_func,
  80. Eigen::PlainObjectBase<DerivedVC > & VC,
  81. Eigen::PlainObjectBase<DerivedFC > & FC,
  82. Eigen::PlainObjectBase<DerivedJ > & J);
  83. template <
  84. typename DerivedVA,
  85. typename DerivedFA,
  86. typename DerivedVB,
  87. typename DerivedFB,
  88. typename DerivedVC,
  89. typename DerivedFC,
  90. typename DerivedJ>
  91. IGL_INLINE void mesh_boolean(
  92. const Eigen::PlainObjectBase<DerivedVA > & VA,
  93. const Eigen::PlainObjectBase<DerivedFA > & FA,
  94. const Eigen::PlainObjectBase<DerivedVB > & VB,
  95. const Eigen::PlainObjectBase<DerivedFB > & FB,
  96. const MeshBooleanType & type,
  97. Eigen::PlainObjectBase<DerivedVC > & VC,
  98. Eigen::PlainObjectBase<DerivedFC > & FC,
  99. Eigen::PlainObjectBase<DerivedJ > & J);
  100. template <
  101. typename DerivedVA,
  102. typename DerivedFA,
  103. typename DerivedVB,
  104. typename DerivedFB,
  105. typename DerivedVC,
  106. typename DerivedFC>
  107. IGL_INLINE void mesh_boolean(
  108. const Eigen::PlainObjectBase<DerivedVA > & VA,
  109. const Eigen::PlainObjectBase<DerivedFA > & FA,
  110. const Eigen::PlainObjectBase<DerivedVB > & VB,
  111. const Eigen::PlainObjectBase<DerivedFB > & FB,
  112. const MeshBooleanType & type,
  113. Eigen::PlainObjectBase<DerivedVC > & VC,
  114. Eigen::PlainObjectBase<DerivedFC > & FC);
  115. }
  116. }
  117. }
  118. #ifndef IGL_STATIC_LIBRARY
  119. # include "mesh_boolean.cpp"
  120. #endif
  121. #endif