propagate_winding_numbers.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. // Compute winding number on each side of the face. The input mesh must
  65. // be a single edge-connected component.
  66. //
  67. // Inputs:
  68. // V #V by 3 list of vertex positions.
  69. // F #F by 3 list of triangle indices into V.
  70. // labels #F list of facet labels ranging from 0 to k-1.
  71. //
  72. // Output:
  73. // W #F by 2*k list of winding numbers.
  74. // ``W(i, 2*j)`` is the winding number on the positive side of
  75. // facet ``i`` with respect to facets labelled ``j``.
  76. // ``W(i, 2*j+1)`` is the winding number on the negative side of
  77. // facet ``i`` with respect to facets labelled ``j``.
  78. //
  79. // Returns:
  80. // True iff integer winding number can be consistently assigned.
  81. template<
  82. typename DerivedV,
  83. typename DerivedF,
  84. typename DerivedC,
  85. typename DerivedW>
  86. IGL_INLINE bool propagate_winding_numbers_single_component(
  87. const Eigen::PlainObjectBase<DerivedV>& V,
  88. const Eigen::PlainObjectBase<DerivedF>& F,
  89. const Eigen::PlainObjectBase<DerivedC>& labels,
  90. Eigen::PlainObjectBase<DerivedW>& W);
  91. // Compute the winding number on each side of the face.
  92. // This method assumes the input mesh (V, F) forms a single connected
  93. // component.
  94. //
  95. // Inputs:
  96. // V #V by 3 list of vertex positions.
  97. // F #F by 3 list of triangle indices into V.
  98. //
  99. // Output:
  100. // W #F by 2 list of winding numbers. W(i,0) is the winding number
  101. // on the positive side of facet i, and W(i, 1) is the winding
  102. // number on the negative side of facet I[i].
  103. //
  104. // Returns:
  105. // True iff integer winding number can be consistently assigned.
  106. template<
  107. typename DerivedV,
  108. typename DerivedF,
  109. typename DerivedW>
  110. IGL_INLINE bool propagate_winding_numbers_single_component(
  111. const Eigen::PlainObjectBase<DerivedV>& V,
  112. const Eigen::PlainObjectBase<DerivedF>& F,
  113. Eigen::PlainObjectBase<DerivedW>& W);
  114. // Compute winding number on each side of the face. The input mesh
  115. // could contain multiple connected components. The input mesh must
  116. // represent the boundary of a valid 3D volume, which means it is
  117. // closed, consistently oriented and induces integer winding numbers.
  118. //
  119. // Inputs:
  120. // V #V by 3 list of vertex positions.
  121. // F #F by 3 list of triangle indices into V.
  122. // labels #F list of facet labels ranging from 0 to k-1.
  123. //
  124. // Output:
  125. // W #F by k*2 list of winding numbers. ``W(i,j*2)`` is the winding
  126. // number on the positive side of facet ``i`` with respect to the
  127. // facets labeled ``j``. Similarly, ``W(i,j*2+1)`` is the winding
  128. // number on the negative side of facet ``i`` with respect to the
  129. // facets labeled ``j``.
  130. template<
  131. typename DerivedV,
  132. typename DerivedF,
  133. typename DerivedL,
  134. typename DerivedW>
  135. IGL_INLINE void propagate_winding_numbers(
  136. const Eigen::PlainObjectBase<DerivedV>& V,
  137. const Eigen::PlainObjectBase<DerivedF>& F,
  138. const Eigen::PlainObjectBase<DerivedL>& labels,
  139. Eigen::PlainObjectBase<DerivedW>& W);
  140. }
  141. }
  142. #ifndef IGL_STATIC_LIBRARY
  143. # include "propagate_winding_numbers.cpp"
  144. #endif
  145. #endif