MrSID Decode SDK for LiDAR Reference Manual 1.1.4.4709

- Main Page
- Classes
- Files

- File List
- File Members

PointData.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_POINT_DATA_H__
13 #define __LIDAR_POINT_DATA_H__
14
15 #include "lidar/Base.h"
16
17 LT_BEGIN_LIDAR_NAMESPACE
18 class ChannelData;
19 class PointData;
20
26 enum DataType
27 {
28 // don't change the values they are serialized
29 // all values must be less then 1 << 16
30
31 DATATYPE_INVALID = 0x0000,
32
33 DATATYPE_UINT8 = 0x0100,
34 DATATYPE_SINT8 = 0x0101,
35 DATATYPE_UINT16 = 0x0200,
36 DATATYPE_SINT16 = 0x0201,
37 DATATYPE_UINT32 = 0x0400,
38 DATATYPE_SINT32 = 0x0401,
39 DATATYPE_UINT64 = 0x0800,
40 DATATYPE_SINT64 = 0x0801,
41
42 DATATYPE_FLOAT32 = 0x0403,
43 DATATYPE_FLOAT64 = 0x0803
44 };
45
49 struct DataTypeUtils
50 {
58 static inline bool isSigned(DataType dt) { return (dt & 0x1) == 0x1; }
59
67 static inline bool isFloat(DataType dt) { return (dt & 0x2) == 0x2; }
68
77 static inline int byteWidth(DataType dt) { return (dt >> 8) & 0xFF; }
78
87 static const char *toString(DataType dt);
88 static DataType toDataType(const char *str);
89 };
90
94 #define CHANNEL_NAME_X "X"
95 #define CHANNEL_NAME_Y "Y"
96 #define CHANNEL_NAME_Z "Z"
97 #define CHANNEL_NAME_Intensity "Intensity"
98 #define CHANNEL_NAME_ReturnNum "ReturnNum"
99 #define CHANNEL_NAME_NumReturns "NumReturns"
100 #define CHANNEL_NAME_ScanDir "ScanDir"
101 #define CHANNEL_NAME_EdgeFlightLine "EdgeFlightLine"
102 #define CHANNEL_NAME_ScannerChannel "ScannerChannel"
103 #define CHANNEL_NAME_ClassId "ClassId"
104 #define CHANNEL_NAME_ClassFlags "ClassFlags"
105 #define CHANNEL_NAME_ScanAngle "ScanAngle"
106 #define CHANNEL_NAME_UserData "UserData"
107 #define CHANNEL_NAME_SourceId "SourceId"
108 #define CHANNEL_NAME_GPSTime_Week "GPSTime"
109 #define CHANNEL_NAME_GPSTime_Adjusted "GPSTime_Adjusted"
110 #define CHANNEL_NAME_Red "Red"
111 #define CHANNEL_NAME_Green "Green"
112 #define CHANNEL_NAME_Blue "Blue"
113 #define CHANNEL_NAME_NearInfrared "NearInfrared"
114
115 // Used with the TXTPointReader to skip a field
116 #define CHANNEL_NAME_Skip "@Skip"
117
118
119
126 class ChannelInfo
127 {
128 SIMPLE_OBJECT(ChannelInfo);
129 public:
130 ~ChannelInfo(void);
131 ChannelInfo(void);
132
133 void init(const char *name, DataType datatype, int bits, double quantization = 0);
134 void init(const ChannelInfo &info);
135
141 const char *getName(void) const;
142
148 DataType getDataType(void) const;
149
157 size_t getBits(void) const;
158
164 double getQuantization(void) const;
165 void setQuantization(double value);
166
167 bool operator==(const ChannelInfo &rhs) const;
168 bool operator!=(const ChannelInfo &rhs) const { return !operator==(rhs); }
169
170 protected:
171 char *m_name;
172 DataType m_datatype;
173 int m_bits;
174 double m_quantization;
175 };
176
185 class PointInfo
186 {
187 SIMPLE_OBJECT(PointInfo);
188 public:
189 ~PointInfo(void);
190 PointInfo(void);
191
192 void init(size_t numChannels);
193 void init(const PointInfo &pointInfo);
194 void init(const PointData &pointData);
195
196 void init(const PointInfo &pointInfo, const char * const *channels, size_t numChannels);
197 void init(const PointData &pointData, const char * const *channels, size_t numChannels);
198
199 void init(const PointInfo &pointInfo, const size_t *channels, size_t numChannels);
200 void init(const PointData &pointData, const size_t *channels, size_t numChannels);
201
202
208 size_t getNumChannels(void) const;
209
218 const ChannelInfo &getChannel(size_t idx) const;
219
228 ChannelInfo &getChannel(size_t idx);
229
238 bool hasChannel(const char *name) const;
239
248 const ChannelInfo *getChannel(const char *name) const;
249
258 ChannelInfo *getChannel(const char *name);
259
268 size_t getChannelIndex(const char *name) const;
269
276 bool hasValidXYZ(void) const;
277
278
279 bool operator==(const PointInfo &rhs) const;
280 bool operator!=(const PointInfo &rhs) const { return !operator==(rhs); }
281
282 protected:
283 size_t m_numChannels;
284 ChannelInfo *m_channel;
285 };
286
290 class ChannelData : public ChannelInfo
291 {
292 DISABLE_COPY(ChannelData);
293 public:
294 ~ChannelData(void);
295 ChannelData(void);
296
297 void init(const ChannelInfo &info, size_t numSamples);
298
305 size_t getNumSamples(void) const;
306
315 const void *getData(void) const;
316
325 void *getData(void);
326
340 static void copy(ChannelData &dst, size_t dstOffset,
341 const ChannelData &src, size_t srcOffset,
342 size_t length);
343
359 static void convert(ChannelData &dst, size_t dstOffset,
360 const ChannelData &src, size_t srcOffset,
361 size_t length);
362
382 static void convert(ChannelData &dst, size_t dstOffset,
383 const ChannelData &src, size_t srcOffset,
384 double offset, double scale,
385 size_t length);
386
396 void setDataType(DataType datatype);
397
404 void resize(size_t newNumSamples);
405
407 void setOffset(size_t offset);
408
410 void setData(void *data, bool deleteData);
411
412 protected:
413 size_t m_numSamples;
414 size_t m_offset;
415 void *m_data;
416 bool m_deleteData;
417 };
418
427 class PointData
428 {
429 SIMPLE_OBJECT(PointData);
430 public:
431 ~PointData(void);
432 PointData(void);
433
434 void init(const PointInfo &pointInfo, size_t numSamples);
435
441 size_t getNumChannels(void) const;
442
449 size_t getNumSamples(void) const;
450
459 const ChannelData &getChannel(size_t idx) const;
460
469 ChannelData &getChannel(size_t idx);
470
479 bool hasChannel(const char *name) const;
480
489 const ChannelData *getChannel(const char *name) const;
490
499 ChannelData *getChannel(const char *name);
500
506 const double *getX(void) const;
507
513 double *getX(void);
514
520 const double *getY(void) const;
521
527 double *getY(void);
528
534 const double *getZ(void) const;
535
541 double *getZ(void);
542
556 static void copy(PointData &dst, size_t dstOffset,
557 const PointData &src, size_t srcOffset,
558 size_t length);
559
573 static void merge(PointData &dst, size_t dstNumPoints,
574 const PointData &src, size_t srcNumPoints);
575
582 void resize(size_t newNumSamples);
583
585 void setOffset(size_t offset);
586 protected:
587 size_t m_numChannels;
588 ChannelData *m_channel;
589 size_t m_numSamples;
590 size_t m_offset;
591
592 // just pointers into m_channel[]
593 double *m_x;
594 double *m_y;
595 double *m_z;
596 };
597
598 LT_END_LIDAR_NAMESPACE
599 #endif /* __LIDAR_POINT_DATA_H__ */

LizardTech