vertex_components.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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_COMPONENTS_H
  9. #define IGL_COMPONENTS_H
  10. #include "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
  16. /// matrix.
  17. ///
  18. /// Outputs a component ID per vertex of the graph where connectivity is established by edges.
  19. ///
  20. /// @param[in] A n by n adjacency matrix
  21. /// @param[out] C n list of component ids (starting with 0)
  22. /// @param[out] counts #components list of counts for each component
  23. ///
  24. template <typename DerivedA, typename DerivedC, typename Derivedcounts>
  25. IGL_INLINE void vertex_components(
  26. const Eigen::SparseCompressedBase<DerivedA> & A,
  27. Eigen::PlainObjectBase<DerivedC> & C,
  28. Eigen::PlainObjectBase<Derivedcounts> & counts);
  29. /// \overload
  30. template <typename DerivedA, typename DerivedC>
  31. IGL_INLINE void vertex_components(
  32. const Eigen::SparseCompressedBase<DerivedA> & A,
  33. Eigen::PlainObjectBase<DerivedC> & C);
  34. /// Compute the connected components for a mesh given its faces.
  35. /// Returns a component ID per vertex of the mesh where connectivity is established by edges.
  36. ///
  37. /// For computing connected components per face see igl::facet_components
  38. ///
  39. ///
  40. /// @param[in] F n by 3 list of triangle indices
  41. /// @param[out] C max(F) list of component ids
  42. template <typename DerivedF, typename DerivedC>
  43. IGL_INLINE void vertex_components(
  44. const Eigen::MatrixBase<DerivedF> & F,
  45. Eigen::PlainObjectBase<DerivedC> & C);
  46. }
  47. #ifndef IGL_STATIC_LIBRARY
  48. # include "vertex_components.cpp"
  49. #endif
  50. #endif