random_points_on_mesh_intrinsic.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_INTRINSIC_H
  9. #define IGL_RANDOM_POINTS_ON_MESH_INTRINSIC_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] dblA #F list of double areas of triangles
  20. /// @param[out] B n by 3 list of barycentric coordinates, ith row are coordinates of
  21. /// ith sampled point in face FI(i)
  22. /// @param[out] FI n list of indices into F
  23. /// @param[in,out] urbg An instance of UnformRandomBitGenerator.
  24. template <
  25. typename DeriveddblA,
  26. typename DerivedB,
  27. typename DerivedFI,
  28. typename URBG = DEFAULT_URBG>
  29. IGL_INLINE void random_points_on_mesh_intrinsic(
  30. const int n,
  31. const Eigen::MatrixBase<DeriveddblA > & dblA,
  32. Eigen::PlainObjectBase<DerivedB > & B,
  33. Eigen::PlainObjectBase<DerivedFI > & FI,
  34. URBG && urbg = igl::generate_default_urbg());
  35. /// \overload
  36. ///
  37. /// @param[in] num_vertices number of vertices in mesh
  38. /// @param[in] F #F by 3 list of mesh triangle indices
  39. /// @param[out] B n by num_vertices sparse matrix so that B*V produces a list
  40. /// of sample points if dbl = doublearea(V,F)
  41. ///
  42. template <
  43. typename DeriveddblA,
  44. typename DerivedF,
  45. typename ScalarB,
  46. typename DerivedFI,
  47. typename URBG>
  48. IGL_INLINE void random_points_on_mesh_intrinsic(
  49. const int n,
  50. const Eigen::MatrixBase<DeriveddblA > & dblA,
  51. const int num_vertices,
  52. const Eigen::MatrixBase<DerivedF> & F,
  53. Eigen::SparseMatrix<ScalarB > & B,
  54. Eigen::PlainObjectBase<DerivedFI > & FI,
  55. URBG && urbg);
  56. }
  57. #ifndef IGL_STATIC_LIBRARY
  58. # include "random_points_on_mesh_intrinsic.cpp"
  59. #endif
  60. #endif