combine.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 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_COMBINE_H
  9. #define IGL_COMBINE_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl
  14. {
  15. // Combine k meshes into a single >=k connected component mesh with a single
  16. // vertex list and face list. Similar to Maya's Combine operation.
  17. //
  18. // Inputs:
  19. // VV k-long list of lists of mesh vertex positions
  20. // FF k-long list of lists of mesh face indices so that FF[i] indexes
  21. // VV[i]
  22. // Outputs:
  23. // V VV[0].rows()+...+VV[k-1].rows() by VV[0].cols() list of mesh
  24. // vertex positions
  25. // F FF[0].rows()+...+FF[k-1].rows() by FF[0].cols() list of mesh faces
  26. // indices into V
  27. // Example:
  28. // // Suppose you have mesh A (VA,FA) and mesh B (VB,FB)
  29. // igl::combine<Eigen::MatrixXd,Eigen::MatrixXi>({VA,VB},{FA,FB},V,F);
  30. //
  31. template <
  32. typename DerivedVV,
  33. typename DerivedFF,
  34. typename DerivedV,
  35. typename DerivedF>
  36. IGL_INLINE void combine(
  37. const std::vector<DerivedVV> & VV,
  38. const std::vector<DerivedFF> & FF,
  39. Eigen::PlainObjectBase<DerivedV> & V,
  40. Eigen::PlainObjectBase<DerivedF> & F);
  41. }
  42. #ifndef IGL_STATIC_LIBRARY
  43. # include "combine.cpp"
  44. #endif
  45. #endif