MrSID Decode SDK for LiDAR Reference Manual
1.1.4.4709
|
00001 /* ////////////////////////////////////////////////////////////////////////// 00002 // // 00003 // This code is Copyright (c) 2008-2010 LizardTech, Inc, 1008 Western // 00004 // Avenue, Suite 200, Seattle, WA 98104. Unauthorized use or distribution // 00005 // prohibited. Access to and use of this code is permitted only under // 00006 // license from LizardTech, Inc. Portions of the code are protected by // 00007 // US and foreign patents and other filings. All Rights Reserved. // 00008 // // 00010 /* PUBLIC */ 00011 00012 #ifndef __LIDAR_POINT_DATA_H__ 00013 #define __LIDAR_POINT_DATA_H__ 00014 00015 #include "lidar/Base.h" 00016 00017 LT_BEGIN_LIDAR_NAMESPACE 00018 class ChannelData; 00019 class PointData; 00020 00026 enum DataType 00027 { 00028 // don't change the values they are serialized 00029 // all values must be less then 1 << 16 00030 00031 DATATYPE_INVALID = 0x0000, 00032 00033 DATATYPE_UINT8 = 0x0100, 00034 DATATYPE_SINT8 = 0x0101, 00035 DATATYPE_UINT16 = 0x0200, 00036 DATATYPE_SINT16 = 0x0201, 00037 DATATYPE_UINT32 = 0x0400, 00038 DATATYPE_SINT32 = 0x0401, 00039 DATATYPE_UINT64 = 0x0800, 00040 DATATYPE_SINT64 = 0x0801, 00041 00042 DATATYPE_FLOAT32 = 0x0403, 00043 DATATYPE_FLOAT64 = 0x0803 00044 }; 00045 00049 struct DataTypeUtils 00050 { 00058 static inline bool isSigned(DataType dt) { return (dt & 0x1) == 0x1; } 00059 00067 static inline bool isFloat(DataType dt) { return (dt & 0x2) == 0x2; } 00068 00077 static inline int byteWidth(DataType dt) { return (dt >> 8) & 0xFF; } 00078 00087 static const char *toString(DataType dt); 00088 static DataType toDataType(const char *str); 00089 }; 00090 00094 #define CHANNEL_NAME_X "X" 00095 #define CHANNEL_NAME_Y "Y" 00096 #define CHANNEL_NAME_Z "Z" 00097 #define CHANNEL_NAME_Intensity "Intensity" 00098 #define CHANNEL_NAME_ReturnNum "ReturnNum" 00099 #define CHANNEL_NAME_NumReturns "NumReturns" 00100 #define CHANNEL_NAME_ScanDir "ScanDir" 00101 #define CHANNEL_NAME_EdgeFlightLine "EdgeFlightLine" 00102 #define CHANNEL_NAME_ScannerChannel "ScannerChannel" 00103 #define CHANNEL_NAME_ClassId "ClassId" 00104 #define CHANNEL_NAME_ClassFlags "ClassFlags" 00105 #define CHANNEL_NAME_ScanAngle "ScanAngle" 00106 #define CHANNEL_NAME_UserData "UserData" 00107 #define CHANNEL_NAME_SourceId "SourceId" 00108 #define CHANNEL_NAME_GPSTime_Week "GPSTime" 00109 #define CHANNEL_NAME_GPSTime_Adjusted "GPSTime_Adjusted" 00110 #define CHANNEL_NAME_Red "Red" 00111 #define CHANNEL_NAME_Green "Green" 00112 #define CHANNEL_NAME_Blue "Blue" 00113 #define CHANNEL_NAME_NearInfrared "NearInfrared" 00114 00115 // Used with the TXTPointReader to skip a field 00116 #define CHANNEL_NAME_Skip "@Skip" 00117 00118 00119 00126 class ChannelInfo 00127 { 00128 SIMPLE_OBJECT(ChannelInfo); 00129 public: 00130 ~ChannelInfo(void); 00131 ChannelInfo(void); 00132 00133 void init(const char *name, DataType datatype, int bits, double quantization = 0); 00134 void init(const ChannelInfo &info); 00135 00141 const char *getName(void) const; 00142 00148 DataType getDataType(void) const; 00149 00157 size_t getBits(void) const; 00158 00164 double getQuantization(void) const; 00165 void setQuantization(double value); 00166 00167 bool operator==(const ChannelInfo &rhs) const; 00168 bool operator!=(const ChannelInfo &rhs) const { return !operator==(rhs); } 00169 00170 protected: 00171 char *m_name; 00172 DataType m_datatype; 00173 int m_bits; 00174 double m_quantization; 00175 }; 00176 00185 class PointInfo 00186 { 00187 SIMPLE_OBJECT(PointInfo); 00188 public: 00189 ~PointInfo(void); 00190 PointInfo(void); 00191 00192 void init(size_t numChannels); 00193 void init(const PointInfo &pointInfo); 00194 void init(const PointData &pointData); 00195 00196 void init(const PointInfo &pointInfo, const char * const *channels, size_t numChannels); 00197 void init(const PointData &pointData, const char * const *channels, size_t numChannels); 00198 00199 void init(const PointInfo &pointInfo, const size_t *channels, size_t numChannels); 00200 void init(const PointData &pointData, const size_t *channels, size_t numChannels); 00201 00202 00208 size_t getNumChannels(void) const; 00209 00218 const ChannelInfo &getChannel(size_t idx) const; 00219 00228 ChannelInfo &getChannel(size_t idx); 00229 00238 bool hasChannel(const char *name) const; 00239 00248 const ChannelInfo *getChannel(const char *name) const; 00249 00258 ChannelInfo *getChannel(const char *name); 00259 00268 size_t getChannelIndex(const char *name) const; 00269 00276 bool hasValidXYZ(void) const; 00277 00278 00279 bool operator==(const PointInfo &rhs) const; 00280 bool operator!=(const PointInfo &rhs) const { return !operator==(rhs); } 00281 00282 protected: 00283 size_t m_numChannels; 00284 ChannelInfo *m_channel; 00285 }; 00286 00290 class ChannelData : public ChannelInfo 00291 { 00292 DISABLE_COPY(ChannelData); 00293 public: 00294 ~ChannelData(void); 00295 ChannelData(void); 00296 00297 void init(const ChannelInfo &info, size_t numSamples); 00298 00305 size_t getNumSamples(void) const; 00306 00315 const void *getData(void) const; 00316 00325 void *getData(void); 00326 00340 static void copy(ChannelData &dst, size_t dstOffset, 00341 const ChannelData &src, size_t srcOffset, 00342 size_t length); 00343 00359 static void convert(ChannelData &dst, size_t dstOffset, 00360 const ChannelData &src, size_t srcOffset, 00361 size_t length); 00362 00382 static void convert(ChannelData &dst, size_t dstOffset, 00383 const ChannelData &src, size_t srcOffset, 00384 double offset, double scale, 00385 size_t length); 00386 00396 void setDataType(DataType datatype); 00397 00404 void resize(size_t newNumSamples); 00405 00407 void setOffset(size_t offset); 00408 00410 void setData(void *data, bool deleteData); 00411 00412 protected: 00413 size_t m_numSamples; 00414 size_t m_offset; 00415 void *m_data; 00416 bool m_deleteData; 00417 }; 00418 00427 class PointData 00428 { 00429 SIMPLE_OBJECT(PointData); 00430 public: 00431 ~PointData(void); 00432 PointData(void); 00433 00434 void init(const PointInfo &pointInfo, size_t numSamples); 00435 00441 size_t getNumChannels(void) const; 00442 00449 size_t getNumSamples(void) const; 00450 00459 const ChannelData &getChannel(size_t idx) const; 00460 00469 ChannelData &getChannel(size_t idx); 00470 00479 bool hasChannel(const char *name) const; 00480 00489 const ChannelData *getChannel(const char *name) const; 00490 00499 ChannelData *getChannel(const char *name); 00500 00506 const double *getX(void) const; 00507 00513 double *getX(void); 00514 00520 const double *getY(void) const; 00521 00527 double *getY(void); 00528 00534 const double *getZ(void) const; 00535 00541 double *getZ(void); 00542 00556 static void copy(PointData &dst, size_t dstOffset, 00557 const PointData &src, size_t srcOffset, 00558 size_t length); 00559 00573 static void merge(PointData &dst, size_t dstNumPoints, 00574 const PointData &src, size_t srcNumPoints); 00575 00582 void resize(size_t newNumSamples); 00583 00585 void setOffset(size_t offset); 00586 protected: 00587 size_t m_numChannels; 00588 ChannelData *m_channel; 00589 size_t m_numSamples; 00590 size_t m_offset; 00591 00592 // just pointers into m_channel[] 00593 double *m_x; 00594 double *m_y; 00595 double *m_z; 00596 }; 00597 00598 LT_END_LIDAR_NAMESPACE 00599 #endif /* __LIDAR_POINT_DATA_H__ */