MrSID Decode SDK for LiDAR Reference Manual  1.1.5.5244
PointData.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_POINT_DATA_H__
9 #define __LIDAR_POINT_DATA_H__
10 
11 #include "lidar/Base.h"
12 
13 LT_BEGIN_LIDAR_NAMESPACE
14 class ChannelData;
15 class PointData;
16 
23 {
24  // don't change the values they are serialized
25  // all values must be less then 1 << 16
26 
27  DATATYPE_INVALID = 0x0000,
28 
29  DATATYPE_UINT8 = 0x0100,
30  DATATYPE_SINT8 = 0x0101,
31  DATATYPE_UINT16 = 0x0200,
32  DATATYPE_SINT16 = 0x0201,
33  DATATYPE_UINT32 = 0x0400,
34  DATATYPE_SINT32 = 0x0401,
35  DATATYPE_UINT64 = 0x0800,
36  DATATYPE_SINT64 = 0x0801,
37 
38  DATATYPE_FLOAT32 = 0x0403,
39  DATATYPE_FLOAT64 = 0x0803
40 };
41 
46 {
54  static inline bool isSigned(DataType dt) { return (dt & 0x1) == 0x1; }
55 
63  static inline bool isFloat(DataType dt) { return (dt & 0x2) == 0x2; }
64 
73  static inline int byteWidth(DataType dt) { return (dt >> 8) & 0xFF; }
74 
83  static const char *toString(DataType dt);
84  static DataType toDataType(const char *str);
85 };
86 
90 #define CHANNEL_NAME_X "X"
91 #define CHANNEL_NAME_Y "Y"
92 #define CHANNEL_NAME_Z "Z"
93 #define CHANNEL_NAME_Intensity "Intensity"
94 #define CHANNEL_NAME_ReturnNum "ReturnNum"
95 #define CHANNEL_NAME_NumReturns "NumReturns"
96 #define CHANNEL_NAME_ScanDir "ScanDir"
97 #define CHANNEL_NAME_EdgeFlightLine "EdgeFlightLine"
98 #define CHANNEL_NAME_ScannerChannel "ScannerChannel"
99 #define CHANNEL_NAME_ClassId "ClassId"
100 #define CHANNEL_NAME_ClassFlags "ClassFlags"
101 #define CHANNEL_NAME_ScanAngle "ScanAngle"
102 #define CHANNEL_NAME_UserData "UserData"
103 #define CHANNEL_NAME_SourceId "SourceId"
104 #define CHANNEL_NAME_GPSTime_Week "GPSTime"
105 #define CHANNEL_NAME_GPSTime_Adjusted "GPSTime_Adjusted"
106 #define CHANNEL_NAME_Red "Red"
107 #define CHANNEL_NAME_Green "Green"
108 #define CHANNEL_NAME_Blue "Blue"
109 #define CHANNEL_NAME_NearInfrared "NearInfrared"
110 
111 // Used with the TXTPointReader to skip a field
112 #define CHANNEL_NAME_Skip "@Skip"
113 
114 
115 
123 {
124  SIMPLE_OBJECT(ChannelInfo);
125 public:
127  ChannelInfo(void);
128 
129  void init(const char *name, DataType datatype, int bits, double quantization = 0);
130  void init(const ChannelInfo &info);
131 
137  const char *getName(void) const;
138 
144  DataType getDataType(void) const;
145 
153  size_t getBits(void) const;
154 
160  double getQuantization(void) const;
161  void setQuantization(double value);
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 
192  void init(const PointInfo &pointInfo, const char * const *channels, size_t numChannels);
193  void init(const PointData &pointData, const char * const *channels, size_t numChannels);
194 
195  void init(const PointInfo &pointInfo, const size_t *channels, size_t numChannels);
196  void init(const PointData &pointData, const size_t *channels, size_t numChannels);
197 
198 
204  size_t getNumChannels(void) const;
205 
214  const ChannelInfo &getChannel(size_t idx) const;
215 
224  ChannelInfo &getChannel(size_t idx);
225 
234  bool hasChannel(const char *name) const;
235 
244  const ChannelInfo *getChannel(const char *name) const;
245 
254  ChannelInfo *getChannel(const char *name);
255 
264  size_t getChannelIndex(const char *name) const;
265 
272  bool hasValidXYZ(void) const;
273 
281  size_t getBits(void) const;
282 
283 
284  bool operator==(const PointInfo &rhs) const;
285  bool operator!=(const PointInfo &rhs) const { return !operator==(rhs); }
286 
287 protected:
290 };
291 
295 class ChannelData : public ChannelInfo
296 {
297  DISABLE_COPY(ChannelData);
298 public:
300  ChannelData(void);
301 
302  void init(const ChannelInfo &info, size_t numSamples);
303 
310  size_t getNumSamples(void) const;
311 
320  const void *getData(void) const;
321 
330  void *getData(void);
331 
345  static void copy(ChannelData &dst, size_t dstOffset,
346  const ChannelData &src, size_t srcOffset,
347  size_t length);
348 
364  static void convert(ChannelData &dst, size_t dstOffset,
365  const ChannelData &src, size_t srcOffset,
366  size_t length);
367 
387  static void convert(ChannelData &dst, size_t dstOffset,
388  const ChannelData &src, size_t srcOffset,
389  double offset, double scale,
390  size_t length);
391 
401  void setDataType(DataType datatype);
402 
409  void resize(size_t newNumSamples);
410 
412  void setOffset(size_t offset);
413 
415  void setData(void *data, bool deleteData);
416 
417 protected:
418  size_t m_numSamples;
419  size_t m_offset;
420  void *m_data;
422 };
423 
433 {
434  SIMPLE_OBJECT(PointData);
435 public:
436  ~PointData(void);
437  PointData(void);
438 
439  void init(const PointInfo &pointInfo, size_t numSamples);
440 
446  size_t getNumChannels(void) const;
447 
454  size_t getNumSamples(void) const;
455 
464  const ChannelData &getChannel(size_t idx) const;
465 
474  ChannelData &getChannel(size_t idx);
475 
484  bool hasChannel(const char *name) const;
485 
494  const ChannelData *getChannel(const char *name) const;
495 
504  ChannelData *getChannel(const char *name);
505 
511  const double *getX(void) const;
512 
518  double *getX(void);
519 
525  const double *getY(void) const;
526 
532  double *getY(void);
533 
539  const double *getZ(void) const;
540 
546  double *getZ(void);
547 
561  static void copy(PointData &dst, size_t dstOffset,
562  const PointData &src, size_t srcOffset,
563  size_t length);
564 
578  static void merge(PointData &dst, size_t dstNumPoints,
579  const PointData &src, size_t srcNumPoints);
580 
587  void resize(size_t newNumSamples);
588 
590  void setOffset(size_t offset);
591 protected:
594  size_t m_numSamples;
595  size_t m_offset;
596 
597  // just pointers into m_channel[]
598  double *m_x;
599  double *m_y;
600  double *m_z;
601 };
602 
603 LT_END_LIDAR_NAMESPACE
604 #endif /* __LIDAR_POINT_DATA_H__ */
DataType
Channel data types.
Definition: PointData.h:23
@ DATATYPE_UINT16
Definition: PointData.h:31
@ DATATYPE_SINT32
Definition: PointData.h:34
@ DATATYPE_UINT32
Definition: PointData.h:33
@ DATATYPE_UINT64
Definition: PointData.h:35
@ DATATYPE_UINT8
Definition: PointData.h:29
@ DATATYPE_SINT16
Definition: PointData.h:32
@ DATATYPE_INVALID
Definition: PointData.h:27
@ DATATYPE_FLOAT32
Definition: PointData.h:38
@ DATATYPE_SINT64
Definition: PointData.h:36
@ DATATYPE_FLOAT64
Definition: PointData.h:39
@ DATATYPE_SINT8
Definition: PointData.h:30
Helper functions for interaction with the DataType enum.
Definition: PointData.h:46
static int byteWidth(DataType dt)
Get the data type size.
Definition: PointData.h:73
static DataType toDataType(const char *str)
static bool isFloat(DataType dt)
Determine if the datatype is a floating point type.
Definition: PointData.h:63
static bool isSigned(DataType dt)
Determine if the datatype is signed.
Definition: PointData.h:54
static const char * toString(DataType dt)
Get the string representation.
ChannelInfo stores the basic properties of a channel.
Definition: PointData.h:123
const char * getName(void) const
Get the name.
bool operator!=(const ChannelInfo &rhs) const
Definition: PointData.h:164
~ChannelInfo(void)
double getQuantization(void) const
Get the quantization scale.
DataType m_datatype
Definition: PointData.h:168
DataType getDataType(void) const
Get the data type.
size_t getBits(void) const
Get the bit precision.
char * m_name
Definition: PointData.h:167
void setQuantization(double value)
void init(const char *name, DataType datatype, int bits, double quantization=0)
void init(const ChannelInfo &info)
ChannelInfo(void)
double m_quantization
Definition: PointData.h:170
bool operator==(const ChannelInfo &rhs) const
PointInfo is a group of ChannelInfo objects.
Definition: PointData.h:182
void init(const PointData &pointData)
bool hasChannel(const char *name) const
Determine if there is a channel with a given name.
size_t m_numChannels
Definition: PointData.h:288
bool operator==(const PointInfo &rhs) const
const ChannelInfo & getChannel(size_t idx) const
Access the channel info.
size_t getChannelIndex(const char *name) const
Get the index for a given channel.
const ChannelInfo * getChannel(const char *name) const
Access the channel data.
ChannelInfo & getChannel(size_t idx)
Access the channel info.
void init(const PointInfo &pointInfo, const char *const *channels, size_t numChannels)
void init(const PointData &pointData, const size_t *channels, size_t numChannels)
void init(size_t numChannels)
ChannelInfo * getChannel(const char *name)
Access the channel data.
void init(const PointInfo &pointInfo, const size_t *channels, size_t numChannels)
PointInfo(void)
void init(const PointData &pointData, const char *const *channels, size_t numChannels)
bool hasValidXYZ(void) const
Make sure the PointInfo has X, Y, and Z channels.
~PointInfo(void)
size_t getBits(void) const
Get the total bits used by all channels.
void init(const PointInfo &pointInfo)
bool operator!=(const PointInfo &rhs) const
Definition: PointData.h:285
ChannelInfo * m_channel
Definition: PointData.h:289
size_t getNumChannels(void) const
Get the number of channels.
ChannelData adds sample values to the ChannelInfo class.
Definition: PointData.h:296
size_t getNumSamples(void) const
Get the number of samples.
size_t m_offset
Definition: PointData.h:419
size_t m_numSamples
Definition: PointData.h:418
const void * getData(void) const
Get the data buffer.
void * getData(void)
Get the data buffer.
void setOffset(size_t offset)
dirty hack – only use this if you're the buffer onwer
void init(const ChannelInfo &info, size_t numSamples)
void setData(void *data, bool deleteData)
change the buffer
void setDataType(DataType datatype)
Channge the data type on the fly.
void * m_data
Definition: PointData.h:420
static void convert(ChannelData &dst, size_t dstOffset, const ChannelData &src, size_t srcOffset, double offset, double scale, size_t length)
Copy and convert the data type of samples between channel.
~ChannelData(void)
static void copy(ChannelData &dst, size_t dstOffset, const ChannelData &src, size_t srcOffset, size_t length)
Copy samples between channels.
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.
void resize(size_t newNumSamples)
Resize the data buffer.
bool m_deleteData
Definition: PointData.h:421
ChannelData(void)
PointData is a group of ChannelData objects.
Definition: PointData.h:433
const double * getY(void) const
Get the Y values.
static void copy(PointData &dst, size_t dstOffset, const PointData &src, size_t srcOffset, size_t length)
Copy samples between buffers.
~PointData(void)
const double * getZ(void) const
Get the Z values.
size_t m_numSamples
Definition: PointData.h:594
const ChannelData * getChannel(const char *name) const
Access the channel data.
double * m_y
Definition: PointData.h:599
double * m_x
Definition: PointData.h:598
double * getX(void)
Get the X values.
ChannelData * m_channel
Definition: PointData.h:593
void init(const PointInfo &pointInfo, size_t numSamples)
void resize(size_t newNumSamples)
Resize the data buffer.
size_t m_offset
Definition: PointData.h:595
static void merge(PointData &dst, size_t dstNumPoints, const PointData &src, size_t srcNumPoints)
Merge points.
void setOffset(size_t offset)
dirty hack – only use this if you're the buffer onwer
double * getY(void)
Get the Y values.
const double * getX(void) const
Get the X values.
double * getZ(void)
Get the Z values.
ChannelData * getChannel(const char *name)
Access the channel data.
double * m_z
Definition: PointData.h:600
size_t getNumChannels(void) const
Get the number of channels.
size_t getNumSamples(void) const
Get the number of samples.
const ChannelData & getChannel(size_t idx) const
Access the channel data.
PointData(void)
bool hasChannel(const char *name) const
Determine if there is a channel with a given name.
ChannelData & getChannel(size_t idx)
Access the channel data.
size_t m_numChannels
Definition: PointData.h:592

Extensis