order_facets_around_edges.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. namespace igl
  14. {
  15. namespace cgal
  16. {
  17. // For each undirected edge, sort its adjacent faces. Assuming the
  18. // undirected edge is (s, d). Sort the adjacent faces clockwise around the
  19. // axis (d - s), i.e. left-hand rule. An adjacent face is consistently
  20. // oriented if it contains (d, s) as a directed edge.
  21. //
  22. // For overlapping faces, break the tie using signed face index, smaller
  23. // signed index comes before the larger signed index. Signed index is
  24. // computed as (consistent? 1:-1) * index.
  25. //
  26. // Inputs:
  27. // V #V by 3 list of vertices.
  28. // F #F by 3 list of faces
  29. // N #F by 3 list of face normals.
  30. // E #F*3 by 2 list vertex indices, represents directed edges.
  31. // uE #uE by 2 list of vertex_indices, represents undirected edges.
  32. // EMAP #F*3 list of indices that maps E to uE. (a many-to-one map)
  33. // uE2E #uE list of lists that maps uE to E. (a one-to-many map)
  34. //
  35. // Outputs:
  36. // uE2oE #uE list of lists that maps uE to an ordered list of E. (a
  37. // one-to-many map)
  38. // uE2C #uE list of lists of bools indicates whether each face in
  39. // uE2oE[i] is consistently orientated as the ordering.
  40. //
  41. template<
  42. typename DerivedV,
  43. typename DerivedF,
  44. typename DerivedN,
  45. typename DerivedE,
  46. typename DeriveduE,
  47. typename DerivedEMAP,
  48. typename uE2EType,
  49. typename uE2oEType,
  50. typename uE2CType >
  51. IGL_INLINE
  52. typename std::enable_if<!std::is_same<typename DerivedV::Scalar,
  53. typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
  54. order_facets_around_edges(
  55. const Eigen::PlainObjectBase<DerivedV>& V,
  56. const Eigen::PlainObjectBase<DerivedF>& F,
  57. const Eigen::PlainObjectBase<DerivedN>& N,
  58. const Eigen::PlainObjectBase<DerivedE>& E,
  59. const Eigen::PlainObjectBase<DeriveduE>& uE,
  60. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  61. const std::vector<std::vector<uE2EType> >& uE2E,
  62. std::vector<std::vector<uE2oEType> >& uE2oE,
  63. std::vector<std::vector<uE2CType > >& uE2C );
  64. template<
  65. typename DerivedV,
  66. typename DerivedF,
  67. typename DerivedN,
  68. typename DerivedE,
  69. typename DeriveduE,
  70. typename DerivedEMAP,
  71. typename uE2EType,
  72. typename uE2oEType,
  73. typename uE2CType >
  74. IGL_INLINE
  75. typename std::enable_if<std::is_same<typename DerivedV::Scalar,
  76. typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
  77. order_facets_around_edges(
  78. const Eigen::PlainObjectBase<DerivedV>& V,
  79. const Eigen::PlainObjectBase<DerivedF>& F,
  80. const Eigen::PlainObjectBase<DerivedN>& N,
  81. const Eigen::PlainObjectBase<DerivedE>& E,
  82. const Eigen::PlainObjectBase<DeriveduE>& uE,
  83. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  84. const std::vector<std::vector<uE2EType> >& uE2E,
  85. std::vector<std::vector<uE2oEType> >& uE2oE,
  86. std::vector<std::vector<uE2CType > >& uE2C );
  87. // Order faces around each edge. Only exact predicate is used in the algorithm.
  88. // Normal is not needed.
  89. template<
  90. typename DerivedV,
  91. typename DerivedF,
  92. typename DerivedE,
  93. typename DeriveduE,
  94. typename DerivedEMAP,
  95. typename uE2EType,
  96. typename uE2oEType,
  97. typename uE2CType >
  98. IGL_INLINE void order_facets_around_edges(
  99. const Eigen::PlainObjectBase<DerivedV>& V,
  100. const Eigen::PlainObjectBase<DerivedF>& F,
  101. const Eigen::PlainObjectBase<DerivedE>& E,
  102. const Eigen::PlainObjectBase<DeriveduE>& uE,
  103. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  104. const std::vector<std::vector<uE2EType> >& uE2E,
  105. std::vector<std::vector<uE2oEType> >& uE2oE,
  106. std::vector<std::vector<uE2CType > >& uE2C );
  107. }
  108. }
  109. #ifndef IGL_STATIC_LIBRARY
  110. #include "order_facets_around_edges.cpp"
  111. #endif
  112. #endif