MrSID Decode SDK for LiDAR Reference Manual  1.1.4.4709
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  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 
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;
173  int m_bits;
175 };
176 
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:
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;
417 };
418 
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:
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__ */
bool operator!=(const PointInfo &rhs) const
Definition: PointData.h:280
size_t m_numChannels
Definition: PointData.h:283
size_t getNumSamples(void) const
Get the number of samples.
bool hasValidXYZ(void) const
Make sure the PointInfo has X, Y, and Z channels.
ChannelInfo stores the basic properties of a channel.
Definition: PointData.h:126
static void copy(ChannelData &dst, size_t dstOffset, const ChannelData &src, size_t srcOffset, size_t length)
Copy samples between channels.
void setOffset(size_t offset)
dirty hack – only use this if you're the buffer onwer
const double * getY(void) const
Get the Y values.
size_t m_numSamples
Definition: PointData.h:413
size_t m_offset
Definition: PointData.h:414
void init(const ChannelInfo &info, size_t numSamples)
void setQuantization(double value)
const void * getData(void) const
Get the data buffer.
bool operator==(const PointInfo &rhs) const
DataType getDataType(void) const
Get the data type.
ChannelData * m_channel
Definition: PointData.h:588
void * m_data
Definition: PointData.h:415
static bool isFloat(DataType dt)
Determine if the datatype is a floating point type.
Definition: PointData.h:67
void init(const char *name, DataType datatype, int bits, double quantization=0)
PointInfo(void)
PointInfo is a group of ChannelInfo objects.
Definition: PointData.h:185
static DataType toDataType(const char *str)
double * m_y
Definition: PointData.h:594
void resize(size_t newNumSamples)
Resize the data buffer.
void init(size_t numChannels)
bool operator!=(const ChannelInfo &rhs) const
Definition: PointData.h:168
bool hasChannel(const char *name) const
Determine if there is a channel with a given name.
DataType m_datatype
Definition: PointData.h:172
void setOffset(size_t offset)
dirty hack – only use this if you're the buffer onwer
size_t m_numChannels
Definition: PointData.h:587
double * m_x
Definition: PointData.h:593
bool hasChannel(const char *name) const
Determine if there is a channel with a given name.
double m_quantization
Definition: PointData.h:174
static const char * toString(DataType dt)
Get the string representation.
void setData(void *data, bool deleteData)
change the buffer
~PointInfo(void)
~PointData(void)
~ChannelInfo(void)
const char * getName(void) const
Get the name.
double getQuantization(void) const
Get the quantization scale.
PointData is a group of ChannelData objects.
Definition: PointData.h:427
size_t getChannelIndex(const char *name) const
Get the index for a given channel.
~ChannelData(void)
const double * getX(void) const
Get the X values.
void init(const PointInfo &pointInfo, size_t numSamples)
const double * getZ(void) const
Get the Z values.
const ChannelData & getChannel(size_t idx) const
Access the channel data.
bool m_deleteData
Definition: PointData.h:416
bool operator==(const ChannelInfo &rhs) const
size_t m_numSamples
Definition: PointData.h:589
ChannelInfo * m_channel
Definition: PointData.h:284
static int byteWidth(DataType dt)
Get the data type size.
Definition: PointData.h:77
PointData(void)
const ChannelInfo & getChannel(size_t idx) const
Access the channel info.
ChannelData(void)
char * m_name
Definition: PointData.h:171
size_t getNumChannels(void) const
Get the number of channels.
size_t getNumChannels(void) const
Get the number of channels.
static void merge(PointData &dst, size_t dstNumPoints, const PointData &src, size_t srcNumPoints)
Merge points.
static bool isSigned(DataType dt)
Determine if the datatype is signed.
Definition: PointData.h:58
void resize(size_t newNumSamples)
Resize the data buffer.
static void copy(PointData &dst, size_t dstOffset, const PointData &src, size_t srcOffset, size_t length)
Copy samples between buffers.
size_t m_offset
Definition: PointData.h:590
Helper functions for interaction with the DataType enum.
Definition: PointData.h:49
void setDataType(DataType datatype)
Channge the data type on the fly.
DataType
Channel data types.
Definition: PointData.h:26
ChannelData adds sample values to the ChannelInfo class.
Definition: PointData.h:290
ChannelInfo(void)
static void convert(ChannelData &dst, size_t dstOffset, const ChannelData &src, size_t srcOffset, size_t length)
Copy and convert the data type of samples between channel.
size_t getNumSamples(void) const
Get the number of samples.
double * m_z
Definition: PointData.h:595
size_t getBits(void) const
Get the bit precision.

LizardTech