random_points_on_mesh.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_RANDOM_POINTS_ON_MESH_H
  9. #define IGL_RANDOM_POINTS_ON_MESH_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. // RANDOM_POINTS_ON_MESH Randomly sample a mesh (V,F) n times.
  16. //
  17. // Inputs:
  18. // n number of samples
  19. // V #V by dim list of mesh vertex positions
  20. // F #F by 3 list of mesh triangle indices
  21. // Outputs:
  22. // B n by 3 list of barycentric coordinates, ith row are coordinates of
  23. // ith sampled point in face FI(i)
  24. // FI n list of indices into F
  25. //
  26. template <typename DerivedV, typename DerivedF, typename DerivedB, typename DerivedFI>
  27. IGL_INLINE void random_points_on_mesh(
  28. const int n,
  29. const Eigen::PlainObjectBase<DerivedV > & V,
  30. const Eigen::PlainObjectBase<DerivedF > & F,
  31. Eigen::PlainObjectBase<DerivedB > & B,
  32. Eigen::PlainObjectBase<DerivedFI > & FI);
  33. // Outputs:
  34. // B n by #V sparse matrix so that B*V produces a list of sample points
  35. template <typename DerivedV, typename DerivedF, typename ScalarB, typename DerivedFI>
  36. IGL_INLINE void random_points_on_mesh(
  37. const int n,
  38. const Eigen::PlainObjectBase<DerivedV > & V,
  39. const Eigen::PlainObjectBase<DerivedF > & F,
  40. Eigen::SparseMatrix<ScalarB > & B,
  41. Eigen::PlainObjectBase<DerivedFI > & FI);
  42. }
  43. #ifndef IGL_STATIC_LIBRARY
  44. # include "random_points_on_mesh.cpp"
  45. #endif
  46. #endif