fast_winding_number.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef IGL_FAST_WINDING_NUMBER
  2. #define IGL_FAST_WINDING_NUMBER
  3. #include "igl_inline.h"
  4. #include <Eigen/Core>
  5. #include <vector>
  6. namespace igl
  7. {
  8. // Generate the precomputation for the fast winding number for point data
  9. // [Barill et. al 2018].
  10. //
  11. // Given a set of 3D points P, with normals N, areas A, along with octree
  12. // data, and an expansion order, we define a taylor series expansion at each
  13. // octree cell.
  14. //
  15. // The octree data is designed to come from igl::octree, and the areas
  16. // (if not obtained at scan time), may be calculated using
  17. // igl::copyleft::cgal::point_areas.
  18. //
  19. // Inputs:
  20. // P #P by 3 list of point locations
  21. // N #P by 3 list of point normals
  22. // A #P by 1 list of point areas
  23. // point_indices a vector of vectors, where the ith entry is a vector of
  24. // the indices into P that are the ith octree cell's points
  25. // CH #OctreeCells by 8, where the ith row is the indices of
  26. // the ith octree cell's children
  27. // expansion_order the order of the taylor expansion. We support 0,1,2.
  28. // Outputs:
  29. // CM #OctreeCells by 3 list of each cell's center of mass
  30. // R #OctreeCells by 1 list of each cell's maximum distance of any point
  31. // to the center of mass
  32. // EC #OctreeCells by #TaylorCoefficients list of expansion coefficients.
  33. // (Note that #TaylorCoefficients = ∑_{i=1}^{expansion_order} 3^i)
  34. //
  35. template <typename DerivedP, typename DerivedA, typename DerivedN,
  36. typename Index, typename DerivedCH, typename DerivedCM, typename DerivedR,
  37. typename DerivedEC>
  38. IGL_INLINE void fast_winding_number(const Eigen::MatrixBase<DerivedP>& P,
  39. const Eigen::MatrixBase<DerivedN>& N,
  40. const Eigen::MatrixBase<DerivedA>& A,
  41. const std::vector<std::vector<Index> > & point_indices,
  42. const Eigen::MatrixBase<DerivedCH>& CH,
  43. const int expansion_order,
  44. Eigen::PlainObjectBase<DerivedCM>& CM,
  45. Eigen::PlainObjectBase<DerivedR>& R,
  46. Eigen::PlainObjectBase<DerivedEC>& EC);
  47. // Evaluate the fast winding number for point data, having already done the
  48. // the precomputation
  49. //
  50. // Inputs:
  51. // P #P by 3 list of point locations
  52. // N #P by 3 list of point normals
  53. // A #P by 1 list of point areas
  54. // point_indices a vector of vectors, where the ith entry is a vector of
  55. // the indices into P that are the ith octree cell's points
  56. // CH #OctreeCells by 8, where the ith row is the indices of
  57. // the ith octree cell's children
  58. // CM #OctreeCells by 3 list of each cell's center of mass
  59. // R #OctreeCells by 1 list of each cell's maximum distance of any point
  60. // to the center of mass
  61. // EC #OctreeCells by #TaylorCoefficients list of expansion coefficients.
  62. // (Note that #TaylorCoefficients = ∑_{i=1}^{expansion_order} 3^i)
  63. // Q #Q by 3 list of query points for the winding number
  64. // beta This is a Barnes-Hut style accuracy term that separates near feild
  65. // from far field. The higher the beta, the more accurate and slower
  66. // the evaluation. We reccommend using a beta value of 2. Note that
  67. // for a beta value ≤ 0, we use the direct evaluation, rather than
  68. // the fast approximation
  69. // Outputs:
  70. // WN #Q by 1 list of windinng number values at each query point
  71. //
  72. template <typename DerivedP, typename DerivedA, typename DerivedN,
  73. typename Index, typename DerivedCH, typename DerivedCM, typename DerivedR,
  74. typename DerivedEC, typename DerivedQ, typename BetaType,
  75. typename DerivedWN>
  76. IGL_INLINE void fast_winding_number(const Eigen::MatrixBase<DerivedP>& P,
  77. const Eigen::MatrixBase<DerivedN>& N,
  78. const Eigen::MatrixBase<DerivedA>& A,
  79. const std::vector<std::vector<Index> > & point_indices,
  80. const Eigen::MatrixBase<DerivedCH>& CH,
  81. const Eigen::MatrixBase<DerivedCM>& CM,
  82. const Eigen::MatrixBase<DerivedR>& R,
  83. const Eigen::MatrixBase<DerivedEC>& EC,
  84. const Eigen::MatrixBase<DerivedQ>& Q,
  85. const BetaType beta,
  86. Eigen::PlainObjectBase<DerivedWN>& WN);
  87. // Evaluate the fast winding number for point data, with default expansion
  88. // order and beta (both are set to 2).
  89. //
  90. // This function performes the precomputation and evaluation all in one.
  91. // If you need to acess the precomuptation for repeated evaluations, use the
  92. // two functions designed for exposed precomputation (described above).
  93. //
  94. // Inputs:
  95. // P #P by 3 list of point locations
  96. // N #P by 3 list of point normals
  97. // A #P by 1 list of point areas
  98. // Q #Q by 3 list of query points for the winding number
  99. // Outputs:
  100. // WN #Q by 1 list of windinng number values at each query point
  101. //
  102. template <typename DerivedP, typename DerivedA, typename DerivedN,
  103. typename DerivedQ, typename DerivedWN>
  104. IGL_INLINE void fast_winding_number(const Eigen::MatrixBase<DerivedP>& P,
  105. const Eigen::MatrixBase<DerivedN>& N,
  106. const Eigen::MatrixBase<DerivedA>& A,
  107. const Eigen::MatrixBase<DerivedQ>& Q,
  108. Eigen::PlainObjectBase<DerivedWN>& WN
  109. );
  110. }
  111. #ifndef IGL_STATIC_LIBRARY
  112. # include "fast_winding_number.cpp"
  113. #endif
  114. #endif