combine.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 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_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. /// @param[in] VV k-long list of lists of mesh vertex positions
  19. /// @param[in] FF k-long list of lists of mesh face indices so that FF[i] indexes
  20. /// VV[i]
  21. /// @param[out] V VV[0].rows()+...+VV[k-1].rows() by VV[0].cols() list of mesh
  22. /// vertex positions
  23. /// @param[out] F FF[0].rows()+...+FF[k-1].rows() by FF[0].cols() list of mesh faces
  24. /// indices into V
  25. /// @param[out] Vsizes k list so that Vsizes(i) is the #vertices in the ith input
  26. /// @param[out] Fsizes k list so that Fsizes(i) is the #faces in the ith input
  27. ///
  28. /// #### Example
  29. /// \code{cpp}
  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. /// \endcode
  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. /// \overload
  49. template <
  50. typename DerivedVV,
  51. typename DerivedFF,
  52. typename DerivedV,
  53. typename DerivedF>
  54. IGL_INLINE void combine(
  55. const std::vector<DerivedVV> & VV,
  56. const std::vector<DerivedFF> & FF,
  57. Eigen::PlainObjectBase<DerivedV> & V,
  58. Eigen::PlainObjectBase<DerivedF> & F);
  59. }
  60. #ifndef IGL_STATIC_LIBRARY
  61. # include "combine.cpp"
  62. #endif
  63. #endif