triangles_from_strip.cpp 897 B

1234567891011121314151617181920212223242526272829303132333435
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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. #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. F.resize(S.size()-2,3);
  16. for(int s = 0;s < S.size()-2;s++)
  17. {
  18. if(s%2 == 0)
  19. {
  20. F(s,0) = S(s+2);
  21. F(s,1) = S(s+1);
  22. F(s,2) = S(s+0);
  23. }else
  24. {
  25. F(s,0) = S(s+0);
  26. F(s,1) = S(s+1);
  27. F(s,2) = S(s+2);
  28. }
  29. }
  30. }
  31. #ifdef IGL_STATIC_LIBRARY
  32. // Explicit template instantiation
  33. #endif