MrSID Decode SDK for LiDAR Reference Manual  1.1.3.4427
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_ClassId "ClassId"
103 #define CHANNEL_NAME_ScanAngle "ScanAngle"
104 #define CHANNEL_NAME_UserData "UserData"
105 #define CHANNEL_NAME_SourceId "SourceId"
106 #define CHANNEL_NAME_GPSTime_Week "GPSTime"
107 #define CHANNEL_NAME_GPSTime_Adjusted "GPSTime_Adjusted"
108 #define CHANNEL_NAME_Red "Red"
109 #define CHANNEL_NAME_Green "Green"
110 #define CHANNEL_NAME_Blue "Blue"
111 
112 // Used with the TXTPointReader to skip a field
113 #define CHANNEL_NAME_Skip "@Skip"
114 
115 
116 
124 {
125  SIMPLE_OBJECT(ChannelInfo);
126 public:
127  ~ChannelInfo(void);
128  ChannelInfo(void);
129 
130  void init(const char *name, DataType datatype, int bits, double quantization = 0);
131  void init(const ChannelInfo &info);
132 
138  const char *getName(void) const;
139 
145  DataType getDataType(void) const;
146 
154  size_t getBits(void) const;
155 
161  double getQuantization(void) const;
162 
163  bool operator==(const ChannelInfo &rhs) const;
164  bool operator!=(const ChannelInfo &rhs) const { return !operator==(rhs); }
165 
166 protected:
167  char *m_name;
169  int m_bits;
171 };
172 
182 {
183  SIMPLE_OBJECT(PointInfo);
184 public:
185  ~PointInfo(void);
186  PointInfo(void);
187 
188  void init(size_t numChannels);
189  void init(const PointInfo &pointInfo);
190  void init(const PointData &pointData);
191 
197  size_t getNumChannels(void) const;
198 
207  const ChannelInfo &getChannel(size_t idx) const;
208 
217  ChannelInfo &getChannel(size_t idx);
218 
227  bool hasChannel(const char *name) const;
228 
237  const ChannelInfo *getChannel(const char *name) const;
238 
247  ChannelInfo *getChannel(const char *name);
248 
257  size_t getChannelIndex(const char *name) const;
258 
265  bool hasValidXYZ(void) const;
266 
267 
268  bool operator==(const PointInfo &rhs) const;
269  bool operator!=(const PointInfo &rhs) const { return !operator==(rhs); }
270 
271 protected:
274 };
275 
279 class ChannelData : public ChannelInfo
280 {
281  DISABLE_COPY(ChannelData);
282 public:
283  ~ChannelData(void);
284  ChannelData(void);
285 
286  void init(const ChannelInfo &info, size_t numSamples);
287 
294  size_t getNumSamples(void) const;
295 
304  const void *getData(void) const;
305 
314  void *getData(void);
315 
329  static void copy(ChannelData &dst, size_t dstOffset,
330  const ChannelData &src, size_t srcOffset,
331  size_t length);
332 
348  static void convert(ChannelData &dst, size_t dstOffset,
349  const ChannelData &src, size_t srcOffset,
350  size_t length);
351 
371  static void convert(ChannelData &dst, size_t dstOffset,
372  const ChannelData &src, size_t srcOffset,
373  double offset, double scale,
374  size_t length);
375 
385  void setDataType(DataType datatype);
386 
393  void resize(size_t newNumSamples);
394 
396  void setOffset(size_t offset);
397 protected:
398  size_t m_numSamples;
399  size_t m_offset;
400  void *m_data;
401 };
402 
412 {
413  SIMPLE_OBJECT(PointData);
414 public:
415  ~PointData(void);
416  PointData(void);
417 
418  void init(const PointInfo &pointInfo, size_t numSamples);
419 
425  size_t getNumChannels(void) const;
426 
433  size_t getNumSamples(void) const;
434 
443  const ChannelData &getChannel(size_t idx) const;
444 
453  ChannelData &getChannel(size_t idx);
454 
463  bool hasChannel(const char *name) const;
464 
473  const ChannelData *getChannel(const char *name) const;
474 
483  ChannelData *getChannel(const char *name);
484 
490  const double *getX(void) const;
491 
497  double *getX(void);
498 
504  const double *getY(void) const;
505 
511  double *getY(void);
512 
518  const double *getZ(void) const;
519 
525  double *getZ(void);
526 
540  static void copy(PointData &dst, size_t dstOffset,
541  const PointData &src, size_t srcOffset,
542  size_t length);
543 
557  static void merge(PointData &dst, size_t dstNumPoints,
558  const PointData &src, size_t srcNumPoints);
559 
566  void resize(size_t newNumSamples);
567 
569  void setOffset(size_t offset);
570 protected:
573  size_t m_numSamples;
574  size_t m_offset;
575 
576  // just pointers into m_channel[]
577  double *m_x;
578  double *m_y;
579  double *m_z;
580 };
581 
582 LT_END_LIDAR_NAMESPACE
583 #endif /* __LIDAR_POINT_DATA_H__ */
bool operator!=(const PointInfo &rhs) const
Definition: PointData.h:269
size_t m_numChannels
Definition: PointData.h:272
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:123
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:398
size_t m_offset
Definition: PointData.h:399
void init(const ChannelInfo &info, size_t numSamples)
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:572
void * m_data
Definition: PointData.h:400
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:181
static DataType toDataType(const char *str)
double * m_y
Definition: PointData.h:578
void resize(size_t newNumSamples)
Resize the data buffer.
void init(size_t numChannels)
bool operator!=(const ChannelInfo &rhs) const
Definition: PointData.h:164
bool hasChannel(const char *name) const
Determine if there is a channel with a given name.
DataType m_datatype
Definition: PointData.h:168
void setOffset(size_t offset)
dirty hack – only use this if you're the buffer onwer
size_t m_numChannels
Definition: PointData.h:571
double * m_x
Definition: PointData.h:577
bool hasChannel(const char *name) const
Determine if there is a channel with a given name.
double m_quantization
Definition: PointData.h:170
static const char * toString(DataType dt)
Get the string representation.
~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:411
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 operator==(const ChannelInfo &rhs) const
size_t m_numSamples
Definition: PointData.h:573
ChannelInfo * m_channel
Definition: PointData.h:273
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:167
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:574
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:279
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:579
size_t getBits(void) const
Get the bit precision.

LizardTech