readWRL.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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. /// @tparam Scalar type for positions and vectors (will be read as double and cast
  20. /// to Scalar)
  21. /// @tparam Index type for indices (will be read as int and cast to Index)
  22. /// @param[in] str path to .wrl file
  23. /// @param[out] V double matrix of vertex positions #V by 3
  24. /// @param[out] F #F list of face indices into vertex positions
  25. /// @return true on success, false on errors
  26. template <typename Scalar, typename Index>
  27. IGL_INLINE bool readWRL(
  28. const std::string wrl_file_name,
  29. std::vector<std::vector<Scalar > > & V,
  30. std::vector<std::vector<Index > > & F);
  31. /// \overload
  32. /// @param[in,out] wrl_file pointer to already opened .wrl file (will be closed)
  33. template <typename Scalar, typename Index>
  34. IGL_INLINE bool readWRL(
  35. FILE * wrl_file,
  36. std::vector<std::vector<Scalar > > & V,
  37. std::vector<std::vector<Index > > & F);
  38. }
  39. #ifndef IGL_STATIC_LIBRARY
  40. # include "readWRL.cpp"
  41. #endif
  42. #endif