readOFF.h 2.2 KB

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