polygons_to_triangles.h 1.7 KB

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