random_points_on_mesh.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_RANDOM_POINTS_ON_MESH_H
  9. #define IGL_RANDOM_POINTS_ON_MESH_H
  10. #include "igl_inline.h"
  11. #include "generate_default_urbg.h"
  12. #include <Eigen/Core>
  13. #include <Eigen/Sparse>
  14. namespace igl
  15. {
  16. /// Randomly sample a mesh (V,F) n times.
  17. ///
  18. /// @param[in] n number of samples
  19. /// @param[in] V #V by dim list of mesh vertex positions
  20. /// @param[in] F #F by 3 list of mesh triangle indices
  21. /// @param[out] B n by 3 list of barycentric coordinates, ith row are coordinates of
  22. /// ith sampled point in face FI(i)
  23. /// @param[in] urbg An instance of UnformRandomBitGenerator (e.g.,
  24. /// `std::minstd_rand(0)`)
  25. /// @param[out] FI n list of indices into F
  26. /// @param[in,out] urbg An instance of UnformRandomBitGenerator.
  27. /// @param[out] X n by dim list of sample positions.
  28. template <
  29. typename DerivedV,
  30. typename DerivedF,
  31. typename DerivedB,
  32. typename DerivedFI,
  33. typename DerivedX,
  34. typename URBG = DEFAULT_URBG>
  35. IGL_INLINE void random_points_on_mesh(
  36. const int n,
  37. const Eigen::MatrixBase<DerivedV > & V,
  38. const Eigen::MatrixBase<DerivedF > & F,
  39. Eigen::PlainObjectBase<DerivedB > & B,
  40. Eigen::PlainObjectBase<DerivedFI > & FI,
  41. Eigen::PlainObjectBase<DerivedX> & X,
  42. URBG && urbg = igl::generate_default_urbg());
  43. }
  44. #ifndef IGL_STATIC_LIBRARY
  45. # include "random_points_on_mesh.cpp"
  46. #endif
  47. #endif