mesh_boolean.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. //
  44. template <
  45. typename DerivedVA,
  46. typename DerivedFA,
  47. typename DerivedVB,
  48. typename DerivedFB,
  49. typename WindingNumberOp,
  50. typename KeepFunc,
  51. typename ResolveFunc,
  52. typename DerivedVC,
  53. typename DerivedFC,
  54. typename DerivedJ>
  55. IGL_INLINE void mesh_boolean(
  56. const Eigen::PlainObjectBase<DerivedVA> & VA,
  57. const Eigen::PlainObjectBase<DerivedFA> & FA,
  58. const Eigen::PlainObjectBase<DerivedVB> & VB,
  59. const Eigen::PlainObjectBase<DerivedFB> & FB,
  60. const WindingNumberOp& wind_num_op,
  61. const KeepFunc& keep,
  62. const ResolveFunc& resolve_fun,
  63. Eigen::PlainObjectBase<DerivedVC > & VC,
  64. Eigen::PlainObjectBase<DerivedFC > & FC,
  65. Eigen::PlainObjectBase<DerivedJ > & J);
  66. // Inputs:
  67. // VA #VA by 3 list of vertex positions of first mesh
  68. // FA #FA by 3 list of triangle indices into VA
  69. // VB #VB by 3 list of vertex positions of second mesh
  70. // FB #FB by 3 list of triangle indices into VB
  71. // type type of boolean operation
  72. // resolve_fun function handle for computing resolve of a
  73. // self-intersections of a mesh and outputting the new mesh.
  74. // Outputs:
  75. // VC #VC by 3 list of vertex positions of boolean result mesh
  76. // FC #FC by 3 list of triangle indices into VC
  77. // J #FC list of indices into [FA;FB] revealing "birth" facet
  78. //
  79. // See also: mesh_boolean_cork, intersect_other,
  80. // remesh_self_intersections
  81. template <
  82. typename DerivedVA,
  83. typename DerivedFA,
  84. typename DerivedVB,
  85. typename DerivedFB,
  86. typename ResolveFunc,
  87. typename DerivedVC,
  88. typename DerivedFC,
  89. typename DerivedJ>
  90. IGL_INLINE void mesh_boolean(
  91. const Eigen::PlainObjectBase<DerivedVA > & VA,
  92. const Eigen::PlainObjectBase<DerivedFA > & FA,
  93. const Eigen::PlainObjectBase<DerivedVB > & VB,
  94. const Eigen::PlainObjectBase<DerivedFB > & FB,
  95. const MeshBooleanType & type,
  96. const ResolveFunc& resolve_func,
  97. Eigen::PlainObjectBase<DerivedVC > & VC,
  98. Eigen::PlainObjectBase<DerivedFC > & FC,
  99. Eigen::PlainObjectBase<DerivedJ > & J);
  100. // Inputs:
  101. // VA #VA by 3 list of vertex positions of first mesh
  102. // FA #FA by 3 list of triangle indices into VA
  103. // VB #VB by 3 list of vertex positions of second mesh
  104. // FB #FB by 3 list of triangle indices into VB
  105. // type type of boolean operation
  106. // Outputs:
  107. // VC #VC by 3 list of vertex positions of boolean result mesh
  108. // FC #FC by 3 list of triangle indices into VC
  109. // J #FC list of indices into [FA;FB] revealing "birth" facet
  110. //
  111. // See also: mesh_boolean_cork, intersect_other,
  112. // remesh_self_intersections
  113. template <
  114. typename DerivedVA,
  115. typename DerivedFA,
  116. typename DerivedVB,
  117. typename DerivedFB,
  118. typename DerivedVC,
  119. typename DerivedFC,
  120. typename DerivedJ>
  121. IGL_INLINE void mesh_boolean(
  122. const Eigen::PlainObjectBase<DerivedVA > & VA,
  123. const Eigen::PlainObjectBase<DerivedFA > & FA,
  124. const Eigen::PlainObjectBase<DerivedVB > & VB,
  125. const Eigen::PlainObjectBase<DerivedFB > & FB,
  126. const MeshBooleanType & type,
  127. Eigen::PlainObjectBase<DerivedVC > & VC,
  128. Eigen::PlainObjectBase<DerivedFC > & FC,
  129. Eigen::PlainObjectBase<DerivedJ > & J);
  130. // Inputs:
  131. // VA #VA by 3 list of vertex positions of first mesh
  132. // FA #FA by 3 list of triangle indices into VA
  133. // VB #VB by 3 list of vertex positions of second mesh
  134. // FB #FB by 3 list of triangle indices into VB
  135. // type type of boolean operation
  136. // Outputs:
  137. // VC #VC by 3 list of vertex positions of boolean result mesh
  138. // FC #FC by 3 list of triangle indices into VC
  139. template <
  140. typename DerivedVA,
  141. typename DerivedFA,
  142. typename DerivedVB,
  143. typename DerivedFB,
  144. typename DerivedVC,
  145. typename DerivedFC>
  146. IGL_INLINE void mesh_boolean(
  147. const Eigen::PlainObjectBase<DerivedVA > & VA,
  148. const Eigen::PlainObjectBase<DerivedFA > & FA,
  149. const Eigen::PlainObjectBase<DerivedVB > & VB,
  150. const Eigen::PlainObjectBase<DerivedFB > & FB,
  151. const MeshBooleanType & type,
  152. Eigen::PlainObjectBase<DerivedVC > & VC,
  153. Eigen::PlainObjectBase<DerivedFC > & FC);
  154. }
  155. }
  156. }
  157. #ifndef IGL_STATIC_LIBRARY
  158. # include "mesh_boolean.cpp"
  159. #endif
  160. #endif