order_facets_around_edges.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. // E #F*3 by 2 list vertex indices, represents directed edges.
  32. // uE #uE by 2 list of vertex_indices, represents undirected edges.
  33. // EMAP #F*3 list of indices that maps E to uE. (a many-to-one map)
  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 DerivedE,
  47. typename DeriveduE,
  48. typename DerivedEMAP,
  49. typename uE2EType,
  50. typename uE2oEType,
  51. typename uE2CType >
  52. IGL_INLINE
  53. typename std::enable_if<!std::is_same<typename DerivedV::Scalar,
  54. typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
  55. order_facets_around_edges(
  56. const Eigen::PlainObjectBase<DerivedV>& V,
  57. const Eigen::PlainObjectBase<DerivedF>& F,
  58. const Eigen::PlainObjectBase<DerivedN>& N,
  59. const Eigen::PlainObjectBase<DerivedE>& E,
  60. const Eigen::PlainObjectBase<DeriveduE>& uE,
  61. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  62. const std::vector<std::vector<uE2EType> >& uE2E,
  63. std::vector<std::vector<uE2oEType> >& uE2oE,
  64. std::vector<std::vector<uE2CType > >& uE2C );
  65. template<
  66. typename DerivedV,
  67. typename DerivedF,
  68. typename DerivedN,
  69. typename DerivedE,
  70. typename DeriveduE,
  71. typename DerivedEMAP,
  72. typename uE2EType,
  73. typename uE2oEType,
  74. typename uE2CType >
  75. IGL_INLINE
  76. typename std::enable_if<std::is_same<typename DerivedV::Scalar,
  77. typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
  78. order_facets_around_edges(
  79. const Eigen::PlainObjectBase<DerivedV>& V,
  80. const Eigen::PlainObjectBase<DerivedF>& F,
  81. const Eigen::PlainObjectBase<DerivedN>& N,
  82. const Eigen::PlainObjectBase<DerivedE>& E,
  83. const Eigen::PlainObjectBase<DeriveduE>& uE,
  84. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  85. const std::vector<std::vector<uE2EType> >& uE2E,
  86. std::vector<std::vector<uE2oEType> >& uE2oE,
  87. std::vector<std::vector<uE2CType > >& uE2C );
  88. // Order faces around each edge. Only exact predicate is used in the algorithm.
  89. // Normal is not needed.
  90. template<
  91. typename DerivedV,
  92. typename DerivedF,
  93. typename DerivedE,
  94. typename DeriveduE,
  95. typename DerivedEMAP,
  96. typename uE2EType,
  97. typename uE2oEType,
  98. typename uE2CType >
  99. IGL_INLINE void order_facets_around_edges(
  100. const Eigen::PlainObjectBase<DerivedV>& V,
  101. const Eigen::PlainObjectBase<DerivedF>& F,
  102. const Eigen::PlainObjectBase<DerivedE>& E,
  103. const Eigen::PlainObjectBase<DeriveduE>& uE,
  104. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  105. const std::vector<std::vector<uE2EType> >& uE2E,
  106. std::vector<std::vector<uE2oEType> >& uE2oE,
  107. std::vector<std::vector<uE2CType > >& uE2C );
  108. }
  109. }
  110. #ifndef IGL_STATIC_LIBRARY
  111. #include "order_facets_around_edges.cpp"
  112. #endif
  113. #endif