propagate_winding_numbers.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. }
  58. }
  59. }
  60. #ifndef IGL_STATIC_LIBRARY
  61. # include "propagate_winding_numbers.cpp"
  62. #endif
  63. #endif