MrSID Decode SDK for LiDAR Reference Manual 1.1.5.5244
Types.h
Go to the documentation of this file.
1//
2// This code is property of Celartem, Inc dba Extensis.
3// Copyright (c) 1995-2023. All rights reserved.
4// Use permitted only under license from Extensis.
5//
6/* PUBLIC */
7
8#ifndef __LIDAR_TYPES_H__
9#define __LIDAR_TYPES_H__
10
11#include "lidar/Base.h"
12#include <math.h>
13/* this should be a vaild C header file */
14
15LT_BEGIN_LIDAR_NAMESPACE
16
17#ifdef _WIN32
18/* it looks like windows.h defined min() and max() */
19#undef min
20#undef max
21#endif
22
29struct Range
30{
31 double min; /* -HUGE_VAL is valid */
32 double max; /* +HUGE_VAL is valid */
33
34#ifdef __cplusplus
35 Range(double amin = +HUGE_VAL, double amax = -HUGE_VAL) :
36 min(amin), max(amax) {}
37
38 bool operator==(const Range &r) const
39 {
40 return min == r.min && max == r.max;
41 }
42
43 bool operator!=(const Range &r) const
44 {
45 return min != r.min || max != r.max;
46 }
47
49 bool contains(double v) const
50 {
51 return min <= v && v <= max;
52 }
53
55 bool overlaps(const Range &r) const
56 {
57 // assumes both are not empty()
58 return min <= r.max && max >= r.min;
59 }
60
62 bool empty(void) const
63 {
64 return min >= max;
65 }
66
68 double length(void) const
69 {
70 return max - min;
71 }
72
74 void shift(double v)
75 {
76 min += v;
77 max += v;
78 }
79
81 void scale(double v)
82 {
83 min *= v;
84 max *= v;
85 }
86
88 void clip(const Range &r)
89 {
90 if(r.min > min)
91 min = r.min;
92 if(r.max < max)
93 max = r.max;
94 }
95
97 void grow(const Range &r)
98 {
99 if(r.min < min)
100 min = r.min;
101 if(r.max > max)
102 max = r.max;
103 }
104
106 void grow(double v)
107 {
108 if(v < min)
109 min = v;
110 if(v > max)
111 max = v;
112 }
113#endif
114};
115typedef struct Range Range;
116
123struct Bounds
124{
128
129#ifdef __cplusplus
130
131 static const Bounds &Huge(void);
132
133 Bounds(double xmin = +HUGE_VAL, double xmax = -HUGE_VAL,
134 double ymin = +HUGE_VAL, double ymax = -HUGE_VAL,
135 double zmin = +HUGE_VAL, double zmax = -HUGE_VAL) :
136 x(xmin, xmax), y(ymin, ymax), z(zmin, zmax) {}
137
138 Bounds(const Range &ax, const Range &ay, const Range &az) :
139 x(ax), y(ay), z(az) {}
140
141 bool operator==(const Bounds &b) const
142 {
143 return x == b.x && y == b.y && z == b.z;
144 }
145
146 bool operator!=(const Bounds &b) const
147 {
148 return x != b.x || y != b.y || z != b.z;
149 }
150
152 bool contains(double ax, double ay, double az) const
153 {
154 return x.contains(ax) && y.contains(ay) && z.contains(az);
155 }
156
158 bool overlaps(const Bounds &b) const
159 {
160 return x.overlaps(b.x) && y.overlaps(b.y) && z.overlaps(b.z);
161 }
162
164 bool empty(void) const
165 {
166 return x.empty() || y.empty() || z.empty();
167 }
168
170 double volume(void) const
171 {
172 return x.length() * y.length() * z.length();
173 }
174
176 void shift(double dx, double dy, double dz)
177 {
178 x.shift(dx);
179 y.shift(dy);
180 z.shift(dz);
181 }
182
184 void scale(double dx, double dy, double dz)
185 {
186 x.scale(dx);
187 y.scale(dy);
188 z.scale(dz);
189 }
190
192 void clip(const Bounds &r)
193 {
194 x.clip(r.x);
195 y.clip(r.y);
196 z.clip(r.z);
197 }
198
200 void grow(const Bounds &r)
201 {
202 x.grow(r.x);
203 y.grow(r.y);
204 z.grow(r.z);
205 }
206
208 void grow(double ax, double ay, double az)
209 {
210 x.grow(ax);
211 y.grow(ay);
212 z.grow(az);
213 }
214
223 static double overlapFraction(const Bounds &r1, const Bounds &r2);
224#endif
225};
226typedef struct Bounds Bounds;
227
228LT_END_LIDAR_NAMESPACE
229#endif /* __LIDAR_TYPES_H__ */
Range is a 1-dimensional interval.
Definition: Types.h:30
double max
Definition: Types.h:32
double min
Definition: Types.h:31
Bounds is a 3-dimensional bounding box.
Definition: Types.h:124
Range z
Definition: Types.h:127
Range x
Definition: Types.h:125
Range y
Definition: Types.h:126

Extensis