order_facets_around_edges.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGES_H
  9. #define IGL_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGES_H
  10. #include "../../igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
  13. #include <vector>
  14. namespace igl
  15. {
  16. namespace copyleft
  17. {
  18. namespace cgal
  19. {
  20. // For each undirected edge, sort its adjacent faces. Assuming the
  21. // undirected 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) * index.
  28. //
  29. // Inputs:
  30. // V #V by 3 list of vertices.
  31. // F #F by 3 list of faces
  32. // N #F by 3 list of face normals.
  33. // uE #uE by 2 list of vertex_indices, represents undirected edges.
  34. // uE2E #uE list of lists that maps uE to E. (a one-to-many map)
  35. //
  36. // Outputs:
  37. // uE2oE #uE list of lists that maps uE to an ordered list of E. (a
  38. // one-to-many map)
  39. // uE2C #uE list of lists of bools indicates whether each face in
  40. // uE2oE[i] is consistently orientated as the ordering.
  41. //
  42. template<
  43. typename DerivedV,
  44. typename DerivedF,
  45. typename DerivedN,
  46. typename DeriveduE,
  47. typename uE2EType,
  48. typename uE2oEType,
  49. typename uE2CType >
  50. IGL_INLINE
  51. typename std::enable_if<!std::is_same<typename DerivedV::Scalar,
  52. typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
  53. order_facets_around_edges(
  54. const Eigen::PlainObjectBase<DerivedV>& V,
  55. const Eigen::PlainObjectBase<DerivedF>& F,
  56. const Eigen::PlainObjectBase<DerivedN>& N,
  57. const Eigen::PlainObjectBase<DeriveduE>& uE,
  58. const std::vector<std::vector<uE2EType> >& uE2E,
  59. std::vector<std::vector<uE2oEType> >& uE2oE,
  60. std::vector<std::vector<uE2CType > >& uE2C );
  61. template<
  62. typename DerivedV,
  63. typename DerivedF,
  64. typename DerivedN,
  65. typename DeriveduE,
  66. typename uE2EType,
  67. typename uE2oEType,
  68. typename uE2CType >
  69. IGL_INLINE
  70. typename std::enable_if<std::is_same<typename DerivedV::Scalar,
  71. typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
  72. order_facets_around_edges(
  73. const Eigen::PlainObjectBase<DerivedV>& V,
  74. const Eigen::PlainObjectBase<DerivedF>& F,
  75. const Eigen::PlainObjectBase<DerivedN>& N,
  76. const Eigen::PlainObjectBase<DeriveduE>& uE,
  77. const std::vector<std::vector<uE2EType> >& uE2E,
  78. std::vector<std::vector<uE2oEType> >& uE2oE,
  79. std::vector<std::vector<uE2CType > >& uE2C );
  80. // Order faces around each edge. Only exact predicate is used in the algorithm.
  81. // Normal is not needed.
  82. template<
  83. typename DerivedV,
  84. typename DerivedF,
  85. typename DeriveduE,
  86. typename uE2EType,
  87. typename uE2oEType,
  88. typename uE2CType >
  89. IGL_INLINE void order_facets_around_edges(
  90. const Eigen::PlainObjectBase<DerivedV>& V,
  91. const Eigen::PlainObjectBase<DerivedF>& F,
  92. const Eigen::PlainObjectBase<DeriveduE>& uE,
  93. const std::vector<std::vector<uE2EType> >& uE2E,
  94. std::vector<std::vector<uE2oEType> >& uE2oE,
  95. std::vector<std::vector<uE2CType > >& uE2C );
  96. }
  97. }
  98. }
  99. #ifndef IGL_STATIC_LIBRARY
  100. #include "order_facets_around_edges.cpp"
  101. #endif
  102. #endif