adjacency_list.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef IGL_ADJACENCY_LIST_H
  2. #define IGL_ADJACENCY_LIST_H
  3. #include "igl_inline.h"
  4. #include <Eigen/Dense>
  5. #include <Eigen/Sparse>
  6. #include <vector>
  7. namespace igl
  8. {
  9. // Constructs the graph adjacency list 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. // sorted flag that indicates if the list should be sorted counter-clockwise
  15. // Outputs:
  16. // A vector<vector<T> > containing at row i the adjacent vertices of vertex i
  17. //
  18. // Example:
  19. // // Mesh in (V,F)
  20. // vector<vector<double> > A;
  21. // adjacency_list(F,A);
  22. //
  23. // See also: edges, cotmatrix, diag
  24. template <typename Index, typename IndexVector>
  25. IGL_INLINE void adjacency_list(
  26. const Eigen::PlainObjectBase<Index> & F,
  27. std::vector<std::vector<IndexVector> >& A,
  28. bool sorted = false);
  29. // Variant that accepts polygonal faces.
  30. // Each element of F is a set of indices of a polygonal face.
  31. template <typename Index>
  32. IGL_INLINE void adjacency_list(
  33. const std::vector<std::vector<Index> > & F,
  34. std::vector<std::vector<Index> >& A);
  35. }
  36. #ifdef IGL_HEADER_ONLY
  37. # include "adjacency_list.cpp"
  38. #endif
  39. #endif