components.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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_COMPONENTS_H
  9. #define IGL_COMPONENTS_H
  10. #include <igl/igl_inline.h>
  11. #include <Eigen/Core>
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. // Compute connected components of a graph represented by an adjacency matrix
  16. //
  17. // Inputs:
  18. // A n by n adjacency matrix
  19. // Outputs:
  20. // C n list of component ids
  21. //
  22. template <typename AScalar, typename DerivedC>
  23. IGL_INLINE void components(
  24. const Eigen::SparseMatrix<AScalar> & A,
  25. Eigen::PlainObjectBase<DerivedC> & C);
  26. // Ditto but for mesh faces as input. This computes connected components of
  27. // **vertices** where **edges** establish connectivity.
  28. //
  29. // Inputs:
  30. // F n by 3 list of triangle indices
  31. // Outputs:
  32. // C max(F) list of component ids
  33. template <typename DerivedF, typename DerivedC>
  34. IGL_INLINE void components(
  35. const Eigen::PlainObjectBase<DerivedF> & F,
  36. Eigen::PlainObjectBase<DerivedC> & C);
  37. }
  38. #ifndef IGL_STATIC_LIBRARY
  39. # include "components.cpp"
  40. #endif
  41. #endif