lasreaditemraw.hpp
Go to the documentation of this file.
1 /*
2 ===============================================================================
3 
4  FILE: LASitemreadraw.hpp
5 
6  CONTENTS:
7 
8  Implementation of LASitemReadRaw for *all* items that compose a point.
9 
10  PROGRAMMERS:
11 
12  martin.isenburg@gmail.com
13 
14  COPYRIGHT:
15 
16  (c) 2010-2011, Martin Isenburg, LASSO - tools to catch reality
17 
18  This is free software; you can redistribute and/or modify it under the
19  terms of the GNU Lesser General Licence as published by the Free Software
20  Foundation. See the COPYING file for more information.
21 
22  This software is distributed WITHOUT ANY WARRANTY and without even the
23  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24 
25  CHANGE HISTORY:
26 
27  10 January 2011 -- licensing change for LGPL release and liblas integration
28  7 December 2010 -- refactored after getting invited to KAUST in Saudi Arabia
29 
30 ===============================================================================
31 */
32 #ifndef LAS_READ_ITEM_RAW_H
33 #define LAS_READ_ITEM_RAW_H
34 
35 #include "lasreaditem.hpp"
36 
37 #include <assert.h>
38 
40 {
41 public:
43  inline void read(U8* item)
44  {
45  instream->getBytes(item, 20);
46  }
47 };
48 
50 {
51 public:
53  inline void read(U8* item)
54  {
56  ENDIAN_SWAP_32(&swapped[ 0], &item[ 0]); // x
57  ENDIAN_SWAP_32(&swapped[ 4], &item[ 4]); // y
58  ENDIAN_SWAP_32(&swapped[ 8], &item[ 8]); // z
59  ENDIAN_SWAP_16(&swapped[12], &item[12]); // intensity
60  *((U32*)&item[14]) = *((U32*)&swapped[14]); // bitfield, classification, scan_angle_rank, user_data
61  ENDIAN_SWAP_16(&swapped[18], &item[18]); // point_source_ID
62  };
63 private:
64  U8 swapped[20];
65 };
66 
68 {
69 public:
71  inline void read(U8* item)
72  {
73  instream->getBytes(item, 8);
74  };
75 };
76 
78 {
79 public:
81  inline void read(U8* item)
82  {
84  ENDIAN_SWAP_64(swapped, item);
85  };
86 private:
87  U8 swapped[8];
88 };
89 
91 {
92 public:
94  inline void read(U8* item)
95  {
96  instream->getBytes(item, 6);
97  };
98 };
99 
101 {
102 public:
104  inline void read(U8* item)
105  {
107  ENDIAN_SWAP_32(&swapped[ 0], &item[ 0]); // R
108  ENDIAN_SWAP_32(&swapped[ 2], &item[ 2]); // G
109  ENDIAN_SWAP_32(&swapped[ 4], &item[ 4]); // B
110  };
111 private:
112  U8 swapped[6];
113 };
114 
116 {
117 public:
119  inline void read(U8* item)
120  {
121  instream->getBytes(item, 29);
122  };
123 };
124 
126 {
127 public:
129  inline void read(U8* item)
130  {
131  instream->getBytes(swapped, 29);
132  item[0] = swapped[0]; // wavepacket descriptor index
133  ENDIAN_SWAP_64(&swapped[ 1], &item[ 1]); // byte offset to waveform data
134  ENDIAN_SWAP_32(&swapped[ 9], &item[ 9]); // waveform packet size in bytes
135  ENDIAN_SWAP_32(&swapped[13], &item[13]); // return point waveform location
136  ENDIAN_SWAP_32(&swapped[17], &item[17]); // X(t)
137  ENDIAN_SWAP_32(&swapped[21], &item[21]); // Y(t)
138  ENDIAN_SWAP_32(&swapped[25], &item[25]); // Z(t)
139  };
140 private:
141  U8 swapped[29];
142 };
143 
145 {
146 public:
148  {
149  this->number = number;
150  }
151  inline void read(U8* item)
152  {
153  instream->getBytes(item, number);
154  };
155 private:
156  U32 number;
157 };
158 
160 {
161 public:
174  // LAS 1.4 only
180 };
181 
183 {
184 public:
199 };
200 
202 {
203 public:
205  inline void read(U8* item)
206  {
207  instream->getBytes(buffer, 30);
208  ((LAStempReadPoint10*)item)->x = ((LAStempReadPoint14*)buffer)->x;
209  ((LAStempReadPoint10*)item)->y = ((LAStempReadPoint14*)buffer)->y;
210  ((LAStempReadPoint10*)item)->z = ((LAStempReadPoint14*)buffer)->z;
211  ((LAStempReadPoint10*)item)->intensity = ((LAStempReadPoint14*)buffer)->intensity;
212  if (((LAStempReadPoint14*)buffer)->number_of_returns_of_given_pulse > 7)
213  {
214  if (((LAStempReadPoint14*)buffer)->return_number > 6)
215  {
216  if (((LAStempReadPoint14*)buffer)->return_number >= ((LAStempReadPoint14*)buffer)->number_of_returns_of_given_pulse)
217  {
218  ((LAStempReadPoint10*)item)->number_of_returns_of_given_pulse = 7;
219  }
220  else
221  {
222  ((LAStempReadPoint10*)item)->number_of_returns_of_given_pulse = 6;
223  }
224  }
225  else
226  {
227  ((LAStempReadPoint10*)item)->return_number = ((LAStempReadPoint14*)buffer)->return_number;
228  }
229  ((LAStempReadPoint10*)item)->number_of_returns_of_given_pulse = 7;
230  }
231  else
232  {
233  ((LAStempReadPoint10*)item)->return_number = ((LAStempReadPoint14*)buffer)->return_number;
234  ((LAStempReadPoint10*)item)->number_of_returns_of_given_pulse = ((LAStempReadPoint14*)buffer)->number_of_returns_of_given_pulse;
235  }
236  ((LAStempReadPoint10*)item)->scan_direction_flag = ((LAStempReadPoint14*)buffer)->scan_direction_flag;
237  ((LAStempReadPoint10*)item)->edge_of_flight_line = ((LAStempReadPoint14*)buffer)->edge_of_flight_line;
238  ((LAStempReadPoint10*)item)->classification = (((LAStempReadPoint14*)buffer)->classification_flags << 5) | (((LAStempReadPoint14*)buffer)->classification & 31);
239  ((LAStempReadPoint10*)item)->scan_angle_rank = I8_CLAMP(I16_QUANTIZE(((LAStempReadPoint14*)buffer)->scan_angle*0.006f));
240  ((LAStempReadPoint10*)item)->user_data = ((LAStempReadPoint14*)buffer)->user_data;
241  ((LAStempReadPoint10*)item)->point_source_ID = ((LAStempReadPoint14*)buffer)->point_source_ID;
242  ((LAStempReadPoint10*)item)->extended_classification = (((LAStempReadPoint14*)buffer)->classification & 31);
243  ((LAStempReadPoint10*)item)->extended_return_number = ((LAStempReadPoint14*)buffer)->return_number;
244  ((LAStempReadPoint10*)item)->extended_number_of_returns_of_given_pulse = ((LAStempReadPoint14*)buffer)->number_of_returns_of_given_pulse;
245  ((LAStempReadPoint10*)item)->extended_scanner_channel = ((LAStempReadPoint14*)buffer)->scanner_channel;
246  ((LAStempReadPoint10*)item)->gps_time = *((F64*)&buffer[22]);
247  }
248 private:
249  U8 buffer[30];
250 };
251 
253 {
254 public:
256  inline void read(U8* item)
257  {
258  instream->getBytes(item, 8);
259  };
260 };
261 
263 {
264 public:
266  inline void read(U8* item)
267  {
269  ENDIAN_SWAP_32(&swapped[ 0], &item[ 0]); // R
270  ENDIAN_SWAP_32(&swapped[ 2], &item[ 2]); // G
271  ENDIAN_SWAP_32(&swapped[ 4], &item[ 4]); // B
272  ENDIAN_SWAP_32(&swapped[ 6], &item[ 6]); // NIR
273  };
274 private:
275  U8 swapped[8];
276 };
277 
278 #endif
LAStempReadPoint14::user_data
U8 user_data
Definition: lasreaditemraw.hpp:196
LASreadItemRaw_POINT14_LE
Definition: lasreaditemraw.hpp:201
LAStempReadPoint10::z
I32 z
Definition: lasreaditemraw.hpp:164
LASreadItemRaw_POINT10_LE::LASreadItemRaw_POINT10_LE
LASreadItemRaw_POINT10_LE()
Definition: lasreaditemraw.hpp:42
LAStempReadPoint10::intensity
U16 intensity
Definition: lasreaditemraw.hpp:165
LASreadItemRaw_RGB12_LE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:94
LAStempReadPoint10::number_of_returns_of_given_pulse
U8 number_of_returns_of_given_pulse
Definition: lasreaditemraw.hpp:167
LASreadItemRaw_POINT10_LE
Definition: lasreaditemraw.hpp:39
LASreadItemRaw_GPSTIME11_BE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:81
LASreadItemRaw_RGBNIR14_BE::swapped
U8 swapped[8]
Definition: lasreaditemraw.hpp:273
LAStempReadPoint10::classification
U8 classification
Definition: lasreaditemraw.hpp:170
LASreadItemRaw_WAVEPACKET13_BE
Definition: lasreaditemraw.hpp:125
LAStempReadPoint14::scan_angle
I16 scan_angle
Definition: lasreaditemraw.hpp:197
I8
char I8
Definition: mydefs.hpp:37
LASreadItemRaw_POINT14_LE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:205
LASreadItemRaw_POINT10_BE::swapped
U8 swapped[20]
Definition: lasreaditemraw.hpp:62
LASreadItemRaw_POINT10_BE::LASreadItemRaw_POINT10_BE
LASreadItemRaw_POINT10_BE()
Definition: lasreaditemraw.hpp:52
ENDIAN_SWAP_16
void ENDIAN_SWAP_16(U8 *field)
Definition: mydefs.hpp:160
F64
double F64
Definition: mydefs.hpp:52
LASreadItemRaw_RGB12_BE::LASreadItemRaw_RGB12_BE
LASreadItemRaw_RGB12_BE()
Definition: lasreaditemraw.hpp:103
LASreadItemRaw_POINT10_BE
Definition: lasreaditemraw.hpp:49
LAStempReadPoint14::scan_direction_flag
U8 scan_direction_flag
Definition: lasreaditemraw.hpp:193
LASreadItemRaw::instream
ByteStreamIn * instream
Definition: lasreaditem.hpp:60
I32
int I32
Definition: mydefs.hpp:35
LAStempReadPoint10::extended_scanner_channel
U8 extended_scanner_channel
Definition: lasreaditemraw.hpp:178
LASreadItemRaw_GPSTIME11_BE
Definition: lasreaditemraw.hpp:77
LAStempReadPoint14::return_number
U8 return_number
Definition: lasreaditemraw.hpp:189
LASreadItemRaw_RGBNIR14_BE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:266
LASreadItemRaw_GPSTIME11_LE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:71
LAStempReadPoint10::return_number
U8 return_number
Definition: lasreaditemraw.hpp:166
LASreadItemRaw_GPSTIME11_BE::LASreadItemRaw_GPSTIME11_BE
LASreadItemRaw_GPSTIME11_BE()
Definition: lasreaditemraw.hpp:80
I16_QUANTIZE
#define I16_QUANTIZE(n)
Definition: mydefs.hpp:108
LAStempReadPoint10::x
I32 x
Definition: lasreaditemraw.hpp:162
LAStempReadPoint14::number_of_returns_of_given_pulse
U8 number_of_returns_of_given_pulse
Definition: lasreaditemraw.hpp:190
LAStempReadPoint14::scanner_channel
U8 scanner_channel
Definition: lasreaditemraw.hpp:192
LASreadItemRaw_RGB12_BE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:104
LASreadItemRaw_RGBNIR14_LE
Definition: lasreaditemraw.hpp:252
LASreadItemRaw_WAVEPACKET13_LE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:119
LAStempReadPoint14::intensity
U16 intensity
Definition: lasreaditemraw.hpp:188
LASreadItemRaw_RGBNIR14_LE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:256
LAStempReadPoint10::y
I32 y
Definition: lasreaditemraw.hpp:163
LAStempReadPoint10::extended_number_of_returns_of_given_pulse
U8 extended_number_of_returns_of_given_pulse
Definition: lasreaditemraw.hpp:177
LASreadItemRaw
Definition: lasreaditem.hpp:47
LAStempReadPoint10::extended_classification
U8 extended_classification
Definition: lasreaditemraw.hpp:175
LASreadItemRaw_RGBNIR14_BE::LASreadItemRaw_RGBNIR14_BE
LASreadItemRaw_RGBNIR14_BE()
Definition: lasreaditemraw.hpp:265
LASreadItemRaw_POINT14_LE::LASreadItemRaw_POINT14_LE
LASreadItemRaw_POINT14_LE()
Definition: lasreaditemraw.hpp:204
LAStempReadPoint10::scan_angle_rank
I8 scan_angle_rank
Definition: lasreaditemraw.hpp:171
lasreaditem.hpp
LASreadItemRaw_GPSTIME11_LE
Definition: lasreaditemraw.hpp:67
U16
unsigned short U16
Definition: mydefs.hpp:40
LAStempReadPoint14::classification_flags
U8 classification_flags
Definition: lasreaditemraw.hpp:191
LASreadItemRaw_GPSTIME11_BE::swapped
U8 swapped[8]
Definition: lasreaditemraw.hpp:85
ENDIAN_SWAP_64
void ENDIAN_SWAP_64(U8 *field)
Definition: mydefs.hpp:178
LAStempReadPoint10::edge_of_flight_line
U8 edge_of_flight_line
Definition: lasreaditemraw.hpp:169
LASreadItemRaw_RGB12_LE::LASreadItemRaw_RGB12_LE
LASreadItemRaw_RGB12_LE()
Definition: lasreaditemraw.hpp:93
LASreadItemRaw_RGB12_BE::swapped
U8 swapped[6]
Definition: lasreaditemraw.hpp:110
LAStempReadPoint14::z
I32 z
Definition: lasreaditemraw.hpp:187
LAStempReadPoint10::scan_direction_flag
U8 scan_direction_flag
Definition: lasreaditemraw.hpp:168
ENDIAN_SWAP_32
void ENDIAN_SWAP_32(U8 *field)
Definition: mydefs.hpp:167
LASreadItemRaw_WAVEPACKET13_BE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:129
U8
unsigned char U8
Definition: mydefs.hpp:41
LASreadItemRaw_GPSTIME11_LE::LASreadItemRaw_GPSTIME11_LE
LASreadItemRaw_GPSTIME11_LE()
Definition: lasreaditemraw.hpp:70
LASreadItemRaw_WAVEPACKET13_BE::swapped
U8 swapped[29]
Definition: lasreaditemraw.hpp:139
LASreadItemRaw_WAVEPACKET13_LE::LASreadItemRaw_WAVEPACKET13_LE
LASreadItemRaw_WAVEPACKET13_LE()
Definition: lasreaditemraw.hpp:118
I8_CLAMP
#define I8_CLAMP(n)
Definition: mydefs.hpp:96
LASreadItemRaw_WAVEPACKET13_BE::LASreadItemRaw_WAVEPACKET13_BE
LASreadItemRaw_WAVEPACKET13_BE()
Definition: lasreaditemraw.hpp:128
LASreadItemRaw_RGBNIR14_BE
Definition: lasreaditemraw.hpp:262
LASreadItemRaw_BYTE::number
U32 number
Definition: lasreaditemraw.hpp:154
LAStempReadPoint10::gps_time
F64 gps_time
Definition: lasreaditemraw.hpp:179
LAStempReadPoint10::user_data
U8 user_data
Definition: lasreaditemraw.hpp:172
LAStempReadPoint10::extended_return_number
U8 extended_return_number
Definition: lasreaditemraw.hpp:176
LASreadItemRaw_RGBNIR14_LE::LASreadItemRaw_RGBNIR14_LE
LASreadItemRaw_RGBNIR14_LE()
Definition: lasreaditemraw.hpp:255
LAStempReadPoint14::edge_of_flight_line
U8 edge_of_flight_line
Definition: lasreaditemraw.hpp:194
LAStempReadPoint14::point_source_ID
U16 point_source_ID
Definition: lasreaditemraw.hpp:198
LASreadItemRaw_BYTE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:151
LAStempReadPoint10
Definition: lasreaditemraw.hpp:159
U32
unsigned int U32
Definition: mydefs.hpp:39
LASreadItemRaw_POINT10_BE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:53
LASreadItemRaw_WAVEPACKET13_LE
Definition: lasreaditemraw.hpp:115
LASreadItemRaw_RGB12_BE
Definition: lasreaditemraw.hpp:100
LAStempReadPoint14::y
I32 y
Definition: lasreaditemraw.hpp:186
LASreadItemRaw_POINT14_LE::buffer
U8 buffer[30]
Definition: lasreaditemraw.hpp:249
LASreadItemRaw_BYTE::LASreadItemRaw_BYTE
LASreadItemRaw_BYTE(U32 number)
Definition: lasreaditemraw.hpp:147
LAStempReadPoint14::x
I32 x
Definition: lasreaditemraw.hpp:185
LASreadItemRaw_BYTE
Definition: lasreaditemraw.hpp:144
ByteStreamIn::getBytes
virtual void getBytes(U8 *bytes, const U32 num_bytes)=0
LAStempReadPoint14
Definition: lasreaditemraw.hpp:182
LAStempReadPoint10::point_source_ID
U16 point_source_ID
Definition: lasreaditemraw.hpp:173
LASreadItemRaw_RGB12_LE
Definition: lasreaditemraw.hpp:90
LASreadItemRaw_POINT10_LE::read
void read(U8 *item)
Definition: lasreaditemraw.hpp:43
LAStempReadPoint14::classification
U8 classification
Definition: lasreaditemraw.hpp:195
I16
short I16
Definition: mydefs.hpp:36


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:23