Path Tracer
Functions
InterfaceCreation.cpp File Reference
#include "InterfaceCreation.h"
Include dependency graph for InterfaceCreation.cpp:

Functions

std::string getStringFromUser (std::string question, std::string prompt)
 Gets a string from the user. More...
 
char getLowerCaseCharFromUser (std::string question, std::string prompt)
 Gets a lowercase character from the user. More...
 
int getIntFromUser (std::string question, std::string prompt)
 Gets an integer from the user. More...
 
unsigned int getUnsignedIntFromUser (std::string question, std::string prompt)
 Gets a positive integer from the user. More...
 
double getDoubleFromUser (std::string question, std::string prompt)
 Gets a number from the user. More...
 
double getPositiveDoubleFromUser (std::string question, std::string prompt)
 Gets a positive number from the user. More...
 
bool getBoolFromUser (std::string question, std::string prompt)
 Gets a boolean from the user. More...
 
DoubleVec3D getXYZDoubleVec3DFromUser (std::string question, std::string prompt)
 Gets a vector from the user. More...
 
DoubleVec3D getRGBDoubleVec3DFromUser (std::string question, std::string prompt)
 Gets a vector with only positive coordinates from the user. More...
 
MaterialcreateDiffuseMaterial (const DoubleVec3D &emittance)
 Interactive creation of a DiffuseMaterial. More...
 
MaterialcreateRefractiveMaterial (const DoubleVec3D &emittance)
 Interactive creation of a RefractiveMaterial. More...
 
MaterialcreateSpecularMaterial (const DoubleVec3D &emittance)
 Interactive creation of a SpecularMaterial. More...
 
MaterialcreateMaterial ()
 Interactive creation of a Material. More...
 
Object3DcreateSphere (Material *material)
 Interactive creation of a Sphere. More...
 
Object3DcreateTriangle (Material *material)
 Interactive creation of a Triangle. More...
 
Object3DcreateObject3D ()
 Interactive creation of an Object3D. More...
 
void to_json (json &j, const Material &mat)
 Material conversion to json. More...
 
MaterialimportMaterialFromJson (const json &j)
 Material conversion from json. More...
 
void to_json (json &j, const Object3D &obj)
 Object3D conversion to json. More...
 
Object3DimportObject3DFromJson (const json &j)
 Object3D conversion from json. More...
 
bool fileExists (std::string fileName)
 Verifies if the file exists. More...
 
std::string formatFileName (std::string fileName, std::string extension)
 Formats the name of the file the user gave and the extension we want. More...
 

Function Documentation

◆ createDiffuseMaterial()

Material * createDiffuseMaterial ( const DoubleVec3D emittance)

Interactive creation of a DiffuseMaterial.

Parameters
emittanceThe emittance of the material.
Returns
A pointer to the created diffuse material.
See also
createRefractiveMaterial(), createSpecularMaterial(), createMaterial()

◆ createMaterial()

Material * createMaterial ( )

Interactive creation of a Material.

Gets the main parameters of a material, and then calls createDiffuseMaterial(), createRefractiveMaterial() or createSpecularMaterial().

Returns
A pointer to the created material.
See also
createDiffuseMaterial(), createRefractiveMaterial(), createSpecularMaterial()

◆ createObject3D()

Object3D * createObject3D ( )

Interactive creation of an Object3D.

Gets the main parameters of an object, and then calls createSphere() or createTriangle().

Returns
A pointer to the created object.
See also
createSphere(), createTriangle()

◆ createRefractiveMaterial()

Material * createRefractiveMaterial ( const DoubleVec3D emittance)

Interactive creation of a RefractiveMaterial.

Parameters
emittanceThe emittance of the material.
Returns
A pointer to the created refractive material.
See also
createDiffuseMaterial(), createSpecularMaterial(), createMaterial()

◆ createSpecularMaterial()

Material * createSpecularMaterial ( const DoubleVec3D emittance)

Interactive creation of a SpecularMaterial.

Parameters
emittanceThe emittance of the material.
Returns
A pointer to the created specular material.
See also
createDiffuseMaterial(), createRefractiveMaterial(), createMaterial()

◆ createSphere()

Object3D * createSphere ( Material material)

Interactive creation of a Sphere.

Parameters
materialThe material of this sphere.
Returns
A pointer to the created sphere.
See also
createTriangle(), createObject3D()

◆ createTriangle()

Object3D * createTriangle ( Material material)

Interactive creation of a Triangle.

Parameters
materialThe material of this triangle.
Returns
A pointer to the created triangle.
See also
createSphere(), createObject3D()

◆ fileExists()

bool fileExists ( std::string  fileName)

Verifies if the file exists.

Parameters
fileNameThe path to the file.
Returns
True if the file exists, false else.

◆ formatFileName()

std::string formatFileName ( std::string  fileName,
std::string  extension 
)

Formats the name of the file the user gave and the extension we want.

For example, it will format "test.txt" into "test.txt" and "test" into "test.txt".

Parameters
fileNameThe path to the file we want to format.
extensionThe file extension with which we want to format the file.
Returns
The formated file name.

◆ getBoolFromUser()

