mesh_boolean.h 3.4 KB

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