propagate_winding_numbers.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. namespace copyleft
  22. {
  23. namespace cgal {
  24. // Compute winding number on each side of the face. The input mesh
  25. // could contain multiple connected components. The input mesh must
  26. // represent the boundary of a valid 3D volume, which means it is
  27. // closed, consistently oriented and induces integer winding numbers.
  28. //
  29. // Inputs:
  30. // V #V by 3 list of vertex positions.
  31. // F #F by 3 list of triangle indices into V.
  32. // labels #F list of facet labels ranging from 0 to k-1.
  33. //
  34. // Output:
  35. // W #F by k*2 list of winding numbers. ``W(i,j*2)`` is the winding
  36. // number on the positive side of facet ``i`` with respect to the
  37. // facets labeled ``j``. Similarly, ``W(i,j*2+1)`` is the winding
  38. // number on the negative side of facet ``i`` with respect to the
  39. // facets labeled ``j``.
  40. template<
  41. typename DerivedV,
  42. typename DerivedF,
  43. typename DerivedL,
  44. typename DerivedW>
  45. IGL_INLINE void propagate_winding_numbers(
  46. const Eigen::PlainObjectBase<DerivedV>& V,
  47. const Eigen::PlainObjectBase<DerivedF>& F,
  48. const Eigen::PlainObjectBase<DerivedL>& labels,
  49. Eigen::PlainObjectBase<DerivedW>& W);
  50. }
  51. }
  52. }
  53. #ifndef IGL_STATIC_LIBRARY
  54. # include "propagate_winding_numbers.cpp"
  55. #endif
  56. #endif