order_facets_around_edge.h 2.7 KB

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