random_points_on_mesh.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 #V list of barycentric coordinates such that each row i has
  23. // three nonzero entries hoding barycentric corridinates of the point.
  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. template <typename DerivedV, typename DerivedF, typename ScalarB, typename DerivedFI>
  34. IGL_INLINE void random_points_on_mesh(
  35. const int n,
  36. const Eigen::PlainObjectBase<DerivedV > & V,
  37. const Eigen::PlainObjectBase<DerivedF > & F,
  38. Eigen::SparseMatrix<ScalarB > & B,
  39. Eigen::PlainObjectBase<DerivedFI > & FI);
  40. }
  41. #ifndef IGL_STATIC_LIBRARY
  42. # include "random_points_on_mesh.cpp"
  43. #endif
  44. #endif