laswriteitemraw.hpp
Go to the documentation of this file.
1 /*
2 ===============================================================================
3 
4  FILE: LASwriteitemraw.hpp
5 
6  CONTENTS:
7 
8  Implementation of LASwriteItemRaw 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 January 2011 -- introduced swap buffers to reduce number of fwrite calls
29  12 December 2010 -- refactored after watching two movies with silke
30 
31 ===============================================================================
32 */
33 #ifndef LAS_WRITE_ITEM_RAW_H
34 #define LAS_WRITE_ITEM_RAW_H
35 
36 #include "laswriteitem.hpp"
37 
38 #include <assert.h>
39 
41 {
42 public:
44  inline BOOL write(const U8* item)
45  {
46  return outstream->putBytes(item, 20);
47  };
48 };
49 
51 {
52 public:
54  inline BOOL write(const U8* item)
55  {
56  ENDIAN_SWAP_32(&item[ 0], &swapped[ 0]); // x
57  ENDIAN_SWAP_32(&item[ 4], &swapped[ 4]); // y
58  ENDIAN_SWAP_32(&item[ 8], &swapped[ 8]); // z
59  ENDIAN_SWAP_16(&item[12], &swapped[12]); // intensity
60  *((U32*)&swapped[14]) = *((U32*)&item[14]); // bitfield, classification, scan_angle_rank, user_data
61  ENDIAN_SWAP_16(&item[18], &swapped[18]); // point_source_ID
62  return outstream->putBytes(swapped, 20);
63  };
64 private:
65  U8 swapped[20];
66 };
67 
69 {
70 public:
72  inline BOOL write(const U8* item)
73  {
74  return outstream->putBytes(item, 8);
75  };
76 };
77 
79 {
80 public:
82  inline BOOL write(const U8* item)
83  {
84  ENDIAN_SWAP_64(item, swapped);
85  return outstream->putBytes(swapped, 8);
86  };
87 private:
88  U8 swapped[8];
89 };
90 
92 {
93 public:
95  inline BOOL write(const U8* item)
96  {
97  return outstream->putBytes(item, 6);
98  };
99 };
100 
102 {
103 public:
105  inline BOOL write(const U8* item)
106  {
107  ENDIAN_SWAP_32(&item[ 0], &swapped[ 0]); // R
108  ENDIAN_SWAP_32(&item[ 2], &swapped[ 2]); // G
109  ENDIAN_SWAP_32(&item[ 4], &swapped[ 4]); // B
110  return outstream->putBytes(swapped, 6);
111  };
112 private:
113  U8 swapped[6];
114 };
115 
117 {
118 public:
120  inline BOOL write(const U8* item)
121  {
122  return outstream->putBytes(item, 29);
123  };
124 };
125 
127 {
128 public:
130  inline BOOL write(const U8* item)
131  {
132  swapped[0] = item[0]; // wavepacket descriptor index
133  ENDIAN_SWAP_64(&item[ 1], &swapped[ 1]); // byte offset to waveform data
134  ENDIAN_SWAP_32(&item[ 9], &swapped[ 9]); // waveform packet size in bytes
135  ENDIAN_SWAP_32(&item[13], &swapped[13]); // return point waveform location
136  ENDIAN_SWAP_32(&item[17], &swapped[17]); // X(t)
137  ENDIAN_SWAP_32(&item[21], &swapped[21]); // Y(t)
138  ENDIAN_SWAP_32(&item[25], &swapped[25]); // Z(t)
139  return outstream->putBytes(swapped, 29);
140  };
141 private:
142  U8 swapped[29];
143 };
144 
146 {
147 public:
149  {
150  this->number = number;
151  }
152  inline BOOL write(const U8* item)
153  {
154  return outstream->putBytes(item, number);
155  };
156 private:
157  U32 number;
158 };
159 
161 {
162 public:
175 };
176 
178 {
179 public:
194 };
195 
197 {
198 public:
200  inline BOOL write(const U8* item)
201  {
202  ((LAStempWritePoint14*)buffer)->x = ((LAStempWritePoint10*)item)->x;
203  ((LAStempWritePoint14*)buffer)->y = ((LAStempWritePoint10*)item)->y;
204  ((LAStempWritePoint14*)buffer)->z = ((LAStempWritePoint10*)item)->z;
205  ((LAStempWritePoint14*)buffer)->intensity = ((LAStempWritePoint10*)item)->intensity;
206  ((LAStempWritePoint14*)buffer)->return_number = ((LAStempWritePoint10*)item)->return_number;
207  ((LAStempWritePoint14*)buffer)->number_of_returns_of_given_pulse = ((LAStempWritePoint10*)item)->number_of_returns_of_given_pulse;
208  ((LAStempWritePoint14*)buffer)->classification_flags = (((LAStempWritePoint10*)item)->classification >> 5);
209  ((LAStempWritePoint14*)buffer)->scanner_channel = 0;
210  ((LAStempWritePoint14*)buffer)->scan_direction_flag = ((LAStempWritePoint10*)item)->scan_direction_flag;
211  ((LAStempWritePoint14*)buffer)->edge_of_flight_line = ((LAStempWritePoint10*)item)->edge_of_flight_line;
212  ((LAStempWritePoint14*)buffer)->classification = ((LAStempWritePoint10*)item)->classification & 31;
213  ((LAStempWritePoint14*)buffer)->user_data = ((LAStempWritePoint10*)item)->user_data;
214  ((LAStempWritePoint14*)buffer)->scan_angle = I16_QUANTIZE(((LAStempWritePoint10*)item)->scan_angle_rank/0.006f);
215  ((LAStempWritePoint14*)buffer)->point_source_ID = ((LAStempWritePoint10*)item)->point_source_ID;
216  *((F64*)&buffer[22]) = *((F64*)&item[24]);
217  return outstream->putBytes(buffer, 30);
218  }
219 private:
220  U8 buffer[30];
221 };
222 
224 {
225 public:
227  inline BOOL write(const U8* item)
228  {
229  return outstream->putBytes(item, 8);
230  };
231 };
232 
234 {
235 public:
237  inline BOOL write(const U8* item)
238  {
239  ENDIAN_SWAP_32(&item[ 0], &swapped[ 0]); // R
240  ENDIAN_SWAP_32(&item[ 2], &swapped[ 2]); // G
241  ENDIAN_SWAP_32(&item[ 4], &swapped[ 4]); // B
242  ENDIAN_SWAP_32(&item[ 6], &swapped[ 6]); // NIR
243  return outstream->putBytes(swapped, 8);
244  };
245 private:
246  U8 swapped[8];
247 };
248 
249 #endif
LASwriteItemRaw_GPSTIME11_LE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:72
LASwriteItemRaw_POINT10_BE::LASwriteItemRaw_POINT10_BE
LASwriteItemRaw_POINT10_BE()
Definition: laswriteitemraw.hpp:53
LASwriteItemRaw_RGBNIR14_LE
Definition: laswriteitemraw.hpp:223
LAStempWritePoint10::scan_angle_rank
I8 scan_angle_rank
Definition: laswriteitemraw.hpp:172
LAStempWritePoint14::edge_of_flight_line
U8 edge_of_flight_line
Definition: laswriteitemraw.hpp:189
LAStempWritePoint14
Definition: laswriteitemraw.hpp:177
LAStempWritePoint14::classification_flags
U8 classification_flags
Definition: laswriteitemraw.hpp:186
LAStempWritePoint14::classification
U8 classification
Definition: laswriteitemraw.hpp:190
LASwriteItemRaw_GPSTIME11_LE
Definition: laswriteitemraw.hpp:68
LAStempWritePoint10::number_of_returns_of_given_pulse
U8 number_of_returns_of_given_pulse
Definition: laswriteitemraw.hpp:168
LASwriteItemRaw_RGBNIR14_BE::swapped
U8 swapped[8]
Definition: laswriteitemraw.hpp:244
LAStempWritePoint10::user_data
U8 user_data
Definition: laswriteitemraw.hpp:173
LASwriteItemRaw_POINT10_LE::LASwriteItemRaw_POINT10_LE
LASwriteItemRaw_POINT10_LE()
Definition: laswriteitemraw.hpp:43
LASwriteItemRaw_RGBNIR14_LE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:227
I8
char I8
Definition: mydefs.hpp:37
LAStempWritePoint10::y
I32 y
Definition: laswriteitemraw.hpp:164
LASwriteItemRaw_RGBNIR14_BE::LASwriteItemRaw_RGBNIR14_BE
LASwriteItemRaw_RGBNIR14_BE()
Definition: laswriteitemraw.hpp:236
ENDIAN_SWAP_16
void ENDIAN_SWAP_16(U8 *field)
Definition: mydefs.hpp:160
LASwriteItemRaw_WAVEPACKET13_BE
Definition: laswriteitemraw.hpp:126
F64
double F64
Definition: mydefs.hpp:52
LASwriteItemRaw_RGB12_BE
Definition: laswriteitemraw.hpp:101
LASwriteItemRaw_BYTE::LASwriteItemRaw_BYTE
LASwriteItemRaw_BYTE(U32 number)
Definition: laswriteitemraw.hpp:148
laswriteitem.hpp
LASwriteItemRaw_BYTE::number
U32 number
Definition: laswriteitemraw.hpp:155
LASwriteItemRaw_GPSTIME11_BE
Definition: laswriteitemraw.hpp:78
LASwriteItemRaw_GPSTIME11_BE::swapped
U8 swapped[8]
Definition: laswriteitemraw.hpp:86
LASwriteItemRaw_RGBNIR14_LE::LASwriteItemRaw_RGBNIR14_LE
LASwriteItemRaw_RGBNIR14_LE()
Definition: laswriteitemraw.hpp:226
I32
int I32
Definition: mydefs.hpp:35
LAStempWritePoint14::number_of_returns_of_given_pulse
U8 number_of_returns_of_given_pulse
Definition: laswriteitemraw.hpp:185
LAStempWritePoint14::scan_angle
I16 scan_angle
Definition: laswriteitemraw.hpp:192
LASwriteItemRaw_WAVEPACKET13_LE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:120
LASwriteItemRaw_GPSTIME11_LE::LASwriteItemRaw_GPSTIME11_LE
LASwriteItemRaw_GPSTIME11_LE()
Definition: laswriteitemraw.hpp:71
LASwriteItemRaw_RGB12_LE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:95
LASwriteItemRaw
Definition: laswriteitem.hpp:47
LASwriteItemRaw_POINT14_LE::buffer
U8 buffer[30]
Definition: laswriteitemraw.hpp:220
LASwriteItemRaw_POINT10_LE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:44
LAStempWritePoint10::return_number
U8 return_number
Definition: laswriteitemraw.hpp:167
I16_QUANTIZE
#define I16_QUANTIZE(n)
Definition: mydefs.hpp:108
LASwriteItemRaw_WAVEPACKET13_LE::LASwriteItemRaw_WAVEPACKET13_LE
LASwriteItemRaw_WAVEPACKET13_LE()
Definition: laswriteitemraw.hpp:119
LAStempWritePoint14::return_number
U8 return_number
Definition: laswriteitemraw.hpp:184
LASwriteItemRaw_POINT14_LE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:200
LASwriteItemRaw_RGBNIR14_BE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:237
LASwriteItemRaw_WAVEPACKET13_LE
Definition: laswriteitemraw.hpp:116
LAStempWritePoint10::scan_direction_flag
U8 scan_direction_flag
Definition: laswriteitemraw.hpp:169
LAStempWritePoint14::x
I32 x
Definition: laswriteitemraw.hpp:180
LASwriteItemRaw_WAVEPACKET13_BE::swapped
U8 swapped[29]
Definition: laswriteitemraw.hpp:140
LASwriteItemRaw_RGB12_BE::swapped
U8 swapped[6]
Definition: laswriteitemraw.hpp:111
LAStempWritePoint14::intensity
U16 intensity
Definition: laswriteitemraw.hpp:183
LASwriteItemRaw_GPSTIME11_BE::LASwriteItemRaw_GPSTIME11_BE
LASwriteItemRaw_GPSTIME11_BE()
Definition: laswriteitemraw.hpp:81
LASwriteItemRaw_POINT10_BE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:54
LASwriteItemRaw_RGB12_LE
Definition: laswriteitemraw.hpp:91
LAStempWritePoint10::point_source_ID
U16 point_source_ID
Definition: laswriteitemraw.hpp:174
LAStempWritePoint10::intensity
U16 intensity
Definition: laswriteitemraw.hpp:166
LASwriteItemRaw_POINT10_BE
Definition: laswriteitemraw.hpp:50
LAStempWritePoint14::scan_direction_flag
U8 scan_direction_flag
Definition: laswriteitemraw.hpp:188
LAStempWritePoint14::y
I32 y
Definition: laswriteitemraw.hpp:181
LASwriteItemRaw_RGB12_LE::LASwriteItemRaw_RGB12_LE
LASwriteItemRaw_RGB12_LE()
Definition: laswriteitemraw.hpp:94
LAStempWritePoint10::z
I32 z
Definition: laswriteitemraw.hpp:165
U16
unsigned short U16
Definition: mydefs.hpp:40
LASwriteItemRaw_POINT10_BE::swapped
U8 swapped[20]
Definition: laswriteitemraw.hpp:63
LAStempWritePoint14::z
I32 z
Definition: laswriteitemraw.hpp:182
LAStempWritePoint10::edge_of_flight_line
U8 edge_of_flight_line
Definition: laswriteitemraw.hpp:170
ENDIAN_SWAP_64
void ENDIAN_SWAP_64(U8 *field)
Definition: mydefs.hpp:178
ENDIAN_SWAP_32
void ENDIAN_SWAP_32(U8 *field)
Definition: mydefs.hpp:167
LASwriteItemRaw_BYTE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:152
LAStempWritePoint10
Definition: laswriteitemraw.hpp:160
U8
unsigned char U8
Definition: mydefs.hpp:41
LAStempWritePoint14::user_data
U8 user_data
Definition: laswriteitemraw.hpp:191
BOOL
int BOOL
Definition: mydefs.hpp:57
LASwriteItemRaw_WAVEPACKET13_BE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:130
LAStempWritePoint14::scanner_channel
U8 scanner_channel
Definition: laswriteitemraw.hpp:187
LASwriteItemRaw_WAVEPACKET13_BE::LASwriteItemRaw_WAVEPACKET13_BE
LASwriteItemRaw_WAVEPACKET13_BE()
Definition: laswriteitemraw.hpp:129
LASwriteItemRaw_RGBNIR14_BE
Definition: laswriteitemraw.hpp:233
LASwriteItemRaw_POINT10_LE
Definition: laswriteitemraw.hpp:40
U32
unsigned int U32
Definition: mydefs.hpp:39
LASwriteItemRaw_BYTE
Definition: laswriteitemraw.hpp:145
LASwriteItemRaw_GPSTIME11_BE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:82
LASwriteItemRaw::outstream
ByteStreamOut * outstream
Definition: laswriteitem.hpp:60
LAStempWritePoint14::point_source_ID
U16 point_source_ID
Definition: laswriteitemraw.hpp:193
LASwriteItemRaw_POINT14_LE
Definition: laswriteitemraw.hpp:196
LASwriteItemRaw_RGB12_BE::LASwriteItemRaw_RGB12_BE
LASwriteItemRaw_RGB12_BE()
Definition: laswriteitemraw.hpp:104
LAStempWritePoint10::classification
U8 classification
Definition: laswriteitemraw.hpp:171
LAStempWritePoint10::x
I32 x
Definition: laswriteitemraw.hpp:163
LASwriteItemRaw_RGB12_BE::write
BOOL write(const U8 *item)
Definition: laswriteitemraw.hpp:105
LASwriteItemRaw_POINT14_LE::LASwriteItemRaw_POINT14_LE
LASwriteItemRaw_POINT14_LE()
Definition: laswriteitemraw.hpp:199
ByteStreamOut::putBytes
virtual BOOL putBytes(const U8 *bytes, U32 num_bytes)=0
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