harmonic.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_HARMONIC_H
  9. #define IGL_HARMONIC_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. /// Compute k-harmonic weight functions "coordinates".
  16. ///
  17. /// @param[in] V #V by dim vertex positions
  18. /// @param[in] F #F by simplex-size list of element indices
  19. /// @param[in] b #b boundary indices into V
  20. /// @param[in] bc #b by #W list of boundary values
  21. /// @param[in] k power of harmonic operation (1: harmonic, 2: biharmonic, etc)
  22. /// @param[out] W #V by #W list of weights
  23. ///
  24. template <
  25. typename DerivedV,
  26. typename DerivedF,
  27. typename Derivedb,
  28. typename Derivedbc,
  29. typename DerivedW>
  30. IGL_INLINE bool harmonic(
  31. const Eigen::MatrixBase<DerivedV> & V,
  32. const Eigen::MatrixBase<DerivedF> & F,
  33. const Eigen::MatrixBase<Derivedb> & b,
  34. const Eigen::MatrixBase<Derivedbc> & bc,
  35. const int k,
  36. Eigen::PlainObjectBase<DerivedW> & W);
  37. /// \overload
  38. /// \brief Compute harmonic map using uniform laplacian operator
  39. template <
  40. typename DerivedF,
  41. typename Derivedb,
  42. typename Derivedbc,
  43. typename DerivedW>
  44. IGL_INLINE bool harmonic(
  45. const Eigen::MatrixBase<DerivedF> & F,
  46. const Eigen::MatrixBase<Derivedb> & b,
  47. const Eigen::MatrixBase<Derivedbc> & bc,
  48. const int k,
  49. Eigen::PlainObjectBase<DerivedW> & W);
  50. /// \overload
  51. /// Compute a harmonic map using a given Laplacian and mass matrix
  52. ///
  53. /// @param[in] L #V by #V discrete (integrated) Laplacian
  54. /// @param[in] M #V by #V mass matrix
  55. template <
  56. typename DerivedL,
  57. typename DerivedM,
  58. typename Derivedb,
  59. typename Derivedbc,
  60. typename DerivedW>
  61. IGL_INLINE bool harmonic(
  62. const Eigen::SparseCompressedBase<DerivedL> & L,
  63. const Eigen::SparseCompressedBase<DerivedM> & M,
  64. const Eigen::MatrixBase<Derivedb> & b,
  65. const Eigen::MatrixBase<Derivedbc> & bc,
  66. const int k,
  67. Eigen::PlainObjectBase<DerivedW> & W);
  68. /// Build the discrete k-harmonic operator (computing integrated quantities).
  69. /// That is, if the k-harmonic PDE is Q x = 0, then this minimizes x' Q x
  70. ///
  71. /// @param[in] L #V by #V discrete (integrated) Laplacian
  72. /// @param[in] M #V by #V mass matrix
  73. /// @param[in] k power of harmonic operation (1: harmonic, 2: biharmonic, etc)
  74. /// @param[out] Q #V by #V discrete (integrated) k-Laplacian
  75. template <
  76. typename DerivedL,
  77. typename DerivedM,
  78. typename DerivedQ>
  79. IGL_INLINE void harmonic(
  80. const Eigen::SparseCompressedBase<DerivedL> & L,
  81. const Eigen::SparseCompressedBase<DerivedM> & M,
  82. const int k,
  83. DerivedQ & Q);
  84. /// \overload
  85. /// @param[in] V #V by dim vertex positions
  86. /// @param[in] F #F by simplex-size list of element indices
  87. template <
  88. typename DerivedV,
  89. typename DerivedF,
  90. typename DerivedQ>
  91. IGL_INLINE void harmonic(
  92. const Eigen::MatrixBase<DerivedV> & V,
  93. const Eigen::MatrixBase<DerivedF> & F,
  94. const int k,
  95. DerivedQ & Q);
  96. };
  97. #ifndef IGL_STATIC_LIBRARY
  98. #include "harmonic.cpp"
  99. #endif
  100. #endif