mesh_boolean.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. // MESH_BOOLEAN Compute boolean csg operations on "solid", consistently
  23. // oriented meshes.
  24. //
  25. // Inputs:
  26. // VA #VA by 3 list of vertex positions of first mesh
  27. // FA #FA by 3 list of triangle indices into VA
  28. // VB #VB by 3 list of vertex positions of second mesh
  29. // FB #FB by 3 list of triangle indices into VB
  30. // wind_num_op function handle for filtering winding numbers from
  31. // tuples of integer values to [0,1] outside/inside values
  32. // keep function handle for determining if a patch should be "kept"
  33. // in the output based on the winding number on either side
  34. // resolve_fun function handle for computing resolve of a
  35. // self-intersections of a mesh and outputting the new mesh.
  36. // Outputs:
  37. // VC #VC by 3 list of vertex positions of boolean result mesh
  38. // FC #FC by 3 list of triangle indices into VC
  39. // J #FC list of indices into [FA;FB] revealing "birth" facet
  40. //
  41. // See also: mesh_boolean_cork, intersect_other,
  42. // remesh_self_intersections
  43. template <
  44. typename DerivedVA,
  45. typename DerivedFA,
  46. typename DerivedVB,
  47. typename DerivedFB,
  48. typename WindingNumberOp,
  49. typename KeepFunc,
  50. typename ResolveFunc,
  51. typename DerivedVC,
  52. typename DerivedFC,
  53. typename DerivedJ>
  54. IGL_INLINE void mesh_boolean(
  55. const Eigen::PlainObjectBase<DerivedVA> & VA,
  56. const Eigen::PlainObjectBase<DerivedFA> & FA,
  57. const Eigen::PlainObjectBase<DerivedVB> & VB,
  58. const Eigen::PlainObjectBase<DerivedFB> & FB,
  59. const WindingNumberOp& wind_num_op,
  60. const KeepFunc& keep,
  61. const ResolveFunc& resolve_fun,
  62. Eigen::PlainObjectBase<DerivedVC > & VC,
  63. Eigen::PlainObjectBase<DerivedFC > & FC,
  64. Eigen::PlainObjectBase<DerivedJ > & J);
  65. // Inputs:
  66. // VA #VA by 3 list of vertex positions of first mesh
  67. // FA #FA by 3 list of triangle indices into VA
  68. // VB #VB by 3 list of vertex positions of second mesh
  69. // FB #FB by 3 list of triangle indices into VB
  70. // type type of boolean operation
  71. // resolve_fun function handle for computing resolve of a
  72. // self-intersections of a mesh and outputting the new mesh.
  73. // Outputs:
  74. // VC #VC by 3 list of vertex positions of boolean result mesh
  75. // FC #FC by 3 list of triangle indices into VC
  76. // J #FC list of indices into [FA;FB] revealing "birth" facet
  77. //
  78. // See also: mesh_boolean_cork, intersect_other,
  79. // remesh_self_intersections
  80. template <
  81. typename DerivedVA,
  82. typename DerivedFA,
  83. typename DerivedVB,
  84. typename DerivedFB,
  85. typename ResolveFunc,
  86. typename DerivedVC,
  87. typename DerivedFC,
  88. typename DerivedJ>
  89. IGL_INLINE void mesh_boolean(
  90. const Eigen::PlainObjectBase<DerivedVA > & VA,
  91. const Eigen::PlainObjectBase<DerivedFA > & FA,
  92. const Eigen::PlainObjectBase<DerivedVB > & VB,
  93. const Eigen::PlainObjectBase<DerivedFB > & FB,
  94. const MeshBooleanType & type,
  95. const ResolveFunc& resolve_func,
  96. Eigen::PlainObjectBase<DerivedVC > & VC,
  97. Eigen::PlainObjectBase<DerivedFC > & FC,
  98. Eigen::PlainObjectBase<DerivedJ > & J);
  99. // Inputs:
  100. // VA #VA by 3 list of vertex positions of first mesh
  101. // FA #FA by 3 list of triangle indices into VA
  102. // VB #VB by 3 list of vertex positions of second mesh
  103. // FB #FB by 3 list of triangle indices into VB
  104. // type type of boolean operation
  105. // Outputs:
  106. // VC #VC by 3 list of vertex positions of boolean result mesh
  107. // FC #FC by 3 list of triangle indices into VC
  108. // J #FC list of indices into [FA;FB] revealing "birth" facet
  109. //
  110. // See also: mesh_boolean_cork, intersect_other,
  111. // remesh_self_intersections
  112. template <
  113. typename DerivedVA,
  114. typename DerivedFA,
  115. typename DerivedVB,
  116. typename DerivedFB,
  117. typename DerivedVC,
  118. typename DerivedFC,
  119. typename DerivedJ>
  120. IGL_INLINE void mesh_boolean(
  121. const Eigen::PlainObjectBase<DerivedVA > & VA,
  122. const Eigen::PlainObjectBase<DerivedFA > & FA,
  123. const Eigen::PlainObjectBase<DerivedVB > & VB,
  124. const Eigen::PlainObjectBase<DerivedFB > & FB,
  125. const MeshBooleanType & type,
  126. Eigen::PlainObjectBase<DerivedVC > & VC,
  127. Eigen::PlainObjectBase<DerivedFC > & FC,
  128. Eigen::PlainObjectBase<DerivedJ > & J);
  129. // Inputs:
  130. // VA #VA by 3 list of vertex positions of first mesh
  131. // FA #FA by 3 list of triangle indices into VA
  132. // VB #VB by 3 list of vertex positions of second mesh
  133. // FB #FB by 3 list of triangle indices into VB
  134. // type type of boolean operation
  135. // Outputs:
  136. // VC #VC by 3 list of vertex positions of boolean result mesh
  137. // FC #FC by 3 list of triangle indices into VC
  138. template <
  139. typename DerivedVA,
  140. typename DerivedFA,
  141. typename DerivedVB,
  142. typename DerivedFB,
  143. typename DerivedVC,
  144. typename DerivedFC>
  145. IGL_INLINE void mesh_boolean(
  146. const Eigen::PlainObjectBase<DerivedVA > & VA,
  147. const Eigen::PlainObjectBase<DerivedFA > & FA,
  148. const Eigen::PlainObjectBase<DerivedVB > & VB,
  149. const Eigen::PlainObjectBase<DerivedFB > & FB,
  150. const MeshBooleanType & type,
  151. Eigen::PlainObjectBase<DerivedVC > & VC,
  152. Eigen::PlainObjectBase<DerivedFC > & FC);
  153. }
  154. }
  155. }
  156. #ifndef IGL_STATIC_LIBRARY
  157. # include "mesh_boolean.cpp"
  158. #endif
  159. #endif