1 /*
2 ===============================================================================
3
4 FILE: laszip_api.c
5
6 CONTENTS:
7
8 A simple set of linkable function signatures for the DLL of LASzip
9
10 PROGRAMMERS:
11
12 martin.isenburg@rapidlasso.com - http://rapidlasso.com
13
14 COPYRIGHT:
15
16 (c) 2007-2017, martin isenburg, rapidlasso - fast 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 header file
28
29 ===============================================================================
30 */
31
32 #include "laszip_api.h"
33
34 // DLL function definitions
35
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40
41 /*---------------------------------------------------------------------------*/
42 /*---------------- DLL functions to manage the LASzip DLL -------------------*/
43 /*---------------------------------------------------------------------------*/
44
45 /*---------------------------------------------------------------------------*/
46 typedef laszip_I32 (*laszip_get_version_def)
47 (
48 laszip_U8* version_major
49 , laszip_U8* version_minor
50 , laszip_U16* version_revision
51 , laszip_U32* version_build
52 );
53 laszip_get_version_def laszip_get_version_ptr = 0;
54 LASZIP_API laszip_I32
laszip_get_version(laszip_U8 * version_major,laszip_U8 * version_minor,laszip_U16 * version_revision,laszip_U32 * version_build)55 laszip_get_version
56 (
57 laszip_U8* version_major
58 , laszip_U8* version_minor
59 , laszip_U16* version_revision
60 , laszip_U32* version_build
61 )
62 {
63 if (laszip_get_version_ptr)
64 {
65 return (*laszip_get_version_ptr)(version_major, version_minor, version_revision, version_build);
66 }
67 return 1;
68 };
69
70 /*---------------------------------------------------------------------------*/
71 typedef laszip_I32 (*laszip_create_def)
72 (
73 laszip_POINTER* pointer
74 );
75 laszip_create_def laszip_create_ptr = 0;
76 LASZIP_API laszip_I32
laszip_create(laszip_POINTER * pointer)77 laszip_create
78 (
79 laszip_POINTER* pointer
80 )
81 {
82 if (laszip_create_ptr)
83 {
84 return (*laszip_create_ptr)(pointer);
85 }
86 return 1;
87 };
88
89 /*---------------------------------------------------------------------------*/
90 typedef laszip_I32 (*laszip_clean_def)
91 (
92 laszip_POINTER pointer
93 );
94 laszip_clean_def laszip_clean_ptr = 0;
95 LASZIP_API laszip_I32
laszip_clean(laszip_POINTER pointer)96 laszip_clean
97 (
98 laszip_POINTER pointer
99 )
100 {
101 if (laszip_clean_ptr)
102 {
103 return (*laszip_clean_ptr)(pointer);
104 }
105 return 1;
106 };
107
108 /*---------------------------------------------------------------------------*/
109 typedef laszip_I32 (*laszip_get_error_def)
110 (
111 laszip_POINTER pointer
112 , laszip_CHAR** error
113 );
114 laszip_get_error_def laszip_get_error_ptr = 0;
115 LASZIP_API laszip_I32
laszip_get_error(laszip_POINTER pointer,laszip_CHAR ** error)116 laszip_get_error
117 (
118 laszip_POINTER pointer
119 , laszip_CHAR** error
120 )
121 {
122 if (laszip_get_error_ptr)
123 {
124 return (*laszip_get_error_ptr)(pointer, error);
125 }
126 return 1;
127 };
128
129 /*---------------------------------------------------------------------------*/
130 typedef laszip_I32 (*laszip_get_warning_def)
131 (
132 laszip_POINTER pointer
133 , laszip_CHAR** warning
134 );
135 laszip_get_warning_def laszip_get_warning_ptr = 0;
136 LASZIP_API laszip_I32
laszip_get_warning(laszip_POINTER pointer,laszip_CHAR ** warning)137 laszip_get_warning
138 (
139 laszip_POINTER pointer
140 , laszip_CHAR** warning
141 )
142 {
143 if (laszip_get_warning_ptr)
144 {
145 return (*laszip_get_warning_ptr)(pointer, warning);
146 }
147 return 1;
148 };
149
150 /*---------------------------------------------------------------------------*/
151 typedef laszip_I32 (*laszip_destroy_def)
152 (
153 laszip_POINTER pointer
154 );
155 laszip_destroy_def laszip_destroy_ptr = 0;
156 LASZIP_API laszip_I32
laszip_destroy(laszip_POINTER pointer)157 laszip_destroy
158 (
159 laszip_POINTER pointer
160 )
161 {
162 if (laszip_destroy_ptr)
163 {
164 return (*laszip_destroy_ptr)(pointer);
165 }
166 return 1;
167 };
168
169 /*---------------------------------------------------------------------------*/
170 /*---------- DLL functions to write and read LAS and LAZ files --------------*/
171 /*---------------------------------------------------------------------------*/
172
173 /*---------------------------------------------------------------------------*/
174 typedef laszip_I32 (*laszip_get_header_pointer_def)
175 (
176 laszip_POINTER pointer
177 , laszip_header_struct** header_pointer
178 );
179 laszip_get_header_pointer_def laszip_get_header_pointer_ptr = 0;
180 LASZIP_API laszip_I32
laszip_get_header_pointer(laszip_POINTER pointer,laszip_header_struct ** header_pointer)181 laszip_get_header_pointer
182 (
183 laszip_POINTER pointer
184 , laszip_header_struct** header_pointer
185 )
186 {
187 if (laszip_get_header_pointer_ptr)
188 {
189 return (*laszip_get_header_pointer_ptr)(pointer, header_pointer);
190 }
191 return 1;
192 };
193
194 /*---------------------------------------------------------------------------*/
195 typedef laszip_I32 (*laszip_get_point_pointer_def)
196 (
197 laszip_POINTER pointer
198 , laszip_point_struct** point_pointer
199 );
200 laszip_get_point_pointer_def laszip_get_point_pointer_ptr = 0;
201 LASZIP_API laszip_I32
laszip_get_point_pointer(laszip_POINTER pointer,laszip_point_struct ** point_pointer)202 laszip_get_point_pointer
203 (
204 laszip_POINTER pointer
205 , laszip_point_struct** point_pointer
206 )
207 {
208 if (laszip_get_point_pointer_ptr)
209 {
210 return (*laszip_get_point_pointer_ptr)(pointer, point_pointer);
211 }
212 return 1;
213 };
214
215 /*---------------------------------------------------------------------------*/
216 typedef laszip_I32 (*laszip_get_point_count_def)
217 (
218 laszip_POINTER pointer
219 , laszip_I64* point_count
220 );
221 laszip_get_point_count_def laszip_get_point_count_ptr = 0;
222 LASZIP_API laszip_I32
laszip_get_point_count(laszip_POINTER pointer,laszip_I64 * point_count)223 laszip_get_point_count
224 (
225 laszip_POINTER pointer
226 , laszip_I64* point_count
227 )
228 {
229 if (laszip_get_point_count_ptr)
230 {
231 return (*laszip_get_point_count_ptr)(pointer, point_count);
232 }
233 return 1;
234 };
235
236 /*---------------------------------------------------------------------------*/
237 typedef laszip_I32 (*laszip_set_header_def)
238 (
239 laszip_POINTER pointer
240 , const laszip_header_struct* header
241 );
242 laszip_set_header_def laszip_set_header_ptr = 0;
243 LASZIP_API laszip_I32
laszip_set_header(laszip_POINTER pointer,const laszip_header_struct * header)244 laszip_set_header
245 (
246 laszip_POINTER pointer
247 , const laszip_header_struct* header
248 )
249 {
250 if (laszip_set_header_ptr)
251 {
252 return (*laszip_set_header_ptr)(pointer, header);
253 }
254 return 1;
255 };
256
257 /*---------------------------------------------------------------------------*/
258 typedef laszip_I32 (*laszip_set_point_type_and_size_def)
259 (
260 laszip_POINTER pointer
261 , laszip_U8 point_type
262 , laszip_U16 point_size
263 );
264 laszip_set_point_type_and_size_def laszip_set_point_type_and_size_ptr = 0;
265 LASZIP_API laszip_I32
laszip_set_point_type_and_size(laszip_POINTER pointer,laszip_U8 point_type,laszip_U16 point_size)266 laszip_set_point_type_and_size
267 (
268 laszip_POINTER pointer
269 , laszip_U8 point_type
270 , laszip_U16 point_size
271 )
272 {
273 if (laszip_set_point_type_and_size_ptr)
274 {
275 return (*laszip_set_point_type_and_size_ptr)(pointer, point_type, point_size);
276 }
277 return 1;
278 };
279
280 /*---------------------------------------------------------------------------*/
281 typedef laszip_I32 (*laszip_check_for_integer_overflow_def)
282 (
283 laszip_POINTER pointer
284 );
285 laszip_check_for_integer_overflow_def laszip_check_for_integer_overflow_ptr = 0;
286 LASZIP_API laszip_I32
laszip_check_for_integer_overflow(laszip_POINTER pointer)287 laszip_check_for_integer_overflow
288 (
289 laszip_POINTER pointer
290 )
291 {
292 if (laszip_check_for_integer_overflow_ptr)
293 {
294 return (*laszip_check_for_integer_overflow_ptr)(pointer);
295 }
296 return 1;
297 };
298
299 /*---------------------------------------------------------------------------*/
300 typedef laszip_I32 (*laszip_auto_offset_def)
301 (
302 laszip_POINTER pointer
303 );
304 laszip_auto_offset_def laszip_auto_offset_ptr = 0;
305 LASZIP_API laszip_I32
laszip_auto_offset(laszip_POINTER pointer)306 laszip_auto_offset
307 (
308 laszip_POINTER pointer
309 )
310 {
311 if (laszip_auto_offset_ptr)
312 {
313 return (*laszip_auto_offset_ptr)(pointer);
314 }
315 return 1;
316 };
317
318 /*---------------------------------------------------------------------------*/
319 typedef laszip_I32 (*laszip_set_point_def)
320 (
321 laszip_POINTER pointer
322 , const laszip_point_struct* point
323 );
324 laszip_set_point_def laszip_set_point_ptr = 0;
325 LASZIP_API laszip_I32
laszip_set_point(laszip_POINTER pointer,const laszip_point_struct * point)326 laszip_set_point
327 (
328 laszip_POINTER pointer
329 , const laszip_point_struct* point
330 )
331 {
332 if (laszip_set_point_ptr)
333 {
334 return (*laszip_set_point_ptr)(pointer, point);
335 }
336 return 1;
337 };
338
339 /*---------------------------------------------------------------------------*/
340 typedef laszip_I32 (*laszip_set_coordinates_def)
341 (
342 laszip_POINTER pointer
343 , const laszip_F64* coordinates
344 );
345 laszip_set_coordinates_def laszip_set_coordinates_ptr = 0;
346 LASZIP_API laszip_I32
laszip_set_coordinates(laszip_POINTER pointer,const laszip_F64 * coordinates)347 laszip_set_coordinates
348 (
349 laszip_POINTER pointer
350 , const laszip_F64* coordinates
351 )
352 {
353 if (laszip_set_coordinates_ptr)
354 {
355 return (*laszip_set_coordinates_ptr)(pointer, coordinates);
356 }
357 return 1;
358 };
359
360 /*---------------------------------------------------------------------------*/
361 typedef laszip_I32 (*laszip_get_coordinates_def)
362 (
363 laszip_POINTER pointer
364 , laszip_F64* coordinates
365 );
366 laszip_get_coordinates_def laszip_get_coordinates_ptr = 0;
367 LASZIP_API laszip_I32
laszip_get_coordinates(laszip_POINTER pointer,laszip_F64 * coordinates)368 laszip_get_coordinates
369 (
370 laszip_POINTER pointer
371 , laszip_F64* coordinates
372 )
373 {
374 if (laszip_get_coordinates_ptr)
375 {
376 return (*laszip_get_coordinates_ptr)(pointer, coordinates);
377 }
378 return 1;
379 };
380
381 /*---------------------------------------------------------------------------*/
382 typedef laszip_I32 (*laszip_set_geokeys_def)
383 (
384 laszip_POINTER pointer
385 , laszip_U32 number
386 , const laszip_geokey_struct* key_entries
387 );
388 laszip_set_geokeys_def laszip_set_geokeys_ptr = 0;
389 LASZIP_API laszip_I32
laszip_set_geokeys(laszip_POINTER pointer,laszip_U32 number,const laszip_geokey_struct * key_entries)390 laszip_set_geokeys
391 (
392 laszip_POINTER pointer
393 , laszip_U32 number
394 , const laszip_geokey_struct* key_entries
395 )
396 {
397 if (laszip_set_geokeys_ptr)
398 {
399 return (*laszip_set_geokeys_ptr)(pointer, number, key_entries);
400 }
401 return 1;
402 };
403
404 /*---------------------------------------------------------------------------*/
405 typedef laszip_I32 (*laszip_set_geodouble_params_def)
406 (
407 laszip_POINTER pointer
408 , laszip_U32 number
409 , const laszip_F64* geodouble_params
410 );
411 laszip_set_geodouble_params_def laszip_set_geodouble_params_ptr = 0;
412 LASZIP_API laszip_I32
laszip_set_geodouble_params(laszip_POINTER pointer,laszip_U32 number,const laszip_F64 * geodouble_params)413 laszip_set_geodouble_params
414 (
415 laszip_POINTER pointer
416 , laszip_U32 number
417 , const laszip_F64* geodouble_params
418 )
419 {
420 if (laszip_set_geodouble_params_ptr)
421 {
422 return (*laszip_set_geodouble_params_ptr)(pointer, number, geodouble_params);
423 }
424 return 1;
425 };
426
427 /*---------------------------------------------------------------------------*/
428 typedef laszip_I32 (*laszip_set_geoascii_params_def)
429 (
430 laszip_POINTER pointer
431 , laszip_U32 number
432 , const laszip_CHAR* geoascii_params
433 );
434 laszip_set_geoascii_params_def laszip_set_geoascii_params_ptr = 0;
435 LASZIP_API laszip_I32
laszip_set_geoascii_params(laszip_POINTER pointer,laszip_U32 number,const laszip_CHAR * geoascii_params)436 laszip_set_geoascii_params
437 (
438 laszip_POINTER pointer
439 , laszip_U32 number
440 , const laszip_CHAR* geoascii_params
441 )
442 {
443 if (laszip_set_geoascii_params_ptr)
444 {
445 return (*laszip_set_geoascii_params_ptr)(pointer, number, geoascii_params);
446 }
447 return 1;
448 };
449
450 /*---------------------------------------------------------------------------*/
451 typedef laszip_I32 (*laszip_add_attribute_def)
452 (
453 laszip_POINTER pointer
454 , laszip_U32 type
455 , const laszip_CHAR* name
456 , const laszip_CHAR* description
457 , laszip_F64 scale
458 , laszip_F64 offset
459 );
460 laszip_add_attribute_def laszip_add_attribute_ptr = 0;
461 LASZIP_API laszip_I32
laszip_add_attribute(laszip_POINTER pointer,laszip_U32 type,const laszip_CHAR * name,const laszip_CHAR * description,laszip_F64 scale,laszip_F64 offset)462 laszip_add_attribute
463 (
464 laszip_POINTER pointer
465 , laszip_U32 type
466 , const laszip_CHAR* name
467 , const laszip_CHAR* description
468 , laszip_F64 scale
469 , laszip_F64 offset
470 )
471 {
472 if (laszip_add_attribute_ptr)
473 {
474 return (*laszip_add_attribute_ptr)(pointer, type, name, description, scale, offset);
475 }
476 return 1;
477 };
478
479 /*---------------------------------------------------------------------------*/
480 typedef laszip_I32 (*laszip_add_vlr_def)
481 (
482 laszip_POINTER pointer
483 , const laszip_CHAR* user_id
484 , laszip_U16 record_id
485 , laszip_U16 record_length_after_header
486 , const laszip_CHAR* description
487 , const laszip_U8* data
488 );
489 laszip_add_vlr_def laszip_add_vlr_ptr = 0;
490 LASZIP_API laszip_I32
laszip_add_vlr(laszip_POINTER pointer,const laszip_CHAR * user_id,laszip_U16 record_id,laszip_U16 record_length_after_header,const laszip_CHAR * description,const laszip_U8 * data)491 laszip_add_vlr
492 (
493 laszip_POINTER pointer
494 , const laszip_CHAR* user_id
495 , laszip_U16 record_id
496 , laszip_U16 record_length_after_header
497 , const laszip_CHAR* description
498 , const laszip_U8* data
499 )
500 {
501 if (laszip_add_vlr_ptr)
502 {
503 return (*laszip_add_vlr_ptr)(pointer, user_id, record_id, record_length_after_header, description, data);
504 }
505 return 1;
506 };
507
508 /*---------------------------------------------------------------------------*/
509 typedef laszip_I32 (*laszip_remove_vlr_def)
510 (
511 laszip_POINTER pointer
512 , const laszip_CHAR* user_id
513 , laszip_U16 record_id
514 );
515 laszip_remove_vlr_def laszip_remove_vlr_ptr = 0;
516 LASZIP_API laszip_I32
laszip_remove_vlr(laszip_POINTER pointer,const laszip_CHAR * user_id,laszip_U16 record_id)517 laszip_remove_vlr
518 (
519 laszip_POINTER pointer
520 , const laszip_CHAR* user_id
521 , laszip_U16 record_id
522 )
523 {
524 if (laszip_remove_vlr_ptr)
525 {
526 return (*laszip_remove_vlr_ptr)(pointer, user_id, record_id);
527 }
528 return 1;
529 };
530
531 /*---------------------------------------------------------------------------*/
532 typedef laszip_I32 (*laszip_create_spatial_index_def)
533 (
534 laszip_POINTER pointer
535 , const laszip_BOOL create
536 , const laszip_BOOL append
537 );
538 laszip_create_spatial_index_def laszip_create_spatial_index_ptr = 0;
539 LASZIP_API laszip_I32
laszip_create_spatial_index(laszip_POINTER pointer,const laszip_BOOL create,const laszip_BOOL append)540 laszip_create_spatial_index
541 (
542 laszip_POINTER pointer
543 , const laszip_BOOL create
544 , const laszip_BOOL append
545 )
546 {
547 if (laszip_create_spatial_index_ptr)
548 {
549 return (*laszip_create_spatial_index_ptr)(pointer, create, append);
550 }
551 return 1;
552 };
553
554 /*---------------------------------------------------------------------------*/
555 typedef laszip_I32 (*laszip_preserve_generating_software_def)
556 (
557 laszip_POINTER pointer
558 , const laszip_BOOL preserve
559 );
560 laszip_preserve_generating_software_def laszip_preserve_generating_software_ptr = 0;
561 LASZIP_API laszip_I32
laszip_preserve_generating_software(laszip_POINTER pointer,const laszip_BOOL preserve)562 laszip_preserve_generating_software
563 (
564 laszip_POINTER pointer
565 , const laszip_BOOL preserve
566 )
567 {
568 if (laszip_preserve_generating_software_ptr)
569 {
570 return (*laszip_preserve_generating_software_ptr)(pointer, preserve);
571 }
572 return 1;
573 };
574
575 /*---------------------------------------------------------------------------*/
576 typedef laszip_I32 (*laszip_request_native_extension_def)
577 (
578 laszip_POINTER pointer
579 , const laszip_BOOL request
580 );
581 laszip_request_native_extension_def laszip_request_native_extension_ptr = 0;
582 LASZIP_API laszip_I32
laszip_request_native_extension(laszip_POINTER pointer,const laszip_BOOL request)583 laszip_request_native_extension
584 (
585 laszip_POINTER pointer
586 , const laszip_BOOL request
587 )
588 {
589 if (laszip_request_native_extension_ptr)
590 {
591 return (*laszip_request_native_extension_ptr)(pointer, request);
592 }
593 return 1;
594 };
595
596 /*---------------------------------------------------------------------------*/
597 typedef laszip_I32 (*laszip_request_compatibility_mode_def)
598 (
599 laszip_POINTER pointer
600 , const laszip_BOOL request
601 );
602 laszip_request_compatibility_mode_def laszip_request_compatibility_mode_ptr = 0;
603 LASZIP_API laszip_I32
laszip_request_compatibility_mode(laszip_POINTER pointer,const laszip_BOOL request)604 laszip_request_compatibility_mode
605 (
606 laszip_POINTER pointer
607 , const laszip_BOOL request
608 )
609 {
610 if (laszip_request_compatibility_mode_ptr)
611 {
612 return (*laszip_request_compatibility_mode_ptr)(pointer, request);
613 }
614 return 1;
615 };
616
617 /*---------------------------------------------------------------------------*/
618 typedef laszip_I32 (*laszip_set_chunk_size_def)
619 (
620 laszip_POINTER pointer
621 , const laszip_U32 chunk_size
622 );
623 laszip_set_chunk_size_def laszip_set_chunk_size_ptr = 0;
624 LASZIP_API laszip_I32
laszip_set_chunk_size(laszip_POINTER pointer,const laszip_U32 chunk_size)625 laszip_set_chunk_size
626 (
627 laszip_POINTER pointer
628 , const laszip_U32 chunk_size
629 )
630 {
631 if (laszip_set_chunk_size_ptr)
632 {
633 return (*laszip_set_chunk_size_ptr)(pointer, chunk_size);
634 }
635 return 1;
636 };
637
638 /*---------------------------------------------------------------------------*/
639 typedef laszip_I32 (*laszip_open_writer_def)
640 (
641 laszip_POINTER pointer
642 , const laszip_CHAR* file_name
643 , laszip_BOOL compress
644 );
645 laszip_open_writer_def laszip_open_writer_ptr = 0;
646 LASZIP_API laszip_I32
laszip_open_writer(laszip_POINTER pointer,const laszip_CHAR * file_name,laszip_BOOL compress)647 laszip_open_writer
648 (
649 laszip_POINTER pointer
650 , const laszip_CHAR* file_name
651 , laszip_BOOL compress
652 )
653 {
654 if (laszip_open_writer_ptr)
655 {
656 return (*laszip_open_writer_ptr)(pointer, file_name, compress);
657 }
658 return 1;
659 };
660
661 /*---------------------------------------------------------------------------*/
662 typedef laszip_I32 (*laszip_write_point_def)
663 (
664 laszip_POINTER pointer
665 );
666 laszip_write_point_def laszip_write_point_ptr = 0;
667 LASZIP_API laszip_I32
laszip_write_point(laszip_POINTER pointer)668 laszip_write_point
669 (
670 laszip_POINTER pointer
671 )
672 {
673 if (laszip_write_point_ptr)
674 {
675 return (*laszip_write_point_ptr)(pointer);
676 }
677 return 1;
678 };
679
680 /*---------------------------------------------------------------------------*/
681 typedef laszip_I32 (*laszip_write_indexed_point_def)
682 (
683 laszip_POINTER pointer
684 );
685 laszip_write_indexed_point_def laszip_write_indexed_point_ptr = 0;
686 LASZIP_API laszip_I32
laszip_write_indexed_point(laszip_POINTER pointer)687 laszip_write_indexed_point
688 (
689 laszip_POINTER pointer
690 )
691 {
692 if (laszip_write_indexed_point_ptr)
693 {
694 return (*laszip_write_indexed_point_ptr)(pointer);
695 }
696 return 1;
697 };
698
699 /*---------------------------------------------------------------------------*/
700 typedef laszip_I32 (*laszip_update_inventory_def)
701 (
702 laszip_POINTER pointer
703 );
704 laszip_update_inventory_def laszip_update_inventory_ptr = 0;
705 LASZIP_API laszip_I32
laszip_update_inventory(laszip_POINTER pointer)706 laszip_update_inventory
707 (
708 laszip_POINTER pointer
709 )
710 {
711 if (laszip_update_inventory_ptr)
712 {
713 return (*laszip_update_inventory_ptr)(pointer);
714 }
715 return 1;
716 };
717
718 /*---------------------------------------------------------------------------*/
719 typedef laszip_I32 (*laszip_close_writer_def)
720 (
721 laszip_POINTER pointer
722 );
723 laszip_close_writer_def laszip_close_writer_ptr = 0;
724 LASZIP_API laszip_I32
laszip_close_writer(laszip_POINTER pointer)725 laszip_close_writer
726 (
727 laszip_POINTER pointer
728 )
729 {
730 if (laszip_close_writer_ptr)
731 {
732 return (*laszip_close_writer_ptr)(pointer);
733 }
734 return 1;
735 };
736
737 /*---------------------------------------------------------------------------*/
738 typedef laszip_I32 (*laszip_exploit_spatial_index_def)
739 (
740 laszip_POINTER pointer
741 , const laszip_BOOL exploit
742 );
743 laszip_exploit_spatial_index_def laszip_exploit_spatial_index_ptr = 0;
744 LASZIP_API laszip_I32
laszip_exploit_spatial_index(laszip_POINTER pointer,const laszip_BOOL exploit)745 laszip_exploit_spatial_index
746 (
747 laszip_POINTER pointer
748 , const laszip_BOOL exploit
749 )
750 {
751 if (laszip_exploit_spatial_index_ptr)
752 {
753 return (*laszip_exploit_spatial_index_ptr)(pointer, exploit);
754 }
755 return 1;
756 };
757
758 /*---------------------------------------------------------------------------*/
759 typedef laszip_I32 (*laszip_decompress_selective_def)
760 (
761 laszip_POINTER pointer
762 , const laszip_U32 decompress_selective
763 );
764 laszip_decompress_selective_def laszip_decompress_selective_ptr = 0;
765 LASZIP_API laszip_I32
laszip_decompress_selective(laszip_POINTER pointer,const laszip_U32 decompress_selective)766 laszip_decompress_selective
767 (
768 laszip_POINTER pointer
769 , const laszip_U32 decompress_selective
770 )
771 {
772 if (laszip_decompress_selective_ptr)
773 {
774 return (*laszip_decompress_selective_ptr)(pointer, decompress_selective);
775 }
776 return 1;
777 };
778
779 /*---------------------------------------------------------------------------*/
780 typedef laszip_I32 (*laszip_open_reader_def)
781 (
782 laszip_POINTER pointer
783 , const laszip_CHAR* file_name
784 , laszip_BOOL* is_compressed
785 );
786 laszip_open_reader_def laszip_open_reader_ptr = 0;
787 LASZIP_API laszip_I32
laszip_open_reader(laszip_POINTER pointer,const laszip_CHAR * file_name,laszip_BOOL * is_compressed)788 laszip_open_reader
789 (
790 laszip_POINTER pointer
791 , const laszip_CHAR* file_name
792 , laszip_BOOL* is_compressed
793 )
794 {
795 if (laszip_open_reader_ptr)
796 {
797 return (*laszip_open_reader_ptr)(pointer, file_name, is_compressed);
798 }
799 return 1;
800 };
801
802 /*---------------------------------------------------------------------------*/
803 typedef laszip_I32 (*laszip_has_spatial_index_def)
804 (
805 laszip_POINTER pointer
806 , laszip_BOOL* is_compressed
807 , laszip_BOOL* is_appended
808 );
809 laszip_has_spatial_index_def laszip_has_spatial_index_ptr = 0;
810 LASZIP_API laszip_I32
laszip_has_spatial_index(laszip_POINTER pointer,laszip_BOOL * is_compressed,laszip_BOOL * is_appended)811 laszip_has_spatial_index
812 (
813 laszip_POINTER pointer
814 , laszip_BOOL* is_compressed
815 , laszip_BOOL* is_appended
816 )
817 {
818 if (laszip_has_spatial_index_ptr)
819 {
820 return (*laszip_has_spatial_index_ptr)(pointer, is_compressed, is_appended);
821 }
822 return 1;
823 };
824
825 /*---------------------------------------------------------------------------*/
826 typedef laszip_I32 (*laszip_inside_rectangle_def)
827 (
828 laszip_POINTER pointer
829 , laszip_F64 r_min_x
830 , laszip_F64 r_min_y
831 , laszip_F64 r_max_x
832 , laszip_F64 r_max_y
833 , laszip_BOOL* is_empty
834 );
835 laszip_inside_rectangle_def laszip_inside_rectangle_ptr = 0;
836 LASZIP_API laszip_I32
laszip_inside_rectangle(laszip_POINTER pointer,laszip_F64 r_min_x,laszip_F64 r_min_y,laszip_F64 r_max_x,laszip_F64 r_max_y,laszip_BOOL * is_empty)837 laszip_inside_rectangle
838 (
839 laszip_POINTER pointer
840 , laszip_F64 r_min_x
841 , laszip_F64 r_min_y
842 , laszip_F64 r_max_x
843 , laszip_F64 r_max_y
844 , laszip_BOOL* is_empty
845 )
846 {
847 if (laszip_inside_rectangle_ptr)
848 {
849 return (*laszip_inside_rectangle_ptr)(pointer, r_min_x, r_min_y, r_max_x, r_max_y, is_empty);
850 }
851 return 1;
852 };
853
854 /*---------------------------------------------------------------------------*/
855 typedef laszip_I32 (*laszip_seek_point_def)
856 (
857 laszip_POINTER pointer
858 , laszip_I64 index
859 );
860 laszip_seek_point_def laszip_seek_point_ptr = 0;
861 LASZIP_API laszip_I32
laszip_seek_point(laszip_POINTER pointer,laszip_I64 index)862 laszip_seek_point(
863 laszip_POINTER pointer
864 , laszip_I64 index
865 )
866 {
867 if (laszip_seek_point_ptr)
868 {
869 return (*laszip_seek_point_ptr)(pointer, index);
870 }
871 return 1;
872 }
873
874 /*---------------------------------------------------------------------------*/
875 typedef laszip_I32 (*laszip_read_point_def)
876 (
877 laszip_POINTER pointer
878 );
879 laszip_read_point_def laszip_read_point_ptr = 0;
880 LASZIP_API laszip_I32
laszip_read_point(laszip_POINTER pointer)881 laszip_read_point(
882 laszip_POINTER pointer
883 )
884 {
885 if (laszip_read_point_ptr)
886 {
887 return (*laszip_read_point_ptr)(pointer);
888 }
889 return 1;
890 }
891
892 /*---------------------------------------------------------------------------*/
893 typedef laszip_I32 (*laszip_read_inside_point_def)
894 (
895 laszip_POINTER pointer
896 , laszip_BOOL* is_done
897 );
898 laszip_read_inside_point_def laszip_read_inside_point_ptr = 0;
899 LASZIP_API laszip_I32
laszip_read_inside_point(laszip_POINTER pointer,laszip_BOOL * is_done)900 laszip_read_inside_point(
901 laszip_POINTER pointer
902 , laszip_BOOL* is_done
903 )
904 {
905 if (laszip_read_inside_point_ptr)
906 {
907 return (*laszip_read_inside_point_ptr)(pointer, is_done);
908 }
909 return 1;
910 }
911
912 /*---------------------------------------------------------------------------*/
913 typedef laszip_I32 (*laszip_close_reader_def)
914 (
915 laszip_POINTER pointer
916 );
917 laszip_close_reader_def laszip_close_reader_ptr = 0;
918 LASZIP_API laszip_I32
laszip_close_reader(laszip_POINTER pointer)919 laszip_close_reader
920 (
921 laszip_POINTER pointer
922 )
923 {
924 if (laszip_close_reader_ptr)
925 {
926 return (*laszip_close_reader_ptr)(pointer);
927 }
928 return 1;
929 };
930
931 /*---------------------------------------------------------------------------*/
932 /*---------------- DLL functions to load and unload LASzip ------------------*/
933 /*---------------------------------------------------------------------------*/
934
935 /*---------------------------------------------------------------------------*/
936 #ifdef _WIN32
937 #include <windows.h>
938 #define FreeLibraryZeroMeansFail 1
939 #else
940 #include <dlfcn.h>
941 typedef void* HINSTANCE;
942 #ifndef NULL
943 #define NULL 0
944 #endif
945 #define LoadLibrary dlopen
946 #define GetProcAddress dlsym
947 #define FreeLibrary dlclose
948 #define FreeLibraryZeroMeansFail 0
949 #define TEXT
950 #endif
951 static HINSTANCE laszip_HINSTANCE = NULL;
laszip_load_dll()952 laszip_I32 laszip_load_dll()
953 {
954 // Assure DLL not yet loaded
955 if (laszip_HINSTANCE != NULL) {
956 return 1;
957 }
958 // Load DLL file
959 #ifdef _WIN32
960 laszip_HINSTANCE = LoadLibrary(TEXT("LASzip.dll"));
961 #elif __APPLE__
962 laszip_HINSTANCE = LoadLibrary("liblaszip.dylib", RTLD_NOW);
963 #else
964 laszip_HINSTANCE = LoadLibrary("liblaszip.so", RTLD_NOW);
965 #endif
966 if (laszip_HINSTANCE == NULL) {
967 return 1;
968 }
969 // Get function pointers
970 laszip_get_version_ptr = (laszip_get_version_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_version");
971 if (laszip_get_version_ptr == NULL) {
972 FreeLibrary(laszip_HINSTANCE);
973 return 1;
974 }
975 laszip_create_ptr = (laszip_create_def)GetProcAddress(laszip_HINSTANCE, "laszip_create");
976 if (laszip_create_ptr == NULL) {
977 FreeLibrary(laszip_HINSTANCE);
978 return 1;
979 }
980 laszip_clean_ptr = (laszip_clean_def)GetProcAddress(laszip_HINSTANCE, "laszip_clean");
981 if (laszip_clean_ptr == NULL) {
982 FreeLibrary(laszip_HINSTANCE);
983 return 1;
984 }
985 laszip_get_error_ptr = (laszip_get_error_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_error");
986 if (laszip_get_error_ptr == NULL) {
987 FreeLibrary(laszip_HINSTANCE);
988 return 1;
989 }
990 laszip_get_warning_ptr = (laszip_get_warning_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_warning");
991 if (laszip_get_warning_ptr == NULL) {
992 FreeLibrary(laszip_HINSTANCE);
993 return 1;
994 }
995 laszip_destroy_ptr = (laszip_destroy_def)GetProcAddress(laszip_HINSTANCE, "laszip_destroy");
996 if (laszip_destroy_ptr == NULL) {
997 FreeLibrary(laszip_HINSTANCE);
998 return 1;
999 }
1000 laszip_get_header_pointer_ptr = (laszip_get_header_pointer_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_header_pointer");
1001 if (laszip_get_header_pointer_ptr == NULL) {
1002 FreeLibrary(laszip_HINSTANCE);
1003 return 1;
1004 }
1005 laszip_get_point_pointer_ptr = (laszip_get_point_pointer_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_point_pointer");
1006 if (laszip_get_point_pointer_ptr == NULL) {
1007 FreeLibrary(laszip_HINSTANCE);
1008 return 1;
1009 }
1010 laszip_get_point_count_ptr = (laszip_get_point_count_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_point_count");
1011 if (laszip_get_point_count_ptr == NULL) {
1012 FreeLibrary(laszip_HINSTANCE);
1013 return 1;
1014 }
1015 laszip_set_header_ptr = (laszip_set_header_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_header");
1016 if (laszip_set_header_ptr == NULL) {
1017 FreeLibrary(laszip_HINSTANCE);
1018 return 1;
1019 }
1020 laszip_set_point_type_and_size_ptr = (laszip_set_point_type_and_size_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_point_type_and_size");
1021 if (laszip_set_point_type_and_size_ptr == NULL) {
1022 FreeLibrary(laszip_HINSTANCE);
1023 return 1;
1024 }
1025 laszip_check_for_integer_overflow_ptr = (laszip_check_for_integer_overflow_def)GetProcAddress(laszip_HINSTANCE, "laszip_check_for_integer_overflow");
1026 if (laszip_check_for_integer_overflow_ptr == NULL) {
1027 FreeLibrary(laszip_HINSTANCE);
1028 return 1;
1029 }
1030 laszip_auto_offset_ptr = (laszip_auto_offset_def)GetProcAddress(laszip_HINSTANCE, "laszip_auto_offset");
1031 if (laszip_auto_offset_ptr == NULL) {
1032 FreeLibrary(laszip_HINSTANCE);
1033 return 1;
1034 }
1035 laszip_set_point_ptr = (laszip_set_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_point");
1036 if (laszip_set_point_ptr == NULL) {
1037 FreeLibrary(laszip_HINSTANCE);
1038 return 1;
1039 }
1040 laszip_set_coordinates_ptr = (laszip_set_coordinates_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_coordinates");
1041 if (laszip_set_coordinates_ptr == NULL) {
1042 FreeLibrary(laszip_HINSTANCE);
1043 return 1;
1044 }
1045 laszip_get_coordinates_ptr = (laszip_get_coordinates_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_coordinates");
1046 if (laszip_get_coordinates_ptr == NULL) {
1047 FreeLibrary(laszip_HINSTANCE);
1048 return 1;
1049 }
1050 laszip_set_geokeys_ptr = (laszip_set_geokeys_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_geokeys");
1051 if (laszip_set_geokeys_ptr == NULL) {
1052 FreeLibrary(laszip_HINSTANCE);
1053 return 1;
1054 }
1055 laszip_set_geodouble_params_ptr = (laszip_set_geodouble_params_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_geodouble_params");
1056 if (laszip_set_geodouble_params_ptr == NULL) {
1057 FreeLibrary(laszip_HINSTANCE);
1058 return 1;
1059 }
1060 laszip_set_geoascii_params_ptr = (laszip_set_geoascii_params_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_geoascii_params");
1061 if (laszip_set_geoascii_params_ptr == NULL) {
1062 FreeLibrary(laszip_HINSTANCE);
1063 return 1;
1064 }
1065 laszip_add_attribute_ptr = (laszip_add_attribute_def)GetProcAddress(laszip_HINSTANCE, "laszip_add_attribute");
1066 if (laszip_add_attribute_ptr == NULL) {
1067 FreeLibrary(laszip_HINSTANCE);
1068 return 1;
1069 }
1070 laszip_add_vlr_ptr = (laszip_add_vlr_def)GetProcAddress(laszip_HINSTANCE, "laszip_add_vlr");
1071 if (laszip_add_vlr_ptr == NULL) {
1072 FreeLibrary(laszip_HINSTANCE);
1073 return 1;
1074 }
1075 laszip_remove_vlr_ptr = (laszip_remove_vlr_def)GetProcAddress(laszip_HINSTANCE, "laszip_remove_vlr");
1076 if (laszip_remove_vlr_ptr == NULL) {
1077 FreeLibrary(laszip_HINSTANCE);
1078 return 1;
1079 }
1080 laszip_create_spatial_index_ptr = (laszip_create_spatial_index_def)GetProcAddress(laszip_HINSTANCE, "laszip_create_spatial_index");
1081 if (laszip_create_spatial_index_ptr == NULL) {
1082 FreeLibrary(laszip_HINSTANCE);
1083 return 1;
1084 }
1085 laszip_preserve_generating_software_ptr = (laszip_preserve_generating_software_def)GetProcAddress(laszip_HINSTANCE, "laszip_preserve_generating_software");
1086 if (laszip_preserve_generating_software_ptr == NULL) {
1087 FreeLibrary(laszip_HINSTANCE);
1088 return 1;
1089 }
1090 laszip_request_native_extension_ptr = (laszip_request_native_extension_def)GetProcAddress(laszip_HINSTANCE, "laszip_request_native_extension");
1091 if (laszip_request_native_extension_ptr == NULL) {
1092 FreeLibrary(laszip_HINSTANCE);
1093 return 1;
1094 }
1095 laszip_request_compatibility_mode_ptr = (laszip_request_compatibility_mode_def)GetProcAddress(laszip_HINSTANCE, "laszip_request_compatibility_mode");
1096 if (laszip_request_compatibility_mode_ptr == NULL) {
1097 FreeLibrary(laszip_HINSTANCE);
1098 return 1;
1099 }
1100 laszip_set_chunk_size_ptr = (laszip_set_chunk_size_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_chunk_size");
1101 if (laszip_set_chunk_size_ptr == NULL) {
1102 FreeLibrary(laszip_HINSTANCE);
1103 return 1;
1104 }
1105 laszip_open_writer_ptr = (laszip_open_writer_def)GetProcAddress(laszip_HINSTANCE, "laszip_open_writer");
1106 if (laszip_open_writer_ptr == NULL) {
1107 FreeLibrary(laszip_HINSTANCE);
1108 return 1;
1109 }
1110 laszip_write_point_ptr = (laszip_write_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_write_point");
1111 if (laszip_write_point_ptr == NULL) {
1112 FreeLibrary(laszip_HINSTANCE);
1113 return 1;
1114 }
1115 laszip_write_indexed_point_ptr = (laszip_write_indexed_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_write_indexed_point");
1116 if (laszip_write_indexed_point_ptr == NULL) {
1117 FreeLibrary(laszip_HINSTANCE);
1118 return 1;
1119 }
1120 laszip_update_inventory_ptr = (laszip_update_inventory_def)GetProcAddress(laszip_HINSTANCE, "laszip_update_inventory");
1121 if (laszip_update_inventory_ptr == NULL) {
1122 FreeLibrary(laszip_HINSTANCE);
1123 return 1;
1124 }
1125 laszip_close_writer_ptr = (laszip_close_writer_def)GetProcAddress(laszip_HINSTANCE, "laszip_close_writer");
1126 if (laszip_close_writer_ptr == NULL) {
1127 FreeLibrary(laszip_HINSTANCE);
1128 return 1;
1129 }
1130 laszip_exploit_spatial_index_ptr = (laszip_exploit_spatial_index_def)GetProcAddress(laszip_HINSTANCE, "laszip_exploit_spatial_index");
1131 if (laszip_exploit_spatial_index_ptr == NULL) {
1132 FreeLibrary(laszip_HINSTANCE);
1133 return 1;
1134 }
1135 laszip_decompress_selective_ptr = (laszip_decompress_selective_def)GetProcAddress(laszip_HINSTANCE, "laszip_decompress_selective");
1136 if (laszip_decompress_selective_ptr == NULL) {
1137 FreeLibrary(laszip_HINSTANCE);
1138 return 1;
1139 }
1140 laszip_open_reader_ptr = (laszip_open_reader_def)GetProcAddress(laszip_HINSTANCE, "laszip_open_reader");
1141 if (laszip_open_reader_ptr == NULL) {
1142 FreeLibrary(laszip_HINSTANCE);
1143 return 1;
1144 }
1145 laszip_has_spatial_index_ptr = (laszip_has_spatial_index_def)GetProcAddress(laszip_HINSTANCE, "laszip_has_spatial_index");
1146 if (laszip_has_spatial_index_ptr == NULL) {
1147 FreeLibrary(laszip_HINSTANCE);
1148 return 1;
1149 }
1150 laszip_inside_rectangle_ptr = (laszip_inside_rectangle_def)GetProcAddress(laszip_HINSTANCE, "laszip_inside_rectangle");
1151 if (laszip_inside_rectangle_ptr == NULL) {
1152 FreeLibrary(laszip_HINSTANCE);
1153 return 1;
1154 }
1155 laszip_seek_point_ptr = (laszip_seek_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_seek_point");
1156 if (laszip_seek_point_ptr == NULL) {
1157 FreeLibrary(laszip_HINSTANCE);
1158 return 1;
1159 }
1160 laszip_read_point_ptr = (laszip_read_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_read_point");
1161 if (laszip_read_point_ptr == NULL) {
1162 FreeLibrary(laszip_HINSTANCE);
1163 return 1;
1164 }
1165 laszip_read_inside_point_ptr = (laszip_read_inside_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_read_inside_point");
1166 if (laszip_read_inside_point_ptr == NULL) {
1167 FreeLibrary(laszip_HINSTANCE);
1168 return 1;
1169 }
1170 laszip_close_reader_ptr = (laszip_close_reader_def)GetProcAddress(laszip_HINSTANCE, "laszip_close_reader");
1171 if (laszip_close_reader_ptr == NULL) {
1172 FreeLibrary(laszip_HINSTANCE);
1173 return 1;
1174 }
1175 return 0;
1176 };
1177
1178 /*---------------------------------------------------------------------------*/
laszip_unload_dll()1179 laszip_I32 laszip_unload_dll()
1180 {
1181 if (laszip_HINSTANCE == NULL) {
1182 return 1;
1183 }
1184 if (FreeLibraryZeroMeansFail)
1185 {
1186 if (!FreeLibrary(laszip_HINSTANCE)) {
1187 return 1;
1188 }
1189 }
1190 else
1191 {
1192 if (FreeLibrary(laszip_HINSTANCE)) {
1193 return 1;
1194 }
1195 }
1196 laszip_HINSTANCE = NULL;
1197 return 0;
1198 }
1199
1200 #ifdef __cplusplus
1201 }
1202 #endif
1203