winding_number.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <alecjacobson@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. #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. // WINDING_NUMBER Compute the sum of solid angles of a triangle/tetrahedron
  19. // described by points (vectors) V
  20. //
  21. // Templates:
  22. // dim dimension of input
  23. // Inputs:
  24. // V n by 3 list of vertex positions
  25. // F #F by 3 list of triangle indices, minimum index is 0
  26. // O no by 3 list of origin positions
  27. // Outputs:
  28. // S no by 1 list of winding numbers
  29. //
  30. // 3d
  31. IGL_INLINE void winding_number(
  32. const Eigen::MatrixXd & V,
  33. const Eigen::MatrixXi & F,
  34. const Eigen::MatrixXd & O,
  35. Eigen::VectorXd & W);
  36. // Inputs:
  37. // V pointer to array containing #V by 3 vertex positions along rows,
  38. // given in column major order
  39. // n number of mesh vertices
  40. // F pointer to array containing #F by 3 face indices along rows,
  41. // given in column major order
  42. // m number of faces
  43. // O pointer to array containing #O by 3 query positions along rows,
  44. // given in column major order
  45. // no number of origins
  46. // Outputs:
  47. // S no by 1 list of winding numbers
  48. template <typename Scalar, typename DerivedF>
  49. IGL_INLINE void winding_number_3(
  50. const Scalar * V,
  51. const int n,
  52. const DerivedF * F,
  53. const int m,
  54. const Scalar * O,
  55. const int no,
  56. Scalar * S);
  57. //// Only one evaluation origin
  58. //template <typename DerivedF>
  59. //IGL_INLINE void winding_number_3(
  60. // const double * V,
  61. // const int n,
  62. // const DerivedF * F,
  63. // const int m,
  64. // const double * O,
  65. // double * S);
  66. // 2d
  67. template <typename DerivedF>
  68. IGL_INLINE void winding_number_2(
  69. const double * V,
  70. const int n,
  71. const DerivedF * F,
  72. const int m,
  73. const double * O,
  74. const int no,
  75. double * S);
  76. }
  77. #ifndef IGL_STATIC_LIBRARY
  78. # include "winding_number.cpp"
  79. #endif
  80. #endif