order_facets_around_edge.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Qingnan Zhou <qnzhou@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. //
  9. #ifndef IGL_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGE_H
  10. #define IGL_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGE_H
  11. #include "../../igl_inline.h"
  12. #include <Eigen/Core>
  13. #include <vector>
  14. namespace igl {
  15. namespace copyleft
  16. {
  17. namespace cgal {
  18. // Given a directed edge, sort its adjacent faces. Assuming the
  19. // directed edge is (s, d). Sort the adjacent faces clockwise around the
  20. // axis (d - s), i.e. left-hand rule. An adjacent face is consistently
  21. // oriented if it contains (d, s) as a directed edge.
  22. //
  23. // For overlapping faces, break the tie using signed face index, smaller
  24. // signed index comes before the larger signed index. Signed index is
  25. // computed as (consistent? 1:-1) * (face_index + 1).
  26. //
  27. // Inputs:
  28. // V #V by 3 list of vertices.
  29. // F #F by 3 list of faces
  30. // s Index of source vertex.
  31. // d Index of desination vertex.
  32. // adj_faces List of adjacent face signed indices.
  33. //
  34. // Output:
  35. // order List of face indices that orders adjacent faces around
  36. // edge (s, d) clockwise.
  37. template<
  38. typename DerivedV,
  39. typename DerivedF,
  40. typename DerivedI >
  41. IGL_INLINE
  42. void order_facets_around_edge(
  43. const Eigen::PlainObjectBase<DerivedV>& V,
  44. const Eigen::PlainObjectBase<DerivedF>& F,
  45. size_t s, size_t d,
  46. const std::vector<int>& adj_faces,
  47. Eigen::PlainObjectBase<DerivedI>& order,
  48. bool debug=false);
  49. // This funciton is a wrapper around the one above. Since the ordering
  50. // is circular, the pivot point is used to define a starting point. So
  51. // order[0] is the index into adj_face that is immediately after the
  52. // pivot face (s, d, pivot point) in clockwise order.
  53. template<
  54. typename DerivedV,
  55. typename DerivedF,
  56. typename DerivedI>
  57. IGL_INLINE
  58. void order_facets_around_edge(
  59. const Eigen::PlainObjectBase<DerivedV>& V,
  60. const Eigen::PlainObjectBase<DerivedF>& F,
  61. size_t s, size_t d,
  62. const std::vector<int>& adj_faces,
  63. const Eigen::PlainObjectBase<DerivedV>& pivot_point,
  64. Eigen::PlainObjectBase<DerivedI>& order);
  65. }
  66. }
  67. }
  68. #ifndef IGL_STATIC_LIBRARY
  69. #include "order_facets_around_edge.cpp"
  70. #endif
  71. #endif