blue_noise.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2020 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_BLUE_NOISE_H
  9. #define IGL_BLUE_NOISE_H
  10. #include "igl_inline.h"
  11. #include "generate_default_urbg.h"
  12. #include <Eigen/Core>
  13. namespace igl
  14. {
  15. /// "Fast Poisson Disk Sampling in Arbitrary Dimensions" [Bridson 2007].
  16. ///
  17. /// For very dense samplings this is faster than (up to 2x) cyCodeBase's
  18. /// implementation of "Sample Elimination for Generating Poisson Disk Sample
  19. /// Sets" [Yuksel 2015]. YMMV
  20. ///
  21. /// @param[in] V #V by dim list of mesh vertex positions
  22. /// @param[in] F #F by 3 list of mesh triangle indices into rows of V
  23. /// @param[in] r Poisson disk radius (evaluated according to Euclidean distance on V)
  24. /// @param[out] B #P by 3 list of barycentric coordinates, ith row are coordinates of
  25. /// ith sampled point in face FI(i)
  26. /// @param[out] FI #P list of indices into F
  27. /// @param[out] P #P by dim list of sample positions.
  28. /// @param[in,out] urbg An instance of UnformRandomBitGenerator (e.g.,
  29. /// `std::minstd_rand(0)`)
  30. /// \see random_points_on_mesh
  31. template <
  32. typename DerivedV,
  33. typename DerivedF,
  34. typename DerivedB,
  35. typename DerivedFI,
  36. typename DerivedP,
  37. typename URBG = DEFAULT_URBG
  38. >
  39. IGL_INLINE void blue_noise(
  40. const Eigen::MatrixBase<DerivedV> & V,
  41. const Eigen::MatrixBase<DerivedF> & F,
  42. const typename DerivedV::Scalar r,
  43. Eigen::PlainObjectBase<DerivedB> & B,
  44. Eigen::PlainObjectBase<DerivedFI> & FI,
  45. Eigen::PlainObjectBase<DerivedP> & P,
  46. URBG && urbg = igl::generate_default_urbg());
  47. }
  48. #ifndef IGL_STATIC_LIBRARY
  49. # include "blue_noise.cpp"
  50. #endif
  51. #endif