readWRL.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_READWRL_H
  9. #define IGL_READWRL_H
  10. #include "igl_inline.h"
  11. #include <string>
  12. #include <vector>
  13. #include <cstdio>
  14. namespace igl
  15. {
  16. // Read a mesh from an ascii wrl file, filling in vertex positions and face
  17. // indices of the first model. Mesh may have faces of any number of degree
  18. //
  19. // Templates:
  20. // Scalar type for positions and vectors (will be read as double and cast
  21. // to Scalar)
  22. // Index type for indices (will be read as int and cast to Index)
  23. // Inputs:
  24. // str path to .wrl file
  25. // Outputs:
  26. // V double matrix of vertex positions #V by 3
  27. // F #F list of face indices into vertex positions
  28. // Returns true on success, false on errors
  29. template <typename Scalar, typename Index>
  30. IGL_INLINE bool readWRL(
  31. const std::string wrl_file_name,
  32. std::vector<std::vector<Scalar > > & V,
  33. std::vector<std::vector<Index > > & F,
  34. std::vector<std::vector<Scalar > > & TC,
  35. std::vector<std::vector<Index > > & TexCoordIndex);
  36. // Inputs:
  37. // wrl_file pointer to already opened .wrl file
  38. // Outputs:
  39. // wrl_file closed file
  40. template <typename Scalar, typename Index>
  41. IGL_INLINE bool readWRL(
  42. FILE * wrl_file,
  43. std::vector<std::vector<Scalar > > & V,
  44. std::vector<std::vector<Index > > & F,
  45. std::vector<std::vector<Scalar > > & TC,
  46. std::vector<std::vector<Index > > & TexCoordIndex);
  47. }
  48. #ifndef IGL_STATIC_LIBRARY
  49. # include "readWRL.cpp"
  50. #endif
  51. #endif