read.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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_READ_H
  9. #define IGL_READ_H
  10. #include "igl_inline.h"
  11. #ifndef IGL_NO_EIGEN
  12. # include <Eigen/Core>
  13. #endif
  14. #include <string>
  15. #include <vector>
  16. // History:
  17. // return type changed from void to bool Alec 18 Sept 2011
  18. namespace igl
  19. {
  20. // read mesh from an ascii file with automatic detection of file format. supported: obj, off)
  21. // Templates:
  22. // Scalar type for positions and vectors (will be read as double and cast
  23. // to Scalar)
  24. // Index type for indices (will be read as int and cast to Index)
  25. // Inputs:
  26. // Inputs:
  27. // str path to .obj/.off file
  28. // Outputs:
  29. // V eigen double matrix #V by 3
  30. // F eigen int matrix #F by 3
  31. template <typename Scalar, typename Index>
  32. IGL_INLINE bool read(
  33. const std::string str,
  34. std::vector<std::vector<Scalar> > & V,
  35. std::vector<std::vector<Index> > & F);
  36. #ifndef IGL_NO_EIGEN
  37. template <typename DerivedV, typename DerivedF>
  38. IGL_INLINE bool read(
  39. const std::string str,
  40. Eigen::PlainObjectBase<DerivedV>& V,
  41. Eigen::PlainObjectBase<DerivedF>& F);
  42. #endif
  43. }
  44. #ifdef IGL_HEADER_ONLY
  45. # include "read.cpp"
  46. #endif
  47. #endif