Helios++
Helios software for LiDAR simulations
Material.h
1 #pragma once
2 
3 #include <string>
4 #include <cmath>
5 
6 #include <boost/archive/text_iarchive.hpp>
7 #include <boost/archive/text_oarchive.hpp>
8 
12 class Material {
13  // *** SERIALIZATION *** //
14  // *********************** //
15  friend class boost::serialization::access;
16  template<class Archive>
17  void serialize(Archive &ar, const unsigned int version) {
18  ar & name;
19  ar & isGround;
20  ar & useVertexColors;
21  ar & matFilePath;
22  ar & map_Kd;
23  ar & reflectance;
24  ar & specularity;
25  ar & specularExponent;
26  ar & classification;
27  ar & spectra;
28  ar & ka & kd & ks;
29  }
30 public:
31  // *** ATTRIBUTES *** //
32  // ******************** //
36  std::string name = "default";
40  bool isGround = false;
46  bool useVertexColors = false;
50  std::string matFilePath;
55  std::string map_Kd = "";
59  double reflectance = NAN;
64  double specularity = 0;
68  double specularExponent = 10;
73  int classification = 0;
74 
81  std::string spectra = "";
82 
86  float ka[4] = { 0, 0, 0, 0 };
90  float kd[4] = { 0, 0, 0, 0 };
94  float ks[4] = { 0, 0, 0, 0 };
95 
96  // *** CONSTRUCTION / DESTRUCTION *** //
97  // ************************************ //
101  Material() = default;
102  Material(const Material &sp);
103  virtual ~Material() {}
104 
105  // *** M E T H O D S *** //
106  // *********************** //
123  float* getKd(float factor);
137  void setSpecularity();
138 
139 #ifdef PYTHON_BINDING
144  inline float getKa0() {return ka[0];}
149  inline void setKa0(double ka0) {ka[0] = ka0;}
154  inline float getKa1() {return ka[1];}
159  inline void setKa1(double ka1) {ka[1] = ka1;}
164  inline float getKa2() {return ka[2];}
169  inline void setKa2(double ka2) {ka[2] = ka2;}
174  inline float getKa3() {return ka[3];}
179  inline void setKa3(double ka3) {ka[3] = ka3;}
184  inline float getKd0() {return kd[0];}
189  inline void setKd0(double kd0) {kd[0] = kd0;}
194  inline float getKd1() {return kd[1];}
199  inline void setKd1(double kd1) {kd[1] = kd1;}
204  inline float getKd2() {return kd[2];}
209  inline void setKd2(double kd2) {kd[2] = kd2;}
214  inline float getKd3() {return kd[3];}
219  inline void setKd3(double kd3) {kd[3] = kd3;}
224  inline float getKs0() {return ks[0];}
229  inline void setKs0(double ks0) {ks[0] = ks0;}
234  inline float getKs1() {return ks[1];}
239  inline void setKs1(double ks1) {ks[1] = ks1;}
244  inline float getKs2() {return ks[2];}
249  inline void setKs2(double ks2) {ks[2] = ks2;}
254  inline float getKs3() {return ks[3];}
259  inline void setKs3(double ks3) {ks[3] = ks3;}
260 #endif
261 
262 };
Class representing a material specification.
Definition: Material.h:12
void setSpecularity()
Compute the specularity .
Definition: Material.cpp:35
void setKd2(double kd2)
PyHelios setter to set third diffuse component.
Definition: Material.h:209
float getKa0()
PyHelios getter to obtain first ambient component.
Definition: Material.h:144
void setKd3(double kd3)
PyHelios setter to set fourth diffuse component.
Definition: Material.h:219
float getKa1()
PyHelios getter to obtain second ambient component.
Definition: Material.h:154
void setKa2(double ka2)
PyHelios setter to obtain third ambient component.
Definition: Material.h:169
double reflectance
Material reflectance.
Definition: Material.h:59
float getKs0()
PyHelios getter to obtain first specular component.
Definition: Material.h:224
float ka[4]
Material ambient components.
Definition: Material.h:86
float getKd0()
PyHelios getter to obtain first diffuse component.
Definition: Material.h:184
bool useVertexColors
Flag specifying if use vertex colors (true) or not (false). Color usage is at the moment excluded fro...
Definition: Material.h:46
float getKs1()
PyHelios getter to obtain second specular component.
Definition: Material.h:234
float getKs2()
PyHelios getter to get third specular component.
Definition: Material.h:244
void setKs0(double ks0)
PyHelios setter to set first specular component.
Definition: Material.h:229
std::string map_Kd
This attribute is currently not being used and might be discarded in the future.
Definition: Material.h:55
float getKa3()
PyHelios getter to obtain fourth ambient component.
Definition: Material.h:174
void setKa0(double ka0)
PyHelios setter to set first ambient component.
Definition: Material.h:149
Material()=default
Material default constructor.
void setKa3(double ka3)
PyHelios setter to set fourth ambient component.
Definition: Material.h:179
double specularExponent
Material specular exponent.
Definition: Material.h:68
void setKs2(double ks2)
PyHelios setter to set third specular component.
Definition: Material.h:249
void setKd1(double kd1)
PyHelios setter to obtain second diffuse component.
Definition: Material.h:199
float kd[4]
Material diffuse components.
Definition: Material.h:90
std::string spectra
Material spectra, used to find material reflectance when using spectral library.
Definition: Material.h:81
void setKd0(double kd0)
PyHelios setter to set first diffuse component.
Definition: Material.h:189
float getKd2()
PyHelios getter to obtain third diffuse component.
Definition: Material.h:204
double specularity
Material specularity.
Definition: Material.h:64
int classification
Material classification.
Definition: Material.h:73
bool isGround
Flag specifying if material is ground (true) or not (false)
Definition: Material.h:40
float getKs3()
PyHelios getter to get fourth specular component.
Definition: Material.h:254
float ks[4]
Material specular components.
Definition: Material.h:94
float * getKd(float factor)
Obtain specular component.
Definition: Material.cpp:27
void setKs1(double ks1)
PyHelios setter to set second specular component.
Definition: Material.h:239
void setKs3(double ks3)
PyHelios setter to set fourth specular component.
Definition: Material.h:259
std::string matFilePath
Path to the file containing material definition.
Definition: Material.h:50
float getKa2()
PyHelios getter to obtain third ambient component.
Definition: Material.h:164
void setKa1(double ka1)
PyHelios setter to set second ambient component.
Definition: Material.h:159
float getKd1()
PyHelios getter to obtain second diffuse component.
Definition: Material.h:194
float getKd3()
PyHelios getter to obtain fourth diffuse component.
Definition: Material.h:214
std::string name
Material name.
Definition: Material.h:36