readPLY.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #include <cstdio>
  15. namespace igl
  16. {
  17. // Read a mesh from a .ply file.
  18. //
  19. // Inputs:
  20. // filename path to .ply file
  21. // Outputs:
  22. // V #V by 3 list of vertex positions
  23. // F #F list of lists of triangle indices
  24. // N #V by 3 list of vertex normals
  25. // UV #V by 2 list of vertex texture coordinates
  26. // Returns true iff success
  27. template <
  28. typename Vtype,
  29. typename Ftype,
  30. typename Ntype,
  31. typename UVtype>
  32. IGL_INLINE bool readPLY(
  33. const std::string filename,
  34. std::vector<std::vector<Vtype> > & V,
  35. std::vector<std::vector<Ftype> > & F,
  36. std::vector<std::vector<Ntype> > & N,
  37. std::vector<std::vector<UVtype> > & UV);
  38. template <
  39. typename Vtype,
  40. typename Ftype,
  41. typename Ntype,
  42. typename UVtype>
  43. // Inputs:
  44. // ply_file pointer to already opened .ply file
  45. // Outputs:
  46. // ply_file closed file
  47. IGL_INLINE bool readPLY(
  48. FILE * ply_file,
  49. std::vector<std::vector<Vtype> > & V,
  50. std::vector<std::vector<Ftype> > & F,
  51. std::vector<std::vector<Ntype> > & N,
  52. std::vector<std::vector<UVtype> > & UV);
  53. template <
  54. typename DerivedV,
  55. typename DerivedF,
  56. typename DerivedN,
  57. typename DerivedUV>
  58. IGL_INLINE bool readPLY(
  59. const std::string filename,
  60. Eigen::PlainObjectBase<DerivedV> & V,
  61. Eigen::PlainObjectBase<DerivedF> & F,
  62. Eigen::PlainObjectBase<DerivedN> & N,
  63. Eigen::PlainObjectBase<DerivedUV> & UV);
  64. template <
  65. typename DerivedV,
  66. typename DerivedF>
  67. IGL_INLINE bool readPLY(
  68. const std::string filename,
  69. Eigen::PlainObjectBase<DerivedV> & V,
  70. Eigen::PlainObjectBase<DerivedF> & F);
  71. }
  72. #ifndef IGL_STATIC_LIBRARY
  73. # include "readPLY.cpp"
  74. #endif
  75. #endif