polygon_corners.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2020 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_POLYGON_CORNERS_H
  9. #define IGL_POLYGON_CORNERS_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl
  14. {
  15. /// Convert a list-of-lists polygon mesh faces representation to list of
  16. /// polygon corners and sizes
  17. ///
  18. /// @param[in] P #P list of lists of vertex indices into rows of some matrix V
  19. /// @param[out] I #I vectorized list of polygon corner indices into rows of some matrix V
  20. /// @param[out] C #P+1 list of cumulative polygon sizes so that C(i+1)-C(i) = size of
  21. /// the ith polygon, and so I(C(i)) through I(C(i+1)-1) are the indices of
  22. /// the ith polygon
  23. ///
  24. template <
  25. typename PType,
  26. typename DerivedI,
  27. typename DerivedC>
  28. IGL_INLINE void polygon_corners(
  29. const std::vector<std::vector<PType> > & P,
  30. Eigen::PlainObjectBase<DerivedI> & I,
  31. Eigen::PlainObjectBase<DerivedC> & C);
  32. /// \overload
  33. /// \brief Convert a pure k-gon list of polygon mesh indices to list of
  34. /// polygon corners and sizes
  35. ///
  36. /// @param[in] Q #Q by k list of polygon indices (ith row is a k-gon, unless Q(i,j) =
  37. /// -1 then it's a j-gon)
  38. template <
  39. typename DerivedQ,
  40. typename DerivedI,
  41. typename DerivedC>
  42. IGL_INLINE void polygon_corners(
  43. const Eigen::MatrixBase<DerivedQ> & Q,
  44. Eigen::PlainObjectBase<DerivedI> & I,
  45. Eigen::PlainObjectBase<DerivedC> & C);
  46. }
  47. #ifndef IGL_STATIC_LIBRARY
  48. # include "polygon_corners.cpp"
  49. #endif
  50. #endif