all_edges.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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 "all_edges.h"
  9. IGL_INLINE void igl::all_edges(
  10. const Eigen::MatrixXi & F,
  11. Eigen::MatrixXi & E)
  12. {
  13. E.resize(F.rows()*F.cols(),F.cols()-1);
  14. switch(F.cols())
  15. {
  16. case 4:
  17. E.block(0*F.rows(),0,F.rows(),1) = F.col(1);
  18. E.block(0*F.rows(),1,F.rows(),1) = F.col(3);
  19. E.block(0*F.rows(),2,F.rows(),1) = F.col(2);
  20. E.block(1*F.rows(),0,F.rows(),1) = F.col(0);
  21. E.block(1*F.rows(),1,F.rows(),1) = F.col(2);
  22. E.block(1*F.rows(),2,F.rows(),1) = F.col(3);
  23. E.block(2*F.rows(),0,F.rows(),1) = F.col(0);
  24. E.block(2*F.rows(),1,F.rows(),1) = F.col(3);
  25. E.block(2*F.rows(),2,F.rows(),1) = F.col(1);
  26. E.block(3*F.rows(),0,F.rows(),1) = F.col(0);
  27. E.block(3*F.rows(),1,F.rows(),1) = F.col(1);
  28. E.block(3*F.rows(),2,F.rows(),1) = F.col(2);
  29. return;
  30. case 3:
  31. E.block(0*F.rows(),0,F.rows(),1) = F.col(1);
  32. E.block(0*F.rows(),1,F.rows(),1) = F.col(2);
  33. E.block(1*F.rows(),0,F.rows(),1) = F.col(2);
  34. E.block(1*F.rows(),1,F.rows(),1) = F.col(0);
  35. E.block(2*F.rows(),0,F.rows(),1) = F.col(0);
  36. E.block(2*F.rows(),1,F.rows(),1) = F.col(1);
  37. return;
  38. }
  39. }