Ocular Engine
MeshResourceLoader_PLY.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_GRAPHICS_MESH_RESOURCE_LOADER_PLY__H__
19 #define __H__OCULAR_GRAPHICS_MESH_RESOURCE_LOADER_PLY__H__
20 
21 #include "Graphics/Mesh/MeshLoaders/MeshResourceLoader.hpp"
22 #include "PLYEnums.hpp"
23 
24 #include <list>
25 #include <fstream>
26 
27 //------------------------------------------------------------------------------------------
28 
33 namespace Ocular
34 {
39  namespace Graphics
40  {
41  class PLYParser;
42  class PLYElementParser;
43  class PLYElementListParser;
44 
52  {
53  public:
54 
56  virtual ~MeshResourceLoader_PLY();
57 
58  protected:
59 
60  virtual bool readFile(Core::File const& file, std::vector<Graphics::Vertex>& vertices, std::vector<uint32_t>& indices, uint32_t& numVertices, uint32_t& numIndices, Math::Vector3f& min, Math::Vector3f& max) override;
61 
62  bool parseHeader(std::ifstream& stream);
63  bool parseElement(std::ifstream& stream, std::string& line, PLYParser** parser);
64  bool parseElementNameAndCount(std::string const& line, PLYParser* parser) const;
65  bool parseProperty(std::string const& line, PLYElementParser* parser) const;
66  bool parsePropertyList(std::string const& line, PLYElementListParser* parser) const;
67 
68  bool parseBody(std::ifstream& stream, std::vector<Graphics::Vertex>& vertices, std::vector<uint32_t>& indices, uint32_t& numVertices, uint32_t& numIndices, Math::Vector3f& min, Math::Vector3f& max);
69 
70  bool isValidPLYFile(std::ifstream& stream) const;
71  bool isComment(std::string const& line) const;
72  bool isElement(std::string const& line) const;
73  bool isElementList(std::string const& line) const;
74  bool isFormatASCII(std::string const& line) const;
75 
76  PLYPropertyType toPropertyType(std::string const& str) const;
77  PLYElementType toElementType(std::string const& str) const;
78 
79  void reserveVectorSpace(std::vector<Graphics::Vertex>& vertices, std::vector<uint32_t>& indices) const;
80 
81  private:
82 
83  std::list<PLYParser*> m_Parsers;
84  };
85  }
89 }
94 //------------------------------------------------------------------------------------------
95 
96 #endif
bool parseHeader(std::ifstream &stream)
Definition: MeshResourceLoader_PLY.cpp:107
virtual bool readFile(Core::File const &file, std::vector< Graphics::Vertex > &vertices, std::vector< uint32_t > &indices, uint32_t &numVertices, uint32_t &numIndices, Math::Vector3f &min, Math::Vector3f &max) override
Definition: MeshResourceLoader_PLY.cpp:60
Definition: MeshResourceLoader.hpp:50
Definition: PLYParser.hpp:45
Definition: MeshResourceLoader_PLY.hpp:51
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Definition: PLYElementParser.hpp:41
Definition: File.hpp:41
Definition: PLYElementListParser.hpp:40