readOFF.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef IGL_READOFF_H
  2. #define IGL_READOFF_H
  3. #include "igl_inline.h"
  4. // History:
  5. // return type changed from void to bool Alec 18 Sept 2011
  6. #ifndef IGL_NO_EIGEN
  7. # include <Eigen/Core>
  8. #endif
  9. #include <string>
  10. #include <vector>
  11. namespace igl
  12. {
  13. // Read a mesh from an ascii obj file, filling in vertex positions, normals
  14. // and texture coordinates. Mesh may have faces of any number of degree
  15. //
  16. // Templates:
  17. // Scalar type for positions and vectors (will be read as double and cast
  18. // to Scalar)
  19. // Index type for indices (will be read as int and cast to Index)
  20. // Inputs:
  21. // str path to .obj file
  22. // Outputs:
  23. // V double matrix of vertex positions #V by 3
  24. // F #F list of face indices into vertex positions
  25. // TC double matrix of texture coordinats #TC by 2
  26. // FTC #F list of face indices into vertex texture coordinates
  27. // N double matrix of corner normals #N by 3
  28. // FN #F list of face indices into vertex normals
  29. // Returns true on success, false on errors
  30. template <typename Scalar, typename Index>
  31. IGL_INLINE bool readOFF(
  32. const std::string off_file_name,
  33. std::vector<std::vector<Scalar > > & V,
  34. std::vector<std::vector<Index > > & F,
  35. std::vector<std::vector<Scalar > > & N);
  36. #ifndef IGL_NO_EIGEN
  37. // read mesh from a ascii off file
  38. // Inputs:
  39. // str path to .off file
  40. // Outputs:
  41. // V eigen double matrix #V by 3
  42. // F eigen int matrix #F by 3
  43. template <typename DerivedV, typename DerivedF>
  44. IGL_INLINE bool readOFF(
  45. const std::string str,
  46. Eigen::PlainObjectBase<DerivedV>& V,
  47. Eigen::PlainObjectBase<DerivedF>& F);
  48. template <typename DerivedV, typename DerivedF>
  49. IGL_INLINE bool readOFF(
  50. const std::string str,
  51. Eigen::PlainObjectBase<DerivedV>& V,
  52. Eigen::PlainObjectBase<DerivedF>& F,
  53. Eigen::PlainObjectBase<DerivedV>& N);
  54. #endif
  55. }
  56. #ifdef IGL_HEADER_ONLY
  57. # include "readOFF.cpp"
  58. #endif
  59. #endif