read_triangle_mesh.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. // 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_triangle_mesh(
  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_triangle_mesh(
  39. const std::string str,
  40. Eigen::PlainObjectBase<DerivedV>& V,
  41. Eigen::PlainObjectBase<DerivedF>& F);
  42. // Outputs:
  43. // dir directory path (see pathinfo.h)
  44. // base base name (see pathinfo.h)
  45. // ext extension (see pathinfo.h)
  46. // name filename (see pathinfo.h)
  47. template <typename DerivedV, typename DerivedF>
  48. IGL_INLINE bool read_triangle_mesh(
  49. const std::string str,
  50. Eigen::PlainObjectBase<DerivedV>& V,
  51. Eigen::PlainObjectBase<DerivedF>& F,
  52. std::string & dir,
  53. std::string & base,
  54. std::string & ext,
  55. std::string & name);
  56. #endif
  57. }
  58. #ifndef IGL_STATIC_LIBRARY
  59. # include "read_triangle_mesh.cpp"
  60. #endif
  61. #endif