propagate_winding_numbers.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #ifndef IGL_CGAL_PROPAGATE_WINDING_NUMBERS_H
  2. #define IGL_CGAL_PROPAGATE_WINDING_NUMBERS_H
  3. #include "../igl_inline.h"
  4. #include <Eigen/Core>
  5. #include <vector>
  6. // The following methods compute the winding number on each side of each facet
  7. // or patch of a 3D mesh. The input mesh is valid if it splits the ambient
  8. // space, R^3, into subspaces with constant integer winding numbers. That is
  9. // the input mesh should be closed and for each directed edge the number of
  10. // clockwise facing facets should equal the number of counterclockwise facing
  11. // facets.
  12. namespace igl {
  13. namespace cgal {
  14. // Compute winding number on each side of each patch. All patches must
  15. // be connected. The per-patch label partitions the patches into
  16. // different components, and winding number is computed for each
  17. // component. For example, ``patch_W(i, j*2)`` for ``i`` in [0, #P)
  18. // and ``j`` in [0, k) is the winding number on the positive side of
  19. // patch ``i`` with respect to component ``j``. Similarly,
  20. // ``patch_W(i, j*2+1)`` is the winding number on the negative side of
  21. // patch ``i`` with respect to component ``j``.
  22. //
  23. // Patch and intersection curve can be generated using:
  24. // ``igl::extract_manifold_patches(...)`` and
  25. // ``igl::extract_non_manifold_edge_curves(...)``
  26. //
  27. //
  28. // Inputs:
  29. // V #V by 3 list of vertices.
  30. // F #F by 3 list of trianlges.
  31. // uE #uE by 2 list of undirected edges.
  32. // uE2E #uE list of lists mapping each undirected edge to directed
  33. // edges.
  34. // labels #P list of labels, ranging from 0 to k-1.
  35. // These labels partition patches into k components, and
  36. // winding number is computed for each component.
  37. // P #F list of patch indices.
  38. // intersection_curves A list of non-manifold curves that separates
  39. // the mesh into patches.
  40. //
  41. // Outputs:
  42. // patch_W #P by k*2 list of winding numbers on each side of a
  43. // patch for each component.
  44. //
  45. // Returns:
  46. // True iff integer winding numbers can be consistently assigned.
  47. template<
  48. typename DerivedV,
  49. typename DerivedF,
  50. typename DeriveduE,
  51. typename uE2EType,
  52. typename DerivedC,
  53. typename DerivedP,
  54. typename DerivedW >
  55. IGL_INLINE bool propagate_winding_numbers_single_component_patch_wise(
  56. const Eigen::PlainObjectBase<DerivedV>& V,
  57. const Eigen::PlainObjectBase<DerivedF>& F,
  58. const Eigen::PlainObjectBase<DeriveduE>& uE,
  59. const std::vector<std::vector<uE2EType> >& uE2E,
  60. const Eigen::PlainObjectBase<DerivedC>& labels,
  61. const Eigen::PlainObjectBase<DerivedP>& P,
  62. const std::vector<std::vector<size_t> >& intersection_curves,
  63. Eigen::PlainObjectBase<DerivedW>& patch_W);
  64. #if 0
  65. template<
  66. typename DerivedV,
  67. typename DerivedF,
  68. typename DeriveduE,
  69. typename uE2EType,
  70. typename DerivedEMAP,
  71. typename DerivedC,
  72. typename DerivedP,
  73. typename DerivedW >
  74. IGL_INLINE bool propagate_winding_numbers_single_component_patch_wise(
  75. const Eigen::PlainObjectBase<DerivedV>& V,
  76. const Eigen::PlainObjectBase<DerivedF>& F,
  77. const Eigen::PlainObjectBase<DeriveduE>& uE,
  78. const std::vector<std::vector<uE2EType> >& uE2E,
  79. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  80. const Eigen::PlainObjectBase<DerivedC>& labels,
  81. const Eigen::PlainObjectBase<DerivedP>& P,
  82. Eigen::PlainObjectBase<DerivedW>& patch_W);
  83. #endif
  84. // Compute winding number on each side of the face. The input mesh must
  85. // be a single edge-connected component.
  86. //
  87. // Inputs:
  88. // V #V by 3 list of vertex positions.
  89. // F #F by 3 list of triangle indices into V.
  90. // labels #F list of facet labels ranging from 0 to k-1.
  91. //
  92. // Output:
  93. // W #F by 2*k list of winding numbers.
  94. // ``W(i, 2*j)`` is the winding number on the positive side of
  95. // facet ``i`` with respect to facets labelled ``j``.
  96. // ``W(i, 2*j+1)`` is the winding number on the negative side of
  97. // facet ``i`` with respect to facets labelled ``j``.
  98. //
  99. // Returns:
  100. // True iff integer winding number can be consistently assigned.
  101. template<
  102. typename DerivedV,
  103. typename DerivedF,
  104. typename DerivedC,
  105. typename DerivedW>
  106. IGL_INLINE bool propagate_winding_numbers_single_component(
  107. const Eigen::PlainObjectBase<DerivedV>& V,
  108. const Eigen::PlainObjectBase<DerivedF>& F,
  109. const Eigen::PlainObjectBase<DerivedC>& labels,
  110. Eigen::PlainObjectBase<DerivedW>& W);
  111. // Compute the winding number on each side of the face.
  112. // This method assumes the input mesh (V, F) forms a single connected
  113. // component.
  114. //
  115. // Inputs:
  116. // V #V by 3 list of vertex positions.
  117. // F #F by 3 list of triangle indices into V.
  118. //
  119. // Output:
  120. // W #F by 2 list of winding numbers. W(i,0) is the winding number
  121. // on the positive side of facet i, and W(i, 1) is the winding
  122. // number on the negative side of facet I[i].
  123. //
  124. // Returns:
  125. // True iff integer winding number can be consistently assigned.
  126. template<
  127. typename DerivedV,
  128. typename DerivedF,
  129. typename DerivedW>
  130. IGL_INLINE bool propagate_winding_numbers_single_component(
  131. const Eigen::PlainObjectBase<DerivedV>& V,
  132. const Eigen::PlainObjectBase<DerivedF>& F,
  133. Eigen::PlainObjectBase<DerivedW>& W);
  134. // Compute winding number on each side of the face. The input mesh
  135. // could contain multiple connected components. The input mesh must
  136. // represent the boundary of a valid 3D volume, which means it is
  137. // closed, consistently oriented and induces integer winding numbers.
  138. //
  139. // Inputs:
  140. // V #V by 3 list of vertex positions.
  141. // F #F by 3 list of triangle indices into V.
  142. // labels #F list of facet labels ranging from 0 to k-1.
  143. //
  144. // Output:
  145. // W #F by k*2 list of winding numbers. ``W(i,j*2)`` is the winding
  146. // number on the positive side of facet ``i`` with respect to the
  147. // facets labeled ``j``. Similarly, ``W(i,j*2+1)`` is the winding
  148. // number on the negative side of facet ``i`` with respect to the
  149. // facets labeled ``j``.
  150. template<
  151. typename DerivedV,
  152. typename DerivedF,
  153. typename DerivedL,
  154. typename DerivedW>
  155. IGL_INLINE void propagate_winding_numbers(
  156. const Eigen::PlainObjectBase<DerivedV>& V,
  157. const Eigen::PlainObjectBase<DerivedF>& F,
  158. const Eigen::PlainObjectBase<DerivedL>& labels,
  159. Eigen::PlainObjectBase<DerivedW>& W);
  160. }
  161. }
  162. #ifndef IGL_STATIC_LIBRARY
  163. # include "propagate_winding_numbers.cpp"
  164. #endif
  165. #endif