read_triangle_mesh.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.
  22. // supported: obj, off, stl, wrl, ply, mesh)
  23. //
  24. // Templates:
  25. // Scalar type for positions and vectors (will be read as double and cast
  26. // to Scalar)
  27. // Index type for indices (will be read as int and cast to Index)
  28. // Inputs:
  29. // str path to file
  30. // Outputs:
  31. // V eigen double matrix #V by 3
  32. // F eigen int matrix #F by 3
  33. template <typename Scalar, typename Index>
  34. IGL_INLINE bool read_triangle_mesh(
  35. const std::string str,
  36. std::vector<std::vector<Scalar> > & V,
  37. std::vector<std::vector<Index> > & F);
  38. #ifndef IGL_NO_EIGEN
  39. template <typename DerivedV, typename DerivedF>
  40. IGL_INLINE bool read_triangle_mesh(
  41. const std::string str,
  42. Eigen::PlainObjectBase<DerivedV>& V,
  43. Eigen::PlainObjectBase<DerivedF>& F);
  44. // Outputs:
  45. // dir directory path (see pathinfo.h)
  46. // base base name (see pathinfo.h)
  47. // ext extension (see pathinfo.h)
  48. // name filename (see pathinfo.h)
  49. template <typename DerivedV, typename DerivedF>
  50. IGL_INLINE bool read_triangle_mesh(
  51. const std::string str,
  52. Eigen::PlainObjectBase<DerivedV>& V,
  53. Eigen::PlainObjectBase<DerivedF>& F,
  54. std::string & dir,
  55. std::string & base,
  56. std::string & ext,
  57. std::string & name);
  58. #endif
  59. }
  60. #ifndef IGL_STATIC_LIBRARY
  61. # include "read_triangle_mesh.cpp"
  62. #endif
  63. #endif