MrSID Decode SDK for LiDAR Reference Manual  1.1.2.4045
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 
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,
44 };
45 
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 };
89 
93 #define CHANNEL_NAME_X "X"
94 #define CHANNEL_NAME_Y "Y"
95 #define CHANNEL_NAME_Z "Z"
96 #define CHANNEL_NAME_Intensity "Intensity"
97 #define CHANNEL_NAME_ReturnNum "ReturnNum"
98 #define CHANNEL_NAME_NumReturns "NumReturns"
99 #define CHANNEL_NAME_ScanDir "ScanDir"
100 #define CHANNEL_NAME_EdgeFlightLine "EdgeFlightLine"
101 #define CHANNEL_NAME_ClassId "ClassId"
102 #define CHANNEL_NAME_ScanAngle "ScanAngle"
103 #define CHANNEL_NAME_UserData "UserData"
104 #define CHANNEL_NAME_SourceId "SourceId"
105 #define CHANNEL_NAME_GPSTime "GPSTime"
106 #define CHANNEL_NAME_Red "Red"
107 #define CHANNEL_NAME_Green "Green"
108 #define CHANNEL_NAME_Blue "Blue"
109 
110 // Used with the TXTPointReader to skip a field
111 #define CHANNEL_NAME_Skip "@Skip"
112 
113 
114 
122 {
123  SIMPLE_OBJECT(ChannelInfo);
124 public:
125  ~ChannelInfo(void);
126  ChannelInfo(void);
127 
128  void init(const char *name, DataType datatype, int bits);
129  void init(const ChannelInfo &info);
130 
136  const char *getName(void) const;
137 
143  DataType getDataType(void) const;
144 
152  size_t getBits(void) const;
153 
154  bool operator==(const ChannelInfo &rhs) const;
155  bool operator!=(const ChannelInfo &rhs) const { return !operator==(rhs); }
156 
157 protected:
158  char *m_name;
160  int m_bits;
161 };
162 
172 {
173  SIMPLE_OBJECT(PointInfo);
174 public:
175  ~PointInfo(void);
176  PointInfo(void);
177 
178  void init(size_t numChannels);
179  void init(const PointInfo &pointInfo);
180  void init(const PointData &pointData);
181 
187  size_t getNumChannels(void) const;
188 
197  const ChannelInfo &getChannel(size_t idx) const;
198 
207  ChannelInfo &getChannel(size_t idx);
208 
217  bool hasChannel(const char *name) const;
218 
227  const ChannelInfo *getChannel(const char *name) const;
228 
237  ChannelInfo *getChannel(const char *name);
238 
247  size_t getChannelIndex(const char *name) const;
248 
255  bool hasValidXYZ(void) const;
256 
257 protected:
260 };
261 
265 class ChannelData : public ChannelInfo
266 {
267  DISABLE_COPY(ChannelData);
268 public:
269  ~ChannelData(void);
270  ChannelData(void);
271 
272  void init(const ChannelInfo &info, size_t numSamples);
273 
280  size_t getNumSamples(void) const;
281 
290  const void *getData(void) const;
291 
300  void *getData(void);
301 
315  static void copy(ChannelData &dst, size_t dstOffset,
316  const ChannelData &src, size_t srcOffset,
317  size_t length);
318 
334  static void convert(ChannelData &dst, size_t dstOffset,
335  const ChannelData &src, size_t srcOffset,
336  size_t length);
337 
357  static void convert(ChannelData &dst, size_t dstOffset,
358  const ChannelData &src, size_t srcOffset,
359  double offset, double scale,
360  size_t length);
361 
371  void setDataType(DataType datatype);
372 
379  void resize(size_t newNumSamples);
380 
382  void setOffset(size_t offset);
383 protected:
384  size_t m_numSamples;
385  size_t m_offset;
386  void *m_data;
387 };
388 
398 {
399  SIMPLE_OBJECT(PointData);
400 public:
401  ~PointData(void);
402  PointData(void);
403 
404  void init(const PointInfo &pointInfo, size_t numSamples);
405 
411  size_t getNumChannels(void) const;
412 
419  size_t getNumSamples(void) const;
420 
429  const ChannelData &getChannel(size_t idx) const;
430 
439  ChannelData &getChannel(size_t idx);
440 
449  bool hasChannel(const char *name) const;
450 
459  const ChannelData *getChannel(const char *name) const;
460 
469  ChannelData *getChannel(const char *name);
470 
476  const double *getX(void) const;
477 
483  double *getX(void);
484 
490  const double *getY(void) const;
491 
497  double *getY(void);
498 
504  const double *getZ(void) const;
505 
511  double *getZ(void);
512 
526  static void copy(PointData &dst, size_t dstOffset,
527  const PointData &src, size_t srcOffset,
528  size_t length);
529 
543  static void merge(PointData &dst, size_t dstNumPoints,
544  const PointData &src, size_t srcNumPoints);
545 
552  void resize(size_t newNumSamples);
553 
555  void setOffset(size_t offset);
556 protected:
559  size_t m_numSamples;
560  size_t m_offset;
561 
562  // just pointers into m_channel[]
563  double *m_x;
564  double *m_y;
565  double *m_z;
566 };
567 
568 LT_END_LIDAR_NAMESPACE
569 #endif /* __LIDAR_POINT_DATA_H__ */

LizardTech