unique_edge_map.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <[email protected]>
  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_UNIQUE_EDGE_MAP_H
  9. #define IGL_UNIQUE_EDGE_MAP_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. #include <vector>
  13. namespace igl
  14. {
  15. /// Construct relationships between facet "half"-(or rather "viewed")-edges E
  16. /// to unique edges of the mesh seen as a graph.
  17. ///
  18. /// @param[in] F #F by 3 list of simplices
  19. /// @param[out] E #F*3 by 2 list of all directed edges, such that E.row(f+#F*c) is the
  20. /// edge opposite F(f,c)
  21. /// @param[out] uE #uE by 2 list of unique undirected edges
  22. /// @param[out] EMAP #F*3 list of indices into uE, mapping each directed edge to unique
  23. /// undirected edge so that uE(EMAP(f+#F*c)) is the unique edge
  24. /// corresponding to E.row(f+#F*c)
  25. /// @param[out] uE2E #uE list of lists of indices into E of coexisting edges, so that
  26. /// E.row(uE2E[i][j]) corresponds to uE.row(i) for all j in
  27. /// 0..uE2E[i].size()-1.
  28. template <
  29. typename DerivedF,
  30. typename DerivedE,
  31. typename DeriveduE,
  32. typename DerivedEMAP,
  33. typename uE2EType>
  34. IGL_INLINE void unique_edge_map(
  35. const Eigen::MatrixBase<DerivedF> & F,
  36. Eigen::PlainObjectBase<DerivedE> & E,
  37. Eigen::PlainObjectBase<DeriveduE> & uE,
  38. Eigen::PlainObjectBase<DerivedEMAP> & EMAP,
  39. std::vector<std::vector<uE2EType> > & uE2E);
  40. /// \overload
  41. template <
  42. typename DerivedF,
  43. typename DerivedE,
  44. typename DeriveduE,
  45. typename DerivedEMAP>
  46. IGL_INLINE void unique_edge_map(
  47. const Eigen::MatrixBase<DerivedF> & F,
  48. Eigen::PlainObjectBase<DerivedE> & E,
  49. Eigen::PlainObjectBase<DeriveduE> & uE,
  50. Eigen::PlainObjectBase<DerivedEMAP> & EMAP);
  51. /// \overload
  52. /// \brief It is usual much faster if your algorithm can be written in terms of
  53. /// (uEC,uEE) rather than (uE2E).
  54. ///
  55. /// @param[out] uEC #uE+1 list of cumulative counts of directed edges sharing each
  56. /// unique edge so the uEC(i+1)-uEC(i) is the number of directed edges
  57. /// sharing the ith unique edge.
  58. /// @param[out] uEE #E list of indices into E, so that the consecutive segment of
  59. /// indices uEE.segment(uEC(i),uEC(i+1)-uEC(i)) lists all directed edges
  60. /// sharing the ith unique edge.
  61. ///
  62. /// #### Example:
  63. ///
  64. /// \code{cpp}
  65. /// // Using uE2E
  66. /// for(int u = 0;u<uE2E.size();u++)
  67. /// {
  68. /// for(int i = 0;i<uE2E[u].size();i++)
  69. /// {
  70. /// // eth directed-edge is ith edge equivalent to uth undirected edge
  71. /// e = uE2E[u][i];
  72. /// }
  73. /// }
  74. /// \endcode
  75. ///
  76. /// \code{cpp}
  77. /// // Using uEC,uEE
  78. /// for(int u = 0;u<uE.rows();u++)
  79. /// {
  80. /// for(int j = uEC(u);j<uEC(u+1);j++)
  81. /// {
  82. /// e = uEE(j); // i = j-uEC(u);
  83. /// }
  84. /// }
  85. /// \endcode
  86. ///
  87. template <
  88. typename DerivedF,
  89. typename DerivedE,
  90. typename DeriveduE,
  91. typename DerivedEMAP,
  92. typename DeriveduEC,
  93. typename DeriveduEE>
  94. IGL_INLINE void unique_edge_map(
  95. const Eigen::MatrixBase<DerivedF> & F,
  96. Eigen::PlainObjectBase<DerivedE> & E,
  97. Eigen::PlainObjectBase<DeriveduE> & uE,
  98. Eigen::PlainObjectBase<DerivedEMAP> & EMAP,
  99. Eigen::PlainObjectBase<DeriveduEC> & uEC,
  100. Eigen::PlainObjectBase<DeriveduEE> & uEE);
  101. }
  102. #ifndef IGL_STATIC_LIBRARY
  103. # include "unique_edge_map.cpp"
  104. #endif
  105. #endif