combine.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. // Concatenate k meshes into a single >=k connected component mesh with a
  16. // single 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. // Vsizes k list so that Vsizes(i) is the #vertices in the ith input
  28. // Fsizes k list so that Fsizes(i) is the #faces in the ith input
  29. // Example:
  30. // // Suppose you have mesh A (VA,FA) and mesh B (VB,FB)
  31. // igl::combine<Eigen::MatrixXd,Eigen::MatrixXi>({VA,VB},{FA,FB},V,F);
  32. //
  33. //
  34. template <
  35. typename DerivedVV,
  36. typename DerivedFF,
  37. typename DerivedV,
  38. typename DerivedF,
  39. typename DerivedVsizes,
  40. typename DerivedFsizes>
  41. IGL_INLINE void combine(
  42. const std::vector<DerivedVV> & VV,
  43. const std::vector<DerivedFF> & FF,
  44. Eigen::PlainObjectBase<DerivedV> & V,
  45. Eigen::PlainObjectBase<DerivedF> & F,
  46. Eigen::PlainObjectBase<DerivedVsizes> & Vsizes,
  47. Eigen::PlainObjectBase<DerivedFsizes> & Fsizes);
  48. template <
  49. typename DerivedVV,
  50. typename DerivedFF,
  51. typename DerivedV,
  52. typename DerivedF>
  53. IGL_INLINE void combine(
  54. const std::vector<DerivedVV> & VV,
  55. const std::vector<DerivedFF> & FF,
  56. Eigen::PlainObjectBase<DerivedV> & V,
  57. Eigen::PlainObjectBase<DerivedF> & F);
  58. }
  59. #ifndef IGL_STATIC_LIBRARY
  60. # include "combine.cpp"
  61. #endif
  62. #endif