bool getBoolFromUser ( std::string  question = "",
std::string  prompt = PROMPT 
)

Gets a boolean from the user.

Uses the getLowerCaseCharFromUser() method. Will continue to ask the question until the user gives 't' or 'f'.

Parameters
questionThe question that will be asked to the user.
promptThe prompt that will be used to show the user that he or she can write something.
Returns
The boolean the user gave.
See also
getLowerCaseCharFromUser()

◆ getDoubleFromUser()

double getDoubleFromUser ( std::string  question = "",
std::string  prompt = PROMPT 
)

Gets a number from the user.

Uses the getStringFromUser() method. Will continue to ask the question until the user gives a string that can be converted to a double.

Parameters
questionThe question that will be asked to the user.
promptThe prompt that will be used to show the user that he or she can write something.
Returns
The double the user gave.
See also
getStringFromUser(), getPositiveDoubleFromUser(), getXYZDoubleVec3DFromUser()

◆ getIntFromUser()

int getIntFromUser ( std::string  question = "",
std::string  prompt = PROMPT 
)

Gets an integer from the user.

Uses the getStringFromUser() method. Will continue to ask the question until the user gives a string that can be converted to an int.

Parameters
questionThe question that will be asked to the user.
promptThe prompt that will be used to show the user that he or she can write something.
Returns
The integer the user gave.
See also
getStringFromUser(), getUnsignedIntFromUser()

◆ getLowerCaseCharFromUser()

char getLowerCaseCharFromUser ( std::string  question = "",
std::string  prompt = PROMPT 
)

Gets a lowercase character from the user.

Uses the getStringFromUser() method and takes the first character of this string.

Parameters
questionThe question that will be asked to the user.
promptThe prompt that will be used to show the user that he or she can write something.
Returns
The character the user gave.
See also
getStringFromUser(), getBoolFromUser()

◆ getPositiveDoubleFromUser()

double getPositiveDoubleFromUser ( std::string  question = "",
std::string  prompt = PROMPT 
)

Gets a positive number from the user.

Uses the getDoubleFromUser() method. Will continue to ask the question until the user gives a positive double.

Parameters
questionThe question that will be asked to the user.
promptThe prompt that will be used to show the user that he or she can write something.
Returns
The postive double the user gave.
See also
getDoubleFromUser(), getRGBDoubleVec3DFromUser()

◆ getRGBDoubleVec3DFromUser()

DoubleVec3D getRGBDoubleVec3DFromUser ( std::string  question = "",
std::string  prompt = PROMPT 
)

Gets a vector with only positive coordinates from the user.

Uses three times the getPositiveDoubleFromUser() method. Adds "r ", "g " or "b " before the prompt, to show the user which component he or she is giving.

Parameters
questionThe question that will be asked to the user.
promptThe prompt that will be used to show the user that he or she can write something.
Returns
The vector the user gave.
See also
getPositiveDoubleFromUser()

◆ getStringFromUser()

std::string getStringFromUser ( std::string  question = "",
std::string  prompt = PROMPT 
)

Gets a string from the user.

Parameters
questionThe question that will be asked to the user.
promptThe prompt that will be used to show the user that he or she can write something.
Returns
The string the user gave.
See also
getLowerCaseCharFromUser(), getIntFromUser(), getStringFromUser()

◆ getUnsignedIntFromUser()

unsigned int getUnsignedIntFromUser ( std::string  question = "",
std::string  prompt = PROMPT 
)

Gets a positive integer from the user.

Uses the getIntFromUser() method. Will continue to ask the question until the user gives a positive integer.

Parameters
questionThe question that will be asked to the user.
promptThe prompt that will be used to show the user that he or she can write something.
Returns
The postive integer the user gave.
See also
getIntFromUser()

◆ getXYZDoubleVec3DFromUser()

DoubleVec3D getXYZDoubleVec3DFromUser ( std::string  question = "",
std::string  prompt = PROMPT 
)

Gets a vector from the user.

Uses three times the getDoubleFromUser() method. Adds "x ", "y " or "z " before the prompt, to show the user which coordinates he or she is giving.

Parameters
questionThe question that will be asked to the user.
promptThe prompt that will be used to show the user that he or she can write something.
Returns
The vector the user gave.
See also
getDoubleFromUser()

◆ importMaterialFromJson()

Material * importMaterialFromJson ( const json j)

Material conversion from json.

Parameters
jJson input.
Returns
A pointer to the material stored in the json.
See also
to_json(json& j, const Material& mat)

◆ importObject3DFromJson()

Object3D * importObject3DFromJson ( const json j)

Object3D conversion from json.

Parameters
jJson input.
Returns
A pointer to the object stored in the json.
See also
to_json(json& j, const Object3D& obj)

◆ to_json() [1/2]

void to_json ( json j,
const Material mat 
)

Material conversion to json.

Parameters
jJson output.
matThe material that will be converted.
See also
importMaterialFromJson()

◆ to_json() [2/2]

void to_json ( json j,
const Object3D obj 
)

Object3D conversion to json.

Parameters
jJson output.
objThe object that will be converted.
See also
importObject3DFromJson()