read_triangle_mesh.h 1.6 KB

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