ColorVertex.hpp
Go to the documentation of this file.
1 
28 /*
29  * ColorVertex.hpp
30  *
31  * @date 17.06.2011
32  * @author Thomas Wiemann
33  */
34 
35 #ifndef COLORVERTEX_H_
36 #define COLORVERTEX_H_
37 
39 
40 #include <ostream>
41 
42 namespace lvr2
43 {
44 
45 
49 template<typename T, typename ColorT>
50 class ColorVertex : public BaseVector<T>
51 {
52 public:
53 
54  using CoordType = T;
60  {
61  this->x = this->y = this->z = 0;
62  this->r = this->g = this->b = 0;
63  fusion = false;
64  }
65 
69  ColorVertex(const CoordType &_x, const CoordType &_y, const CoordType &_z)
70  {
71  this->x = _x;
72  this->y = _y;
73  this->z = _z;
74  this->r = 0;
75  this->g = 100;
76  this->b = 0;
77  fusion = false;
78  }
79 
83  ColorVertex(const CoordType &_x, const CoordType &_y, const CoordType &_z,
84  const unsigned char _r, const unsigned char _g, const unsigned char _b, ...)
85  {
86  this->x = _x;
87  this->y = _y;
88  this->z = _z;
89  this->r = _r;
90  this->g = _g;
91  this->b = _b;
92  fusion = false;
93  }
94 
99  {
100  this->x = o.x;
101  this->y = o.y;
102  this->z = o.z;
103  this->r = o.r;
104  this->g = o.g;
105  this->b = o.b;
106  this->fusion = o.fusion;
107  }
108 
112  ColorVertex(const T &o)
113  {
114  this->x = o.x;
115  this->y = o.y;
116  this->z = o.z;
117  this->r = 0;
118  this->g = 0;
119  this->b = 0;
120  }
121 
122 
123  CoordType operator[](const int &index) const
124  {
125 
126  switch ( index )
127  {
128  case 0: return this->x;
129  case 1: return this->y;
130  case 2: return this->z;
131  case 3: return *((CoordType*) &r);
132  case 4: return *((CoordType*) &g);
133  case 5: return *((CoordType*) &b);
134  case 6: return *((CoordType*) &fusion);
135  default:
136  throw std::overflow_error( "Access index out of range." );
137  }
138  }
139 
140 
141  CoordType& operator[](const int &index)
142  {
143  switch ( index )
144  {
145  case 0: return this->x;
146  case 1: return this->y;
147  case 2: return this->z;
148  case 3: return *((CoordType*) &r);
149  case 4: return *((CoordType*) &g);
150  case 5: return *((CoordType*) &b);
151  case 6: return *((CoordType*) &fusion);
152  default:
153  throw std::overflow_error("Access index out of range.");
154  }
155  }
156 
157 
158  ColorT r, g, b;
159  bool fusion;
160 
161 };
162 
164 
165 
169 template<typename CoordType, typename ColorT>
170 inline std::ostream& operator<<(std::ostream& os, const ColorVertex<CoordType, ColorT> v){
171  os << "ColorVertex: " << v.x << " " << v.y << " " << v.z << " " << (int)v.r << " " << (int)v.g << " " << (int)v.b << std::endl;
172  return os;
173 }
174 
175 } // namespace lvr22
176 
177 #endif /* COLORVERTEX_H_ */
ColorVertex(const CoordType &_x, const CoordType &_y, const CoordType &_z)
Builds a ColorVertex with the given coordinates.
Definition: ColorVertex.hpp:69
ColorVertex()
Default constructor. All coordinates and the color are initialized with zeros.
Definition: ColorVertex.hpp:59
CoordType operator[](const int &index) const
A color vertex.
Definition: ColorVertex.hpp:50
ColorVertex(const T &o)
Copy Ctor.
ColorVertex(const CoordType &_x, const CoordType &_y, const CoordType &_z, const unsigned char _r, const unsigned char _g, const unsigned char _b,...)
Builds a Vertex with the given coordinates.
Definition: ColorVertex.hpp:83
ColorVertex(const ColorVertex &o)
Copy Ctor.
Definition: ColorVertex.hpp:98
A generic, weakly-typed vector.
Definition: BaseVector.hpp:60
CoordType & operator[](const int &index)


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:06