all_edges.cpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. template <typename DerivedF, typename DerivedE>
  10. IGL_INLINE void igl::all_edges(
  11. const Eigen::PlainObjectBase<DerivedF> & F,
  12. Eigen::PlainObjectBase<DerivedE> & E)
  13. {
  14. E.resize(F.rows()*F.cols(),F.cols()-1);
  15. switch(F.cols())
  16. {
  17. case 4:
  18. E.block(0*F.rows(),0,F.rows(),1) = F.col(1);
  19. E.block(0*F.rows(),1,F.rows(),1) = F.col(3);
  20. E.block(0*F.rows(),2,F.rows(),1) = F.col(2);
  21. E.block(1*F.rows(),0,F.rows(),1) = F.col(0);
  22. E.block(1*F.rows(),1,F.rows(),1) = F.col(2);
  23. E.block(1*F.rows(),2,F.rows(),1) = F.col(3);
  24. E.block(2*F.rows(),0,F.rows(),1) = F.col(0);
  25. E.block(2*F.rows(),1,F.rows(),1) = F.col(3);
  26. E.block(2*F.rows(),2,F.rows(),1) = F.col(1);
  27. E.block(3*F.rows(),0,F.rows(),1) = F.col(0);
  28. E.block(3*F.rows(),1,F.rows(),1) = F.col(1);
  29. E.block(3*F.rows(),2,F.rows(),1) = F.col(2);
  30. return;
  31. case 3:
  32. E.block(0*F.rows(),0,F.rows(),1) = F.col(1);
  33. E.block(0*F.rows(),1,F.rows(),1) = F.col(2);
  34. E.block(1*F.rows(),0,F.rows(),1) = F.col(2);
  35. E.block(1*F.rows(),1,F.rows(),1) = F.col(0);
  36. E.block(2*F.rows(),0,F.rows(),1) = F.col(0);
  37. E.block(2*F.rows(),1,F.rows(),1) = F.col(1);
  38. return;
  39. }
  40. }
  41. #ifdef IGL_STATIC_LIBRARY
  42. // Explicit template specialization
  43. template void igl::all_edges<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
  44. template void igl::all_edges<Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> >&);
  45. template void igl::all_edges<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 2, 0, -1, 2> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> >&);
  46. template void igl::all_edges<Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
  47. template void igl::all_edges<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 2, 0, -1, 2> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 2, 0, -1, 2> >&);
  48. #endif