adjacency_matrix.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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_ADJACENCY_MATRIX_H
  9. #define IGL_ADJACENCY_MATRIX_H
  10. #include "igl_inline.h"
  11. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  12. #include <Eigen/Dense>
  13. #include <Eigen/Sparse>
  14. namespace igl
  15. {
  16. // Constructs the graph adjacency matrix of a given mesh (V,F)
  17. // Templates:
  18. // T should be a eigen sparse matrix primitive type like int or double
  19. // Inputs:
  20. // F #F by dim list of mesh simplices
  21. // Outputs:
  22. // A max(F) by max(F) cotangent matrix, each row i corresponding to V(i,:)
  23. //
  24. // Example:
  25. // // Mesh in (V,F)
  26. // Eigen::SparseMatrix<double> A;
  27. // adjacency_matrix(F,A);
  28. // // sum each row
  29. // SparseVector<double> Asum;
  30. // sum(A,1,Asum);
  31. // // Convert row sums into diagonal of sparse matrix
  32. // SparseMatrix<double> Adiag;
  33. // diag(Asum,Adiag);
  34. // // Build uniform laplacian
  35. // SparseMatrix<double> U;
  36. // U = A-Adiag;
  37. //
  38. // See also: edges, cotmatrix, diag
  39. template <typename DerivedF, typename T>
  40. IGL_INLINE void adjacency_matrix(
  41. const Eigen::PlainObjectBase<DerivedF> & F,
  42. Eigen::SparseMatrix<T>& A);
  43. }
  44. #ifndef IGL_STATIC_LIBRARY
  45. # include "adjacency_matrix.cpp"
  46. #endif
  47. #endif