read_triangle_mesh.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. // Returns true iff success
  34. template <typename Scalar, typename Index>
  35. IGL_INLINE bool read_triangle_mesh(
  36. const std::string str,
  37. std::vector<std::vector<Scalar> > & V,
  38. std::vector<std::vector<Index> > & F);
  39. #ifndef IGL_NO_EIGEN
  40. template <typename DerivedV, typename DerivedF>
  41. IGL_INLINE bool read_triangle_mesh(
  42. const std::string str,
  43. Eigen::PlainObjectBase<DerivedV>& V,
  44. Eigen::PlainObjectBase<DerivedF>& F);
  45. // Outputs:
  46. // dir directory path (see pathinfo.h)
  47. // base base name (see pathinfo.h)
  48. // ext extension (see pathinfo.h)
  49. // name filename (see pathinfo.h)
  50. template <typename DerivedV, typename DerivedF>
  51. IGL_INLINE bool read_triangle_mesh(
  52. const std::string str,
  53. Eigen::PlainObjectBase<DerivedV>& V,
  54. Eigen::PlainObjectBase<DerivedF>& F,
  55. std::string & dir,
  56. std::string & base,
  57. std::string & ext,
  58. std::string & name);
  59. #endif
  60. }
  61. #ifndef IGL_STATIC_LIBRARY
  62. # include "read_triangle_mesh.cpp"
  63. #endif
  64. #endif