propagate_winding_numbers.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Qingnan Zhou <qnzhou@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. //
  9. #ifndef IGL_COPYLEFT_CGAL_PROPAGATE_WINDING_NUMBERS_H
  10. #define IGL_COPYLEFT_CGAL_PROPAGATE_WINDING_NUMBERS_H
  11. #include "../../igl_inline.h"
  12. #include <Eigen/Core>
  13. #include <vector>
  14. // The following methods compute the winding number on each side of each facet
  15. // or patch of a 3D mesh. The input mesh is valid if it splits the ambient
  16. // space, R^3, into subspaces with constant integer winding numbers. That is
  17. // the input mesh should be closed and for each directed edge the number of
  18. // clockwise facing facets should equal the number of counterclockwise facing
  19. // facets.
  20. namespace igl
  21. {
  22. namespace copyleft
  23. {
  24. namespace cgal
  25. {
  26. // TODO: This shouldn't need to be in igl::copyleft::cgal, it should
  27. // instead take as input an index of the ambient cell and the winding
  28. // number vector there.
  29. //
  30. // Compute winding number on each side of the face. The input mesh
  31. // could contain multiple connected components. The input mesh must
  32. // represent the boundary of a valid 3D volume, which means it is
  33. // closed, consistently oriented and induces integer winding numbers.
  34. //
  35. // Inputs:
  36. // V #V by 3 list of vertex positions.
  37. // F #F by 3 list of triangle indices into V.
  38. // labels #F list of facet labels ranging from 0 to k-1.
  39. // Output:
  40. // W #F by k*2 list of winding numbers. ``W(i,j*2)`` is the winding
  41. // number on the positive side of facet ``i`` with respect to the
  42. // facets labeled ``j``. Similarly, ``W(i,j*2+1)`` is the winding
  43. // number on the negative side of facet ``i`` with respect to the
  44. // facets labeled ``j``.
  45. // Returns true iff the input induces a piecewise-constant winding number
  46. // field.
  47. template<
  48. typename DerivedV,
  49. typename DerivedF,
  50. typename DerivedL,
  51. typename DerivedW>
  52. IGL_INLINE bool propagate_winding_numbers(
  53. const Eigen::PlainObjectBase<DerivedV>& V,
  54. const Eigen::PlainObjectBase<DerivedF>& F,
  55. const Eigen::PlainObjectBase<DerivedL>& labels,
  56. Eigen::PlainObjectBase<DerivedW>& W);
  57. // Inputs:
  58. // V #V by 3 list of vertex positions.
  59. // F #F by 3 list of triangle indices into V.
  60. // uE #uE by 2 list of vertex_indices, represents undirected edges.
  61. // uE2E #uE list of lists that maps uE to E. (a one-to-many map)
  62. // num_patches number of patches
  63. // P #F list of patch ids.
  64. // num_cells number of cells
  65. // C #P by 2 list of cell ids on each side of each patch.
  66. // labels #F list of facet labels ranging from 0 to k-1.
  67. // Output:
  68. // W #F by k*2 list of winding numbers. ``W(i,j*2)`` is the winding
  69. // number on the positive side of facet ``i`` with respect to the
  70. // facets labeled ``j``. Similarly, ``W(i,j*2+1)`` is the winding
  71. // number on the negative side of facet ``i`` with respect to the
  72. // facets labeled ``j``.
  73. template<
  74. typename DerivedV,
  75. typename DerivedF,
  76. typename DeriveduE,
  77. typename uE2EType,
  78. typename DerivedP,
  79. typename DerivedC,
  80. typename DerivedL,
  81. typename DerivedW>
  82. IGL_INLINE bool propagate_winding_numbers(
  83. const Eigen::PlainObjectBase<DerivedV>& V,
  84. const Eigen::PlainObjectBase<DerivedF>& F,
  85. const Eigen::PlainObjectBase<DeriveduE>& uE,
  86. const std::vector<std::vector<uE2EType> >& uE2E,
  87. const size_t num_patches,
  88. const Eigen::PlainObjectBase<DerivedP>& P,
  89. const size_t num_cells,
  90. const Eigen::PlainObjectBase<DerivedC>& C,
  91. const Eigen::PlainObjectBase<DerivedL>& labels,
  92. Eigen::PlainObjectBase<DerivedW>& W);
  93. }
  94. }
  95. }
  96. #ifndef IGL_STATIC_LIBRARY
  97. # include "propagate_winding_numbers.cpp"
  98. #endif
  99. #endif