Helios++
Helios software for LiDAR simulations
VHScannerAdapter.h
1 #ifdef PCL_BINDING
2 
3 #pragma once
4 
5 #include <scanner/Scanner.h>
6 #include <sim/comps/Survey.h>
7 
8 #include <glm/glm.hpp>
9 
10 namespace visualhelios{
11 
20 protected:
21  // *** ATTRIBUTES *** //
22  // ******************** //
38  unsigned int currentLegIndex = 0;
42  glm::dvec3 origin;
46  glm::dvec3 dir;
50  double originRadius = 1.0;
54  double originColor[3] = {0.6, 0.1, 0.1};
59  double rayLength = 1.0;
63  double rayColor[3] = {0.9, 0.1, 0.15};
68  double nonReturningRayColor[3] = {0.3, 0.2, 0.9};
69 
70 public:
71  // *** CONSTRUCTION / DESTRUCTION *** //
72  // ************************************ //
79  survey(survey)
80  {}
81  virtual ~VHScannerAdapter() = default;
82 
83  // *** SIMULATION *** //
84  // ******************** //
88  void start();
93  void nextStep();
94 
104  void startLeg(unsigned int const legIndex, bool const manual);
109  void stopAndTurn(unsigned int legIndex, shared_ptr<Leg> leg);
110 
111  // *** GETTERs and SETTERs *** //
112  // ***************************** //
122  inline Scanner & getScanner() {return scanner;}
127  inline glm::dvec3 const & getRayOrigin() const {return origin;}
133  inline glm::dvec3 const & getRayDir() const {return dir;}
139  inline double getOriginRadius() const {return originRadius;}
145  inline void setOriginRadius(double const originRadius)
146  {this->originRadius = originRadius;}
152  inline double const * getOriginColor() const {return originColor;}
158  inline double getOriginColorRed() const {return originColor[0];}
164  inline double getOriginColorBlue() const {return originColor[1];}
170  inline double getOriginColorGreen() const {return originColor[2];}
178  inline void setOriginColor(double const *rgb){
179  setOriginColor(rgb[0], rgb[1], rgb[2]);
180  }
188  inline void setOriginColor(double const r, double const g, double const b){
189  originColor[0] = r;
190  originColor[1] = g;
191  originColor[2] = b;
192  }
198  inline double getRayLength() const {return rayLength;}
204  inline void setRayLength(double const rayLength)
205  {this->rayLength = rayLength;}
211  inline double const * getRayColor() const {return rayColor;}
217  inline double getRayColorRed() const {return rayColor[0];}
223  inline double getRayColorGreen() const {return rayColor[1];}
229  inline double getRayColorBlue() const {return rayColor[2];}
237  inline void setRayColor(double const *rgb){
238  setRayColor(rgb[0], rgb[1], rgb[2]);
239  }
247  inline void setRayColor(double const r, double const g, double const b){
248  rayColor[0] = r; rayColor[1] = g; rayColor[2] = b;
249  }
255  inline double const * getNonReturningRayColor() const
256  {return nonReturningRayColor;}
262  inline double getNonReturningRayColorRed() const
263  {return nonReturningRayColor[0];}
269  inline double getNonReturningRayColorGreen() const
270  {return nonReturningRayColor[1];}
276  inline double getNonReturningRayColorBlue() const
277  {return nonReturningRayColor[2];}
285  inline void setNonReturningRayColor(double const *rgb){
286  setNonReturningRayColor(rgb[0], rgb[1], rgb[2]);
287  }
297  double const r, double const g, double const b
298  ){
299  nonReturningRayColor[0] = r;
300  nonReturningRayColor[1] = g;
301  nonReturningRayColor[2] = b;
302  }
308  inline int getPulseFreq_Hz() const {return scanner.getPulseFreq_Hz();}
314  inline void setPulseFreq_Hz(int const pulseFreq_Hz)
315  {scanner.setPulseFreq_Hz(pulseFreq_Hz);}
329  inline double const * getCurrentRayColor() const{
330  if(scanner.getBeamDeflector()->lastPulseLeftDevice()){
331  return getRayColor();
332  }
333  return getNonReturningRayColor();
334  }
335 };
336 
337 }
338 
339 #endif
Class representing a scanner asset.
Definition: Scanner.h:28
virtual std::shared_ptr< AbstractBeamDeflector > getBeamDeflector(size_t const idx)=0
Obtain the beam deflector of the scanning device.
void setPulseFreq_Hz(int const pulseFreq_Hz)
Set the pulse frequency.
Definition: Scanner.cpp:253
int getPulseFreq_Hz() const
Obtain the pulse frequency.
Definition: Scanner.h:601
Class representing a Helios++ survey.
Definition: Survey.h:13
Abstract class defining core mechanism to adapt scanners to the visual Helios context based on PCL an...
Definition: VHScannerAdapter.h:19
double nonReturningRayColor[3]
The color of the line representing the ray when it is not returning an echo.
Definition: VHScannerAdapter.h:68
void setOriginRadius(double const originRadius)
Set the ray's origin radius.
Definition: VHScannerAdapter.h:145
Scanner & scanner
The adapted scanner.
Definition: VHScannerAdapter.h:27
VHScannerAdapter(Scanner &scanner, Survey &survey)
Constructor for the visual Helios scanner adapter.
Definition: VHScannerAdapter.h:77
glm::dvec3 const & getRayDir() const
Return a constant reference to the director vector of the current ray.
Definition: VHScannerAdapter.h:133
void startLeg(unsigned int const legIndex, bool const manual)
Start specified leg.
Definition: VHScannerAdapter.cpp:53
double rayLength
The length of the ray. It specifies the magnitude of the vector representing the ray.
Definition: VHScannerAdapter.h:59
void nextStep()
Compute the next step for the scanner, with respect to the current one.
Definition: VHScannerAdapter.cpp:17
double originColor[3]
The RGB color of the sphere representing the origin of the ray.
Definition: VHScannerAdapter.h:54
glm::dvec3 origin
The coordinates of the origin for the current ray.
Definition: VHScannerAdapter.h:42
double const * getRayColor() const
Obtain the ray's color.
Definition: VHScannerAdapter.h:211
double getOriginColorRed() const
Obtain the ray's origin red color component.
Definition: VHScannerAdapter.h:158
void setNonReturningRayColor(double const r, double const g, double const b)
Set the non returning ray's color.
Definition: VHScannerAdapter.h:296
double rayColor[3]
The color of the line representing the ray.
Definition: VHScannerAdapter.h:63
double getOriginRadius() const
Obtain the ray's origin radius.
Definition: VHScannerAdapter.h:139
double getNonReturningRayColorRed() const
Obtain the non returning ray's red color component.
Definition: VHScannerAdapter.h:262
double getNonReturningRayColorBlue() const
Obtain the non returning ray's blue color component.
Definition: VHScannerAdapter.h:276
int getPulseFreq_Hz() const
Obtain the scanner's pulse frequency, in Hertz.
Definition: VHScannerAdapter.h:308
double getOriginColorGreen() const
Obtain the ray's origin green color component.
Definition: VHScannerAdapter.h:170
void setOriginColor(double const *rgb)
Set the ray's origin color.
Definition: VHScannerAdapter.h:178
double getRayColorBlue() const
Obtain the ray's blue color component.
Definition: VHScannerAdapter.h:229
void setRayLength(double const rayLength)
Set the ray's length.
Definition: VHScannerAdapter.h:204
void start()
Start the scanner.
Definition: VHScannerAdapter.cpp:13
void stopAndTurn(unsigned int legIndex, shared_ptr< Leg > leg)
Perform stop and turn operation to advance to next leg.
Definition: VHScannerAdapter.cpp:135
void setOriginColor(double const r, double const g, double const b)
Set the ray's origin color.
Definition: VHScannerAdapter.h:188
unsigned int currentLegIndex
The index of the current scanning leg.
Definition: VHScannerAdapter.h:38
double getRayColorGreen() const
Obtain the ray's green color component.
Definition: VHScannerAdapter.h:223
double getRayLength() const
Obtain the ray's length.
Definition: VHScannerAdapter.h:198
void setRayColor(double const r, double const g, double const b)
Set the ray's color.
Definition: VHScannerAdapter.h:247
double const * getNonReturningRayColor() const
Obtain the non returning ray's color.
Definition: VHScannerAdapter.h:255
void setRayColor(double const *rgb)
Set the ray's color.
Definition: VHScannerAdapter.h:237
double const * getOriginColor() const
Obtain the ray's origin color.
Definition: VHScannerAdapter.h:152
double originRadius
The radius of the sphere representing the origin of the ray.
Definition: VHScannerAdapter.h:50
double getNonReturningRayColorGreen() const
Obtain the non returning ray's green color component.
Definition: VHScannerAdapter.h:269
glm::dvec3 dir
The director vector of the current ray.
Definition: VHScannerAdapter.h:46
Survey & survey
The survey to which the adapted scanner belongs to.
Definition: VHScannerAdapter.h:32
Scanner & getScanner()
Obtain the scanner object.
Definition: VHScannerAdapter.h:122
void setPulseFreq_Hz(int const pulseFreq_Hz)
Set the scanner's pulse frequency, in Hertz.
Definition: VHScannerAdapter.h:314
double const * getCurrentRayColor() const
Obtain the ray color depending on if the ray is expected to return an echo or not.
Definition: VHScannerAdapter.h:329
glm::dvec3 const & getRayOrigin() const
Return a constant reference to the origin of the current ray.
Definition: VHScannerAdapter.h:127
double getOriginColorBlue() const
Obtain the ray's origin blue color component.
Definition: VHScannerAdapter.h:164
void setNonReturningRayColor(double const *rgb)
Set the non returning ray's color.
Definition: VHScannerAdapter.h:285
double getRayColorRed() const
Obtain the ray's red color component.
Definition: VHScannerAdapter.h:217