readOFF.h 2.0 KB

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