minkowski_sum.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Alec Jacobson <[email protected]>
  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. /// @param[in] VA #VA by 3 list of mesh vertices in 3D
  22. /// @param[in] FA #FA by 3 list of triangle indices into VA
  23. /// @param[in] VB #VB by 3 list of mesh vertices in 3D
  24. /// @param[in] FB #FB by ss list of simplex indices into VB, ss<=3
  25. /// @param[in] resolve_overlaps whether or not to resolve self-union. If false
  26. /// then result may contain self-intersections if input mesh is
  27. /// non-convex.
  28. /// @param[out] W #W by 3 list of mesh vertices in 3D
  29. /// @param[out] G #G by 3 list of triangle indices into W
  30. /// @param[out] J #G by 2 list of indices into
  31. ///
  32. template <
  33. typename DerivedVA,
  34. typename DerivedFA,
  35. typename DerivedVB,
  36. typename DerivedFB,
  37. typename DerivedW,
  38. typename DerivedG,
  39. typename DerivedJ>
  40. IGL_INLINE void minkowski_sum(
  41. const Eigen::MatrixBase<DerivedVA> & VA,
  42. const Eigen::MatrixBase<DerivedFA> & FA,
  43. const Eigen::MatrixBase<DerivedVB> & VB,
  44. const Eigen::MatrixBase<DerivedFB> & FB,
  45. const bool resolve_overlaps,
  46. Eigen::PlainObjectBase<DerivedW> & W,
  47. Eigen::PlainObjectBase<DerivedG> & G,
  48. Eigen::PlainObjectBase<DerivedJ> & J);
  49. /// \overload
  50. /// \brief Compute the Minkowski sum of a closed triangle mesh (V,F) and a
  51. /// segment [s,d] in 3D.
  52. ///
  53. /// @param[in] s segment source endpoint in 3D
  54. /// @param[in] d segment source endpoint in 3D
  55. template <
  56. typename DerivedVA,
  57. typename DerivedFA,
  58. typename sType, int sCols, int sOptions,
  59. typename dType, int dCols, int dOptions,
  60. typename DerivedW,
  61. typename DerivedG,
  62. typename DerivedJ>
  63. IGL_INLINE void minkowski_sum(
  64. const Eigen::MatrixBase<DerivedVA> & VA,
  65. const Eigen::MatrixBase<DerivedFA> & FA,
  66. const Eigen::Matrix<sType,1,sCols,sOptions> & s,
  67. const Eigen::Matrix<dType,1,dCols,dOptions> & d,
  68. const bool resolve_overlaps,
  69. Eigen::PlainObjectBase<DerivedW> & W,
  70. Eigen::PlainObjectBase<DerivedG> & G,
  71. Eigen::PlainObjectBase<DerivedJ> & J);
  72. /// \overload
  73. template <
  74. typename DerivedVA,
  75. typename DerivedFA,
  76. typename sType, int sCols, int sOptions,
  77. typename dType, int dCols, int dOptions,
  78. typename DerivedW,
  79. typename DerivedG,
  80. typename DerivedJ>
  81. IGL_INLINE void minkowski_sum(
  82. const Eigen::MatrixBase<DerivedVA> & VA,
  83. const Eigen::MatrixBase<DerivedFA> & FA,
  84. const Eigen::Matrix<sType,1,sCols,sOptions> & s,
  85. const Eigen::Matrix<dType,1,dCols,dOptions> & d,
  86. Eigen::PlainObjectBase<DerivedW> & W,
  87. Eigen::PlainObjectBase<DerivedG> & G,
  88. Eigen::PlainObjectBase<DerivedJ> & J);
  89. }
  90. }
  91. }
  92. #ifndef IGL_STATIC_LIBRARY
  93. # include "minkowski_sum.cpp"
  94. #endif
  95. #endif