forked from KeckCAVES/LidarViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LidarTypes.h
101 lines (88 loc) · 3.1 KB
/
LidarTypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/***********************************************************************
LidarTypes - Declarations of common data types in LiDAR processing and
visualization.
Copyright (c) 2008 Oliver Kreylos
This file is part of the LiDAR processing and analysis package.
The LiDAR processing and analysis package is free software; you can
redistribute it and/or modify it under the terms of the GNU General
Public License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
The LiDAR processing and analysis package is distributed in the hope
that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with the LiDAR processing and analysis package; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
***********************************************************************/
#ifndef LIDARTYPES_INCLDUDED
#define LIDARTYPES_INCLDUDED
#include <Geometry/Point.h>
#include <Geometry/Vector.h>
#include <Geometry/Box.h>
#include <Geometry/ValuedPoint.h>
typedef float Scalar; // Scalar type for 3D points
typedef Geometry::Point<Scalar,3> Point; // Type for 3D points
typedef Geometry::Vector<Scalar,3> Vector; // Type for vectors
typedef Geometry::Box<Scalar,3> Box; // Type for axis-aligned boxes
struct Color // Structure for RGBA colors (compatible with OpenGL)
{
/* Embedded classes: */
public:
typedef unsigned char Scalar; // Scalar type for color components
/* Elements: */
private:
Scalar rgba[4]; // Color components
/* Constructors and destructors: */
public:
Color(void)
{
}
Color(Scalar r,Scalar g,Scalar b,Scalar a =255)
{
rgba[0]=r;
rgba[1]=g;
rgba[2]=b;
rgba[3]=a;
}
/* Methods: */
const Scalar* getRgba(void) const // Returns color components as an array
{
return rgba;
}
Scalar* getRgba(void) // Ditto
{
return rgba;
}
Scalar operator[](int index) const // Returns a single color component
{
return rgba[index];
}
Scalar& operator[](int index) // Ditto
{
return rgba[index];
}
template <class SourceScalarParam>
static inline Scalar clampRound(SourceScalarParam value) // Rounds and clamps a source value
{
value=value<SourceScalarParam(0)?SourceScalarParam(0):value;
value=value>SourceScalarParam(255)?SourceScalarParam(255):value;
return Scalar(value+SourceScalarParam(0.5));
}
template <class SourceScalarParam>
void setRgb(const SourceScalarParam newRgba[3]) // Sets a color from source array, with clamping and rounding
{
for(int i=0;i<3;++i)
rgba[i]=clampRound(newRgba[i]);
rgba[3]=Scalar(255);
}
template <class SourceScalarParam>
void setRgba(const SourceScalarParam newRgba[4]) // Sets a color from source array, with clamping and rounding
{
for(int i=0;i<4;++i)
rgba[i]=clampRound(newRgba[i]);
}
};
typedef Geometry::ValuedPoint<Point,Color> LidarPoint; // Type for basic LiDAR data points (3D position + RGB color)
#endif