readOFF.h 1.8 KB

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