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
virtual BOOL putBytes(const U8 *bytes, U32 num_bytes)=0
BOOL write(const U8 *item)
int BOOL
Definition: mydefs.hpp:57
BOOL write(const U8 *item)
BOOL write(const U8 *item)
BOOL write(const U8 *item)
short I16
Definition: mydefs.hpp:36
void ENDIAN_SWAP_32(U8 *field)
Definition: mydefs.hpp:167
unsigned int U32
Definition: mydefs.hpp:39
BOOL write(const U8 *item)
LASwriteItemRaw_BYTE(U32 number)
unsigned short U16
Definition: mydefs.hpp:40
unsigned char U8
Definition: mydefs.hpp:41
BOOL write(const U8 *item)
ByteStreamOut * outstream
char I8
Definition: mydefs.hpp:37
BOOL write(const U8 *item)
void ENDIAN_SWAP_16(U8 *field)
Definition: mydefs.hpp:160
int I32
Definition: mydefs.hpp:35
BOOL write(const U8 *item)
#define I16_QUANTIZE(n)
Definition: mydefs.hpp:108
void ENDIAN_SWAP_64(U8 *field)
Definition: mydefs.hpp:178
BOOL write(const U8 *item)
double F64
Definition: mydefs.hpp:52
BOOL write(const U8 *item)


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