adjacency_list.h 1.6 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_LIST_H
  9. #define IGL_ADJACENCY_LIST_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. #include <Eigen/Sparse>
  13. #include <vector>
  14. namespace igl
  15. {
  16. // Constructs the graph adjacency list 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 faces (must be triangles)
  21. // sorted flag that indicates if the list should be sorted counter-clockwise
  22. // Outputs:
  23. // A vector<vector<T> > containing at row i the adjacent vertices of vertex i
  24. //
  25. // Example:
  26. // // Mesh in (V,F)
  27. // vector<vector<double> > A;
  28. // adjacency_list(F,A);
  29. //
  30. // See also: edges, cotmatrix, diag
  31. template <typename Index, typename IndexVector>
  32. IGL_INLINE void adjacency_list(
  33. const Eigen::PlainObjectBase<Index> & F,
  34. std::vector<std::vector<IndexVector> >& A,
  35. bool sorted = false);
  36. // Variant that accepts polygonal faces.
  37. // Each element of F is a set of indices of a polygonal face.
  38. template <typename Index>
  39. IGL_INLINE void adjacency_list(
  40. const std::vector<std::vector<Index> > & F,
  41. std::vector<std::vector<Index> >& A);
  42. }
  43. #ifndef IGL_STATIC_LIBRARY
  44. # include "adjacency_list.cpp"
  45. #endif
  46. #endif