order_facets_around_edges.h 4.0 KB

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