include
lvr2
geometry
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
38
#include "
lvr2/geometry/BaseVector.hpp
"
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;
59
ColorVertex
()
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
98
ColorVertex
(
const
ColorVertex
&o)
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
163
using
uColorVertex
=
ColorVertex<float, unsigned char>
;
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_ */
lvr2::ColorVertex::ColorVertex
ColorVertex(const CoordType &_x, const CoordType &_y, const CoordType &_z)
Builds a ColorVertex with the given coordinates.
Definition:
ColorVertex.hpp:69
BaseVector.hpp
lvr2::ColorVertex::ColorVertex
ColorVertex()
Default constructor. All coordinates and the color are initialized with zeros.
Definition:
ColorVertex.hpp:59
lvr2::BaseVector
A generic, weakly-typed vector.
Definition:
BaseVector.hpp:60
lvr2::ColorVertex::CoordType
T CoordType
Definition:
ColorVertex.hpp:54
lvr2::operator<<
std::ostream & operator<<(std::ostream &os, const BaseVector< T > &v)
Definition:
BaseVector.hpp:227
lvr2::BaseVector< T >::x
T x
Definition:
BaseVector.hpp:65
lvr2::ColorVertex::r
ColorT r
Definition:
ColorVertex.hpp:158
lvr2::ColorVertex::ColorVertex
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
lvr2::BaseVector< T >::y
T y
Definition:
BaseVector.hpp:66
lvr2::ColorVertex::operator[]
CoordType operator[](const int &index) const
Definition:
ColorVertex.hpp:123
lvr2::ColorVertex::operator[]
CoordType & operator[](const int &index)
Definition:
ColorVertex.hpp:141
lvr2::ColorVertex::fusion
bool fusion
Definition:
ColorVertex.hpp:159
lvr2::ColorVertex::b
ColorT b
Definition:
ColorVertex.hpp:158
lvr2::BaseVector< T >::z
T z
Definition:
BaseVector.hpp:67
lvr2::ColorVertex::ColorVertex
ColorVertex(const ColorVertex &o)
Copy Ctor.
Definition:
ColorVertex.hpp:98
lvr2
Definition:
BaseBufferManipulators.hpp:39
lvr2::ColorVertex::g
ColorT g
Definition:
ColorVertex.hpp:158
lvr2::ColorVertex::ColorVertex
ColorVertex(const T &o)
Copy Ctor.
Definition:
ColorVertex.hpp:112
lvr2::ColorVertex
A color vertex.
Definition:
ColorVertex.hpp:50
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 Wed Mar 2 2022 00:37:23