readPLY.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 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_READPLY_H
  9. #define IGL_READPLY_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <string>
  13. #include <vector>
  14. namespace igl
  15. {
  16. // Read a mesh from a .ply file.
  17. //
  18. // Inputs:
  19. // filename path to .ply file
  20. // Outputs:
  21. // V #V by 3 list of vertex positions
  22. // F #F list of lists of triangle indices
  23. // N #V by 3 list of vertex normals
  24. // UV #V by 2 list of vertex texture coordinates
  25. // Returns true iff success
  26. template <
  27. typename Vtype,
  28. typename Ftype,
  29. typename Ntype,
  30. typename UVtype>
  31. IGL_INLINE bool readPLY(
  32. const std::string & filename,
  33. std::vector<std::vector<Vtype> > & V,
  34. std::vector<std::vector<Ftype> > & F,
  35. std::vector<std::vector<Ntype> > & N,
  36. std::vector<std::vector<UVtype> > & UV);
  37. template <
  38. typename DerivedV,
  39. typename DerivedF,
  40. typename DerivedN,
  41. typename DerivedUV>
  42. IGL_INLINE bool readPLY(
  43. const std::string & filename,
  44. Eigen::PlainObjectBase<DerivedV> & V,
  45. Eigen::PlainObjectBase<DerivedF> & F,
  46. Eigen::PlainObjectBase<DerivedN> & N,
  47. Eigen::PlainObjectBase<DerivedUV> & UV);
  48. template <
  49. typename DerivedV,
  50. typename DerivedF>
  51. IGL_INLINE bool readPLY(
  52. const std::string & filename,
  53. Eigen::PlainObjectBase<DerivedV> & V,
  54. Eigen::PlainObjectBase<DerivedF> & F);
  55. }
  56. #ifndef IGL_STATIC_LIBRARY
  57. # include "readPLY.cpp"
  58. #endif
  59. #endif