edge_flaps.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 "edge_flaps.h"
  9. #include "unique_edge_map.h"
  10. #include <vector>
  11. #include <cassert>
  12. IGL_INLINE void igl::edge_flaps(
  13. const Eigen::MatrixXi & F,
  14. const Eigen::MatrixXi & uE,
  15. const Eigen::VectorXi & EMAP,
  16. Eigen::MatrixXi & EF,
  17. Eigen::MatrixXi & EI)
  18. {
  19. // Initialize to boundary value
  20. EF.setConstant(uE.rows(),2,-1);
  21. EI.setConstant(uE.rows(),2,-1);
  22. // loop over all faces
  23. for(int f = 0;f<F.rows();f++)
  24. {
  25. // loop over edges across from corners
  26. for(int v = 0;v<3;v++)
  27. {
  28. // get edge id
  29. const int e = EMAP(v*F.rows()+f);
  30. // See if this is left or right flap w.r.t. edge orientation
  31. if( F(f,(v+1)%3) == uE(e,0) && F(f,(v+2)%3) == uE(e,1))
  32. {
  33. EF(e,0) = f;
  34. EI(e,0) = v;
  35. }else
  36. {
  37. assert(F(f,(v+1)%3) == uE(e,1) && F(f,(v+2)%3) == uE(e,0));
  38. EF(e,1) = f;
  39. EI(e,1) = v;
  40. }
  41. }
  42. }
  43. }
  44. IGL_INLINE void igl::edge_flaps(
  45. const Eigen::MatrixXi & F,
  46. Eigen::MatrixXi & uE,
  47. Eigen::VectorXi & EMAP,
  48. Eigen::MatrixXi & EF,
  49. Eigen::MatrixXi & EI)
  50. {
  51. Eigen::MatrixXi allE;
  52. std::vector<std::vector<int> > uE2E;
  53. igl::unique_edge_map(F,allE,uE,EMAP,uE2E);
  54. // Const-ify to call overload
  55. const auto & cuE = uE;
  56. const auto & cEMAP = EMAP;
  57. return edge_flaps(F,cuE,cEMAP,EF,EI);
  58. }