adjacency_matrix.h 1.1 KB

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