partition.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 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_PARTITION_H
  9. #define IGL_PARTITION_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. namespace igl
  13. {
  14. // PARTITION partition vertices into groups based on each
  15. // vertex's vector: vertices with similar coordinates (close in
  16. // space) will be put in the same group.
  17. //
  18. // Inputs:
  19. // W #W by dim coordinate matrix
  20. // k desired number of groups default is dim
  21. // Output:
  22. // G #W list of group indices (1 to k) for each vertex, such that vertex i
  23. // is assigned to group G(i)
  24. // S k list of seed vertices
  25. // D #W list of squared distances for each vertex to it's corresponding
  26. // closest seed
  27. IGL_INLINE void partition(
  28. const Eigen::MatrixXd & W,
  29. const int k,
  30. Eigen::Matrix<int,Eigen::Dynamic,1> & G,
  31. Eigen::Matrix<int,Eigen::Dynamic,1> & S,
  32. Eigen::Matrix<double,Eigen::Dynamic,1> & D);
  33. }
  34. #ifndef IGL_STATIC_LIBRARY
  35. #include "partition.cpp"
  36. #endif
  37. #endif