winding_number.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <[email protected]>
  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. #ifndef IGL_WINDING_NUMBER_H
  9. #define IGL_WINDING_NUMBER_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. // Minimum number of iterms per openmp thread
  13. #ifndef IGL_WINDING_NUMBER_OMP_MIN_VALUE
  14. # define IGL_WINDING_NUMBER_OMP_MIN_VALUE 1000
  15. #endif
  16. namespace igl
  17. {
  18. /// Computes the generalized winding number at each
  19. /// dim-dimensional query point in O with respect to the oriented
  20. /// one-codimensional mesh (V,F). This is equivalent to summing the subtended
  21. /// signed angles/solid angles of each element in (V,F). See, "Robust
  22. /// Inside-Outside Segmentation using Generalized Winding Numbers" [Jacobson et
  23. /// al. 2013].
  24. ///
  25. ///
  26. /// @param[in] V #V by dim list of mesh vertex positions
  27. /// @param[in] F #F by dim list of mesh facets as indices into rows of V. If dim==2,
  28. /// then (V,F) describes a set of edges in the plane. If dim==3, then (V,F)
  29. /// describes a triangle mesh/soup.
  30. /// @param[in] O #O by dim list of query points
  31. /// @param[out] W #O by 1 list of winding numbers
  32. ///
  33. /// \see fast_winding_number
  34. ///
  35. template <
  36. typename DerivedV,
  37. typename DerivedF,
  38. typename DerivedO,
  39. typename DerivedW>
  40. IGL_INLINE void winding_number(
  41. const Eigen::MatrixBase<DerivedV> & V,
  42. const Eigen::MatrixBase<DerivedF> & F,
  43. const Eigen::MatrixBase<DerivedO> & O,
  44. Eigen::PlainObjectBase<DerivedW> & W);
  45. /// Compute winding number of a single point
  46. ///
  47. /// @param[in] V n by dim list of vertex positions
  48. /// @param[in] F #F by dim list of triangle indices, minimum index is 0
  49. /// @param[in] p single origin position
  50. /// @param[out] w winding number of this point
  51. ///
  52. template <
  53. typename DerivedV,
  54. typename DerivedF,
  55. typename Derivedp>
  56. IGL_INLINE typename DerivedV::Scalar winding_number(
  57. const Eigen::MatrixBase<DerivedV> & V,
  58. const Eigen::MatrixBase<DerivedF> & F,
  59. const Eigen::MatrixBase<Derivedp> & p);
  60. }
  61. #ifndef IGL_STATIC_LIBRARY
  62. # include "winding_number.cpp"
  63. #endif
  64. #endif