polygons_to_triangles.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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_POLYGONS_TO_TRIANGLES_H
  9. #define IGL_POLYGONS_TO_TRIANGLES_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl
  14. {
  15. /// Given a polygon mesh, trivially triangulate each polygon with a fan. This
  16. /// purely combinatorial triangulation will work well for convex/flat polygons
  17. /// and degrade otherwise.
  18. ///
  19. /// @param[in] I #I vectorized list of polygon corner indices into rows of some matrix V
  20. /// @param[in] C #polygons+1 list of cumulative polygon sizes so that C(i+1)-C(i) =
  21. /// size of the ith polygon, and so I(C(i)) through I(C(i+1)-1) are the
  22. /// indices of the ith polygon
  23. /// @param[out] F #F by 3 list of triangle indices into rows of V
  24. /// @param[out] J #F list of indices into 0:#P-1 of corresponding polygon
  25. ///
  26. template <
  27. typename DerivedI,
  28. typename DerivedC,
  29. typename DerivedF,
  30. typename DerivedJ>
  31. IGL_INLINE void polygons_to_triangles(
  32. const Eigen::MatrixBase<DerivedI> & I,
  33. const Eigen::MatrixBase<DerivedC> & C,
  34. Eigen::PlainObjectBase<DerivedF> & F,
  35. Eigen::PlainObjectBase<DerivedJ> & J);
  36. }
  37. #ifndef IGL_STATIC_LIBRARY
  38. # include "polygons_to_triangles.cpp"
  39. #endif
  40. #endif