Helios++
Helios software for LiDAR simulations
typedef.h
1 #pragma once
2 
3 #include <iostream>
4 #include <string>
5 #include <sstream>
6 
7 #include <glm/glm.hpp>
8 #include <glm/gtx/string_cast.hpp>
9 
10 #include "maths/Rotation.h"
11 
12 #include <boost/variant/get.hpp>
13 #include <boost/variant/variant.hpp>
14 
15 
19 typedef boost::variant<
20  bool, int, float, double, std::string, glm::dvec3, Rotation
21 > ObjectT;
22 
27 struct stringVisitor : public boost::static_visitor<std::string>{
31  std::string operator() (bool b) const {
32  std::stringstream ss;
33  ss << b;
34  return ss.str();
35  }
39  std::string operator() (int i) const {
40  std::stringstream ss;
41  ss << i;
42  return ss.str();
43  }
47  std::string operator() (float f) const {
48  std::stringstream ss;
49  ss << f;
50  return ss.str();
51  }
55  std::string operator() (double d) const {
56  std::stringstream ss;
57  ss << d;
58  return ss.str();
59  }
63  std::string operator() (std::string const & s) const {
64  std::stringstream ss;
65  ss << s;
66  return ss.str();
67  }
71  std::string operator() (glm::dvec3 v) const {
72  std::stringstream ss;
73  ss << glm::to_string(v);
74  return ss.str();
75  }
80  std::string operator() (Rotation r) const {
81  std::stringstream ss;
82  ss << r.getQ0() << '\n' << r.getQ1() << '\n' << r.getQ2()
83  << '\n' << r.getQ3();
84  return ss.str();
85  }
86 };
87 
88 // "C/C++, unfortunately, does not have a sgn function in its standard library,
89 // however this is defined in the Boost library."
93 template <typename T> int sgn(T val) {
94  return (T(0) < val) - (val < T(0));
95 }
96 
Definition: Rotation.h:80
double getQ2() const
Get the second coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:130
double getQ1() const
Get the first coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:122
double getQ3() const
Get the third coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:137
double getQ0() const
Get the scalar coordinate of the quaternion.
Definition: Rotation.h:115
stringVisitor defines a different string building behavior for different printable objects
Definition: typedef.h:27
std::string operator()(bool b) const
String visitor behavior fo bool type.
Definition: typedef.h:31