adjacency_list.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_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. ///
  18. /// @tparam T should be a eigen sparse matrix primitive type like int or double
  19. /// @param[in] F #F by dim list of mesh faces (must be triangles)
  20. /// @param[out] A vector<vector<T> > containing at row i the adjacent vertices of vertex i
  21. /// @param[in] sorted flag that indicates if the list should be sorted counter-clockwise. Input assumed to be manifold.
  22. ///
  23. /// Example:
  24. /// \code{.cpp}
  25. /// // Mesh in (V,F)
  26. /// vector<vector<double> > A;
  27. /// adjacency_list(F,A);
  28. /// \endcode
  29. ///
  30. /// \see
  31. /// adjacency_matrix
  32. /// edges,
  33. /// cotmatrix,
  34. /// diag
  35. template <typename Index, typename IndexVector>
  36. IGL_INLINE void adjacency_list(
  37. const Eigen::MatrixBase<Index> & F,
  38. std::vector<std::vector<IndexVector> >& A,
  39. bool sorted = false);
  40. /// Constructs the graph adjacency list of a given _polygon_ mesh (V,F)
  41. ///
  42. /// @tparam T should be a eigen sparse matrix primitive type like int or double
  43. /// @param[in] F #F list of polygon face index lists
  44. /// @param[out] A vector<vector<T> > containing at row i the adjacent vertices of vertex i
  45. template <typename Index>
  46. IGL_INLINE void adjacency_list(
  47. const std::vector<std::vector<Index> > & F,
  48. std::vector<std::vector<Index> >& A);
  49. }
  50. #ifndef IGL_STATIC_LIBRARY
  51. # include "adjacency_list.cpp"
  52. #endif
  53. #endif