New get/set functions. Minor changes.

This commit is contained in:
David Baranyai 2018-07-02 23:04:15 +02:00
parent 7a49a37a9b
commit f497783aae
3 changed files with 90 additions and 11 deletions

View File

@ -26,6 +26,16 @@ public:
std::vector<double> GetMaterialList(); //Get the whole vector
double GetListSize();
double GetEnergy();
void SetEnergy(double);
double GetShape();
void SetShape(double);
std::vector<double> GetDimension();
std::vector<double> GetVoxel();
~Parameters();
private:
Parameters();
@ -36,15 +46,18 @@ private:
double energy;
double shape;
//Shape dimension
double length_x;
double length_y;
double length_z;
/*
* Shape dimension
* X, Y, Z
*/
std::vector<double> dimension;
//Voxel
double n_x;
double n_y;
double n_z;
/*
* Voxel
* X, Y, Z
*/
std::vector<double> n;
double n_sum = 1;
std::vector<double> material;
};

View File

@ -11,8 +11,31 @@
int main(int argc, const char * argv[])
{
//Initialize class
Parameters *param = Parameters::GetInstance();
//Get energy and shape
std::cout << param -> GetEnergy() << " " << param -> GetShape() << std::endl;
//Get dimension
std::vector<double> dimension = param -> GetDimension();
for(int i = 0; i < dimension.size(); i++)
{
std::cout << dimension[i] << " ";
}
std::cout << std::endl;
//Get N
std::vector<double> voxel = param -> GetVoxel();
for(int i = 0; i < voxel.size(); i++)
{
std::cout << voxel[i] << " ";
}
std::cout << std::endl;
//Get materials
for(int i = 0; i < param -> GetListSize(); i++)
{
std::cout << param -> GetMaterial(i) << std::endl;

View File

@ -32,12 +32,25 @@ Parameters::Parameters()
int index_helper = 0;
double material_helper = 0;
double helper = 0;
//Read the data
file >> energy >> shape;
file >> length_x >> length_y >> length_z;
file >> n_x >> n_y >> n_z;
for(int i = 0; i < (n_x * n_y * n_z); i++)
for(int i = 0; i < 3; i++)
{
file >> helper;
dimension.push_back(helper);
}
for (int i = 0; i < 3; i++)
{
file >> helper;
n_sum = n_sum * helper;
n.push_back(helper);
}
for(int i = 0; i < n_sum; i++)
{
file >> index_helper;
if(index_helper == i)
@ -90,3 +103,33 @@ double Parameters::GetListSize()
{
return material.size();
}
double Parameters::GetEnergy()
{
return energy;
}
void Parameters::SetEnergy(double e)
{
energy = e;
}
double Parameters::GetShape()
{
return shape;
}
void Parameters::SetShape(double s)
{
shape = s;
}
std::vector<double> Parameters::GetDimension()
{
return dimension;
}
std::vector<double> Parameters::GetVoxel()
{
return n;
}