readOFF.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_READOFF_H
  9. #define IGL_READOFF_H
  10. #include "igl_inline.h"
  11. // History:
  12. // return type changed from void to bool Alec 18 Sept 2011
  13. #ifndef IGL_NO_EIGEN
  14. # include <Eigen/Core>
  15. #endif
  16. #include <string>
  17. #include <vector>
  18. namespace igl
  19. {
  20. // Read a mesh from an ascii OFF file, filling in vertex positions, normals
  21. // and texture coordinates. Mesh may have faces of any number of degree
  22. //
  23. // Templates:
  24. // Scalar type for positions and vectors (will be read as double and cast
  25. // to Scalar)
  26. // Index type for indices (will be read as int and cast to Index)
  27. // Inputs:
  28. // str path to .obj file
  29. // Outputs:
  30. // V double matrix of vertex positions #V by 3
  31. // F #F list of face indices into vertex positions
  32. // N list of vertex normals #V by 3
  33. // C list of rgb color values per vertex #V by 3
  34. // Returns true on success, false on errors
  35. template <typename Scalar, typename Index>
  36. IGL_INLINE bool readOFF(
  37. const std::string off_file_name,
  38. std::vector<std::vector<Scalar > > & V,
  39. std::vector<std::vector<Index > > & F,
  40. std::vector<std::vector<Scalar > > & N,
  41. std::vector<std::vector<Scalar > > & C);
  42. #ifndef IGL_NO_EIGEN
  43. // read mesh from a ascii off file
  44. // Inputs:
  45. // str path to .off file
  46. // Outputs:
  47. // V eigen double matrix #V by 3
  48. // F eigen int matrix #F by 3
  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. template <typename DerivedV, typename DerivedF>
  55. IGL_INLINE bool readOFF(
  56. const std::string str,
  57. Eigen::PlainObjectBase<DerivedV>& V,
  58. Eigen::PlainObjectBase<DerivedF>& F,
  59. Eigen::PlainObjectBase<DerivedV>& N);
  60. #endif
  61. }
  62. #ifndef IGL_STATIC_LIBRARY
  63. # include "readOFF.cpp"
  64. #endif
  65. #endif