polygons_to_triangles.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "polygons_to_triangles.h"
  2. template <
  3. typename DerivedI,
  4. typename DerivedC,
  5. typename DerivedF,
  6. typename DerivedJ>
  7. IGL_INLINE void igl::polygons_to_triangles(
  8. const Eigen::MatrixBase<DerivedI> & I,
  9. const Eigen::MatrixBase<DerivedC> & C,
  10. Eigen::PlainObjectBase<DerivedF> & F,
  11. Eigen::PlainObjectBase<DerivedJ> & J)
  12. {
  13. // Each polygon results in #sides-2 triangles. So ∑#sides-2
  14. F.resize(C(C.size()-1) - (C.size()-1)*2,3);
  15. J.resize(F.rows());
  16. {
  17. int f = 0;
  18. for(int p = 0;p<C.size()-1;p++)
  19. {
  20. const int np = C(p+1)-C(p);
  21. for(int c = 1;c<np-1;c++)
  22. {
  23. F(f,0) = I(C(p)+0);
  24. F(f,1) = I(C(p)+c);
  25. F(f,2) = I(C(p)+c+1);
  26. J(f) = p;
  27. f++;
  28. }
  29. }
  30. assert(f == F.rows());
  31. }
  32. }
  33. #ifdef IGL_STATIC_LIBRARY
  34. // Explicit template instantiation
  35. // generated by autoexplicit.sh
  36. template void igl::polygons_to_triangles<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<unsigned int, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
  37. // generated by autoexplicit.sh
  38. template void igl::polygons_to_triangles<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
  39. // generated by autoexplicit.sh
  40. template void igl::polygons_to_triangles<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
  41. // generated by autoexplicit.sh
  42. template void igl::polygons_to_triangles<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
  43. #endif