components.h 884 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef IGL_COMPONENTS_H
  2. #define IGL_COMPONENTS_H
  3. #include <igl/igl_inline.h>
  4. #include <Eigen/Core>
  5. #include <Eigen/Sparse>
  6. namespace igl
  7. {
  8. // Compute connected components of a graph represented by an adjacency matrix
  9. //
  10. // Inputs:
  11. // A n by n adjacency matrix
  12. // Outputs:
  13. // C n list of component ids
  14. //
  15. template <typename AScalar, typename DerivedC>
  16. IGL_INLINE void components(
  17. const Eigen::SparseMatrix<AScalar> & A,
  18. Eigen::PlainObjectBase<DerivedC> & C);
  19. // Ditto but for mesh faces as input
  20. //
  21. // Inputs:
  22. // F n by 3 list of triangle indices
  23. // Outputs:
  24. // C max(F) list of component ids
  25. template <typename DerivedF, typename DerivedC>
  26. IGL_INLINE void components(
  27. const Eigen::PlainObjectBase<DerivedF> & F,
  28. Eigen::PlainObjectBase<DerivedC> & C);
  29. }
  30. #ifdef IGL_HEADER_ONLY
  31. # include "components.cpp"
  32. #endif
  33. #endif