oriented_facets.cpp 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2017 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 "oriented_facets.h"
  9. template <typename DerivedF, typename DerivedE>
  10. IGL_INLINE void igl::oriented_facets(
  11. const Eigen::MatrixBase<DerivedF> & F,
  12. Eigen::PlainObjectBase<DerivedE> & E)
  13. {
  14. E.resize(F.rows()*F.cols(),F.cols()-1);
  15. typedef typename DerivedE::Scalar EScalar;
  16. switch(F.cols())
  17. {
  18. case 4:
  19. E.block(0*F.rows(),0,F.rows(),1) = F.col(1).template cast<EScalar>();
  20. E.block(0*F.rows(),1,F.rows(),1) = F.col(3).template cast<EScalar>();
  21. E.block(0*F.rows(),2,F.rows(),1) = F.col(2).template cast<EScalar>();
  22. E.block(1*F.rows(),0,F.rows(),1) = F.col(0).template cast<EScalar>();
  23. E.block(1*F.rows(),1,F.rows(),1) = F.col(2).template cast<EScalar>();
  24. E.block(1*F.rows(),2,F.rows(),1) = F.col(3).template cast<EScalar>();
  25. E.block(2*F.rows(),0,F.rows(),1) = F.col(0).template cast<EScalar>();
  26. E.block(2*F.rows(),1,F.rows(),1) = F.col(3).template cast<EScalar>();
  27. E.block(2*F.rows(),2,F.rows(),1) = F.col(1).template cast<EScalar>();
  28. E.block(3*F.rows(),0,F.rows(),1) = F.col(0).template cast<EScalar>();
  29. E.block(3*F.rows(),1,F.rows(),1) = F.col(1).template cast<EScalar>();
  30. E.block(3*F.rows(),2,F.rows(),1) = F.col(2).template cast<EScalar>();
  31. return;
  32. case 3:
  33. E.block(0*F.rows(),0,F.rows(),1) = F.col(1).template cast<EScalar>();
  34. E.block(0*F.rows(),1,F.rows(),1) = F.col(2).template cast<EScalar>();
  35. E.block(1*F.rows(),0,F.rows(),1) = F.col(2).template cast<EScalar>();
  36. E.block(1*F.rows(),1,F.rows(),1) = F.col(0).template cast<EScalar>();
  37. E.block(2*F.rows(),0,F.rows(),1) = F.col(0).template cast<EScalar>();
  38. E.block(2*F.rows(),1,F.rows(),1) = F.col(1).template cast<EScalar>();
  39. return;
  40. }
  41. }
  42. #ifdef IGL_STATIC_LIBRARY
  43. // Explicit template instantiation
  44. // generated by autoexplicit.sh
  45. template void igl::oriented_facets<Eigen::Matrix<int, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
  46. template void igl::oriented_facets<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::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
  47. template void igl::oriented_facets<Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> >&);
  48. template void igl::oriented_facets<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 2, 0, -1, 2> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> >&);
  49. template void igl::oriented_facets<Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
  50. template void igl::oriented_facets<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 2, 0, -1, 2> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 2, 0, -1, 2> >&);
  51. #endif