vertex_components.h 1.8 KB

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