mesh_boolean.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. // V #V by 3 list of vertex positions of first mesh
  23. // F #F by 3 list of triangle indices into V
  24. // U #U by 3 list of vertex positions of second mesh
  25. // G #G by 3 list of triangle indices into U
  26. // type type of boolean operation
  27. // Outputs:
  28. // W #W by 3 list of vertex positions of boolean result mesh
  29. // H #H by 3 list of triangle indices into W
  30. // J #H list of indices into [FA;FB] revealing "birth" facet
  31. //
  32. // See also: self_intersect
  33. //
  34. template <
  35. typename DerivedVA,
  36. typename DerivedFA,
  37. typename DerivedVB,
  38. typename DerivedFB,
  39. typename DerivedVC,
  40. typename DerivedFC,
  41. typename DerivedJ>
  42. IGL_INLINE void mesh_boolean(
  43. const Eigen::PlainObjectBase<DerivedVA > & VA,
  44. const Eigen::PlainObjectBase<DerivedFA > & FA,
  45. const Eigen::PlainObjectBase<DerivedVB > & VB,
  46. const Eigen::PlainObjectBase<DerivedFB > & FB,
  47. const MeshBooleanType & type,
  48. Eigen::PlainObjectBase<DerivedVC > & VC,
  49. Eigen::PlainObjectBase<DerivedFC > & FC,
  50. Eigen::PlainObjectBase<DerivedJ > & J);
  51. template <
  52. typename DerivedVA,
  53. typename DerivedFA,
  54. typename DerivedVB,
  55. typename DerivedFB,
  56. typename DerivedVC,
  57. typename DerivedFC>
  58. IGL_INLINE void mesh_boolean(
  59. const Eigen::PlainObjectBase<DerivedVA > & VA,
  60. const Eigen::PlainObjectBase<DerivedFA > & FA,
  61. const Eigen::PlainObjectBase<DerivedVB > & VB,
  62. const Eigen::PlainObjectBase<DerivedFB > & FB,
  63. const MeshBooleanType & type,
  64. Eigen::PlainObjectBase<DerivedVC > & VC,
  65. Eigen::PlainObjectBase<DerivedFC > & FC);
  66. // Inputs:
  67. // resolve_fun function handle for computing resolve of a
  68. // self-intersections of a mesh and outputting the new mesh.
  69. template <
  70. typename DerivedVA,
  71. typename DerivedFA,
  72. typename DerivedVB,
  73. typename DerivedFB,
  74. typename DerivedVC,
  75. typename DerivedFC,
  76. typename DerivedJ>
  77. IGL_INLINE void mesh_boolean(
  78. const Eigen::PlainObjectBase<DerivedVA > & VA,
  79. const Eigen::PlainObjectBase<DerivedFA > & FA,
  80. const Eigen::PlainObjectBase<DerivedVB > & VB,
  81. const Eigen::PlainObjectBase<DerivedFB > & FB,
  82. const MeshBooleanType & type,
  83. const std::function<void(
  84. const Eigen::Matrix<
  85. typename DerivedVC::Scalar,Eigen::Dynamic,3> &,
  86. const Eigen::Matrix<
  87. typename DerivedFC::Scalar,Eigen::Dynamic,3> &,
  88. Eigen::Matrix<
  89. typename DerivedVC::Scalar,Eigen::Dynamic,3> &,
  90. Eigen::Matrix<
  91. typename DerivedFC::Scalar,Eigen::Dynamic,3> &,
  92. Eigen::Matrix<
  93. typename DerivedJ::Scalar,Eigen::Dynamic,1>&)>
  94. & resolve_fun,
  95. Eigen::PlainObjectBase<DerivedVC > & VC,
  96. Eigen::PlainObjectBase<DerivedFC > & FC,
  97. Eigen::PlainObjectBase<DerivedJ > & J);
  98. }
  99. }
  100. #ifndef IGL_STATIC_LIBRARY
  101. # include "mesh_boolean.cpp"
  102. #endif
  103. #endif