propagate_winding_numbers.h 2.3 KB

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