40 inline const char*
name()
const {
return "clip_tile"; };
51 inline const char*
name()
const {
return "clip_circle"; };
52 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g %g %g ",
name(), center_x, center_y, radius); };
62 inline const char*
name()
const {
return "clip"; };
63 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g %g %g %g ",
name(), below_x, below_y, above_x, above_y); };
65 LAScriterionClipXY(
F64 below_x,
F64 below_y,
F64 above_x,
F64 above_y) { this->below_x = below_x; this->below_y = below_y; this->above_x = above_x; this->above_y = above_y; };
67 F64 below_x, below_y, above_x, above_y;
73 inline const char*
name()
const {
return "clip_z"; };
74 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g %g ",
name(), below_z, above_z); };
84 inline const char*
name()
const {
return "clip_x_below"; };
85 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g ",
name(), below_x); };
95 inline const char*
name()
const {
return "clip_x_above"; };
96 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g ",
name(), above_x); };
106 inline const char*
name()
const {
return "clip_y_below"; };
107 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g ",
name(), below_y); };
117 inline const char*
name()
const {
return "clip_y_above"; };
118 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g ",
name(), above_y); };
128 inline const char*
name()
const {
return "clip_z_below"; };
129 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g ",
name(), below_z); };
139 inline const char*
name()
const {
return "clip_z_above"; };
140 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g ",
name(), above_z); };
150 inline const char*
name()
const {
return "clip_raw_xy"; };
151 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d %d %d %d ",
name(), below_x, below_y, above_x, above_y); };
152 inline BOOL filter(
const LASpoint* point) {
return (point->
x < below_x) || (point->
y < below_y) || (point->
x > above_x) || (point->
y > above_y); };
153 LAScriterionClipRawXY(
I32 below_x,
I32 below_y,
I32 above_x,
I32 above_y) { this->below_x = below_x; this->below_y = below_y; this->above_x = above_x; this->above_y = above_y; };
155 I32 below_x, below_y, above_x, above_y;
161 inline const char*
name()
const {
return "clip_raw_z"; };
162 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d %d ",
name(), below_z, above_z); };
166 I32 below_z, above_z;
172 inline const char*
name()
const {
return "clip_raw_x_below"; };
173 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), below_x); };
183 inline const char*
name()
const {
return "clip_raw_x_above"; };
184 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), above_x); };
194 inline const char*
name()
const {
return "clip_raw_y_below"; };
195 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), below_y); };
205 inline const char*
name()
const {
return "clip_raw_y_above"; };
206 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), above_y); };
216 inline const char*
name()
const {
return "clip_raw_z_below"; };
217 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), below_z); };
227 inline const char*
name()
const {
return "clip_raw_z_above"; };
228 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), above_z); };
238 inline const char*
name()
const {
return "keep_first"; };
239 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s ",
name()); };
246 inline const char*
name()
const {
return "keep_middle"; };
247 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s ",
name()); };
254 inline const char*
name()
const {
return "keep_last"; };
255 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s ",
name()); };
262 inline const char*
name()
const {
return "drop_first"; };
263 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s ",
name()); };
270 inline const char*
name()
const {
return "drop_middle"; };
271 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s ",
name()); };
278 inline const char*
name()
const {
return "drop_last"; };
279 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s ",
name()); };
286 inline const char*
name()
const {
return "keep_return_mask"; };
287 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %u ",
name(), ~drop_return_mask); };
291 U32 drop_return_mask;
297 inline const char*
name()
const {
return (numberOfReturns == 1 ?
"keep_single" : (numberOfReturns == 2 ?
"keep_double" : (numberOfReturns == 3 ?
"keep_triple" : (numberOfReturns == 4 ?
"keep_quadruple" :
"keep_quintuple")))); };
298 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s ",
name()); };
308 inline const char*
name()
const {
return (numberOfReturns == 1 ?
"drop_single" : (numberOfReturns == 2 ?
"drop_double" : (numberOfReturns == 3 ?
"drop_triple" : (numberOfReturns == 4 ?
"drop_quadruple" :
"drop_quintuple")))); };
309 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s ",
name()); };
319 inline const char*
name()
const {
return "drop_scan_direction"; };
320 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), scan_direction); };
330 inline const char*
name()
const {
return "scan_direction_change_only"; };
331 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s ",
name()); };
333 void reset() { scan_direction_flag = -1; };
342 inline const char*
name()
const {
return "edge_of_flight_line_only"; };
343 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s ",
name()); };
350 inline const char*
name()
const {
return "keep_scan_angle"; };
351 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d %d ",
name(), below_scan, above_scan); };
353 LAScriterionKeepScanAngle(
I32 below_scan,
I32 above_scan) {
if (above_scan < below_scan) { this->below_scan = above_scan; this->above_scan = below_scan; }
else { this->below_scan = below_scan; this->above_scan = above_scan; } };
355 I32 below_scan, above_scan;
361 inline const char*
name()
const {
return "drop_scan_angle_below"; };
362 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), below_scan); };
372 inline const char*
name()
const {
return "drop_scan_angle_above"; };
373 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), above_scan); };
383 inline const char*
name()
const {
return "drop_scan_angle_between"; };
384 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d %d ",
name(), below_scan, above_scan); };
386 LAScriterionDropScanAngleBetween(
I32 below_scan,
I32 above_scan) {
if (above_scan < below_scan) { this->below_scan = above_scan; this->above_scan = below_scan; }
else { this->below_scan = below_scan; this->above_scan = above_scan; } };
388 I32 below_scan, above_scan;
394 inline const char*
name()
const {
return "keep_intensity"; };
395 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d %d ",
name(), below_intensity, above_intensity); };
399 I32 below_intensity, above_intensity;
405 inline const char*
name()
const {
return "drop_intensity_below"; };
406 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), below_intensity); };
416 inline const char*
name()
const {
return "drop_intensity_above"; };
417 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), above_intensity); };
427 inline const char*
name()
const {
return "drop_intensity_between"; };
428 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d %d ",
name(), below_intensity, above_intensity); };
432 I32 below_intensity, above_intensity;
438 inline const char*
name()
const {
return "keep_classification_mask"; };
439 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %u ",
name(), ~drop_classification_mask); };
443 U32 drop_classification_mask;
449 inline const char*
name()
const {
return "keep_point_source"; };
450 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), point_source_id); };
460 inline const char*
name()
const {
return "keep_point_source_between"; };
461 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d %d ",
name(), below_point_source_id, above_point_source_id); };
465 I32 below_point_source_id, above_point_source_id;
471 inline const char*
name()
const {
return "drop_point_source_below"; };
472 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), below_point_source_id); };
476 I32 below_point_source_id;
482 inline const char*
name()
const {
return "drop_point_source_above"; };
483 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), above_point_source_id); };
487 I32 above_point_source_id;
493 inline const char*
name()
const {
return "drop_point_source_between"; };
494 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d %d ",
name(), below_point_source_id, above_point_source_id); };
498 I32 below_point_source_id, above_point_source_id;
504 inline const char*
name()
const {
return "keep_gps_time"; };
505 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g %g ",
name(), below_gpstime, above_gpstime); };
509 F64 below_gpstime, above_gpstime;
515 inline const char*
name()
const {
return "drop_gps_time_below"; };
516 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g ",
name(), below_gpstime); };
526 inline const char*
name()
const {
return "drop_gps_time_above"; };
527 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g ",
name(), above_gpstime); };
537 inline const char*
name()
const {
return "drop_gps_time_between"; };
538 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g %g ",
name(), below_gpstime, above_gpstime); };
542 F64 below_gpstime, above_gpstime;
548 inline const char*
name()
const {
return "keep_wavepacket_mask"; };
549 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %u ",
name(), ~drop_wavepacket_mask); };
553 U32 drop_wavepacket_mask;
559 inline const char*
name()
const {
return "keep_every_nth"; };
560 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %d ",
name(), every); };
571 inline const char*
name()
const {
return "keep_random_fraction"; };
572 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g ",
name(), fraction); };
582 inline const char*
name()
const {
return "thin_with_grid"; };
583 inline int get_command(
char*
string)
const {
return sprintf(
string,
"-%s %g ",
name(), (grid_spacing > 0 ? grid_spacing : -grid_spacing)); };
586 if (grid_spacing < 0)
588 grid_spacing = -grid_spacing;
601 ankers = &minus_ankers;
602 if ((
U32)pos_y < minus_plus_size && minus_plus_sizes[pos_y])
604 pos_x -= minus_ankers[pos_y];
608 array_size = &minus_minus_size;
609 array = &minus_minus;
610 array_sizes = &minus_minus_sizes;
614 array_size = &minus_plus_size;
616 array_sizes = &minus_plus_sizes;
622 array_size = &minus_plus_size;
624 array_sizes = &minus_plus_sizes;
629 ankers = &plus_ankers;
630 if ((
U32)pos_y < plus_plus_size && plus_plus_sizes[pos_y])
632 pos_x -= plus_ankers[pos_y];
636 array_size = &plus_minus_size;
638 array_sizes = &plus_minus_sizes;
642 array_size = &plus_plus_size;
644 array_sizes = &plus_plus_sizes;
650 array_size = &plus_plus_size;
652 array_sizes = &plus_plus_sizes;
656 if ((
U32)pos_y >= *array_size)
658 U32 array_size_new = ((pos_y/1024)+1)*1024;
661 if (array == &minus_plus || array == &plus_plus) *ankers = (
I32*)realloc(*ankers, array_size_new*
sizeof(
I32));
662 *array = (
U32**)realloc(*array, array_size_new*
sizeof(
U32*));
663 *array_sizes = (
U16*)realloc(*array_sizes, array_size_new*
sizeof(
U16));
667 if (array == &minus_plus || array == &plus_plus) *ankers = (
I32*)malloc(array_size_new*
sizeof(
I32));
668 *array = (
U32**)malloc(array_size_new*
sizeof(
U32*));
669 *array_sizes = (
U16*)malloc(array_size_new*
sizeof(
U16));
671 for (
U32 i = *array_size; i < array_size_new; i++)
674 (*array_sizes)[i] = 0;
676 *array_size = array_size_new;
681 (*ankers)[pos_y] = pos_x;
685 U32 pos_x_pos = pos_x/32;
686 if (pos_x_pos >= (*array_sizes)[pos_y])
688 U32 array_sizes_new = ((pos_x_pos/256)+1)*256;
689 if ((*array_sizes)[pos_y])
691 (*array)[pos_y] = (
U32*)realloc((*array)[pos_y], array_sizes_new*
sizeof(
U32));
695 (*array)[pos_y] = (
U32*)malloc(array_sizes_new*
sizeof(
U32));
697 for (
U16 i = (*array_sizes)[pos_y]; i < array_sizes_new; i++)
699 (*array)[pos_y][i] = 0;
701 (*array_sizes)[pos_y] = array_sizes_new;
703 U32 pos_x_bit = 1 << (pos_x%32);
704 if ((*array)[pos_y][pos_x_pos] & pos_x_bit)
return TRUE;
705 (*array)[pos_y][pos_x_pos] |= pos_x_bit;
710 if (grid_spacing > 0) grid_spacing = -grid_spacing;
711 if (minus_minus_size)
713 for (
U32 i = 0; i < minus_minus_size; i++)
if (minus_minus[i]) free(minus_minus[i]);
716 free(minus_minus_sizes);
717 minus_minus_sizes = 0;
718 minus_minus_size = 0;
724 for (
U32 i = 0; i < minus_plus_size; i++)
if (minus_plus[i]) free(minus_plus[i]);
727 free(minus_plus_sizes);
728 minus_plus_sizes = 0;
733 for (
U32 i = 0; i < plus_minus_size; i++)
if (plus_minus[i]) free(plus_minus[i]);
736 free(plus_minus_sizes);
737 plus_minus_sizes = 0;
744 for (
U32 i = 0; i < plus_plus_size; i++)
if (plus_plus[i]) free(plus_plus[i]);
747 free(plus_plus_sizes);
754 this->grid_spacing = -grid_spacing;
756 minus_minus_size = 0;
758 minus_minus_sizes = 0;
761 minus_plus_sizes = 0;
765 plus_minus_sizes = 0;
793 for (i = 0; i < num_criteria; i++)
797 if (criteria)
delete [] criteria;
798 if (counters)
delete [] counters;
807 fprintf(stderr,
"Filter points based on their coordinates.\n");
808 fprintf(stderr,
" -clip_tile 631000 4834000 1000 (ll_x, ll_y, size)\n");
809 fprintf(stderr,
" -clip_circle 630250.00 4834750.00 100 (x, y, radius)\n");
810 fprintf(stderr,
" -clip 630000 4834000 631000 4836000 (min_x, min_y, max_x, max_y)\n");
811 fprintf(stderr,
" -clip_x_below 630000.50 (min_x)\n");
812 fprintf(stderr,
" -clip_y_below 4834500.25 (min_y)\n");
813 fprintf(stderr,
" -clip_x_above 630500.50 (max_x)\n");
814 fprintf(stderr,
" -clip_y_above 4836000.75 (max_y)\n");
815 fprintf(stderr,
" -clip_z 11.125 130.725 (min_z, max_z)\n");
816 fprintf(stderr,
" -clip_z_below 11.125 (min_z)\n");
817 fprintf(stderr,
" -clip_z_above 130.725 (max_z)\n");
818 fprintf(stderr,
"Filter points based on their return number.\n");
819 fprintf(stderr,
" -first_only -keep_first -drop_first\n");
820 fprintf(stderr,
" -last_only -keep_last -drop_last\n");
821 fprintf(stderr,
" -keep_middle -drop_middle\n");
822 fprintf(stderr,
" -keep_return 1 2 3\n");
823 fprintf(stderr,
" -drop_return 3 4\n");
824 fprintf(stderr,
" -keep_single -drop_single\n");
825 fprintf(stderr,
" -keep_double -drop_double\n");
826 fprintf(stderr,
" -keep_triple -drop_triple\n");
827 fprintf(stderr,
" -keep_quadruple -drop_quadruple\n");
828 fprintf(stderr,
" -keep_quintuple -drop_quintuple\n");
829 fprintf(stderr,
"Filter points based on the scanline flags.\n");
830 fprintf(stderr,
" -drop_scan_direction 0\n");
831 fprintf(stderr,
" -scan_direction_change_only\n");
832 fprintf(stderr,
" -edge_of_flight_line_only\n");
833 fprintf(stderr,
"Filter points based on their intensity.\n");
834 fprintf(stderr,
" -keep_intensity 20 380\n");
835 fprintf(stderr,
" -drop_intensity_below 20\n");
836 fprintf(stderr,
" -drop_intensity_above 380\n");
837 fprintf(stderr,
" -drop_intensity_between 4000 5000\n");
838 fprintf(stderr,
"Filter points based on their classification.\n");
839 fprintf(stderr,
" -keep_class 1 3 7\n");
840 fprintf(stderr,
" -drop_class 4 2\n");
841 fprintf(stderr,
"Filter points based on their point source ID.\n");
842 fprintf(stderr,
" -keep_point_source 3\n");
843 fprintf(stderr,
" -keep_point_source_between 2 6\n");
844 fprintf(stderr,
" -drop_point_source_below 6\n");
845 fprintf(stderr,
" -drop_point_source_above 15\n");
846 fprintf(stderr,
" -drop_point_source_between 17 21\n");
847 fprintf(stderr,
"Filter points based on their scan angle.\n");
848 fprintf(stderr,
" -keep_scan_angle -15 15\n");
849 fprintf(stderr,
" -drop_scan_angle_below -15\n");
850 fprintf(stderr,
" -drop_scan_angle_above 15\n");
851 fprintf(stderr,
" -drop_scan_angle_between -25 -23\n");
852 fprintf(stderr,
"Filter points based on their gps time.\n");
853 fprintf(stderr,
" -keep_gps_time 11.125 130.725\n");
854 fprintf(stderr,
" -drop_gps_time_below 11.125\n");
855 fprintf(stderr,
" -drop_gps_time_above 130.725\n");
856 fprintf(stderr,
" -drop_gps_time_between 22.0 48.0\n");
857 fprintf(stderr,
"Filter points based on their wavepacket.\n");
858 fprintf(stderr,
" -keep_wavepacket 1 2\n");
859 fprintf(stderr,
" -drop_wavepacket 0\n");
860 fprintf(stderr,
"Filter points with simple thinning.\n");
861 fprintf(stderr,
" -keep_every_nth 2\n");
862 fprintf(stderr,
" -keep_random_fraction 0.1\n");
863 fprintf(stderr,
" -thin_with_grid 1.0\n");
870 U32 keep_return_mask = 0;
871 U32 drop_return_mask = 0;
873 U32 keep_classification_mask = 0;
874 U32 drop_classification_mask = 0;
876 U32 keep_wavepacket_mask = 0;
877 U32 drop_wavepacket_mask = 0;
879 for (i = 1; i <
argc; i++)
881 if (argv[i][0] ==
'\0')
885 else if (strcmp(argv[i],
"-h") == 0 || strcmp(argv[i],
"-help") == 0)
890 else if (strcmp(argv[i],
"-clip_tile") == 0)
894 fprintf(stderr,
"ERROR: '%s' needs 3 arguments: llx lly size\n", argv[i]);
898 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; *argv[i+3]=
'\0'; i+=3;
900 else if (strcmp(argv[i],
"-clip_circle") == 0)
904 fprintf(stderr,
"ERROR: '%s' needs 3 arguments: center_x center_y radius\n", argv[i]);
908 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; *argv[i+3]=
'\0'; i+=3;
910 else if (strcmp(argv[i],
"-clip") == 0 || strcmp(argv[i],
"-clip_xy") == 0)
914 fprintf(stderr,
"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]);
917 add_criterion(
new LAScriterionClipXY(atof(argv[i+1]), atof(argv[i+2]), atof(argv[i+3]), atof(argv[i+4])));
918 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; *argv[i+3]=
'\0'; *argv[i+4]=
'\0'; i+=4;
920 else if (strcmp(argv[i],
"-clip_z") == 0)
924 fprintf(stderr,
"ERROR: '%s' needs 2 arguments: min_z max_z\n", argv[i]);
928 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; i+=2;
930 else if (strcmp(argv[i],
"-clip_x_below") == 0)
934 fprintf(stderr,
"ERROR: '%s' needs 1 argument: min_x\n", argv[i]);
938 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
940 else if (strcmp(argv[i],
"-clip_y_below") == 0)
944 fprintf(stderr,
"ERROR: '%s' needs 1 argument: min_y\n", argv[i]);
948 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
950 else if (strcmp(argv[i],
"-clip_z_below") == 0)
954 fprintf(stderr,
"ERROR: '%s' needs 1 argument: min_z\n", argv[i]);
958 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
960 else if (strcmp(argv[i],
"-clip_x_above") == 0)
964 fprintf(stderr,
"ERROR: '%s' needs 1 argument: max_x\n", argv[i]);
968 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
970 else if (strcmp(argv[i],
"-clip_y_above") == 0)
974 fprintf(stderr,
"ERROR: '%s' needs 1 argument: max_y\n", argv[i]);
978 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
980 else if (strcmp(argv[i],
"-clip_z_above") == 0)
984 fprintf(stderr,
"ERROR: '%s' needs 1 argument: max_z\n", argv[i]);
988 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
990 else if (strcmp(argv[i],
"-clip_raw") == 0 || strcmp(argv[i],
"-clip_raw_xy") == 0)
994 fprintf(stderr,
"ERROR: '%s' needs 4 arguments: min_raw_x min_raw_y max_raw_x max_raw_y\n", argv[i]);
997 add_criterion(
new LAScriterionClipRawXY(atoi(argv[i+1]), atoi(argv[i+2]), atoi(argv[i+3]), atoi(argv[i+4])));
998 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; *argv[i+3]=
'\0'; *argv[i+4]=
'\0'; i+=4;
1000 else if (strcmp(argv[i],
"-clip_raw_z") == 0)
1004 fprintf(stderr,
"ERROR: '%s' needs 2 arguments: min_raw_z max_raw_z\n", argv[i]);
1008 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; i+=2;
1010 else if (strcmp(argv[i],
"-clip_raw_x_below") == 0)
1014 fprintf(stderr,
"ERROR: '%s' needs 1 argument: min_raw_x\n", argv[i]);
1018 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1020 else if (strcmp(argv[i],
"-clip_raw_y_below") == 0)
1024 fprintf(stderr,
"ERROR: '%s' needs 1 argument: min_raw_y\n", argv[i]);
1028 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1030 else if (strcmp(argv[i],
"-clip_raw_z_below") == 0)
1034 fprintf(stderr,
"ERROR: '%s' needs 1 argument: min_raw_z\n", argv[i]);
1038 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1040 else if (strcmp(argv[i],
"-clip_raw_x_above") == 0)
1044 fprintf(stderr,
"ERROR: '%s' needs 1 argument: max_raw_x\n", argv[i]);
1048 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1050 else if (strcmp(argv[i],
"-clip_raw_y_above") == 0)
1054 fprintf(stderr,
"ERROR: '%s' needs 1 argument: max_raw_y\n", argv[i]);
1058 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1060 else if (strcmp(argv[i],
"-clip_raw_z_above") == 0)
1064 fprintf(stderr,
"ERROR: '%s' needs 1 argument: max_raw_z\n", argv[i]);
1068 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1070 else if ((strcmp(argv[i],
"-first_only") == 0) || (strcmp(argv[i],
"-keep_first") == 0))
1075 else if (strcmp(argv[i],
"-keep_middle") == 0)
1080 else if ((strcmp(argv[i],
"-last_only") == 0) || (strcmp(argv[i],
"-keep_last") == 0))
1085 else if (strcmp(argv[i],
"-drop_first") == 0)
1090 else if (strcmp(argv[i],
"-drop_middle") == 0)
1095 else if (strcmp(argv[i],
"-drop_last") == 0)
1100 else if (strcmp(argv[i],
"-keep_return") == 0)
1104 fprintf(stderr,
"ERROR: '%s' needs at least 1 argument: return_number\n", argv[i]);
1111 keep_return_mask |= (1 << atoi(argv[i]));
1114 }
while ((i < argc) && (
'0' <= *argv[i]) && (*argv[i] <=
'9'));
1117 else if (strcmp(argv[i],
"-keep_return_mask") == 0)
1121 fprintf(stderr,
"ERROR: '%s' needs 1 argument: return_mask\n", argv[i]);
1124 keep_return_mask = atoi(argv[i+1]);
1125 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1127 else if (strcmp(argv[i],
"-drop_return") == 0)
1131 fprintf(stderr,
"ERROR: '%s' needs at least 1 argument: return_number\n", argv[i]);
1138 drop_return_mask |= (1 << atoi(argv[i]));
1141 }
while ((i < argc) && (
'0' <= *argv[i]) && (*argv[i] <=
'9'));
1144 else if (strcmp(argv[i],
"-keep_single") == 0 || strcmp(argv[i],
"-single_only") == 0)
1149 else if (strcmp(argv[i],
"-keep_double") == 0 || strcmp(argv[i],
"-double_only") == 0)
1154 else if (strcmp(argv[i],
"-keep_triple") == 0 || strcmp(argv[i],
"-triple_only") == 0)
1159 else if (strcmp(argv[i],
"-keep_quadruple") == 0 || strcmp(argv[i],
"-quadruple_only") == 0)
1164 else if (strcmp(argv[i],
"-keep_quintuple") == 0 || strcmp(argv[i],
"-quintuple_only") == 0)
1169 else if (strcmp(argv[i],
"-drop_single") == 0)
1174 else if (strcmp(argv[i],
"-drop_double") == 0)
1179 else if (strcmp(argv[i],
"-drop_triple") == 0)
1184 else if (strcmp(argv[i],
"-drop_quadruple") == 0)
1189 else if (strcmp(argv[i],
"-drop_quintuple") == 0)
1194 else if (strcmp(argv[i],
"-drop_scan_direction") == 0)
1197 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1199 else if (strcmp(argv[i],
"-scan_direction_change_only") == 0 || strcmp(argv[i],
"-scan_direction_change") == 0)
1204 else if (strcmp(argv[i],
"-edge_of_flight_line_only") == 0 || strcmp(argv[i],
"-edge_of_flight_line") == 0)
1209 else if (strcmp(argv[i],
"-keep_intensity") == 0)
1213 fprintf(stderr,
"ERROR: '%s' needs 2 arguments: min max\n", argv[i]);
1217 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; i+=2;
1219 else if (strcmp(argv[i],
"-drop_intensity_above") == 0)
1223 fprintf(stderr,
"ERROR: '%s' needs 1 argument: max\n", argv[i]);
1227 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1229 else if (strcmp(argv[i],
"-drop_intensity_below") == 0)
1233 fprintf(stderr,
"ERROR: '%s' needs 1 argument: min\n", argv[i]);
1237 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1239 else if (strcmp(argv[i],
"-drop_intensity_between") == 0)
1243 fprintf(stderr,
"ERROR: '%s' needs 2 arguments: min max\n", argv[i]);
1247 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; i+=2;
1249 else if (strcmp(argv[i],
"-keep_scan_angle") == 0 || strcmp(argv[i],
"-keep_scan") == 0)
1253 fprintf(stderr,
"ERROR: '%s' needs 2 arguments: min max\n", argv[i]);
1257 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; i+=2;
1259 else if (strcmp(argv[i],
"-drop_scan_angle_above") == 0 || strcmp(argv[i],
"-drop_scan_above") == 0)
1263 fprintf(stderr,
"ERROR: '%s' needs 1 argument: max\n", argv[i]);
1267 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1269 else if (strcmp(argv[i],
"-drop_scan_angle_below") == 0 || strcmp(argv[i],
"-drop_scan_below") == 0)
1273 fprintf(stderr,
"ERROR: '%s' needs 1 argument: min\n", argv[i]);
1277 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1279 else if (strcmp(argv[i],
"-drop_scan_angle_between") == 0 || strcmp(argv[i],
"-drop_scan_between") == 0)
1283 fprintf(stderr,
"ERROR: '%s' needs 2 arguments: min max\n", argv[i]);
1287 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; i+=2;
1289 else if (strcmp(argv[i],
"-keep_classification") == 0 || strcmp(argv[i],
"-keep_class") == 0)
1293 fprintf(stderr,
"ERROR: '%s' needs 1 at least argument: classification\n", argv[i]);
1300 keep_classification_mask |= (1 << atoi(argv[i]));
1303 }
while ((i < argc) && (
'0' <= *argv[i]) && (*argv[i] <=
'9'));
1306 else if (strcmp(argv[i],
"-keep_classification_mask") == 0)
1310 fprintf(stderr,
"ERROR: '%s' needs 1 argument: classifications_mask\n", argv[i]);
1313 keep_classification_mask = atoi(argv[i+1]);
1314 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1316 else if (strcmp(argv[i],
"-drop_classification") == 0 || strcmp(argv[i],
"-drop_class") == 0)
1320 fprintf(stderr,
"ERROR: '%s' needs at least 1 argument: classification\n", argv[i]);
1327 drop_classification_mask |= (1 << atoi(argv[i]));
1330 }
while ((i < argc) && (
'0' <= *argv[i]) && (*argv[i] <=
'9'));
1333 else if (strcmp(argv[i],
"-keep_wavepacket") == 0)
1337 fprintf(stderr,
"ERROR: '%s' needs 1 at least argument: index\n", argv[i]);
1344 keep_wavepacket_mask |= (1 << atoi(argv[i]));
1347 }
while ((i < argc) && (
'0' <= *argv[i]) && (*argv[i] <=
'9'));
1350 else if (strcmp(argv[i],
"-drop_wavepacket") == 0)
1354 fprintf(stderr,
"ERROR: '%s' needs at least 1 argument: index\n", argv[i]);
1361 drop_wavepacket_mask |= (1 << atoi(argv[i]));
1364 }
while ((i < argc) && (
'0' <= *argv[i]) && (*argv[i] <=
'9'));
1367 else if (strcmp(argv[i],
"-keep_point_source") == 0)
1371 fprintf(stderr,
"ERROR: '%s' needs 1 argument: ID\n", argv[i]);
1375 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1377 else if (strcmp(argv[i],
"-keep_point_source_between") == 0)
1381 fprintf(stderr,
"ERROR: '%s' needs 2 arguments: min_ID max_ID\n", argv[i]);
1385 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; i+=2;
1387 else if (strcmp(argv[i],
"-drop_point_source_below") == 0)
1391 fprintf(stderr,
"ERROR: '%s' needs 1 argument: min_ID\n", argv[i]);
1395 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1397 else if (strcmp(argv[i],
"-drop_point_source_above") == 0)
1401 fprintf(stderr,
"ERROR: '%s' needs 1 argument: max_ID\n", argv[i]);
1405 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1407 else if (strcmp(argv[i],
"-drop_point_source_between") == 0)
1411 fprintf(stderr,
"ERROR: '%s' needs 2 arguments: min_ID max_ID\n", argv[i]);
1415 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; i+=2;
1417 else if (strcmp(argv[i],
"-keep_gps_time") == 0 || strcmp(argv[i],
"-keep_gpstime") == 0)
1421 fprintf(stderr,
"ERROR: '%s' needs 2 arguments: min max\n", argv[i]);
1425 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; i+=2;
1427 else if (strcmp(argv[i],
"-drop_gps_time_above") == 0 || strcmp(argv[i],
"-drop_gpstime_above") == 0)
1431 fprintf(stderr,
"ERROR: '%s' needs 1 argument: max_gps_time\n", argv[i]);
1435 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1437 else if (strcmp(argv[i],
"-drop_gps_time_below") == 0 || strcmp(argv[i],
"-drop_gpstime_below") == 0)
1441 fprintf(stderr,
"ERROR: '%s' needs 1 argument: min_gps_time\n", argv[i]);
1445 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1447 else if (strcmp(argv[i],
"-drop_gps_time_between") == 0 || strcmp(argv[i],
"-drop_gpstime_between") == 0)
1451 fprintf(stderr,
"ERROR: '%s' needs 2 arguments: min max\n", argv[i]);
1455 *argv[i]=
'\0'; *argv[i+1]=
'\0'; *argv[i+2]=
'\0'; i+=2;
1457 else if (strcmp(argv[i],
"-keep_every_nth") == 0)
1461 fprintf(stderr,
"ERROR: '%s' needs 1 argument: nth\n", argv[i]);
1465 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1467 else if (strcmp(argv[i],
"-keep_random_fraction") == 0)
1471 fprintf(stderr,
"ERROR: '%s' needs 1 argument: fraction\n", argv[i]);
1475 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1477 else if (strcmp(argv[i],
"-thin_with_grid") == 0)
1481 fprintf(stderr,
"ERROR: '%s' needs 1 argument: grid_spacing\n", argv[i]);
1485 *argv[i]=
'\0'; *argv[i+1]=
'\0'; i+=1;
1489 if (drop_return_mask)
1491 if (keep_return_mask == 0) keep_return_mask = 255 & ~drop_return_mask;
1495 if (drop_classification_mask)
1497 if (keep_classification_mask == 0) keep_classification_mask = ~drop_classification_mask;
1501 if (drop_wavepacket_mask)
1503 if (keep_wavepacket_mask == 0) keep_wavepacket_mask = ~drop_wavepacket_mask;
1514 for (i = 0; i < num_criteria; i++)
1516 n += criteria[i]->get_command(&
string[n]);
1535 for (i = 0; i < num_criteria; i++)
1537 if (criteria[i]->
filter(point))
1549 for (i = 0; i < num_criteria; i++)
1551 criteria[i]->reset();
1565 if (criteria) clean();
1570 if (num_criteria == alloc_criteria)
1573 alloc_criteria += 16;
1575 int* temp_counters =
new int[alloc_criteria];
1578 for (i = 0; i < num_criteria; i++)
1580 temp_criteria[i] = criteria[i];
1581 temp_counters[i] = counters[i];
1586 criteria = temp_criteria;
1587 counters = temp_counters;
1589 criteria[num_criteria] = filter_criterion;
1590 counters[num_criteria] = 0;
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
LAScriterionClipRawXY(I32 below_x, I32 below_y, I32 above_x, I32 above_y)
LAScriterionKeepEveryNth(I32 every)
const char * name() const
int get_command(char *string) const
BOOL filter(const LASpoint *point)
int get_command(char *string) const
LAScriterionKeepReturns(U32 keep_return_mask)
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
LAScriterionClipZAbove(F64 above_z)
void addScanDirectionChangeOnly()
LAScriterionKeepIntensity(I32 below_intensity, I32 above_intensity)
LAScriterionClipYAbove(F64 above_y)
BOOL filter(const LASpoint *point)
int get_command(char *string) const
const char * name() const
const char * name() const
BOOL filter(const LASpoint *point)
const char * name() const
LAScriterionDropPointSourceBetween(I32 below_point_source_id, I32 above_point_source_id)
const char * name() const
int get_command(char *string) const
BOOL filter(const LASpoint *point)
const char * name() const
LAScriterionDropIntensityBelow(I32 below_intensity)
BOOL filter(const LASpoint *point)
void addClipCircle(F64 x, F64 y, F64 radius)
BOOL filter(const LASpoint *point)
int get_command(char *string) const
const char * name() const
BOOL filter(const LASpoint *point)
const char * name() const
BOOL filter(const LASpoint *point)
LAScriterionClipRawZBelow(I32 below_z)
int get_command(char *string) const
int get_command(char *string) const
int get_command(char *string) const
BOOL filter(const LASpoint *point)
int get_command(char *string) const
int get_command(char *string) const
LAScriterionDropIntensityBetween(I32 below_intensity, I32 above_intensity)
BOOL filter(const LASpoint *point)
int get_command(char *string) const
const char * name() const
int get_command(char *string) const
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
int get_command(char *string) const
LAScriterionDropScanAngleBetween(I32 below_scan, I32 above_scan)
int get_command(char *string) const
BOOL filter(const LASpoint *point)
int get_command(char *string) const
int get_command(char *string) const
int get_command(char *string) const
LAScriterionClipXBelow(F64 below_x)
LAScriterionDropGpsTimeBelow(F64 below_gpstime)
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
LAScriterionClipRawZAbove(I32 above_z)
LAScriterionClipZBelow(F64 below_z)
BOOL filter(const LASpoint *point)
int get_command(char *string) const
const char * name() const
LAScriterionDropScanAngleAbove(I32 above_scan)
BOOL filter(const LASpoint *point)
const char * name() const
LAScriterionKeepPointSourceBetween(I32 below_point_source_id, I32 above_point_source_id)
BOOL inside_rectangle(const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y) const
const char * name() const
LAScriterionThinWithGrid(F32 grid_spacing)
const char * name() const
LAScriterionClipTile(F32 ll_x, F32 ll_y, F32 tile_size)
int get_command(char *string) const
int get_command(char *string) const
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
int get_command(char *string) const
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
int get_command(char *string) const
const char * name() const
BOOL filter(const LASpoint *point)
int get_command(char *string) const
LAScriterionClipRawXAbove(I32 above_x)
LAScriterionClipRawZ(I32 below_z, I32 above_z)
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
const char * name() const
int get_command(char *string) const
int get_command(char *string) const
LAScriterionDropScanAngleBelow(I32 below_scan)
BOOL filter(const LASpoint *point)
LAScriterionClipXY(F64 below_x, F64 below_y, F64 above_x, F64 above_y)
LAScriterionDropIntensityAbove(I32 above_intensity)
int get_command(char *string) const
const char * name() const
const char * name() const
int get_command(char *string) const
const char * name() const
int get_command(char *string) const
int get_command(char *string) const
BOOL filter(const LASpoint *point)
const char * name() const
const char * name() const
BOOL parse(int argc, char *argv[])
BOOL inside_circle(const F64 center_x, const F64 center_y, F64 squared_radius) const
BOOL filter(const LASpoint *point)
int get_command(char *string) const
int get_command(char *string) const
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
int get_command(char *string) const
int get_command(char *string) const
BOOL filter(const LASpoint *point)
int get_command(char *string) const
const char * name() const
const char * name() const
LAScriterionClipZ(F64 below_z, F64 above_z)
const char * name() const
const char * name() const
BOOL filter(const LASpoint *point)
const char * name() const
BOOL filter(const LASpoint *point)
const char * name() const
LAScriterionClipRawYAbove(I32 above_y)
int get_command(char *string) const
const char * name() const
int get_command(char *string) const
BOOL filter(const LASpoint *point)
LAScriterionClipXAbove(F64 above_x)
const char * name() const
int get_command(char *string) const
LAScriterionKeepGpsTime(F64 below_gpstime, F64 above_gpstime)
int unparse(char *string) const
const char * name() const
LAScriterionClipRawXBelow(I32 below_x)
~LAScriterionThinWithGrid()
BOOL filter(const LASpoint *point)
LAScriterionKeepRandomFraction(F32 fraction)
const char * name() const
int get_command(char *string) const
int get_command(char *string) const
int get_command(char *string) const
LAScriterionDropPointSourceAbove(I32 above_point_source_id)
LAScriterionKeepClassifications(U32 keep_classification_mask)
const char * name() const
BOOL filter(const LASpoint *point)
const char * name() const
LAScriterionDropPointSourceBelow(I32 below_point_source_id)
const char * name() const
int get_command(char *string) const
LAScriterionClipRawYBelow(I32 below_y)
BOOL inside_tile(const F32 ll_x, const F32 ll_y, const F32 ur_x, const F32 ur_y) const
int get_command(char *string) const
LAScriterionDropGpsTimeBetween(F64 below_gpstime, F64 above_gpstime)
const char * name() const
const char * name() const
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
const char * name() const
void add_criterion(LAScriterion *criterion)
BOOL filter(const LASpoint *point)
int get_command(char *string) const
const char * name() const
const char * name() const
LAScriterionKeepScanAngle(I32 below_scan, I32 above_scan)
int get_command(char *string) const
BOOL filter(const LASpoint *point)
int get_command(char *string) const
const char * name() const
int get_command(char *string) const
const char * name() const
int get_command(char *string) const
int get_command(char *string) const
const char * name() const
const char * name() const
LAScriterionKeepWavepackets(U32 keep_wavepacket_mask)
int get_command(char *string) const
BOOL filter(const LASpoint *point)
const char * name() const
int get_command(char *string) const
const char * name() const
const char * name() const
BOOL filter(const LASpoint *point)
LAScriterionDropGpsTimeAbove(F64 above_gpstime)
BOOL filter(const LASpoint *point)
const char * name() const
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
const char * name() const
int get_command(char *string) const
BOOL filter(const LASpoint *point)
const char * name() const
const char * name() const
int get_command(char *string) const
const char * name() const
const char * name() const
BOOL filter(const LASpoint *point)
U8 number_of_returns_of_given_pulse
const char * name() const
BOOL filter(const LASpoint *point)
BOOL filter(const LASpoint *point)
LAScriterionClipYBelow(F64 below_y)