vf.h 1.1 KB

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