massmatrix.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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_MASSMATRIX_H
  9. #define IGL_MASSMATRIX_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. /// Type of mass matrix
  16. enum MassMatrixType
  17. {
  18. /// Lumping area of each element to corner vertices in equal parts
  19. MASSMATRIX_TYPE_BARYCENTRIC = 0,
  20. /// Lumping area by Voronoi dual area (clamped to be positive according to
  21. /// Meyer et al. 2003)
  22. MASSMATRIX_TYPE_VORONOI = 1,
  23. /// Full (non-diagonal mass matrix) for piecewise linear functions
  24. MASSMATRIX_TYPE_FULL = 2,
  25. /// Use MASSMATRIX_TYPE_VORONOI for triangles and MASSMATRIX_TYPE_BARYCENTRIC
  26. /// for tetrahedra
  27. MASSMATRIX_TYPE_DEFAULT = 3,
  28. /// Total number of mass matrix types
  29. NUM_MASSMATRIX_TYPES = 4
  30. };
  31. /// Constructs the mass (area) matrix for a given mesh (V,F).
  32. ///
  33. /// @tparam DerivedV derived type of eigen matrix for V (e.g. derived from
  34. /// MatrixXd)
  35. /// @tparam DerivedF derived type of eigen matrix for F (e.g. derived from
  36. /// MatrixXi)
  37. /// @tparam Scalar scalar type for eigen sparse matrix (e.g. double)
  38. /// @param[in] V #V by dim list of mesh vertex positions
  39. /// @param[in] F #F by simplex_size list of mesh elements (triangles or tetrahedra)
  40. /// @param[in] type one of the following ints:
  41. /// MASSMATRIX_TYPE_BARYCENTRIC barycentric {default for tetrahedra}
  42. /// MASSMATRIX_TYPE_VORONOI voronoi-hybrid {default for triangles, not implemented for tetrahedra}
  43. /// MASSMATRIX_TYPE_FULL full
  44. /// @param[out] M #V by #V mass matrix
  45. ///
  46. /// \see cotmatrix
  47. ///
  48. template <typename DerivedV, typename DerivedF, typename Scalar>
  49. IGL_INLINE void massmatrix(
  50. const Eigen::MatrixBase<DerivedV> & V,
  51. const Eigen::MatrixBase<DerivedF> & F,
  52. const MassMatrixType type,
  53. Eigen::SparseMatrix<Scalar>& M);
  54. }
  55. #ifndef IGL_STATIC_LIBRARY
  56. # include "massmatrix.cpp"
  57. #endif
  58. #endif