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  {
55  instream->getBytes(swapped, 20);
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  {
83  instream->getBytes(swapped, 8);
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  {
106  instream->getBytes(swapped, 6);
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  {
268  instream->getBytes(swapped, 8);
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
LASreadItemRaw_BYTE(U32 number)
short I16
Definition: mydefs.hpp:36
void ENDIAN_SWAP_32(U8 *field)
Definition: mydefs.hpp:167
unsigned int U32
Definition: mydefs.hpp:39
unsigned short U16
Definition: mydefs.hpp:40
#define I8_CLAMP(n)
Definition: mydefs.hpp:96
unsigned char U8
Definition: mydefs.hpp:41
virtual void getBytes(U8 *bytes, const U32 num_bytes)=0
char I8
Definition: mydefs.hpp:37
void ENDIAN_SWAP_16(U8 *field)
Definition: mydefs.hpp:160
int I32
Definition: mydefs.hpp:35
#define I16_QUANTIZE(n)
Definition: mydefs.hpp:108
ByteStreamIn * instream
Definition: lasreaditem.hpp:60
void ENDIAN_SWAP_64(U8 *field)
Definition: mydefs.hpp:178
U8 extended_number_of_returns_of_given_pulse
double F64
Definition: mydefs.hpp:52


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 Mon Feb 28 2022 22:46:07