vf.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef IGL_VF_H
  2. #define IGL_VF_H
  3. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  4. #include <Eigen/Dense>
  5. #include <Eigen/Sparse>
  6. namespace igl
  7. {
  8. // Constructs the vertex-face topology of a given mesh (V,F)
  9. // Inputs:
  10. // V #V by 3 list of vertex coordinates
  11. // F #F by dim list of mesh faces (must be triangles)
  12. // Outputs:
  13. //
  14. //
  15. // See also: edges, cotmatrix, diag, vv
  16. template <typename T, typename S>
  17. inline void vf(
  18. const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic> & V,
  19. const Eigen::MatrixXi & F,
  20. vector<vector<T> >& VF, vector<vector<T> >& VFi);
  21. }
  22. // Implementation
  23. #include "verbose.h"
  24. template <typename T, typename S>
  25. inline void igl::vf(
  26. const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic> & V,
  27. const Eigen::MatrixXi & F,
  28. vector<vector<T> >& VF, vector<vector<T> >& VFi)
  29. {
  30. VF.clear();
  31. VFi.clear();
  32. VF.resize(V.rows());
  33. VFi.resize(V.rows());
  34. for(int fi=0; fi<F.rows(); ++fi)
  35. {
  36. for(int i = 0; i < 3; ++i)
  37. {
  38. VF[F(fi,i)].push_back(fi);
  39. VFi[F(fi,i)].push_back(i);
  40. }
  41. }
  42. }
  43. #endif