mesh_boolean.h 4.0 KB

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