minkowski_sum.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 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_COPYLEFT_CGAL_MINKOWSKI_SUM_H
  9. #define IGL_COPYLEFT_CGAL_MINKOWSKI_SUM_H
  10. #include "../../igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. namespace copyleft
  15. {
  16. namespace cgal
  17. {
  18. // Compute the Minkowski sum of a closed triangle mesh (V,F) and a
  19. // set of simplices in 3D.
  20. //
  21. // Inputs:
  22. // VA #VA by 3 list of mesh vertices in 3D
  23. // FA #FA by 3 list of triangle indices into VA
  24. // VB #VB by 3 list of mesh vertices in 3D
  25. // FB #FB by ss list of simplex indices into VB, ss<=3
  26. // resolve_overlaps whether or not to resolve self-union. If false
  27. // then result may contain self-intersections if input mesh is
  28. // non-convex.
  29. // Outputs:
  30. // W #W by 3 list of mesh vertices in 3D
  31. // G #G by 3 list of triangle indices into W
  32. // J #G by 2 list of indices into
  33. //
  34. template <
  35. typename DerivedVA,
  36. typename DerivedFA,
  37. typename DerivedVB,
  38. typename DerivedFB,
  39. typename DerivedW,
  40. typename DerivedG,
  41. typename DerivedJ>
  42. IGL_INLINE void minkowski_sum(
  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 bool resolve_overlaps,
  48. Eigen::PlainObjectBase<DerivedW> & W,
  49. Eigen::PlainObjectBase<DerivedG> & G,
  50. Eigen::PlainObjectBase<DerivedJ> & J);
  51. // Compute the Minkowski sum of a closed triangle mesh (V,F) and a
  52. // segment [s,d] in 3D.
  53. //
  54. // Inputs:
  55. // VA #VA by 3 list of mesh vertices in 3D
  56. // FA #FA by 3 list of triangle indices into VA
  57. // s segment source endpoint in 3D
  58. // d segment source endpoint in 3D
  59. // resolve_overlaps whether or not to resolve self-union. If false
  60. // then result may contain self-intersections if input mesh is
  61. // non-convex.
  62. // Outputs:
  63. // W #W by 3 list of mesh vertices in 3D
  64. // G #G by 3 list of triangle indices into W
  65. // J #G list of indices into [F;#V+F;[s d]] of birth parents
  66. //
  67. template <
  68. typename DerivedVA,
  69. typename DerivedFA,
  70. typename sType, int sCols, int sOptions,
  71. typename dType, int dCols, int dOptions,
  72. typename DerivedW,
  73. typename DerivedG,
  74. typename DerivedJ>
  75. IGL_INLINE void minkowski_sum(
  76. const Eigen::PlainObjectBase<DerivedVA> & VA,
  77. const Eigen::PlainObjectBase<DerivedFA> & FA,
  78. const Eigen::Matrix<sType,1,sCols,sOptions> & s,
  79. const Eigen::Matrix<dType,1,dCols,dOptions> & d,
  80. const bool resolve_overlaps,
  81. Eigen::PlainObjectBase<DerivedW> & W,
  82. Eigen::PlainObjectBase<DerivedG> & G,
  83. Eigen::PlainObjectBase<DerivedJ> & J);
  84. template <
  85. typename DerivedVA,
  86. typename DerivedFA,
  87. typename sType, int sCols, int sOptions,
  88. typename dType, int dCols, int dOptions,
  89. typename DerivedW,
  90. typename DerivedG,
  91. typename DerivedJ>
  92. IGL_INLINE void minkowski_sum(
  93. const Eigen::PlainObjectBase<DerivedVA> & VA,
  94. const Eigen::PlainObjectBase<DerivedFA> & FA,
  95. const Eigen::Matrix<sType,1,sCols,sOptions> & s,
  96. const Eigen::Matrix<dType,1,dCols,dOptions> & d,
  97. Eigen::PlainObjectBase<DerivedW> & W,
  98. Eigen::PlainObjectBase<DerivedG> & G,
  99. Eigen::PlainObjectBase<DerivedJ> & J);
  100. }
  101. }
  102. }
  103. #ifndef IGL_STATIC_LIBRARY
  104. # include "minkowski_sum.cpp"
  105. #endif
  106. #endif