Path Tracer
Picture.h
Go to the documentation of this file.
1 #ifndef DEF_PICTURE
2 #define DEF_PICTURE
3 
4 #include <algorithm>
5 #include <iomanip>
6 
7 #include "CImg/CImg.h"
8 
9 #include "InterfaceCreation.h"
10 
120 class Picture {
121 private:
122  const unsigned int width;
123  const unsigned int height;
124  double renderTime;
125  DoubleVec3D** pixels;
126 
127 public:
128  static constexpr unsigned int MAX_COLOUR_VALUE = 255;
129 
130  Picture();
131  Picture(unsigned int width, unsigned int height, double renderTime = -1);
132  Picture(const Picture& picture);
133  ~Picture();
134 
135  unsigned int getWidth() const;
136  unsigned int getHeight() const;
137  double getRenderTime() const;
138  std::vector<std::vector<DoubleVec3D>> getPixels() const;
139 
140  void addValuePix(unsigned int x, unsigned int y, DoubleVec3D value);
141  void setValuePix(unsigned int x, unsigned int y, DoubleVec3D value);
142  void setRenderTime(double renderTime);
143 
144  void export2File(double middleGrey, std::string fileName, unsigned int movingAverage = 0) const;
145  void printAll() const;
146  void modify();
147 };
148 
149 DoubleVec3D toneMapping(const DoubleVec3D& radiance, double middleGrey);
150 DoubleVec3D getColourMovingAverage(const std::vector<std::vector<DoubleVec3D>>& pixelValues, unsigned int pixelX, unsigned int pixelY, unsigned int size);
151 
152 void to_json(json& j, const Picture& picture);
154 
155 #endif
156 
Defines functions that are used to ask for values to the user, and to interactively create 3D objects...
nlohmann::json json
Definition: InterfaceGestion.h:14
DoubleVec3D getColourMovingAverage(const std::vector< std::vector< DoubleVec3D >> &pixelValues, unsigned int pixelX, unsigned int pixelY, unsigned int size)
Computes the value of a pixel when having applied a moving average.
Definition: Picture.cpp:176
DoubleVec3D toneMapping(const DoubleVec3D &radiance, double middleGrey)
Converts a radiance to a colour value.
Definition: Picture.cpp:167
Picture importPictureFromJson(const json &j)
Imports a picture out of json.
Definition: Picture.cpp:212
void to_json(json &j, const Picture &picture)
Conversion to json.
Definition: Picture.cpp:207
A three-dimensional vector using double values.
Definition: DoubleVec3D.h:190
Stores radiance for every pixel.
Definition: Picture.h:120
static constexpr unsigned int MAX_COLOUR_VALUE
The maximum value that will be used to write a colour in a file.
Definition: Picture.h:128
~Picture()
Destructor.
Definition: Picture.cpp:17
unsigned int getHeight() const
Getter for the height.
Definition: Picture.cpp:26
void export2File(double middleGrey, std::string fileName, unsigned int movingAverage=0) const
Writes this as a picture file.
Definition: Picture.cpp:47
void setRenderTime(double renderTime)
Setter for the render time.
Definition: Picture.cpp:44
Picture()
Default constructor.
Definition: Picture.cpp:4
unsigned int getWidth() const
Getter for the width.
Definition: Picture.cpp:25
void setValuePix(unsigned int x, unsigned int y, DoubleVec3D value)
Sets a pixel value.
Definition: Picture.cpp:43
void printAll() const
Prints the whole page.
Definition: Picture.cpp:82
std::vector< std::vector< DoubleVec3D > > getPixels() const
Getter for the pixels.
Definition: Picture.cpp:29
double getRenderTime() const
Getter for the render time.
Definition: Picture.cpp:27
void addValuePix(unsigned int x, unsigned int y, DoubleVec3D value)
Adds a value to a pixel.
Definition: Picture.cpp:42
void modify()
Interactive modification of this picture.
Definition: Picture.cpp:98