readWRL.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. // Inputs:
  35. // wrl_file pointer to already opened .wrl file
  36. // Outputs:
  37. // wrl_file closed file
  38. template <typename Scalar, typename Index>
  39. IGL_INLINE bool readWRL(
  40. FILE * wrl_file,
  41. std::vector<std::vector<Scalar > > & V,
  42. std::vector<std::vector<Index > > & F);
  43. }
  44. #ifndef IGL_STATIC_LIBRARY
  45. # include "readWRL.cpp"
  46. #endif
  47. #endif