lastransform.cpp
Go to the documentation of this file.
1 /*
2 ===============================================================================
3 
4  FILE: lastransform.cpp
5 
6  CONTENTS:
7 
8  see corresponding header file
9 
10  PROGRAMMERS:
11 
12  martin.isenburg@gmail.com
13 
14  COPYRIGHT:
15 
16  (c) 2007-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  see corresponding header file
28 
29 ===============================================================================
30 */
31 #include "lastransform.hpp"
32 
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <math.h>
37 
39 {
40 public:
41  inline const char* name() const { return "translate_x"; };
42  inline void transform(LASpoint* point) const {
43  point->set_x(point->get_x() + offset);
44  };
45  LASoperationTranslateX(F64 offset) { this->offset = offset; };
46 private:
47  F64 offset;
48 };
49 
51 {
52 public:
53  inline const char* name() const { return "translate_y"; };
54  inline void transform(LASpoint* point) const {
55  point->set_y(point->get_y() + offset);
56  };
57  LASoperationTranslateY(F64 offset) { this->offset = offset; };
58 private:
59  F64 offset;
60 };
61 
63 {
64 public:
65  inline const char* name() const { return "translate_z"; };
66  inline void transform(LASpoint* point) const {
67  point->set_z(point->get_z() + offset);
68  };
69  LASoperationTranslateZ(F64 offset) { this->offset = offset; };
70 private:
71  F64 offset;
72 };
73 
75 {
76 public:
77  inline const char* name() const { return "translate_xyz"; };
78  inline void transform(LASpoint* point) const {
79  point->set_x(point->get_x() + offset[0]);
80  point->set_y(point->get_y() + offset[1]);
81  point->set_z(point->get_z() + offset[2]);
82  };
83  LASoperationTranslateXYZ(F64 x_offset, F64 y_offset, F64 z_offset) { this->offset[0] = x_offset; this->offset[1] = y_offset; this->offset[2] = z_offset; };
84 private:
85  F64 offset[3];
86 };
87 
89 {
90 public:
91  inline const char* name() const { return "scale_x"; };
92  inline void transform(LASpoint* point) const {
93  point->set_x(point->get_x() * scale);
94  };
95  LASoperationScaleX(F64 scale) { this->scale = scale; };
96 private:
97  F64 scale;
98 };
99 
101 {
102 public:
103  inline const char* name() const { return "scale_y"; };
104  inline void transform(LASpoint* point) const {
105  point->set_y(point->get_y() * scale);
106  };
107  LASoperationScaleY(F64 scale) { this->scale = scale; };
108 private:
109  F64 scale;
110 };
111 
113 {
114 public:
115  inline const char* name() const { return "scale_z"; };
116  inline void transform(LASpoint* point) const {
117  point->set_z(point->get_z() * scale);
118  };
119  LASoperationScaleZ(F64 scale) { this->scale = scale; };
120 private:
121  F64 scale;
122 };
123 
125 {
126 public:
127  inline const char* name() const { return "scale_xyz"; };
128  inline void transform(LASpoint* point) const {
129  point->set_x(point->get_x() * scale[0]);
130  point->set_y(point->get_y() * scale[1]);
131  point->set_z(point->get_z() * scale[2]);
132  };
133  LASoperationScaleXYZ(F64 x_scale, F64 y_scale, F64 z_scale) { this->scale[0] = x_scale; this->scale[1] = y_scale; this->scale[2] = z_scale; };
134 private:
135  F64 scale[3];
136 };
137 
139 {
140 public:
141  inline const char* name() const { return "translate_then_scale_x"; };
142  inline void transform(LASpoint* point) const {
143  point->set_x((point->get_x()+offset)*scale);
144  };
145  LASoperationTranslateThenScaleX(F64 offset, F64 scale_factor) { this->offset = offset; };
146 private:
147  F64 offset;
149 };
150 
152 {
153 public:
154  inline const char* name() const { return "translate_then_scale_y"; };
155  inline void transform(LASpoint* point) const {
156  point->set_y((point->get_y()+offset)*scale);
157  };
158  LASoperationTranslateThenScaleY(F64 offset, F64 scale) { this->offset = offset; this->scale = scale; };
159 private:
160  F64 offset;
162 };
163 
165 {
166 public:
167  inline const char* name() const { return "translate_then_scale_z"; };
168  inline void transform(LASpoint* point) const {
169  point->set_z((point->get_z()+offset)*scale);
170  };
171  LASoperationTranslateThenScaleZ(F64 offset, F64 scale) { this->offset = offset; this->scale = scale; };
172 private:
173  F64 offset;
175 };
176 
178 {
179 public:
180  inline const char* name() const { return "rotate_xy"; };
181  inline void transform(LASpoint* point) const {
182  F64 x = point->get_x() - x_offset;
183  F64 y = point->get_y() - y_offset;
184  point->set_x(cos_angle*x - sin_angle*y + x_offset);
185  point->set_y(cos_angle*y + sin_angle*x + y_offset);
186  };
187  LASoperationRotateXY(F64 angle, F64 x_offset, F64 y_offset) { this->x_offset = x_offset; this->y_offset = y_offset; cos_angle = cos(3.141592653589793238462643383279502884197169/180*angle); sin_angle = sin(3.141592653589793238462643383279502884197169/180*angle); };
188 private:
189  F64 x_offset, y_offset;
190  F64 cos_angle, sin_angle;
191 };
192 
194 {
195 public:
196  inline const char* name() const { return "clamp_z"; };
197  inline void transform(LASpoint* point) const {
198  F64 z = point->get_z();
199  if (z < min) point->set_z(min);
200  else if (z > max) point->set_z(max);
201  };
202  LASoperationClampZ(F64 min, F64 max) { this->min = min; this->max = max; };
203 private:
204  F64 min, max;
205 };
206 
208 {
209 public:
210  inline const char* name() const { return "clamp_z_min"; };
211  inline void transform(LASpoint* point) const {
212  F64 z = point->get_z();
213  if (z < min) point->set_z(min);
214  };
215  LASoperationClampZmin(F64 min) { this->min = min; };
216 private:
217  F64 min;
218 };
219 
221 {
222 public:
223  inline const char* name() const { return "clamp_z_max"; };
224  inline void transform(LASpoint* point) const {
225  F64 z = point->get_z();
226  if (z > max) point->set_z(max);
227  };
228  LASoperationClampZmax(F64 max) { this->max = max; };
229 private:
230  F64 max;
231 };
232 
234 {
235 public:
236  inline const char* name() const { return "translate_raw_x"; };
237  inline void transform(LASpoint* point) const {
238  point->x += offset;
239  };
241 private:
242  I32 offset;
243 };
244 
246 {
247 public:
248  inline const char* name() const { return "translate_raw_y"; };
249  inline void transform(LASpoint* point) const {
250  point->y += offset;
251  };
253 private:
254  I32 offset;
255 };
256 
258 {
259 public:
260  inline const char* name() const { return "translate_raw_z"; };
261  inline void transform(LASpoint* point) const {
262  point->z += offset;
263  };
265 private:
266  I32 offset;
267 };
268 
270 {
271 public:
272  inline const char* name() const { return "translate_raw_xyz"; };
273  inline void transform(LASpoint* point) const {
274  point->x += offset[0];
275  point->y += offset[1];
276  point->z += offset[2];
277  };
278  LASoperationTranslateRawXYZ(I32 x_offset, I32 y_offset, I32 z_offset) { this->offset[0] = x_offset; this->offset[1] = y_offset; this->offset[2] = z_offset; };
279 private:
280  I32 offset[3];
281 };
282 
284 {
285 public:
286  inline const char* name() const { return "clamp_raw_z"; };
287  inline void transform(LASpoint* point) const {
288  if (point->z < min) point->z = min;
289  else if (point->z > max) point->z = max;
290  };
291  LASoperationClampRawZ(I32 min, I32 max) { this->min = min; this->max = max; };
292 private:
293  I32 min, max;
294 };
295 
297 {
298 public:
299  inline const char* name() const { return "scale_intensity"; };
300  inline void transform(LASpoint* point) const {
301  F32 intensity = scale*point->intensity;
302  point->intensity = U16_CLAMP((I32)intensity);
303  };
304  LASoperationScaleIntensity(F32 scale) { this->scale = scale; };
305 private:
306  F32 scale;
307 };
308 
310 {
311 public:
312  inline const char* name() const { return "translate_intensity"; };
313  inline void transform(LASpoint* point) const {
314  F32 intensity = offset+point->intensity;
315  point->intensity = U16_CLAMP((I32)intensity);
316  };
318 private:
319  F32 offset;
320 };
321 
323 {
324 public:
325  inline const char* name() const { return "translate_then_scale_intensity"; };
326  inline void transform(LASpoint* point) const {
327  F32 intensity = (offset+point->intensity)*scale;
328  point->intensity = U16_CLAMP((I32)intensity);
329  };
330  LASoperationTranslateThenScaleIntensity(F32 offset, F32 scale) { this->offset = offset; this->scale = scale; };
331 private:
332  F32 offset;
334 };
335 
337 {
338 public:
339  inline const char* name() const { return "scale_scan_angle"; };
340  inline void transform(LASpoint* point) const {
341  F32 scan_angle_rank = scale*point->scan_angle_rank;
342  point->scan_angle_rank = I8_CLAMP(I32_QUANTIZE(scan_angle_rank));
343  };
344  LASoperationScaleScanAngle(F32 scale) { this->scale = scale; };
345 private:
346  F32 scale;
347 };
348 
350 {
351 public:
352  inline const char* name() const { return "translate_scan_angle"; };
353  inline void transform(LASpoint* point) const {
354  F32 scan_angle_rank = offset+point->scan_angle_rank;
355  point->scan_angle_rank = I8_CLAMP(I32_QUANTIZE(scan_angle_rank));
356  };
358 private:
359  F32 offset;
360 };
361 
363 {
364 public:
365  inline const char* name() const { return "translate_then_scale_scan_angle"; };
366  inline void transform(LASpoint* point) const {
367  F32 scan_angle_rank = (offset+point->scan_angle_rank)*scale;
368  point->scan_angle_rank = I8_CLAMP(I32_QUANTIZE(scan_angle_rank));
369  };
370  LASoperationTranslateThenScaleScanAngle(F32 offset, F32 scale) { this->offset = offset; this->scale = scale; };
371 private:
372  F32 offset;
374 };
375 
377 {
378 public:
379  inline const char* name() const { return "change_classification_from_to"; };
380  inline void transform(LASpoint* point) const { if ((point->classification & 31) == class_from) point->classification = (point->classification & 224) | class_to; };
381  LASoperationChangeClassificationFromTo(U8 class_from, U8 class_to) { this->class_from = class_from; this->class_to = class_to; };
382 private:
383  U8 class_from;
385 };
386 
388 {
389 public:
390  inline const char* name() const { return "change_point_source_from_to"; };
391  inline void transform(LASpoint* point) const { if (point->point_source_ID == psid_from) point->point_source_ID = psid_to; };
392  LASoperationChangePointSourceFromTo(U16 psid_from, U16 psid_to) { this->psid_from = psid_from; this->psid_to = psid_to; };
393 private:
394  U16 psid_from;
396 };
397 
399 {
400 public:
401  inline const char* name() const { return "repair_zero_returns"; };
402  inline void transform(LASpoint* point) const { if (point->number_of_returns_of_given_pulse == 0) point->number_of_returns_of_given_pulse = 1; if (point->return_number == 0) point->return_number = 1; };
403 };
404 
406 {
407 public:
408  inline const char* name() const { return "change_return_number_from_to"; };
409  inline void transform(LASpoint* point) const { if (point->return_number == return_number_from) point->return_number = return_number_to; };
410  LASoperationChangeReturnNumberFromTo(U8 return_number_from, U8 return_number_to) { this->return_number_from = return_number_from; this->return_number_to = return_number_to; };
411 private:
414 };
415 
417 {
418 public:
419  inline const char* name() const { return "change_number_of_returns_from_to"; };
420  inline void transform(LASpoint* point) const { if (point->number_of_returns_of_given_pulse == number_of_returns_from) point->number_of_returns_of_given_pulse = number_of_returns_to; };
421  LASoperationChangeNumberOfReturnsFromTo(U8 number_of_returns_from, U8 number_of_returns_to) { this->number_of_returns_from = number_of_returns_from; this->number_of_returns_to = number_of_returns_to; };
422 private:
425 };
426 
428 {
429 public:
430  inline const char* name() const { return "translate_gps_time"; };
431  inline void transform(LASpoint* point) const { point->gps_time += offset; };
433 private:
434  F64 offset;
435 };
436 
438 {
439 public:
440  inline const char* name() const { return "scale_rgb_down"; };
441  inline void transform(LASpoint* point) const { point->rgb[0] = point->rgb[0]/256; point->rgb[1] = point->rgb[1]/256; point->rgb[2] = point->rgb[2]/256; };
442 };
443 
445 {
446 public:
447  inline const char* name() const { return "scale_rgb_up"; };
448  inline void transform(LASpoint* point) const { point->rgb[0] = point->rgb[0]*256; point->rgb[1] = point->rgb[1]*256; point->rgb[2] = point->rgb[2]*256; };
449 };
450 
452 {
453 public:
454  inline const char* name() const { return "switch_x_y"; };
455  inline void transform(LASpoint* point) const { I32 temp = point->x; point->x = point->y; point->y = temp; };
456 };
457 
459 {
460 public:
461  inline const char* name() const { return "switch_x_z"; };
462  inline void transform(LASpoint* point) const { I32 temp = point->x; point->x = point->z; point->z = temp; };
463 };
464 
466 {
467 public:
468  inline const char* name() const { return "switch_y_z"; };
469  inline void transform(LASpoint* point) const { I32 temp = point->y; point->y = point->z; point->z = temp; };
470 };
471 
473 {
474 public:
475  inline const char* name() const { return "flip_waveform_direction"; };
476  inline void transform(LASpoint* point) const { point->wavepacket.flipDirection(); };
477 };
478 
480 {
481  U32 i;
482  for (i = 0; i < num_operations; i++)
483  {
484  delete operations[i];
485  }
486  if (operations) delete [] operations;
487  change_coordinates = FALSE;
488  alloc_operations = 0;
489  num_operations = 0;
490  operations = 0;
491 }
492 
494 {
495  fprintf(stderr,"Transform coordinates.\n");
496  fprintf(stderr," -translate_x -2.5\n");
497  fprintf(stderr," -scale_z 0.3048\n");
498  fprintf(stderr," -rotate_xy 15.0 620000 4100000 (angle + origin)\n");
499  fprintf(stderr," -translate_xyz 0.5 0.5 0\n");
500  fprintf(stderr," -translate_then_scale_y -0.5 1.001\n");
501  fprintf(stderr," -clamp_z_min 70.5\n");
502  fprintf(stderr," -clamp_z 70.5 72.5\n");
503  fprintf(stderr,"Transform raw xyz integers.\n");
504  fprintf(stderr," -translate_raw_z 20\n");
505  fprintf(stderr," -translate_raw_xyz 1 1 0\n");
506  fprintf(stderr," -clamp_raw_z 500 800\n");
507  fprintf(stderr,"Transform intensity.\n");
508  fprintf(stderr," -scale_intensity 2.5\n");
509  fprintf(stderr," -translate_intensity 50\n");
510  fprintf(stderr," -translate_then_scale_intensity 0.5 3.1\n");
511  fprintf(stderr,"Transform scan_angle.\n");
512  fprintf(stderr," -scale_scan_angle 1.944445\n");
513  fprintf(stderr," -translate_scan_angle -5\n");
514  fprintf(stderr," -translate_then_scale_scan_angle -0.5 2.1\n");
515  fprintf(stderr,"Change the return number or return count of points.\n");
516  fprintf(stderr," -repair_zero_returns\n");
517  fprintf(stderr," -change_return_number_from_to 2 1\n");
518  fprintf(stderr," -change_number_of_returns_from_to 0 2\n");
519  fprintf(stderr,"Change classification by replacing one with another.\n");
520  fprintf(stderr," -change_classification_from_to 2 4\n");
521  fprintf(stderr,"Change point source ID by replacing one with another.\n");
522  fprintf(stderr," -change_point_source_from_to 1023 1024\n");
523  fprintf(stderr,"Transform gps_time.\n");
524  fprintf(stderr," -translate_gps_time 40.50\n");
525  fprintf(stderr,"Transform RGB colors.\n");
526  fprintf(stderr," -scale_rgb_down (by 256)\n");
527  fprintf(stderr," -scale_rgb_up (by 256)\n");
528 }
529 
531 {
532  int i;
533 
534  for (i = 1; i < argc; i++)
535  {
536  if (argv[i][0] == '\0')
537  {
538  continue;
539  }
540  else if (strcmp(argv[i],"-h") == 0 || strcmp(argv[i],"-help") == 0)
541  {
542  usage();
543  return TRUE;
544  }
545  else if (strcmp(argv[i],"-translate_x") == 0)
546  {
547  if ((i+1) >= argc)
548  {
549  fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]);
550  return FALSE;
551  }
552  change_coordinates = TRUE;
553  add_operation(new LASoperationTranslateX((F64)atof(argv[i+1])));
554  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
555  }
556  else if (strcmp(argv[i],"-translate_y") == 0)
557  {
558  if ((i+1) >= argc)
559  {
560  fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]);
561  return FALSE;
562  }
563  change_coordinates = TRUE;
564  add_operation(new LASoperationTranslateY((F64)atof(argv[i+1])));
565  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
566  }
567  else if (strcmp(argv[i],"-translate_z") == 0)
568  {
569  if ((i+1) >= argc)
570  {
571  fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]);
572  return FALSE;
573  }
574  change_coordinates = TRUE;
575  add_operation(new LASoperationTranslateZ((F64)atof(argv[i+1])));
576  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
577  }
578  else if (strcmp(argv[i],"-translate_xyz") == 0)
579  {
580  if ((i+3) >= argc)
581  {
582  fprintf(stderr,"ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z\n", argv[i]);
583  return FALSE;
584  }
585  change_coordinates = TRUE;
586  add_operation(new LASoperationTranslateXYZ((F64)atof(argv[i+1]), (F64)atof(argv[i+2]), (F64)atof(argv[i+3])));
587  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3;
588  }
589  else if (strcmp(argv[i],"-scale_x") == 0)
590  {
591  if ((i+1) >= argc)
592  {
593  fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]);
594  return FALSE;
595  }
596  change_coordinates = TRUE;
597  add_operation(new LASoperationScaleX((F64)atof(argv[i+1])));
598  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
599  }
600  else if (strcmp(argv[i],"-scale_y") == 0)
601  {
602  if ((i+1) >= argc)
603  {
604  fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]);
605  return FALSE;
606  }
607  change_coordinates = TRUE;
608  add_operation(new LASoperationScaleY((F64)atof(argv[i+1])));
609  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
610  }
611  else if (strcmp(argv[i],"-scale_z") == 0)
612  {
613  if ((i+1) >= argc)
614  {
615  fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]);
616  return FALSE;
617  }
618  change_coordinates = TRUE;
619  add_operation(new LASoperationScaleZ((F64)atof(argv[i+1])));
620  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
621  }
622  else if (strcmp(argv[i],"-scale_xyz") == 0)
623  {
624  if ((i+3) >= argc)
625  {
626  fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z\n", argv[i]);
627  return FALSE;
628  }
629  change_coordinates = TRUE;
630  add_operation(new LASoperationScaleXYZ((F64)atof(argv[i+1]), (F64)atof(argv[i+2]), (F64)atof(argv[i+3])));
631  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3;
632  }
633  else if (strcmp(argv[i],"-translate_then_scale_x") == 0)
634  {
635  if ((i+2) >= argc)
636  {
637  fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]);
638  return FALSE;
639  }
640  change_coordinates = TRUE;
641  add_operation(new LASoperationTranslateThenScaleX((F64)atof(argv[i+1]), (F64)atof(argv[i+2])));
642  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2;
643  }
644  else if (strcmp(argv[i],"-translate_then_scale_y") == 0)
645  {
646  if ((i+2) >= argc)
647  {
648  fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]);
649  return FALSE;
650  }
651  change_coordinates = TRUE;
652  add_operation(new LASoperationTranslateThenScaleY((F64)atof(argv[i+1]), (F64)atof(argv[i+2])));
653  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2;
654  }
655  else if (strcmp(argv[i],"-translate_then_scale_z") == 0)
656  {
657  if ((i+2) >= argc)
658  {
659  fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]);
660  return FALSE;
661  }
662  change_coordinates = TRUE;
663  add_operation(new LASoperationTranslateThenScaleZ((F64)atof(argv[i+1]), (F64)atof(argv[i+2])));
664  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2;
665  }
666  else if (strcmp(argv[i],"-rotate_xy") == 0)
667  {
668  if ((i+3) >= argc)
669  {
670  fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle, x, y\n", argv[i]);
671  return FALSE;
672  }
673  change_coordinates = TRUE;
674  add_operation(new LASoperationRotateXY((F64)atof(argv[i+1]), (F64)atof(argv[i+2]), (F64)atof(argv[i+3])));
675  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3;
676  }
677  else if (strcmp(argv[i],"-clamp_z") == 0)
678  {
679  if ((i+2) >= argc)
680  {
681  fprintf(stderr,"ERROR: '%s' needs 2 arguments: min, max\n", argv[i]);
682  return FALSE;
683  }
684  change_coordinates = TRUE;
685  add_operation(new LASoperationClampZ((I32)atoi(argv[i+1]), (I32)atoi(argv[i+2])));
686  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2;
687  }
688  else if (strcmp(argv[i],"-clamp_z_min") == 0)
689  {
690  if ((i+1) >= argc)
691  {
692  fprintf(stderr,"ERROR: '%s' needs 1 argument: min\n", argv[i]);
693  return FALSE;
694  }
695  change_coordinates = TRUE;
696  add_operation(new LASoperationClampZmin((I32)atoi(argv[i+1])));
697  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
698  }
699  else if (strcmp(argv[i],"-clamp_z_max") == 0)
700  {
701  if ((i+1) >= argc)
702  {
703  fprintf(stderr,"ERROR: '%s' needs 1 argument: max\n", argv[i]);
704  return FALSE;
705  }
706  change_coordinates = TRUE;
707  add_operation(new LASoperationClampZmax((I32)atoi(argv[i+1])));
708  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
709  }
710  else if (strcmp(argv[i],"-translate_raw_x") == 0)
711  {
712  if ((i+1) >= argc)
713  {
714  fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]);
715  return FALSE;
716  }
717  change_coordinates = TRUE;
718  add_operation(new LASoperationTranslateRawX((I32)atoi(argv[i+1])));
719  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
720  }
721  else if (strcmp(argv[i],"-translate_raw_y") == 0)
722  {
723  if ((i+1) >= argc)
724  {
725  fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]);
726  return FALSE;
727  }
728  change_coordinates = TRUE;
729  add_operation(new LASoperationTranslateRawY((I32)atoi(argv[i+1])));
730  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
731  }
732  else if (strcmp(argv[i],"-translate_raw_z") == 0)
733  {
734  if ((i+1) >= argc)
735  {
736  fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]);
737  return FALSE;
738  }
739  change_coordinates = TRUE;
740  add_operation(new LASoperationTranslateRawZ((I32)atoi(argv[i+1])));
741  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
742  }
743  else if (strcmp(argv[i],"-translate_raw_xyz") == 0)
744  {
745  if ((i+3) >= argc)
746  {
747  fprintf(stderr,"ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z\n", argv[i]);
748  return FALSE;
749  }
750  change_coordinates = TRUE;
751  add_operation(new LASoperationTranslateRawXYZ((I32)atoi(argv[i+1]), (I32)atoi(argv[i+2]), (I32)atoi(argv[i+3])));
752  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3;
753  }
754  else if (strcmp(argv[i],"-clamp_raw_z") == 0)
755  {
756  if ((i+2) >= argc)
757  {
758  fprintf(stderr,"ERROR: '%s' needs 2 arguments: min, max\n", argv[i]);
759  return FALSE;
760  }
761  change_coordinates = TRUE;
762  add_operation(new LASoperationClampRawZ((I32)atoi(argv[i+1]), (I32)atoi(argv[i+2])));
763  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2;
764  }
765  else if (strcmp(argv[i],"-scale_intensity") == 0)
766  {
767  if ((i+1) >= argc)
768  {
769  fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]);
770  return FALSE;
771  }
772  add_operation(new LASoperationScaleIntensity((F32)atof(argv[i+1])));
773  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
774  }
775  else if (strcmp(argv[i],"-translate_intensity") == 0)
776  {
777  if ((i+1) >= argc)
778  {
779  fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]);
780  return FALSE;
781  }
782  add_operation(new LASoperationTranslateIntensity((F32)atof(argv[i+1])));
783  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
784  }
785  else if (strcmp(argv[i],"-translate_then_scale_intensity") == 0)
786  {
787  if ((i+2) >= argc)
788  {
789  fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]);
790  return FALSE;
791  }
792  add_operation(new LASoperationTranslateThenScaleIntensity((F32)atof(argv[i+1]), (F32)atof(argv[i+2])));
793  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2;
794  }
795  else if (strcmp(argv[i],"-scale_scan_angle") == 0)
796  {
797  if ((i+1) >= argc)
798  {
799  fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]);
800  return FALSE;
801  }
802  add_operation(new LASoperationScaleScanAngle((F32)atof(argv[i+1])));
803  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
804  }
805  else if (strcmp(argv[i],"-translate_scan_angle") == 0)
806  {
807  if ((i+1) >= argc)
808  {
809  fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]);
810  return FALSE;
811  }
812  add_operation(new LASoperationTranslateScanAngle((F32)atof(argv[i+1])));
813  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
814  }
815  else if (strcmp(argv[i],"-translate_then_scale_scan_angle") == 0)
816  {
817  if ((i+2) >= argc)
818  {
819  fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]);
820  return FALSE;
821  }
822  add_operation(new LASoperationTranslateThenScaleScanAngle((F32)atof(argv[i+1]), (F32)atof(argv[i+2])));
823  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2;
824  }
825  else if (strcmp(argv[i],"-change_classification_from_to") == 0)
826  {
827  if ((i+2) >= argc)
828  {
829  fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_class to_class\n", argv[i]);
830  return FALSE;
831  }
832  add_operation(new LASoperationChangeClassificationFromTo((U8)atoi(argv[i+1]), (U8)atoi(argv[i+2])));
833  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2;
834  }
835  else if (strcmp(argv[i],"-change_point_source_from_to") == 0)
836  {
837  if ((i+2) >= argc)
838  {
839  fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_psid to_psid\n", argv[i]);
840  return FALSE;
841  }
842  add_operation(new LASoperationChangePointSourceFromTo((U16)atoi(argv[i+1]), (U16)atoi(argv[i+2])));
843  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2;
844  }
845  else if (strcmp(argv[i],"-repair_zero_returns") == 0)
846  {
847  add_operation(new LASoperationRepairZeroReturns());
848  *argv[i]='\0';
849  }
850  else if (strcmp(argv[i],"-change_return_number_from_to") == 0)
851  {
852  if ((i+2) >= argc)
853  {
854  fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_return_number to_return_number\n", argv[i]);
855  return FALSE;
856  }
857  add_operation(new LASoperationChangeReturnNumberFromTo((U8)atoi(argv[i+1]), (U8)atoi(argv[i+2])));
858  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2;
859  }
860  else if (strcmp(argv[i],"-change_number_of_returns_from_to") == 0)
861  {
862  if ((i+2) >= argc)
863  {
864  fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_number_of_returns to_number_of_returns\n", argv[i]);
865  return FALSE;
866  }
867  add_operation(new LASoperationChangeNumberOfReturnsFromTo((U8)atoi(argv[i+1]), (U8)atoi(argv[i+2])));
868  *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2;
869  }
870  else if (strcmp(argv[i],"-translate_gps_time") == 0)
871  {
872  if ((i+1) >= argc)
873  {
874  fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]);
875  return FALSE;
876  }
877  add_operation(new LASoperationTranslateGpsTime(atof(argv[i+1])));
878  *argv[i]='\0'; *argv[i+1]='\0'; i+=1;
879  }
880  else if (strcmp(argv[i],"-scale_rgb_down") == 0 || strcmp(argv[i],"-scale_rbg_down") == 0)
881  {
882  add_operation(new LASoperationScaleRGBdown());
883  *argv[i]='\0';
884  }
885  else if (strcmp(argv[i],"-scale_rgb_up") == 0 || strcmp(argv[i],"-scale_rbg_up") == 0)
886  {
887  add_operation(new LASoperationScaleRGBup());
888  *argv[i]='\0';
889  }
890  else if (strcmp(argv[i],"-switch_x_y") == 0)
891  {
892  add_operation(new LASoperationSwitchXY());
893  *argv[i]='\0';
894  }
895  else if (strcmp(argv[i],"-switch_x_z") == 0)
896  {
897  add_operation(new LASoperationSwitchXZ());
898  *argv[i]='\0';
899  }
900  else if (strcmp(argv[i],"-switch_y_z") == 0)
901  {
902  add_operation(new LASoperationSwitchYZ());
903  *argv[i]='\0';
904  }
905  else if (strcmp(argv[i],"-flip_waveform_direction") == 0)
906  {
907  add_operation(new LASoperationFlipWaveformDirection());
908  *argv[i]='\0';
909  }
910  }
911  return TRUE;
912 }
913 
915 {
916  U32 i;
917  for (i = 0; i < num_operations; i++) operations[i]->transform(point);
918 }
919 
921 {
922  change_coordinates = FALSE;
923  alloc_operations = 0;
924  num_operations = 0;
925  operations = 0;
926 }
927 
929 {
930  if (operations) clean();
931 }
932 
933 void LAStransform::add_operation(LASoperation* transform_operation)
934 {
935  if (num_operations == alloc_operations)
936  {
937  U32 i;
938  alloc_operations += 16;
939  LASoperation** temp_operations = new LASoperation*[alloc_operations];
940  if (operations)
941  {
942  for (i = 0; i < num_operations; i++)
943  {
944  temp_operations[i] = operations[i];
945  }
946  delete [] operations;
947  }
948  operations = temp_operations;
949  }
950  operations[num_operations] = transform_operation;
951  num_operations++;
952 }
void transform(LASpoint *point) const
#define I32_QUANTIZE(n)
Definition: mydefs.hpp:111
int BOOL
Definition: mydefs.hpp:57
#define FALSE
Definition: mydefs.hpp:133
void transform(LASpoint *point) const
const char * name() const
void transform(LASpoint *point) const
float F32
Definition: mydefs.hpp:51
void transform(LASpoint *point) const
void add_operation(LASoperation *operation)
void transform(LASpoint *point) const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
const char * name() const
unsigned int U32
Definition: mydefs.hpp:39
const char * name() const
const char * name() const
F64 get_y() const
const char * name() const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
BOOL parse(int argc, char *argv[])
const char * name() const
const char * name() const
const char * name() const
unsigned short U16
Definition: mydefs.hpp:40
void transform(LASpoint *point) const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
#define I8_CLAMP(n)
Definition: mydefs.hpp:96
void transform(LASpoint *point) const
void set_x(const F64 x)
void transform(LASpoint *point) const
const char * name() const
LASwavepacket wavepacket
unsigned char U8
Definition: mydefs.hpp:41
const char * name() const
F64 get_x() const
void transform(LASpoint *point) const
const char * name() const
void transform(LASpoint *point) const
const char * name() const
const char * name() const
LASoperationChangeClassificationFromTo(U8 class_from, U8 class_to)
const char * name() const
const char * name() const
void transform(LASpoint *point) const
#define U16_CLAMP(n)
Definition: mydefs.hpp:100
void transform(LASpoint *point) const
const char * name() const
const char * name() const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
int I32
Definition: mydefs.hpp:35
void transform(LASpoint *point) const
void usage() const
const char * name() const
void set_y(const F64 y)
const char * name() const
void set_z(const F64 z)
const char * name() const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
F64 get_z() const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
#define TRUE
Definition: mydefs.hpp:137
const char * name() const
const char * name() const
void transform(LASpoint *point) const
void transform(LASpoint *point) const
const char * name() const
void transform(LASpoint *point) const
LASoperationTranslateX(F64 offset)
void transform(LASpoint *point) const
void transform(LASpoint *point) const
const char * name() const
const char * name() const
void transform(LASpoint *point) const
const char * name() const
double F64
Definition: mydefs.hpp:52
U8 number_of_returns_of_given_pulse
void transform(LASpoint *point) const
char ** argv
void transform(LASpoint *point) const


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