MrSID Decode SDK for LiDAR Reference Manual 1.1.4.4709

- Main Page
- Classes
- Files

- File List
- File Members

Types.h
Go to the documentation of this file.
1 /* //////////////////////////////////////////////////////////////////////////
2 // //
3 // This code is Copyright (c) 2008-2010 LizardTech, Inc, 1008 Western //
4 // Avenue, Suite 200, Seattle, WA 98104. Unauthorized use or distribution //
5 // prohibited. Access to and use of this code is permitted only under //
6 // license from LizardTech, Inc. Portions of the code are protected by //
7 // US and foreign patents and other filings. All Rights Reserved. //
8 // //
10 /* PUBLIC */
11
12 #ifndef __LIDAR_TYPES_H__
13 #define __LIDAR_TYPES_H__
14
15 #include "lidar/Base.h"
16 #include <math.h>
17 /* this should be a vaild C header file */
18
19 LT_BEGIN_LIDAR_NAMESPACE
20
21 #ifdef _WIN32
22 /* it looks like windows.h defined min() and max() */
23 #undef min
24 #undef max
25 #endif
26
33 struct Range
34 {
35 double min; /* -HUGE_VAL is valid */
36 double max; /* +HUGE_VAL is valid */
37
38 #ifdef __cplusplus
39 Range(double amin = +HUGE_VAL, double amax = -HUGE_VAL) :
40 min(amin), max(amax) {}
41
42 bool operator==(const Range &r) const
43 {
44 return min == r.min && max == r.max;
45 }
46
47 bool operator!=(const Range &r) const
48 {
49 return min != r.min || max != r.max;
50 }
51
53 bool contains(double v) const
54 {
55 return min <= v && v <= max;
56 }
57
59 bool overlaps(const Range &r) const
60 {
61 // assumes both are not empty()
62 return min <= r.max && max >= r.min;
63 }
64
66 bool empty(void) const
67 {
68 return min >= max;
69 }
70
72 double length(void) const
73 {
74 return max - min;
75 }
76
78 void shift(double v)
79 {
80 min += v;
81 max += v;
82 }
83
85 void scale(double v)
86 {
87 min *= v;
88 max *= v;
89 }
90
92 void clip(const Range &r)
93 {
94 if(r.min > min)
95 min = r.min;
96 if(r.max < max)
97 max = r.max;
98 }
99
101 void grow(const Range &r)
102 {
103 if(r.min < min)
104 min = r.min;
105 if(r.max > max)
106 max = r.max;
107 }
108
110 void grow(double v)
111 {
112 if(v < min)
113 min = v;
114 if(v > max)
115 max = v;
116 }
117 #endif
118 };
119 typedef struct Range Range;
120
127 struct Bounds
128 {
129 Range x;
130 Range y;
131 Range z;
132
133 #ifdef __cplusplus
134
135 static const Bounds &Huge(void);
136
137 Bounds(double xmin = +HUGE_VAL, double xmax = -HUGE_VAL,
138 double ymin = +HUGE_VAL, double ymax = -HUGE_VAL,
139 double zmin = +HUGE_VAL, double zmax = -HUGE_VAL) :
140 x(xmin, xmax), y(ymin, ymax), z(zmin, zmax) {}
141
142 Bounds(const Range &ax, const Range &ay, const Range &az) :
143 x(ax), y(ay), z(az) {}
144
145 bool operator==(const Bounds &b) const
146 {
147 return x == b.x && y == b.y && z == b.z;
148 }
149
150 bool operator!=(const Bounds &b) const
151 {
152 return x != b.x || y != b.y || z != b.z;
153 }
154
156 bool contains(double ax, double ay, double az) const
157 {
158 return x.contains(ax) && y.contains(ay) && z.contains(az);
159 }
160
162 bool overlaps(const Bounds &b) const
163 {
164 return x.overlaps(b.x) && y.overlaps(b.y) && z.overlaps(b.z);
165 }
166
168 bool empty(void) const
169 {
170 return x.empty() || y.empty() || z.empty();
171 }
172
174 double volume(void) const
175 {
176 return x.length() * y.length() * z.length();
177 }
178
180 void shift(double dx, double dy, double dz)
181 {
182 x.shift(dx);
183 y.shift(dy);
184 z.shift(dz);
185 }
186
188 void scale(double dx, double dy, double dz)
189 {
190 x.scale(dx);
191 y.scale(dy);
192 z.scale(dz);
193 }
194
196 void clip(const Bounds &r)
197 {
198 x.clip(r.x);
199 y.clip(r.y);
200 z.clip(r.z);
201 }
202
204 void grow(const Bounds &r)
205 {
206 x.grow(r.x);
207 y.grow(r.y);
208 z.grow(r.z);
209 }
210
212 void grow(double ax, double ay, double az)
213 {
214 x.grow(ax);
215 y.grow(ay);
216 z.grow(az);
217 }
218
227 static double overlapFraction(const Bounds &r1, const Bounds &r2);
228 #endif
229 };
230 typedef struct Bounds Bounds;
231
232 LT_END_LIDAR_NAMESPACE
233 #endif /* __LIDAR_TYPES_H__ */

LizardTech