Ray Tracer  2020
SceneReader.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef SCENE_READER_H_INCLUDED
4 #define SCENE_READER_H_INCLUDED
5 
6 #include "NonCopyable.h"
7 
8 #include "Colour.h"
9 #include "Material.h"
10 #include "Scene.h"
11 
12 #include <map>
13 #include <queue>
14 #include <string>
15 
152 class SceneReader : private NonCopyable {
153 
154 public:
159  SceneReader(Scene* scene);
160 
162  ~SceneReader();
163 
174  void read(const std::string& filename);
175 
176 private:
177 
186  void parseTokenBlock(std::queue<std::string>& tokenBlock);
187 
199  Colour parseColour(std::queue<std::string>& tokenBlock);
200 
211  double parseNumber(std::queue<std::string>& tokenBlock);
212 
221  void parseSceneBlock(std::queue<std::string>& tokenBlock);
222 
231  void parseCameraBlock(std::queue<std::string>& tokenBlock);
232 
241  void parseLightBlock(std::queue<std::string>& tokenBlock);
242 
251  std::shared_ptr<Object> parseObjectBlock(std::queue<std::string>& tokenBlock);
252 
261  void parseMaterialBlock(std::queue<std::string>& tokenBlock);
262 
265  std::map<std::string, Material> materials_;
266 };
267 
268 #endif
Colour class header file.
Material class header file.
NonCopyable class header file.
Scene class header file.
Class to store colour information.
Definition: Colour.h:25
NonCopyable class.
Definition: NonCopyable.h:27
A Scene to be ray traced.
Definition: Scene.h:44
Simple parser for Scene description files.
Definition: SceneReader.h:152
Scene * scene_
The Scene which information is read to.
Definition: SceneReader.h:263
void parseCameraBlock(std::queue< std::string > &tokenBlock)
Parse a block of tokens representing a Scene.
Definition: SceneReader.cpp:141
~SceneReader()
SceneReader destructor.
Definition: SceneReader.cpp:34
SceneReader(Scene *scene)
SceneReader constructor.
Definition: SceneReader.cpp:29
void parseMaterialBlock(std::queue< std::string > &tokenBlock)
Parse a block of tokens representing a Material.
Definition: SceneReader.cpp:323
void parseSceneBlock(std::queue< std::string > &tokenBlock)
Parse a block of tokens representing a Scene.
Definition: SceneReader.cpp:96
std::map< std::string, Material > materials_
A dictionary of Material types that have been read, and which can be used for subsequent Object prope...
Definition: SceneReader.h:265
void read(const std::string &filename)
Read Scene data from a file.
Definition: SceneReader.cpp:57
std::shared_ptr< Object > parseObjectBlock(std::queue< std::string > &tokenBlock)
Parse a block of tokens representing a LightSource.
Definition: SceneReader.cpp:239
double parseNumber(std::queue< std::string > &tokenBlock)
Read a number information from a block of tokens.
Definition: SceneReader.cpp:121
Colour parseColour(std::queue< std::string > &tokenBlock)
Read Colour information from a block of tokens.
Definition: SceneReader.cpp:133
int startLine_
The first line of the current block being parsed, for error reporting.
Definition: SceneReader.h:264
void parseTokenBlock(std::queue< std::string > &tokenBlock)
Parse a block of tokens.
Definition: SceneReader.cpp:38
void parseLightBlock(std::queue< std::string > &tokenBlock)
Parse a block of tokens representing a Camera.
Definition: SceneReader.cpp:195