83 if (num < 34)
return return_error(
"too few bytes to unpack");
84 if (((num - 34) % 6) != 0)
return return_error(
"wrong number bytes to unpack");
85 if (((num - 34) / 6) == 0)
return return_error(
"zero items to unpack");
124 assert((bytes + num) == b);
139 if (!
check())
return false;
143 if (this->bytes)
delete [] this->
bytes;
144 this->bytes = bytes =
new U8[num];
178 assert((bytes + num) == b);
200 sprintf(error,
"compressor %d not supported", compressor);
208 sprintf(error,
"coder %d not supported", coder);
248 sprintf(error,
"item unknown (%d,%d,%d)", item->
type, item->
size, item->
version);
257 if (num_items == 0)
return return_error(
"number of items cannot be zero");
258 if (items == 0)
return return_error(
"items pointer cannot be NULL");
305 if (this->items)
delete [] this->
items;
314 this->items[i] = items[i];
327 I32 extra_bytes_number = 0;
333 extra_bytes_number = (
I32)point_size - 20;
336 have_gps_time =
TRUE;
337 extra_bytes_number = (
I32)point_size - 28;
341 extra_bytes_number = (
I32)point_size - 26;
344 have_gps_time =
TRUE;
346 extra_bytes_number = (
I32)point_size - 34;
349 have_gps_time =
TRUE;
350 have_wavepacket =
TRUE;
351 extra_bytes_number = (
I32)point_size - 57;
354 have_gps_time =
TRUE;
356 have_wavepacket =
TRUE;
357 extra_bytes_number = (
I32)point_size - 63;
361 extra_bytes_number = (
I32)point_size - 30;
366 extra_bytes_number = (
I32)point_size - 36;
372 extra_bytes_number = (
I32)point_size - 38;
376 have_wavepacket =
TRUE;
377 extra_bytes_number = (
I32)point_size - 59;
383 have_wavepacket =
TRUE;
384 extra_bytes_number = (
I32)point_size - 67;
390 sprintf(error,
"point type %d unknown", point_type);
395 if (extra_bytes_number < 0)
398 sprintf(error,
"point size %d too small for point type %d by %d bytes", point_size, point_type, -extra_bytes_number);
404 (*num_items) = 1 + !!(have_gps_time) + !!(have_rgb) + !!(have_wavepacket) + !!(extra_bytes_number);
411 (*items)[0].size = 30;
412 (*items)[0].version = 0;
417 (*items)[0].size = 20;
418 (*items)[0].version = 0;
423 (*items)[i].size = 8;
424 (*items)[i].version = 0;
432 (*items)[i].size = 8;
433 (*items)[i].version = 0;
438 (*items)[i].size = 6;
439 (*items)[i].version = 0;
446 (*items)[i].size = 29;
447 (*items)[i].version = 0;
450 if (extra_bytes_number)
453 (*items)[i].size = extra_bytes_number;
454 (*items)[i].version = 0;
458 assert(i == *num_items);
478 if (requested_version > 0)
return return_error(
"without compression version is always 0");
482 if (requested_version < 1)
return return_error(
"with compression version is at least 1");
483 if (requested_version > 2)
return return_error(
"version larger than 2 not supported");
488 switch (
items[i].type)
513 if (items == 0)
return return_error(
"LASitem array is zero");
516 if (point_type) *point_type = 127;
523 *record_length += items[i].
size;
528 if (num_items < 1)
return return_error(
"less than one LASitem entries");
530 if (num_items > 5)
return return_error(
"more than five LASitem entries");
537 if (point_type) *point_type = 0;
538 if (record_length) assert(*record_length == 20);
547 if (point_type) *point_type = 1;
548 if (record_length) assert(*record_length == 28);
557 if (point_type) *point_type = 3;
558 if (record_length) assert(*record_length == 34);
567 if (point_type) *point_type = 5;
568 if (record_length) assert(*record_length == 63);
577 if (point_type) *point_type = 5;
578 if (record_length) assert(*record_length == (63 + items[4].size));
588 if (point_type) *point_type = 3;
589 if (record_length) assert(*record_length == (34 + items[3].size));
599 if (point_type) *point_type = 4;
600 if (record_length) assert(*record_length == 57);
609 if (point_type) *point_type = 4;
610 if (record_length) assert(*record_length == (57 + items[3].size));
620 if (point_type) *point_type = 1;
621 if (record_length) assert(*record_length == (28 + items[2].size));
631 if (point_type) *point_type = 2;
632 if (record_length) assert(*record_length == 26);
641 if (point_type) *point_type = 2;
642 if (record_length) assert(*record_length == (26 + items[2].size));
652 if (point_type) *point_type = 0;
653 if (record_length) assert(*record_length == (20 + items[1].size));
664 if (point_type) *point_type = 6;
665 if (record_length) assert(*record_length == 30);
674 if (point_type) *point_type = 7;
675 if (record_length) assert(*record_length == 36);
684 if (point_type) *point_type = 7;
685 if (record_length) assert(*record_length == (36 + items[2].size));
695 if (point_type) *point_type = 8;
696 if (record_length) assert(*record_length == 38);
705 if (point_type) *point_type = 10;
706 if (record_length) assert(*record_length == 67);
715 if (point_type) *point_type = 10;
716 if (record_length) assert(*record_length == (67 + items[3].size));
726 if (point_type) *point_type = 8;
727 if (record_length) assert(*record_length == (38 + items[2].size));
737 if (point_type) *point_type = 9;
738 if (record_length) assert(*record_length == 59);
747 if (point_type) *point_type = 9;
748 if (record_length) assert(*record_length == (59 + items[2].size));
758 if (point_type) *point_type = 6;
759 if (record_length) assert(*record_length == (30 + items[1].size));
767 return_error(
"first LASitem is neither POINT10 nor POINT14");
769 return return_error(
"LASitem array does not match LAS specification 1.4");
774 if (t != type)
return false;
778 if (size != 20)
return false;
781 if (size != 8)
return false;
784 if (size != 6)
return false;
787 if (size != 29)
return false;
790 if (size < 1)
return false;
812 return "WAVEPACKET13";
unsigned char version_minor
bool pack(unsigned char *&bytes, int &num)
bool check_items(const unsigned short num_items, const LASitem *items)
#define LASZIP_CHUNK_SIZE_DEFAULT
#define LASZIP_CODER_ARITHMETIC
bool unpack(const unsigned char *bytes, const int num)
bool set_chunk_size(const unsigned int chunk_size)
bool setup(unsigned short *num_items, LASitem **items, const unsigned char point_type, const unsigned short point_size, const unsigned short compressor=LASZIP_COMPRESSOR_NONE)
bool check_item(const LASitem *item)
unsigned short compressor
#define LASZIP_COMPRESSOR_TOTAL_NUMBER_OF
const char * get_error() const
#define LASZIP_VERSION_MINOR
bool is_standard(const unsigned short num_items, const LASitem *items, unsigned char *point_type=0, unsigned short *record_length=0)
#define LASZIP_COMPRESSOR_DEFAULT
bool is_type(LASitem::Type t) const
#define LASZIP_COMPRESSOR_NONE
unsigned short version_revision
#define LASZIP_CODER_TOTAL_NUMBER_OF
bool check_coder(const unsigned short coder)
KF_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func="")
Error handler. All GPU functions from this subsystem call the function to report an error...
#define LASZIP_VERSION_MAJOR
#define LASZIP_VERSION_REVISION
const char * get_name() const
bool check_compressor(const unsigned short compressor)
bool request_version(const unsigned short requested_version)
bool return_error(const char *err)
#define LASZIP_COMPRESSOR_POINTWISE_CHUNKED
unsigned char version_major