harmonic.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_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. //
  18. // Inputs:
  19. // V #V by dim vertex positions
  20. // F #F by simplex-size list of element indices
  21. // b #b boundary indices into V
  22. // bc #b by #W list of boundary values
  23. // k power of harmonic operation (1: harmonic, 2: biharmonic, etc)
  24. // Outputs:
  25. // W #V by #W list of weights
  26. //
  27. template <
  28. typename DerivedV,
  29. typename DerivedF,
  30. typename Derivedb,
  31. typename Derivedbc,
  32. typename DerivedW>
  33. IGL_INLINE bool harmonic(
  34. const Eigen::PlainObjectBase<DerivedV> & V,
  35. const Eigen::PlainObjectBase<DerivedF> & F,
  36. const Eigen::PlainObjectBase<Derivedb> & b,
  37. const Eigen::PlainObjectBase<Derivedbc> & bc,
  38. const int k,
  39. Eigen::PlainObjectBase<DerivedW> & W);
  40. // Compute harmonic map using uniform laplacian operator
  41. //
  42. // Inputs:
  43. // F #F by simplex-size list of element indices
  44. // b #b boundary indices into V
  45. // bc #b by #W list of boundary values
  46. // k power of harmonic operation (1: harmonic, 2: biharmonic, etc)
  47. // Outputs:
  48. // W #V by #W list of weights
  49. //
  50. template <
  51. typename DerivedF,
  52. typename Derivedb,
  53. typename Derivedbc,
  54. typename DerivedW>
  55. IGL_INLINE bool harmonic(
  56. const Eigen::PlainObjectBase<DerivedF> & F,
  57. const Eigen::PlainObjectBase<Derivedb> & b,
  58. const Eigen::PlainObjectBase<Derivedbc> & bc,
  59. const int k,
  60. Eigen::PlainObjectBase<DerivedW> & W);
  61. // Compute a harmonic map using a given Laplacian and mass matrix
  62. //
  63. // Inputs:
  64. // L #V by #V discrete (integrated) Laplacian
  65. // M #V by #V mass matrix
  66. // b #b boundary indices into V
  67. // bc #b by #W list of boundary values
  68. // k power of harmonic operation (1: harmonic, 2: biharmonic, etc)
  69. // Outputs:
  70. // W #V by #V list of weights
  71. template <
  72. typename DerivedL,
  73. typename DerivedM,
  74. typename Derivedb,
  75. typename Derivedbc,
  76. typename DerivedW>
  77. IGL_INLINE bool harmonic(
  78. const Eigen::SparseMatrix<DerivedL> & L,
  79. const Eigen::SparseMatrix<DerivedM> & M,
  80. const Eigen::PlainObjectBase<Derivedb> & b,
  81. const Eigen::PlainObjectBase<Derivedbc> & bc,
  82. const int k,
  83. Eigen::PlainObjectBase<DerivedW> & W);
  84. };
  85. #ifndef IGL_STATIC_LIBRARY
  86. #include "harmonic.cpp"
  87. #endif
  88. #endif