triangles_from_strip.cpp 921 B

123456789101112131415161718192021222324252627282930313233343536
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
  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. #include "triangles_from_strip.h"
  9. #include <iostream>
  10. template <typename DerivedS, typename DerivedF>
  11. IGL_INLINE void igl::triangles_from_strip(
  12. const Eigen::MatrixBase<DerivedS>& S,
  13. Eigen::PlainObjectBase<DerivedF>& F)
  14. {
  15. using namespace std;
  16. F.resize(S.size()-2,3);
  17. for(int s = 0;s < S.size()-2;s++)
  18. {
  19. if(s%2 == 0)
  20. {
  21. F(s,0) = S(s+2);
  22. F(s,1) = S(s+1);
  23. F(s,2) = S(s+0);
  24. }else
  25. {
  26. F(s,0) = S(s+0);
  27. F(s,1) = S(s+1);
  28. F(s,2) = S(s+2);
  29. }
  30. }
  31. }
  32. #ifdef IGL_STATIC_LIBRARY
  33. // Explicit template specialization
  34. #endif