collapse_edge.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #ifndef IGL_COLLAPSE_EDGE_H
  9. #define IGL_COLLAPSE_EDGE_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. // Assumes (V,F) is a closed manifold mesh (except for previouslly collapsed
  15. // faces which should be set to:
  16. // [IGL_COLLAPSE_EDGE_NULL IGL_COLLAPSE_EDGE_NULL IGL_COLLAPSE_EDGE_NULL].
  17. // Collapses exactly two faces and exactly 3 edges from E (e and one side of
  18. // each face gets collapsed to the other). This is implemented in a way that
  19. // it can be repeatedly called until satisfaction and then the garbage in F
  20. // can be collected by removing NULL faces.
  21. //
  22. // Inputs:
  23. // e index into E of edge to try to collapse. E(e,:) = [s d] or [d s] so
  24. // that s<d, then d is collapsed to s.
  25. /// p dim list of vertex position where to place merged vertex
  26. // Inputs/Outputs:
  27. // V #V by dim list of vertex positions, lesser index of E(e,:) will be set
  28. // to midpoint of edge.
  29. // F #F by 3 list of face indices into V.
  30. // E #E by 2 list of edge indices into V.
  31. // EMAP #F*3 list of indices into E, mapping each directed edge to unique
  32. // unique edge in E
  33. // EF #E by 2 list of edge flaps, EF(e,0)=f means e=(i-->j) is the edge of
  34. // F(f,:) opposite the vth corner, where EI(e,0)=v. Similarly EF(e,1) "
  35. // e=(j->i)
  36. // EI #E by 2 list of edge flap corners (see above).
  37. // e1 index into E of edge collpased on left
  38. // e2 index into E of edge collpased on left
  39. // f1 index into E of edge collpased on left
  40. // f2 index into E of edge collpased on left
  41. // Returns true if edge was collapsed
  42. #define IGL_COLLAPSE_EDGE_NULL 0
  43. IGL_INLINE bool collapse_edge(
  44. const int e,
  45. const Eigen::RowVectorXd & p,
  46. Eigen::MatrixXd & V,
  47. Eigen::MatrixXi & F,
  48. Eigen::MatrixXi & E,
  49. Eigen::VectorXi & EMAP,
  50. Eigen::MatrixXi & EF,
  51. Eigen::MatrixXi & EI,
  52. int & e1,
  53. int & e2,
  54. int & f1,
  55. int & f2);
  56. IGL_INLINE bool collapse_edge(
  57. const int e,
  58. const Eigen::RowVectorXd & p,
  59. Eigen::MatrixXd & V,
  60. Eigen::MatrixXi & F,
  61. Eigen::MatrixXi & E,
  62. Eigen::VectorXi & EMAP,
  63. Eigen::MatrixXi & EF,
  64. Eigen::MatrixXi & EI);
  65. }
  66. #ifndef IGL_STATIC_LIBRARY
  67. # include "collapse_edge.cpp"
  68. #endif
  69. #endif