diff --git a/build/ComputeRasterizer.sln b/build/ComputeRasterizer.sln
index 93dcce0..fa7d573 100644
--- a/build/ComputeRasterizer.sln
+++ b/build/ComputeRasterizer.sln
@@ -1,34 +1,59 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.29728.190
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ComputeRasterizer", "ComputeRasterizer.vcxproj", "{6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}"
+ ProjectSection(ProjectDependencies) = postProject
+ {57010B68-87C5-33AE-8633-D479ABB84636} = {57010B68-87C5-33AE-8633-D479ABB84636}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "laszip", "laszip.vcxproj", "{57010B68-87C5-33AE-8633-D479ABB84636}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
+ MinSizeRel|x64 = MinSizeRel|x64
+ MinSizeRel|x86 = MinSizeRel|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
+ RelWithDebInfo|x64 = RelWithDebInfo|x64
+ RelWithDebInfo|x86 = RelWithDebInfo|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.Debug|x64.ActiveCfg = Debug|x64
{6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.Debug|x64.Build.0 = Debug|x64
{6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.Debug|x86.ActiveCfg = Debug|Win32
{6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.Debug|x86.Build.0 = Debug|Win32
+ {6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.MinSizeRel|x64.ActiveCfg = Release|x64
+ {6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.MinSizeRel|x64.Build.0 = Release|x64
+ {6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.MinSizeRel|x86.ActiveCfg = Release|Win32
+ {6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.MinSizeRel|x86.Build.0 = Release|Win32
{6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.Release|x64.ActiveCfg = Release|x64
{6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.Release|x64.Build.0 = Release|x64
{6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.Release|x86.ActiveCfg = Release|Win32
{6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.Release|x86.Build.0 = Release|Win32
- {90F2F7C7-E01B-4BC5-9A67-088352B9BCE9}.Debug|x64.ActiveCfg = Debug|x64
- {90F2F7C7-E01B-4BC5-9A67-088352B9BCE9}.Debug|x64.Build.0 = Debug|x64
- {90F2F7C7-E01B-4BC5-9A67-088352B9BCE9}.Debug|x86.ActiveCfg = Debug|Win32
- {90F2F7C7-E01B-4BC5-9A67-088352B9BCE9}.Debug|x86.Build.0 = Debug|Win32
- {90F2F7C7-E01B-4BC5-9A67-088352B9BCE9}.Release|x64.ActiveCfg = Release|x64
- {90F2F7C7-E01B-4BC5-9A67-088352B9BCE9}.Release|x64.Build.0 = Release|x64
- {90F2F7C7-E01B-4BC5-9A67-088352B9BCE9}.Release|x86.ActiveCfg = Release|Win32
- {90F2F7C7-E01B-4BC5-9A67-088352B9BCE9}.Release|x86.Build.0 = Release|Win32
+ {6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.RelWithDebInfo|x64.ActiveCfg = Release|x64
+ {6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.RelWithDebInfo|x64.Build.0 = Release|x64
+ {6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
+ {6E98D902-2BE0-4AB8-97B8-1EBD66E95CA5}.RelWithDebInfo|x86.Build.0 = Release|Win32
+ {57010B68-87C5-33AE-8633-D479ABB84636}.Debug|x64.ActiveCfg = Debug|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.Debug|x64.Build.0 = Debug|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.Debug|x86.ActiveCfg = Debug|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.Debug|x86.Build.0 = Debug|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.MinSizeRel|x86.Build.0 = MinSizeRel|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.Release|x64.ActiveCfg = Release|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.Release|x64.Build.0 = Release|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.Release|x86.ActiveCfg = Release|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.Release|x86.Build.0 = Release|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
+ {57010B68-87C5-33AE-8633-D479ABB84636}.RelWithDebInfo|x86.Build.0 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/build/ComputeRasterizer.vcxproj b/build/ComputeRasterizer.vcxproj
index 0c81f1a..53fdbc0 100644
--- a/build/ComputeRasterizer.vcxproj
+++ b/build/ComputeRasterizer.vcxproj
@@ -25,19 +25,6 @@
10.0
-
- Application
- true
- v143
- Unicode
-
-
- Application
- false
- v143
- true
- Unicode
-
Application
true
@@ -140,14 +127,14 @@
NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)
true
stdcpplatest
- $(SolutionDir)..\include;$(SolutionDir)..\libs\glfw\include;$(SolutionDir)..\libs\glew\include;$(SolutionDir)..\libs\imgui\;$(SolutionDir)..\libs\implot\;$(SolutionDir)..\libs\imgui\backends;$(SolutionDir)..\libs\glm;$(SolutionDir)..\modules;$(SolutionDir)..\libs\json;$(SolutionDir)..\libs\openvr\headers;$(CUDA_PATH)\include;%(AdditionalIncludeDirectories)
+ $(SolutionDir)..\include;$(SolutionDir)..\libs\glfw\include;$(SolutionDir)..\libs\glew\include;$(SolutionDir)..\libs\imgui\;$(SolutionDir)..\libs\implot\;$(SolutionDir)..\libs\imgui\backends;$(SolutionDir)..\libs\glm;$(SolutionDir)..\modules;$(SolutionDir)..\libs\json;$(SolutionDir)..\libs\openvr\headers;$(CUDA_PATH)\include;$(SolutionDir)..\libs\laszip;%(AdditionalIncludeDirectories)
Console
true
true
true
- $(SolutionDir)..\libs\glfw\lib\msvc2017_x64\glfw3.lib;opengl32.lib;$(SolutionDir)..\libs\openvr\lib\win64\openvr_api.lib;$(CUDA_PATH)\lib\x64\cuda.lib;$(CUDA_PATH)\lib\x64\nvrtc.lib;%(AdditionalDependencies)
+ $(SolutionDir)..\libs\glfw\lib\msvc2017_x64\glfw3.lib;opengl32.lib;$(SolutionDir)..\libs\openvr\lib\win64\openvr_api.lib;$(CUDA_PATH)\lib\x64\cuda.lib;$(CUDA_PATH)\lib\x64\nvrtc.lib;$(SolutionDir)Release\laszip.lib;%(AdditionalDependencies)
copy /Y "$(SolutionDir)..\libs\openvr\openvr_api.dll" "$(OutDir)"
@@ -167,6 +154,7 @@
+
diff --git a/build/ComputeRasterizer.vcxproj.filters b/build/ComputeRasterizer.vcxproj.filters
index 6f620e9..1f90fb5 100644
--- a/build/ComputeRasterizer.vcxproj.filters
+++ b/build/ComputeRasterizer.vcxproj.filters
@@ -59,6 +59,9 @@
headers
+
+ source
+
diff --git a/build/Release/laszip.exp b/build/Release/laszip.exp
new file mode 100644
index 0000000..6e938e0
Binary files /dev/null and b/build/Release/laszip.exp differ
diff --git a/build/Release/laszip.lib b/build/Release/laszip.lib
new file mode 100644
index 0000000..f025ee6
Binary files /dev/null and b/build/Release/laszip.lib differ
diff --git a/build/laszip.vcxproj b/build/laszip.vcxproj
new file mode 100644
index 0000000..409c9e4
--- /dev/null
+++ b/build/laszip.vcxproj
@@ -0,0 +1,331 @@
+
+
+
+ x64
+
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+ MinSizeRel
+ x64
+
+
+ RelWithDebInfo
+ x64
+
+
+
+ {57010B68-87C5-33AE-8633-D479ABB84636}
+ 10.0
+ Win32Proj
+ x64
+ laszip
+ NoUpgrade
+
+
+
+ DynamicLibrary
+ MultiByte
+ v142
+
+
+ DynamicLibrary
+ MultiByte
+ v143
+
+
+ DynamicLibrary
+ MultiByte
+ v142
+
+
+ DynamicLibrary
+ MultiByte
+ v142
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.20506.1
+ $(SolutionDir)bin\$(Configuration)_$(Platform)
+ laszip.dir\Debug\
+ laszip
+ .dll
+ true
+ true
+ $(SolutionDir)bin\$(Configuration)_$(Platform)
+ $(SolutionDir)obj\$(Configuration)_$(Platform)
+ laszip
+ .dll
+ false
+ true
+ $(SolutionDir)..\build_laszip\MinSizeRel\
+ laszip.dir\MinSizeRel\
+ laszip
+ .dll
+ false
+ true
+ $(SolutionDir)..\build_laszip\RelWithDebInfo\
+ laszip.dir\RelWithDebInfo\
+ laszip
+ .dll
+ true
+ true
+
+
+
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+ $(IntDir)
+ EnableFastChecks
+ ProgramDatabase
+ Sync
+ Disabled
+ stdcpplatest
+ Disabled
+ NotUsing
+ MultiThreadedDebugDLL
+ true
+ false
+ WIN32;_WINDOWS;OPENCV_VERSION=;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNING;_SCL_SECURE_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;LASZIP_DLL_EXPORT=1;LASZIPDLL_EXPORTS;UNORDERED;HAVE_UNORDERED_MAP=1;CMAKE_INTDIR="Debug";laszip_EXPORTS;%(PreprocessorDefinitions)
+ $(IntDir)
+
+
+ WIN32;_DEBUG;_WINDOWS;OPENCV_VERSION=;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNING;_SCL_SECURE_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;LASZIP_DLL_EXPORT=1;LASZIPDLL_EXPORTS;UNORDERED;HAVE_UNORDERED_MAP=1;CMAKE_INTDIR=\"Debug\";laszip_EXPORTS;%(PreprocessorDefinitions)
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+
+
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+ $(ProjectDir)/$(IntDir)
+ %(Filename).h
+ %(Filename).tlb
+ %(Filename)_i.c
+ %(Filename)_p.c
+
+
+ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib
+ %(AdditionalLibraryDirectories)
+ %(AdditionalOptions) /machine:x64
+ true
+ %(IgnoreSpecificDefaultLibraries)
+ $(SolutionDir)Debug/laszip.lib
+ $(SolutionDir)Debug/laszip.pdb
+ Console
+
+
+ false
+
+
+
+
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+ $(IntDir)
+ Sync
+ AnySuitable
+ stdcpplatest
+ MaxSpeed
+ NotUsing
+ MultiThreadedDLL
+ true
+ false
+ WIN32;_WINDOWS;NDEBUG;OPENCV_VERSION=;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNING;_SCL_SECURE_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;LASZIP_DLL_EXPORT=1;LASZIPDLL_EXPORTS;UNORDERED;HAVE_UNORDERED_MAP=1;CMAKE_INTDIR="Release";laszip_EXPORTS;%(PreprocessorDefinitions)
+ $(IntDir)
+
+
+
+
+ WIN32;_WINDOWS;NDEBUG;OPENCV_VERSION=;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNING;_SCL_SECURE_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;LASZIP_DLL_EXPORT=1;LASZIPDLL_EXPORTS;UNORDERED;HAVE_UNORDERED_MAP=1;CMAKE_INTDIR=\"Release\";laszip_EXPORTS;%(PreprocessorDefinitions)
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+
+
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+ $(ProjectDir)/$(IntDir)
+ %(Filename).h
+ %(Filename).tlb
+ %(Filename)_i.c
+ %(Filename)_p.c
+
+
+ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib
+ %(AdditionalLibraryDirectories)
+ %(AdditionalOptions) /machine:x64
+ false
+ %(IgnoreSpecificDefaultLibraries)
+ $(SolutionDir)Release/laszip.lib
+ $(SolutionDir)Release/laszip.pdb
+ Console
+
+
+ false
+
+
+
+
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+ $(IntDir)
+ Sync
+ OnlyExplicitInline
+ stdcpplatest
+ MinSpace
+ NotUsing
+ MultiThreadedDLL
+ true
+ false
+ WIN32;_WINDOWS;NDEBUG;OPENCV_VERSION=;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNING;_SCL_SECURE_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;LASZIP_DLL_EXPORT=1;LASZIPDLL_EXPORTS;UNORDERED;HAVE_UNORDERED_MAP=1;CMAKE_INTDIR="MinSizeRel";laszip_EXPORTS;%(PreprocessorDefinitions)
+ $(IntDir)
+
+
+
+
+ WIN32;_WINDOWS;NDEBUG;OPENCV_VERSION=;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNING;_SCL_SECURE_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;LASZIP_DLL_EXPORT=1;LASZIPDLL_EXPORTS;UNORDERED;HAVE_UNORDERED_MAP=1;CMAKE_INTDIR=\"MinSizeRel\";laszip_EXPORTS;%(PreprocessorDefinitions)
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+
+
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+ $(ProjectDir)/$(IntDir)
+ %(Filename).h
+ %(Filename).tlb
+ %(Filename)_i.c
+ %(Filename)_p.c
+
+
+ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib
+ %(AdditionalLibraryDirectories)
+ %(AdditionalOptions) /machine:x64
+ false
+ %(IgnoreSpecificDefaultLibraries)
+ $(SolutionDir)MinSizeRel/laszip.lib
+ $(SolutionDir)MinSizeRel/laszip.pdb
+ Console
+
+
+ false
+
+
+
+
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+ $(IntDir)
+ ProgramDatabase
+ Sync
+ OnlyExplicitInline
+ stdcpplatest
+ MaxSpeed
+ NotUsing
+ MultiThreadedDLL
+ true
+ false
+ WIN32;_WINDOWS;NDEBUG;OPENCV_VERSION=;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNING;_SCL_SECURE_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;LASZIP_DLL_EXPORT=1;LASZIPDLL_EXPORTS;UNORDERED;HAVE_UNORDERED_MAP=1;CMAKE_INTDIR="RelWithDebInfo";laszip_EXPORTS;%(PreprocessorDefinitions)
+ $(IntDir)
+
+
+ WIN32;_WINDOWS;NDEBUG;OPENCV_VERSION=;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNING;_SCL_SECURE_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;LASZIP_DLL_EXPORT=1;LASZIPDLL_EXPORTS;UNORDERED;HAVE_UNORDERED_MAP=1;CMAKE_INTDIR=\"RelWithDebInfo\";laszip_EXPORTS;%(PreprocessorDefinitions)
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+
+
+ $(SolutionDir)..\libs\laszip\.\dll;$(SolutionDir)..\libs\laszip\.\src;$(SolutionDir)..\libs\laszip\..;%(AdditionalIncludeDirectories)
+ $(ProjectDir)/$(IntDir)
+ %(Filename).h
+ %(Filename).tlb
+ %(Filename)_i.c
+ %(Filename)_p.c
+
+
+ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib
+ %(AdditionalLibraryDirectories)
+ %(AdditionalOptions) /machine:x64
+ true
+ %(IgnoreSpecificDefaultLibraries)
+ $(SolutionDir)RelWithDebInfo/laszip.lib
+ $(SolutionDir)RelWithDebInfo/laszip.pdb
+ Console
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/laszip.vcxproj.filters b/build/laszip.vcxproj.filters
new file mode 100644
index 0000000..8de7ecc
--- /dev/null
+++ b/build/laszip.vcxproj.filters
@@ -0,0 +1,213 @@
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ {A525AD03-DF1D-3DA0-9B3D-ACFFDAEB7A07}
+
+
+ {A64DCB35-0E11-3333-9B3E-001D80484A38}
+
+
+
diff --git a/build/laszip.vcxproj.user b/build/laszip.vcxproj.user
new file mode 100644
index 0000000..0f14913
--- /dev/null
+++ b/build/laszip.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/imgui.ini b/imgui.ini
index 3b89977..8f4e391 100644
--- a/imgui.ini
+++ b/imgui.ini
@@ -9,7 +9,7 @@ Size=490,340
Collapsed=0
[Window][State]
-Pos=2080,10
+Pos=2180,10
Size=370,320
Collapsed=0
@@ -19,17 +19,17 @@ Size=236,313
Collapsed=0
[Window][Settings]
-Pos=2080,340
+Pos=2180,340
Size=370,370
Collapsed=0
[Window][Data Sets]
Pos=10,610
-Size=490,160
+Size=490,260
Collapsed=0
[Window][Debug Stuff]
-Pos=10,780
+Pos=10,880
Size=490,200
Collapsed=0
diff --git a/libs/laszip/CHANGES.txt b/libs/laszip/CHANGES.txt
new file mode 100644
index 0000000..29a8287
--- /dev/null
+++ b/libs/laszip/CHANGES.txt
@@ -0,0 +1,51 @@
+ 9 November 2019 -- upped version to 3.4 revision 3 for selective decompression extra bytes fix
+ 9 November 2019 -- fix for selective decompression of more than 16 extra bytes in new point types 6 or higher
+ 9 November 2019 -- moved UTF8toUTF16() function from laszip.hpp to mydefs.hpp and added new mydefs.cpp
+16 October 2019 -- unicode support added for Windows LASzip.dll via in new UTF8toUTF16() function
+11 August 2019 -- added CMake for DLL build and minor fixes to allow 64 bit Windows compile of LASzip.dll
+11 April 2019 -- increase AC_BUFFER_SIZE from 1024 to 4096 to lower chance of ultra-rare propagate_carry() overflow
+10 April 2019 -- fix potential memory leaks found by Connor Manning using valgrind
+31 March 2019 -- better license terms for core arithmetic coder thanks to Amir Said. upgrade to version 3.4 rev 0
+20 March 2019 -- upped to 3.3 r1 for checking consistent legacy and extended classification for new point types
+19 March 2019 -- bug fix when decompressing new point types: zero "legacy classification" if "classification" > 31
+ 7 March 2019 -- upped to 3.3 r0 because hobu was suggesting it for the next release
+21 February 2019 -- bug fix when writing 4,294,967,296 or more points uncompressed to LAS
+28 December 2018 -- fix for LASzip v4 decompression of WavePacket part of PRDF 9 and 10
+27 December 2018 -- upped to 3.2 r9 for bug fix in multi-channel NIR decompression
+7 November 2018 -- laszip DLL: upped to 3.2 r8 for identical legacy and extended flags check
+20 October 2018 -- fixed rare bug in LASinterval::merge_intervals()
+5 October 2018 -- laszip DLL: upped to 3.2 r6 for corrected 'is_empty' return value in laszip_inside_rectangle()
+28 September 2018 -- laszip DLL: tiny bug fix for writing extended classifications via DLL and updated examples
+17 September 2018 -- laszip DLL: no more support for deprecated LASattributes (aka "extra bytes") with dimensions 2 or 3
+30 July 2018 -- bug fix in selective decompression of "extra_bytes" for point types 6 and higher
+29 March 2018 -- add LASlib only fields to some structs to avoid future mix-up for "native" LAS 1.4
+9 February 2018 -- minor version increment to 3.2 as POINT14_v4 fixes context inefficiency bug
+28 December 2017 -- prepare to correct 'context switch' bug reported by Wanwannodao on some future date
+15 September 2017 -- new C++ istream / ostream interface completed and released
+22 August 2017 -- new C++ istream / ostream interface
+18 July 2017 -- bug fix for spatially-indexed reading from native compressed LAS 1.4 files
+28 May 2017 -- support for "selective decompression" of compressed LAS 1.4 points added into DLL API
+25 April 2017 -- enable "native LAS 1.4 extension" in LASzip DLL via 'request_native_extension'
+30 March 2017 -- alpha-release of "native LAS 1.4 extension" for LASzip compression
+11 January 2017 -- new DLL/API function 'laszip_set_chunk_size()' to change chunk size
+8 January 2017 -- changed file names from "laszip_dll.h" to "laszip_api.h" for hobu
+7 January 2017 -- set reserved field in LASzip VLR from 0xAABB to 0x0
+7 January 2017 -- make scan angle quantization in compatibility mode consistent with LASlib
+7 January 2017 -- compatibility mode *decompression* fix for points with waveforms
+23 September 2015 -- correct update of bounding box and counters from inventory on closing
+23 September 2015 -- correct update of bounding box and counters from inventory on closing
+22 September 2015 -- bug fix for not overwriting description of pre-existing "extra bytes"
+5 September 201 -- the "LAS 1.4 compatibility mode" now allows pre-existing "extra bytes"
+31 July 2015 -- new DLL (incompatible with prior version) supports "LAS 1.4 compatibility mode"
+4 April 2015 -- added DLL functions for creation and exploitation of spatial indexing LAX files
+3 April 2015 -- moved spatial indexing (LAX file generation) from LASlib to LASzip
+16 November 2014 -- improved detection & reporting of file truncation and/or LAZ bit-errors
+6 September 2014 -- removal of (unused) EntropyEncoder and EntropyDecoder purely virtual classes
+24 August 2014 -- when reading LAZ chunk table read is delayed until first read() or seek() is called
+18 September 2013 -- fixed small memory leak
+24 August 2013 -- fixed bug with explicit cast from LASitem:type to unsigned short and vice versa
+11 August 2013 -- laszipdllexample: new EXAMPLE_THREE shows export of geo-referenced LAZ
+8 August 2013 -- LASzip: new DLL calls laszip_get_coordinates() and laszip_set_coordinates()
+6 August 2013 -- LASzip: new DLL calls laszip_auto_offset() and laszip_check_for_integer_overflow()
+1 August 2013 -- LASzip: new DLL calls unload_dll() and get_point_count() for FUSION integration
+29 July 2013 -- LASzip: created an easy-to-use DLL interface for LASzip integration
diff --git a/libs/laszip/CMakeLists.txt b/libs/laszip/CMakeLists.txt
new file mode 100644
index 0000000..0f37668
--- /dev/null
+++ b/libs/laszip/CMakeLists.txt
@@ -0,0 +1,56 @@
+cmake_minimum_required(VERSION 3.16)
+set(CMAKE_SUPPRESS_REGENERATION true)
+
+project(LASzip LANGUAGES CXX)
+
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+
+
+set(ROOT_DIR "${PROJECT_SOURCE_DIR}")
+
+# the next line is the ONLY place in the entire laszip system where
+# the version info is hard-coded
+set(LASZIP_API_VERSION_STRING "3.4.1" CACHE STRING "LASzip version" FORCE)
+set(LASZIP_API_VERSION ${LASZIP_API_VERSION_MAJOR}.${LASZIP_API_VERSION_MINOR}.${LASZIP_API_VERSION_PATCH})
+
+file(GLOB source_files
+ "src/*.h"
+ "src/*.hpp"
+ "src/*.cpp"
+ "dll/*.c"
+ "dll/*.h"
+)
+
+list(FILTER source_files EXCLUDE REGEX ".*src/demzip_dll.cpp$")
+list(FILTER source_files EXCLUDE REGEX ".*dll/demzip_api.c$")
+list(FILTER source_files EXCLUDE REGEX ".*dll/demzip_api.h$")
+list(FILTER source_files EXCLUDE REGEX ".*dll/laszip_api.h$")
+list(FILTER source_files EXCLUDE REGEX ".*dll/laszip_api.c$")
+
+#message("${source_files}")
+
+
+add_library(laszip SHARED ${source_files})
+target_include_directories(laszip PRIVATE
+ ./dll
+ ./src
+ ../
+)
+
+set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
+
+add_compile_definitions(OPENCV_VERSION=${OpenCV_VERSION})
+add_compile_definitions(_CRT_SECURE_NO_DEPRECATE)
+add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
+add_compile_definitions(_CRT_NONSTDC_NO_WARNING)
+add_compile_definitions(_SCL_SECURE_NO_WARNINGS)
+add_compile_definitions(NOMINMAX)
+add_compile_definitions(WIN32_LEAN_AND_MEAN)
+add_compile_definitions(LASZIP_DLL_EXPORT=1)
+add_compile_definitions(LASZIPDLL_EXPORTS)
+add_compile_definitions(UNORDERED)
+add_compile_definitions(HAVE_UNORDERED_MAP=1)
\ No newline at end of file
diff --git a/libs/laszip/COPYING b/libs/laszip/COPYING
new file mode 100644
index 0000000..0c226ad
--- /dev/null
+++ b/libs/laszip/COPYING
@@ -0,0 +1,511 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ , 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/libs/laszip/README.txt b/libs/laszip/README.txt
new file mode 100644
index 0000000..ae3340c
--- /dev/null
+++ b/libs/laszip/README.txt
@@ -0,0 +1,34 @@
+--------------------------------------------------------------------------
+
+ LASzip LiDAR compression DLL
+
+--------------------------------------------------------------------------
+
+ The LASzip LiDAR compressor packaged as a simple stand-alone DLL for
+ easy inclusion of compression and decompression functionality into
+ other software. It compresses LAS files into much more compact LAZ
+ files and vice versa. The resulting files are around 7 - 20 percent
+ of their original size. Follow the code in laszipdllexample.cpp for
+ a simple example how to use the DLL.
+
+ To get LASzip just download the LAStools distribution which contains
+ the LASlib as well as the LASzip sources together with the binaries
+ of the popular LAStools software and some small example LAZ files.
+
+ http://laszip.org/
+ http://lastools.org/
+ http://rapidlasso.com/LAStools/
+
+--------------------------------------------------------------------------
+
+ PROGRAMMERS:
+
+ martin@rapidlasso.com
+
+--------------------------------------------------------------------------
+
+ COPYRIGHT:
+
+ (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality
+
+--------------------------------------------------------------------------
diff --git a/libs/laszip/dll/laszip_api.c b/libs/laszip/dll/laszip_api.c
new file mode 100644
index 0000000..8c0776f
--- /dev/null
+++ b/libs/laszip/dll/laszip_api.c
@@ -0,0 +1,1206 @@
+/*
+===============================================================================
+
+ FILE: laszip_api.c
+
+ CONTENTS:
+
+ A simple set of linkable function signatures for the DLL of LASzip
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ see header file
+
+===============================================================================
+*/
+
+#include
+
+// DLL function definitions
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*---------------------------------------------------------------------------*/
+/*---------------- DLL functions to manage the LASzip DLL -------------------*/
+/*---------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_get_version_def)
+(
+ laszip_U8* version_major
+ , laszip_U8* version_minor
+ , laszip_U16* version_revision
+ , laszip_U32* version_build
+);
+laszip_get_version_def laszip_get_version_ptr = 0;
+LASZIP_API laszip_I32
+laszip_get_version
+(
+ laszip_U8* version_major
+ , laszip_U8* version_minor
+ , laszip_U16* version_revision
+ , laszip_U32* version_build
+)
+{
+ if (laszip_get_version_ptr)
+ {
+ return (*laszip_get_version_ptr)(version_major, version_minor, version_revision, version_build);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_create_def)
+(
+ laszip_POINTER* pointer
+);
+laszip_create_def laszip_create_ptr = 0;
+LASZIP_API laszip_I32
+laszip_create
+(
+ laszip_POINTER* pointer
+)
+{
+ if (laszip_create_ptr)
+ {
+ return (*laszip_create_ptr)(pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_clean_def)
+(
+ laszip_POINTER pointer
+);
+laszip_clean_def laszip_clean_ptr = 0;
+LASZIP_API laszip_I32
+laszip_clean
+(
+ laszip_POINTER pointer
+)
+{
+ if (laszip_clean_ptr)
+ {
+ return (*laszip_clean_ptr)(pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_get_error_def)
+(
+ laszip_POINTER pointer
+ , laszip_CHAR** error
+);
+laszip_get_error_def laszip_get_error_ptr = 0;
+LASZIP_API laszip_I32
+laszip_get_error
+(
+ laszip_POINTER pointer
+ , laszip_CHAR** error
+)
+{
+ if (laszip_get_error_ptr)
+ {
+ return (*laszip_get_error_ptr)(pointer, error);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_get_warning_def)
+(
+ laszip_POINTER pointer
+ , laszip_CHAR** warning
+);
+laszip_get_warning_def laszip_get_warning_ptr = 0;
+LASZIP_API laszip_I32
+laszip_get_warning
+(
+ laszip_POINTER pointer
+ , laszip_CHAR** warning
+)
+{
+ if (laszip_get_warning_ptr)
+ {
+ return (*laszip_get_warning_ptr)(pointer, warning);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_destroy_def)
+(
+ laszip_POINTER pointer
+);
+laszip_destroy_def laszip_destroy_ptr = 0;
+LASZIP_API laszip_I32
+laszip_destroy
+(
+ laszip_POINTER pointer
+)
+{
+ if (laszip_destroy_ptr)
+ {
+ return (*laszip_destroy_ptr)(pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+/*---------- DLL functions to write and read LAS and LAZ files --------------*/
+/*---------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_get_header_pointer_def)
+(
+ laszip_POINTER pointer
+ , laszip_header_struct** header_pointer
+);
+laszip_get_header_pointer_def laszip_get_header_pointer_ptr = 0;
+LASZIP_API laszip_I32
+laszip_get_header_pointer
+(
+ laszip_POINTER pointer
+ , laszip_header_struct** header_pointer
+)
+{
+ if (laszip_get_header_pointer_ptr)
+ {
+ return (*laszip_get_header_pointer_ptr)(pointer, header_pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_get_point_pointer_def)
+(
+ laszip_POINTER pointer
+ , laszip_point_struct** point_pointer
+);
+laszip_get_point_pointer_def laszip_get_point_pointer_ptr = 0;
+LASZIP_API laszip_I32
+laszip_get_point_pointer
+(
+ laszip_POINTER pointer
+ , laszip_point_struct** point_pointer
+)
+{
+ if (laszip_get_point_pointer_ptr)
+ {
+ return (*laszip_get_point_pointer_ptr)(pointer, point_pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_get_point_count_def)
+(
+ laszip_POINTER pointer
+ , laszip_I64* point_count
+);
+laszip_get_point_count_def laszip_get_point_count_ptr = 0;
+LASZIP_API laszip_I32
+laszip_get_point_count
+(
+ laszip_POINTER pointer
+ , laszip_I64* point_count
+)
+{
+ if (laszip_get_point_count_ptr)
+ {
+ return (*laszip_get_point_count_ptr)(pointer, point_count);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_set_header_def)
+(
+ laszip_POINTER pointer
+ , const laszip_header_struct* header
+);
+laszip_set_header_def laszip_set_header_ptr = 0;
+LASZIP_API laszip_I32
+laszip_set_header
+(
+ laszip_POINTER pointer
+ , const laszip_header_struct* header
+)
+{
+ if (laszip_set_header_ptr)
+ {
+ return (*laszip_set_header_ptr)(pointer, header);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_set_point_type_and_size_def)
+(
+ laszip_POINTER pointer
+ , laszip_U8 point_type
+ , laszip_U16 point_size
+);
+laszip_set_point_type_and_size_def laszip_set_point_type_and_size_ptr = 0;
+LASZIP_API laszip_I32
+laszip_set_point_type_and_size
+(
+ laszip_POINTER pointer
+ , laszip_U8 point_type
+ , laszip_U16 point_size
+)
+{
+ if (laszip_set_point_type_and_size_ptr)
+ {
+ return (*laszip_set_point_type_and_size_ptr)(pointer, point_type, point_size);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_check_for_integer_overflow_def)
+(
+ laszip_POINTER pointer
+);
+laszip_check_for_integer_overflow_def laszip_check_for_integer_overflow_ptr = 0;
+LASZIP_API laszip_I32
+laszip_check_for_integer_overflow
+(
+ laszip_POINTER pointer
+)
+{
+ if (laszip_check_for_integer_overflow_ptr)
+ {
+ return (*laszip_check_for_integer_overflow_ptr)(pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_auto_offset_def)
+(
+ laszip_POINTER pointer
+);
+laszip_auto_offset_def laszip_auto_offset_ptr = 0;
+LASZIP_API laszip_I32
+laszip_auto_offset
+(
+ laszip_POINTER pointer
+)
+{
+ if (laszip_auto_offset_ptr)
+ {
+ return (*laszip_auto_offset_ptr)(pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_set_point_def)
+(
+ laszip_POINTER pointer
+ , const laszip_point_struct* point
+);
+laszip_set_point_def laszip_set_point_ptr = 0;
+LASZIP_API laszip_I32
+laszip_set_point
+(
+ laszip_POINTER pointer
+ , const laszip_point_struct* point
+)
+{
+ if (laszip_set_point_ptr)
+ {
+ return (*laszip_set_point_ptr)(pointer, point);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_set_coordinates_def)
+(
+ laszip_POINTER pointer
+ , const laszip_F64* coordinates
+);
+laszip_set_coordinates_def laszip_set_coordinates_ptr = 0;
+LASZIP_API laszip_I32
+laszip_set_coordinates
+(
+ laszip_POINTER pointer
+ , const laszip_F64* coordinates
+)
+{
+ if (laszip_set_coordinates_ptr)
+ {
+ return (*laszip_set_coordinates_ptr)(pointer, coordinates);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_get_coordinates_def)
+(
+ laszip_POINTER pointer
+ , laszip_F64* coordinates
+);
+laszip_get_coordinates_def laszip_get_coordinates_ptr = 0;
+LASZIP_API laszip_I32
+laszip_get_coordinates
+(
+ laszip_POINTER pointer
+ , laszip_F64* coordinates
+)
+{
+ if (laszip_get_coordinates_ptr)
+ {
+ return (*laszip_get_coordinates_ptr)(pointer, coordinates);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_set_geokeys_def)
+(
+ laszip_POINTER pointer
+ , laszip_U32 number
+ , const laszip_geokey_struct* key_entries
+);
+laszip_set_geokeys_def laszip_set_geokeys_ptr = 0;
+LASZIP_API laszip_I32
+laszip_set_geokeys
+(
+ laszip_POINTER pointer
+ , laszip_U32 number
+ , const laszip_geokey_struct* key_entries
+)
+{
+ if (laszip_set_geokeys_ptr)
+ {
+ return (*laszip_set_geokeys_ptr)(pointer, number, key_entries);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_set_geodouble_params_def)
+(
+ laszip_POINTER pointer
+ , laszip_U32 number
+ , const laszip_F64* geodouble_params
+);
+laszip_set_geodouble_params_def laszip_set_geodouble_params_ptr = 0;
+LASZIP_API laszip_I32
+laszip_set_geodouble_params
+(
+ laszip_POINTER pointer
+ , laszip_U32 number
+ , const laszip_F64* geodouble_params
+)
+{
+ if (laszip_set_geodouble_params_ptr)
+ {
+ return (*laszip_set_geodouble_params_ptr)(pointer, number, geodouble_params);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_set_geoascii_params_def)
+(
+ laszip_POINTER pointer
+ , laszip_U32 number
+ , const laszip_CHAR* geoascii_params
+);
+laszip_set_geoascii_params_def laszip_set_geoascii_params_ptr = 0;
+LASZIP_API laszip_I32
+laszip_set_geoascii_params
+(
+ laszip_POINTER pointer
+ , laszip_U32 number
+ , const laszip_CHAR* geoascii_params
+)
+{
+ if (laszip_set_geoascii_params_ptr)
+ {
+ return (*laszip_set_geoascii_params_ptr)(pointer, number, geoascii_params);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_add_attribute_def)
+(
+ laszip_POINTER pointer
+ , laszip_U32 type
+ , const laszip_CHAR* name
+ , const laszip_CHAR* description
+ , laszip_F64 scale
+ , laszip_F64 offset
+);
+laszip_add_attribute_def laszip_add_attribute_ptr = 0;
+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
+)
+{
+ if (laszip_add_attribute_ptr)
+ {
+ return (*laszip_add_attribute_ptr)(pointer, type, name, description, scale, offset);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_add_vlr_def)
+(
+ 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
+);
+laszip_add_vlr_def laszip_add_vlr_ptr = 0;
+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
+)
+{
+ if (laszip_add_vlr_ptr)
+ {
+ return (*laszip_add_vlr_ptr)(pointer, user_id, record_id, record_length_after_header, description, data);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_remove_vlr_def)
+(
+ laszip_POINTER pointer
+ , const laszip_CHAR* user_id
+ , laszip_U16 record_id
+);
+laszip_remove_vlr_def laszip_remove_vlr_ptr = 0;
+LASZIP_API laszip_I32
+laszip_remove_vlr
+(
+ laszip_POINTER pointer
+ , const laszip_CHAR* user_id
+ , laszip_U16 record_id
+)
+{
+ if (laszip_remove_vlr_ptr)
+ {
+ return (*laszip_remove_vlr_ptr)(pointer, user_id, record_id);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_create_spatial_index_def)
+(
+ laszip_POINTER pointer
+ , const laszip_BOOL create
+ , const laszip_BOOL append
+);
+laszip_create_spatial_index_def laszip_create_spatial_index_ptr = 0;
+LASZIP_API laszip_I32
+laszip_create_spatial_index
+(
+ laszip_POINTER pointer
+ , const laszip_BOOL create
+ , const laszip_BOOL append
+)
+{
+ if (laszip_create_spatial_index_ptr)
+ {
+ return (*laszip_create_spatial_index_ptr)(pointer, create, append);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_preserve_generating_software_def)
+(
+ laszip_POINTER pointer
+ , const laszip_BOOL preserve
+);
+laszip_preserve_generating_software_def laszip_preserve_generating_software_ptr = 0;
+LASZIP_API laszip_I32
+laszip_preserve_generating_software
+(
+ laszip_POINTER pointer
+ , const laszip_BOOL preserve
+)
+{
+ if (laszip_preserve_generating_software_ptr)
+ {
+ return (*laszip_preserve_generating_software_ptr)(pointer, preserve);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_request_native_extension_def)
+(
+ laszip_POINTER pointer
+ , const laszip_BOOL request
+);
+laszip_request_native_extension_def laszip_request_native_extension_ptr = 0;
+LASZIP_API laszip_I32
+laszip_request_native_extension
+(
+ laszip_POINTER pointer
+ , const laszip_BOOL request
+)
+{
+ if (laszip_request_native_extension_ptr)
+ {
+ return (*laszip_request_native_extension_ptr)(pointer, request);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_request_compatibility_mode_def)
+(
+ laszip_POINTER pointer
+ , const laszip_BOOL request
+);
+laszip_request_compatibility_mode_def laszip_request_compatibility_mode_ptr = 0;
+LASZIP_API laszip_I32
+laszip_request_compatibility_mode
+(
+ laszip_POINTER pointer
+ , const laszip_BOOL request
+)
+{
+ if (laszip_request_compatibility_mode_ptr)
+ {
+ return (*laszip_request_compatibility_mode_ptr)(pointer, request);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_set_chunk_size_def)
+(
+ laszip_POINTER pointer
+ , const laszip_U32 chunk_size
+);
+laszip_set_chunk_size_def laszip_set_chunk_size_ptr = 0;
+LASZIP_API laszip_I32
+laszip_set_chunk_size
+(
+ laszip_POINTER pointer
+ , const laszip_U32 chunk_size
+)
+{
+ if (laszip_set_chunk_size_ptr)
+ {
+ return (*laszip_set_chunk_size_ptr)(pointer, chunk_size);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_open_writer_def)
+(
+ laszip_POINTER pointer
+ , const laszip_CHAR* file_name
+ , laszip_BOOL compress
+);
+laszip_open_writer_def laszip_open_writer_ptr = 0;
+LASZIP_API laszip_I32
+laszip_open_writer
+(
+ laszip_POINTER pointer
+ , const laszip_CHAR* file_name
+ , laszip_BOOL compress
+)
+{
+ if (laszip_open_writer_ptr)
+ {
+ return (*laszip_open_writer_ptr)(pointer, file_name, compress);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_write_point_def)
+(
+ laszip_POINTER pointer
+);
+laszip_write_point_def laszip_write_point_ptr = 0;
+LASZIP_API laszip_I32
+laszip_write_point
+(
+ laszip_POINTER pointer
+)
+{
+ if (laszip_write_point_ptr)
+ {
+ return (*laszip_write_point_ptr)(pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_write_indexed_point_def)
+(
+ laszip_POINTER pointer
+);
+laszip_write_indexed_point_def laszip_write_indexed_point_ptr = 0;
+LASZIP_API laszip_I32
+laszip_write_indexed_point
+(
+ laszip_POINTER pointer
+)
+{
+ if (laszip_write_indexed_point_ptr)
+ {
+ return (*laszip_write_indexed_point_ptr)(pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_update_inventory_def)
+(
+ laszip_POINTER pointer
+);
+laszip_update_inventory_def laszip_update_inventory_ptr = 0;
+LASZIP_API laszip_I32
+laszip_update_inventory
+(
+ laszip_POINTER pointer
+)
+{
+ if (laszip_update_inventory_ptr)
+ {
+ return (*laszip_update_inventory_ptr)(pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_close_writer_def)
+(
+ laszip_POINTER pointer
+);
+laszip_close_writer_def laszip_close_writer_ptr = 0;
+LASZIP_API laszip_I32
+laszip_close_writer
+(
+ laszip_POINTER pointer
+)
+{
+ if (laszip_close_writer_ptr)
+ {
+ return (*laszip_close_writer_ptr)(pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_exploit_spatial_index_def)
+(
+ laszip_POINTER pointer
+ , const laszip_BOOL exploit
+);
+laszip_exploit_spatial_index_def laszip_exploit_spatial_index_ptr = 0;
+LASZIP_API laszip_I32
+laszip_exploit_spatial_index
+(
+ laszip_POINTER pointer
+ , const laszip_BOOL exploit
+)
+{
+ if (laszip_exploit_spatial_index_ptr)
+ {
+ return (*laszip_exploit_spatial_index_ptr)(pointer, exploit);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_decompress_selective_def)
+(
+ laszip_POINTER pointer
+ , const laszip_U32 decompress_selective
+);
+laszip_decompress_selective_def laszip_decompress_selective_ptr = 0;
+LASZIP_API laszip_I32
+laszip_decompress_selective
+(
+ laszip_POINTER pointer
+ , const laszip_U32 decompress_selective
+)
+{
+ if (laszip_decompress_selective_ptr)
+ {
+ return (*laszip_decompress_selective_ptr)(pointer, decompress_selective);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_open_reader_def)
+(
+ laszip_POINTER pointer
+ , const laszip_CHAR* file_name
+ , laszip_BOOL* is_compressed
+);
+laszip_open_reader_def laszip_open_reader_ptr = 0;
+LASZIP_API laszip_I32
+laszip_open_reader
+(
+ laszip_POINTER pointer
+ , const laszip_CHAR* file_name
+ , laszip_BOOL* is_compressed
+)
+{
+ if (laszip_open_reader_ptr)
+ {
+ return (*laszip_open_reader_ptr)(pointer, file_name, is_compressed);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_has_spatial_index_def)
+(
+ laszip_POINTER pointer
+ , laszip_BOOL* is_compressed
+ , laszip_BOOL* is_appended
+);
+laszip_has_spatial_index_def laszip_has_spatial_index_ptr = 0;
+LASZIP_API laszip_I32
+laszip_has_spatial_index
+(
+ laszip_POINTER pointer
+ , laszip_BOOL* is_compressed
+ , laszip_BOOL* is_appended
+)
+{
+ if (laszip_has_spatial_index_ptr)
+ {
+ return (*laszip_has_spatial_index_ptr)(pointer, is_compressed, is_appended);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_inside_rectangle_def)
+(
+ 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
+);
+laszip_inside_rectangle_def laszip_inside_rectangle_ptr = 0;
+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
+)
+{
+ if (laszip_inside_rectangle_ptr)
+ {
+ return (*laszip_inside_rectangle_ptr)(pointer, r_min_x, r_min_y, r_max_x, r_max_y, is_empty);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_seek_point_def)
+(
+ laszip_POINTER pointer
+ , laszip_I64 index
+);
+laszip_seek_point_def laszip_seek_point_ptr = 0;
+LASZIP_API laszip_I32
+laszip_seek_point(
+ laszip_POINTER pointer
+ , laszip_I64 index
+)
+{
+ if (laszip_seek_point_ptr)
+ {
+ return (*laszip_seek_point_ptr)(pointer, index);
+ }
+ return 1;
+}
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_read_point_def)
+(
+ laszip_POINTER pointer
+);
+laszip_read_point_def laszip_read_point_ptr = 0;
+LASZIP_API laszip_I32
+laszip_read_point(
+ laszip_POINTER pointer
+)
+{
+ if (laszip_read_point_ptr)
+ {
+ return (*laszip_read_point_ptr)(pointer);
+ }
+ return 1;
+}
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_read_inside_point_def)
+(
+ laszip_POINTER pointer
+ , laszip_BOOL* is_done
+);
+laszip_read_inside_point_def laszip_read_inside_point_ptr = 0;
+LASZIP_API laszip_I32
+laszip_read_inside_point(
+ laszip_POINTER pointer
+ , laszip_BOOL* is_done
+)
+{
+ if (laszip_read_inside_point_ptr)
+ {
+ return (*laszip_read_inside_point_ptr)(pointer, is_done);
+ }
+ return 1;
+}
+
+/*---------------------------------------------------------------------------*/
+typedef laszip_I32 (*laszip_close_reader_def)
+(
+ laszip_POINTER pointer
+);
+laszip_close_reader_def laszip_close_reader_ptr = 0;
+LASZIP_API laszip_I32
+laszip_close_reader
+(
+ laszip_POINTER pointer
+)
+{
+ if (laszip_close_reader_ptr)
+ {
+ return (*laszip_close_reader_ptr)(pointer);
+ }
+ return 1;
+};
+
+/*---------------------------------------------------------------------------*/
+/*---------------- DLL functions to load and unload LASzip ------------------*/
+/*---------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------*/
+#ifdef _WIN32
+ #include
+#define FreeLibraryZeroMeansFail 1
+#else
+ #include
+ typedef void* HINSTANCE;
+#ifndef NULL
+#define NULL 0
+#endif
+#define LoadLibrary dlopen
+#define GetProcAddress dlsym
+#define FreeLibrary dlclose
+#define FreeLibraryZeroMeansFail 0
+#define TEXT
+#endif
+static HINSTANCE laszip_HINSTANCE = NULL;
+laszip_I32 laszip_load_dll()
+{
+ // Assure DLL not yet loaded
+ if (laszip_HINSTANCE != NULL) {
+ return 1;
+ }
+ // Load DLL file
+#ifdef _WIN32
+#ifdef _WIN64
+ laszip_HINSTANCE = LoadLibrary(TEXT("LASzip64.dll"));
+#else
+ laszip_HINSTANCE = LoadLibrary(TEXT("LASzip.dll"));
+#endif // _WIN64
+#elif __APPLE__
+ laszip_HINSTANCE = LoadLibrary("liblaszip.dylib", RTLD_NOW);
+#else
+ laszip_HINSTANCE = LoadLibrary("liblaszip.so", RTLD_NOW);
+#endif
+ if (laszip_HINSTANCE == NULL) {
+ return 1;
+ }
+ // Get function pointers
+ laszip_get_version_ptr = (laszip_get_version_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_version");
+ if (laszip_get_version_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_create_ptr = (laszip_create_def)GetProcAddress(laszip_HINSTANCE, "laszip_create");
+ if (laszip_create_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_clean_ptr = (laszip_clean_def)GetProcAddress(laszip_HINSTANCE, "laszip_clean");
+ if (laszip_clean_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_get_error_ptr = (laszip_get_error_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_error");
+ if (laszip_get_error_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_get_warning_ptr = (laszip_get_warning_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_warning");
+ if (laszip_get_warning_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_destroy_ptr = (laszip_destroy_def)GetProcAddress(laszip_HINSTANCE, "laszip_destroy");
+ if (laszip_destroy_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_get_header_pointer_ptr = (laszip_get_header_pointer_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_header_pointer");
+ if (laszip_get_header_pointer_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_get_point_pointer_ptr = (laszip_get_point_pointer_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_point_pointer");
+ if (laszip_get_point_pointer_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_get_point_count_ptr = (laszip_get_point_count_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_point_count");
+ if (laszip_get_point_count_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_set_header_ptr = (laszip_set_header_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_header");
+ if (laszip_set_header_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_set_point_type_and_size_ptr = (laszip_set_point_type_and_size_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_point_type_and_size");
+ if (laszip_set_point_type_and_size_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_check_for_integer_overflow_ptr = (laszip_check_for_integer_overflow_def)GetProcAddress(laszip_HINSTANCE, "laszip_check_for_integer_overflow");
+ if (laszip_check_for_integer_overflow_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_auto_offset_ptr = (laszip_auto_offset_def)GetProcAddress(laszip_HINSTANCE, "laszip_auto_offset");
+ if (laszip_auto_offset_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_set_point_ptr = (laszip_set_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_point");
+ if (laszip_set_point_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_set_coordinates_ptr = (laszip_set_coordinates_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_coordinates");
+ if (laszip_set_coordinates_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_get_coordinates_ptr = (laszip_get_coordinates_def)GetProcAddress(laszip_HINSTANCE, "laszip_get_coordinates");
+ if (laszip_get_coordinates_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_set_geokeys_ptr = (laszip_set_geokeys_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_geokeys");
+ if (laszip_set_geokeys_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_set_geodouble_params_ptr = (laszip_set_geodouble_params_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_geodouble_params");
+ if (laszip_set_geodouble_params_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_set_geoascii_params_ptr = (laszip_set_geoascii_params_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_geoascii_params");
+ if (laszip_set_geoascii_params_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_add_attribute_ptr = (laszip_add_attribute_def)GetProcAddress(laszip_HINSTANCE, "laszip_add_attribute");
+ if (laszip_add_attribute_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_add_vlr_ptr = (laszip_add_vlr_def)GetProcAddress(laszip_HINSTANCE, "laszip_add_vlr");
+ if (laszip_add_vlr_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_remove_vlr_ptr = (laszip_remove_vlr_def)GetProcAddress(laszip_HINSTANCE, "laszip_remove_vlr");
+ if (laszip_remove_vlr_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_create_spatial_index_ptr = (laszip_create_spatial_index_def)GetProcAddress(laszip_HINSTANCE, "laszip_create_spatial_index");
+ if (laszip_create_spatial_index_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_preserve_generating_software_ptr = (laszip_preserve_generating_software_def)GetProcAddress(laszip_HINSTANCE, "laszip_preserve_generating_software");
+ if (laszip_preserve_generating_software_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_request_native_extension_ptr = (laszip_request_native_extension_def)GetProcAddress(laszip_HINSTANCE, "laszip_request_native_extension");
+ if (laszip_request_native_extension_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_request_compatibility_mode_ptr = (laszip_request_compatibility_mode_def)GetProcAddress(laszip_HINSTANCE, "laszip_request_compatibility_mode");
+ if (laszip_request_compatibility_mode_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_set_chunk_size_ptr = (laszip_set_chunk_size_def)GetProcAddress(laszip_HINSTANCE, "laszip_set_chunk_size");
+ if (laszip_set_chunk_size_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_open_writer_ptr = (laszip_open_writer_def)GetProcAddress(laszip_HINSTANCE, "laszip_open_writer");
+ if (laszip_open_writer_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_write_point_ptr = (laszip_write_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_write_point");
+ if (laszip_write_point_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_write_indexed_point_ptr = (laszip_write_indexed_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_write_indexed_point");
+ if (laszip_write_indexed_point_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_update_inventory_ptr = (laszip_update_inventory_def)GetProcAddress(laszip_HINSTANCE, "laszip_update_inventory");
+ if (laszip_update_inventory_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_close_writer_ptr = (laszip_close_writer_def)GetProcAddress(laszip_HINSTANCE, "laszip_close_writer");
+ if (laszip_close_writer_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_exploit_spatial_index_ptr = (laszip_exploit_spatial_index_def)GetProcAddress(laszip_HINSTANCE, "laszip_exploit_spatial_index");
+ if (laszip_exploit_spatial_index_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_decompress_selective_ptr = (laszip_decompress_selective_def)GetProcAddress(laszip_HINSTANCE, "laszip_decompress_selective");
+ if (laszip_decompress_selective_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_open_reader_ptr = (laszip_open_reader_def)GetProcAddress(laszip_HINSTANCE, "laszip_open_reader");
+ if (laszip_open_reader_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_has_spatial_index_ptr = (laszip_has_spatial_index_def)GetProcAddress(laszip_HINSTANCE, "laszip_has_spatial_index");
+ if (laszip_has_spatial_index_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_inside_rectangle_ptr = (laszip_inside_rectangle_def)GetProcAddress(laszip_HINSTANCE, "laszip_inside_rectangle");
+ if (laszip_inside_rectangle_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_seek_point_ptr = (laszip_seek_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_seek_point");
+ if (laszip_seek_point_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_read_point_ptr = (laszip_read_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_read_point");
+ if (laszip_read_point_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_read_inside_point_ptr = (laszip_read_inside_point_def)GetProcAddress(laszip_HINSTANCE, "laszip_read_inside_point");
+ if (laszip_read_inside_point_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ laszip_close_reader_ptr = (laszip_close_reader_def)GetProcAddress(laszip_HINSTANCE, "laszip_close_reader");
+ if (laszip_close_reader_ptr == NULL) {
+ FreeLibrary(laszip_HINSTANCE);
+ return 1;
+ }
+ return 0;
+};
+
+/*---------------------------------------------------------------------------*/
+laszip_I32 laszip_unload_dll()
+{
+ if (laszip_HINSTANCE == NULL) {
+ return 1;
+ }
+ if (FreeLibraryZeroMeansFail)
+ {
+ if (!FreeLibrary(laszip_HINSTANCE)) {
+ return 1;
+ }
+ }
+ else
+ {
+ if (FreeLibrary(laszip_HINSTANCE)) {
+ return 1;
+ }
+ }
+ laszip_HINSTANCE = NULL;
+ return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/libs/laszip/example/5points_14.las b/libs/laszip/example/5points_14.las
new file mode 100644
index 0000000..ea67ccc
Binary files /dev/null and b/libs/laszip/example/5points_14.las differ
diff --git a/libs/laszip/example/Makefile b/libs/laszip/example/Makefile
new file mode 100644
index 0000000..da48b29
--- /dev/null
+++ b/libs/laszip/example/Makefile
@@ -0,0 +1,9 @@
+# makefile for cleanup of LAStools\LASzip\example
+#
+
+clean:
+ rm -rf *.o
+
+clobber:
+ rm -rf *.o
+ rm -rf *~
diff --git a/libs/laszip/example/laszipdllexample.cpp b/libs/laszip/example/laszipdllexample.cpp
new file mode 100644
index 0000000..59dc595
--- /dev/null
+++ b/libs/laszip/example/laszipdllexample.cpp
@@ -0,0 +1,4205 @@
+/*
+===============================================================================
+
+ FILE: laszipdllexample.cpp
+
+ CONTENTS:
+
+ This source code implements several different easy-to-follow examples on
+ how to use the LASzip DLL. The first and the second examples implement a
+ small compression and decompression utilitity. The third example shows
+ how to use the DLL to export points to a proper geo-referenced LAZ file.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2018, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the LICENSE.txt file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 7 September 2018 -- introduced the LASCopyString macro to replace _strdup
+ 28 May 2017 -- 14th example reads compressed LAS 1.4 with "selective decompression"
+ 25 April 2017 -- 13th example writes LAS 1.4 using new "native LAS 1.4 extension"
+ 11 January 2017 -- 12th example changes the default chunk size from 50000 to 5000
+ 8 January 2017 -- changed from "laszip_dll.h" to "laszip_api.h" because of hobu
+ 23 September 2015 -- 11th example writes without a-priori bounding box or counters
+ 22 September 2015 -- 10th upconverts to LAS 1.4 with pre-existing "extra bytes"
+ 5 September 2015 -- eighth and nineth example show pre-existing "extra bytes"
+ 19 July 2015 -- sixth and seventh example show LAS 1.4 compatibility mode
+ 2 April 2015 -- fourth and fifth example with integrated spatially indexing
+ 11 August 2013 -- added third example for exporting geo-referenced points
+ 29 July 2013 -- created for the LASzip DLL after returning to Sommerhausen
+
+===============================================================================
+*/
+
+#include
+#include
+#include
+#include
+
+#include "laszip_api.h"
+
+#if defined(_MSC_VER) && \
+ (_MSC_FULL_VER >= 150000000)
+#define LASCopyString _strdup
+#else
+#define LASCopyString strdup
+#endif
+
+void usage(bool wait=false)
+{
+ fprintf(stderr,"usage:\n");
+ fprintf(stderr,"laszipdllexample\n");
+ fprintf(stderr,"laszipdllexample in.las out.laz\n");
+ fprintf(stderr,"laszipdllexample in.laz out.las\n");
+ fprintf(stderr,"laszipdllexample in.las out.las\n");
+ fprintf(stderr,"laszipdllexample in.laz out.laz\n");
+ fprintf(stderr,"laszipdllexample -h\n");
+ if (wait)
+ {
+ fprintf(stderr,"\n");
+ getc(stdin);
+ }
+ exit(1);
+}
+
+static void dll_error(laszip_POINTER laszip)
+{
+ if (laszip)
+ {
+ laszip_CHAR* error;
+ if (laszip_get_error(laszip, &error))
+ {
+ fprintf(stderr,"DLL ERROR: getting error messages\n");
+ }
+ fprintf(stderr,"DLL ERROR MESSAGE: %s\n", error);
+ }
+}
+
+static void byebye(bool error=false, bool wait=false, laszip_POINTER laszip=0)
+{
+ if (error)
+ {
+ dll_error(laszip);
+ }
+ if (wait)
+ {
+ fprintf(stderr,"\n");
+ getc(stdin);
+ }
+ exit(error);
+}
+
+static double taketime()
+{
+ return (double)(clock())/CLOCKS_PER_SEC;
+}
+
+#define EXAMPLE_ONE 1
+#define EXAMPLE_TWO 2
+#define EXAMPLE_THREE 3
+#define EXAMPLE_FOUR 4
+#define EXAMPLE_FIVE 5
+#define EXAMPLE_SIX 6
+#define EXAMPLE_SEVEN 7
+#define EXAMPLE_EIGHT 8
+#define EXAMPLE_NINE 9
+#define EXAMPLE_TEN 10
+#define EXAMPLE_ELEVEN 11
+#define EXAMPLE_TWELVE 12
+#define EXAMPLE_THIRTEEN 13
+#define EXAMPLE_FOURTEEN 14
+#define EXAMPLE_FIFTEEN 15
+#define EXAMPLE_SIXTEEN 16
+
+#define EXAMPLE EXAMPLE_EIGHT
+
+int main(int argc, char *argv[])
+{
+ laszip_U32 i;
+ double start_time = 0.0;
+ char* file_name_in = 0;
+ char* file_name_out = 0;
+
+ // load LASzip DLL
+
+ if (laszip_load_dll())
+ {
+ fprintf(stderr,"DLL ERROR: loading LASzip DLL\n");
+ byebye(true, argc==1);
+ }
+
+ // get version of LASzip DLL
+
+ laszip_U8 version_major;
+ laszip_U8 version_minor;
+ laszip_U16 version_revision;
+ laszip_U32 version_build;
+
+ if (laszip_get_version(&version_major, &version_minor, &version_revision, &version_build))
+ {
+ fprintf(stderr,"DLL ERROR: getting LASzip DLL version number\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"LASzip DLL v%d.%d r%d (build %d)\n", (int)version_major, (int)version_minor, (int)version_revision, (int)version_build);
+
+ if (argc == 1)
+ {
+ char file_name[256];
+ fprintf(stderr,"%s is better run in the command line\n", argv[0]);
+ fprintf(stderr,"enter input file%s: ", ((EXAMPLE == EXAMPLE_THREE) ? " (not used)" : "")); fgets(file_name, 256, stdin);
+ file_name[strlen(file_name)-1] = '\0';
+ file_name_in = LASCopyString(file_name);
+ fprintf(stderr,"enter output file: "); fgets(file_name, 256, stdin);
+ file_name[strlen(file_name)-1] = '\0';
+ file_name_out = LASCopyString(file_name);
+ }
+ else if (argc == 3)
+ {
+ file_name_in = LASCopyString(argv[1]);
+ file_name_out = LASCopyString(argv[2]);
+ }
+ else
+ {
+ if ((argc != 2) || (strcmp(argv[1], "-h") != 0))
+ {
+ fprintf(stderr, "ERROR: cannot understand arguments\n");
+ }
+ usage();
+ }
+
+ start_time = taketime();
+
+ if (EXAMPLE == EXAMPLE_ONE)
+ {
+ fprintf(stderr,"running EXAMPLE_ONE (reading *without* and writing *without* compatibility mode)\n");
+
+ // create the reader
+
+ laszip_POINTER laszip_reader;
+ if (laszip_create(&laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ // open the reader
+
+ laszip_BOOL is_compressed = 0;
+ if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+ // get a pointer to the header of the reader that was just populated
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_reader, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // how many points does the file have
+
+ laszip_I64 npoints = (header->number_of_point_records ? header->number_of_point_records : header->extended_number_of_point_records);
+
+ // report how many points the file has
+
+ fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+ // get a pointer to the points that will be read
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_reader, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // initialize the header for the writer using the header of the reader
+
+ if (laszip_set_header(laszip_writer, header))
+ {
+ fprintf(stderr,"DLL ERROR: setting header for laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // open the writer
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // read the points
+
+ laszip_I64 p_count = 0;
+
+ while (p_count < npoints)
+ {
+ // read a point
+
+ if (laszip_read_point(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: reading point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // copy the point
+
+ if (laszip_set_point(laszip_writer, point))
+ {
+ fprintf(stderr,"DLL ERROR: setting point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write the point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+ }
+
+ fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // close the reader
+
+ if (laszip_close_reader(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // destroy the reader
+
+ if (laszip_destroy(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+ } // end of EXAMPLE_ONE
+
+ if (EXAMPLE == EXAMPLE_TWO)
+ {
+ fprintf(stderr,"running EXAMPLE_TWO (another way of reading *without* and writing *without* compatibility mode)\n");
+
+ // create the reader
+
+ laszip_POINTER laszip_reader;
+ if (laszip_create(&laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ // open the reader
+
+ laszip_BOOL is_compressed = 0;
+ if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+ // get a pointer to the header of the reader that was just populated
+
+ laszip_header* header_read;
+
+ if (laszip_get_header_pointer(laszip_reader, &header_read))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // how many points does the file have
+
+ laszip_I64 npoints = (header_read->number_of_point_records ? header_read->number_of_point_records : header_read->extended_number_of_point_records);
+
+ // report how many points the file has
+
+ fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // get a pointer to the header of the writer so we can populate it
+
+ laszip_header* header_write;
+
+ if (laszip_get_header_pointer(laszip_writer, &header_write))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // copy entries from the reader header to the writer header
+
+ header_write->file_source_ID = header_read->file_source_ID;
+ header_write->global_encoding = header_read->global_encoding;
+ header_write->project_ID_GUID_data_1 = header_read->project_ID_GUID_data_1;
+ header_write->project_ID_GUID_data_2 = header_read->project_ID_GUID_data_2;
+ header_write->project_ID_GUID_data_3 = header_read->project_ID_GUID_data_3;
+ memcpy(header_write->project_ID_GUID_data_4, header_read->project_ID_GUID_data_4, 8);
+ header_write->version_major = header_read->version_major;
+ header_write->version_minor = header_read->version_minor;
+ memcpy(header_write->system_identifier, header_read->system_identifier, 32);
+ memcpy(header_write->generating_software, header_read->generating_software, 32);
+ header_write->file_creation_day = header_read->file_creation_day;
+ header_write->file_creation_year = header_read->file_creation_year;
+ header_write->header_size = header_read->header_size;
+ header_write->offset_to_point_data = header_read->header_size; /* note !!! */
+ header_write->number_of_variable_length_records = header_read->number_of_variable_length_records;
+ header_write->point_data_format = header_read->point_data_format;
+ header_write->point_data_record_length = header_read->point_data_record_length;
+ header_write->number_of_point_records = header_read->number_of_point_records;
+ for (i = 0; i < 5; i++)
+ {
+ header_write->number_of_points_by_return[i] = header_read->number_of_points_by_return[i];
+ }
+ header_write->x_scale_factor = header_read->x_scale_factor;
+ header_write->y_scale_factor = header_read->y_scale_factor;
+ header_write->z_scale_factor = header_read->z_scale_factor;
+ header_write->x_offset = header_read->x_offset;
+ header_write->y_offset = header_read->y_offset;
+ header_write->z_offset = header_read->z_offset;
+ header_write->max_x = header_read->max_x;
+ header_write->min_x = header_read->min_x;
+ header_write->max_y = header_read->max_y;
+ header_write->min_y = header_read->min_y;
+ header_write->max_z = header_read->max_z;
+ header_write->min_z = header_read->min_z;
+
+ // LAS 1.3 and higher only
+ header_write->start_of_waveform_data_packet_record = header_read->start_of_waveform_data_packet_record;
+
+ // LAS 1.4 and higher only
+ header_write->start_of_first_extended_variable_length_record = header_read->start_of_first_extended_variable_length_record;
+ header_write->number_of_extended_variable_length_records = header_read->number_of_extended_variable_length_records;
+ header_write->extended_number_of_point_records = header_read->extended_number_of_point_records;
+ for (i = 0; i < 15; i++)
+ {
+ header_write->extended_number_of_points_by_return[i] = header_read->extended_number_of_points_by_return[i];
+ }
+
+ // we may modify output because we omit any user defined data that may be ** the header
+
+ if (header_read->user_data_in_header_size)
+ {
+ header_write->header_size -= header_read->user_data_in_header_size;
+ header_write->offset_to_point_data -= header_read->user_data_in_header_size;
+ fprintf(stderr,"omitting %d bytes of user_data_in_header\n", header_read->user_data_after_header_size);
+ }
+
+ // add all the VLRs
+
+ if (header_read->number_of_variable_length_records)
+ {
+ fprintf(stderr,"offset_to_point_data before adding %u VLRs is : %d\n", header_read->number_of_variable_length_records, (laszip_I32)header_write->offset_to_point_data);
+ for (i = 0; i < header_read->number_of_variable_length_records; i++)
+ {
+ if (laszip_add_vlr(laszip_writer, header_read->vlrs[i].user_id, header_read->vlrs[i].record_id, header_read->vlrs[i].record_length_after_header, header_read->vlrs[i].description, header_read->vlrs[i].data))
+ {
+ fprintf(stderr,"DLL ERROR: adding VLR %u of %u to the header of the laszip writer\n", i+i, header_read->number_of_variable_length_records);
+ byebye(true, argc==1, laszip_writer);
+ }
+ fprintf(stderr,"offset_to_point_data after adding VLR number %u is : %d\n", i+1, (laszip_I32)header_write->offset_to_point_data);
+ }
+ }
+
+ // we may modify output because we omit any user defined data that may be *after* the header
+
+ if (header_read->user_data_after_header_size)
+ {
+ fprintf(stderr,"omitting %d bytes of user_data_after_header\n", header_read->user_data_after_header_size);
+ }
+
+ // open the writer
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // get a pointer to the point of the reader will be read
+
+ laszip_point* point_read;
+
+ if (laszip_get_point_pointer(laszip_reader, &point_read))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // get a pointer to the point of the writer that we will populate and write
+
+ laszip_point* point_write;
+
+ if (laszip_get_point_pointer(laszip_writer, &point_write))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // read the points
+
+ laszip_I64 p_count = 0;
+
+ while (p_count < npoints)
+ {
+ // read a point
+
+ if (laszip_read_point(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: reading point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // copy the point
+
+ point_write->X = point_read->X;
+ point_write->Y = point_read->Y;
+ point_write->Z = point_read->Z;
+ point_write->intensity = point_read->intensity;
+ point_write->return_number = point_read->return_number;
+ point_write->number_of_returns = point_read->number_of_returns;
+ point_write->scan_direction_flag = point_read->scan_direction_flag;
+ point_write->edge_of_flight_line = point_read->edge_of_flight_line;
+ point_write->classification = point_read->classification;
+ point_write->withheld_flag = point_read->withheld_flag;
+ point_write->keypoint_flag = point_read->keypoint_flag;
+ point_write->synthetic_flag = point_read->synthetic_flag;
+ point_write->scan_angle_rank = point_read->scan_angle_rank;
+ point_write->user_data = point_read->user_data;
+ point_write->point_source_ID = point_read->point_source_ID;
+
+ point_write->gps_time = point_read->gps_time;
+ memcpy(point_write->rgb, point_read->rgb, 8);
+ memcpy(point_write->wave_packet, point_read->wave_packet, 29);
+
+ // LAS 1.4 only
+ point_write->extended_scanner_channel = point_read->extended_scanner_channel;
+ point_write->extended_classification_flags = point_read->extended_classification_flags;
+ point_write->extended_classification = point_read->extended_classification;
+ point_write->extended_return_number = point_read->extended_return_number;
+ point_write->extended_number_of_returns = point_read->extended_number_of_returns;
+ point_write->extended_scan_angle = point_read->extended_scan_angle;
+
+ if (point_read->num_extra_bytes)
+ {
+ memcpy(point_write->extra_bytes, point_read->extra_bytes, point_read->num_extra_bytes);
+ }
+
+ // write the point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+ }
+
+ fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // close the reader
+
+ if (laszip_close_reader(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // destroy the reader
+
+ if (laszip_destroy(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+ } // end of EXAMPLE_TWO
+
+ if (EXAMPLE == EXAMPLE_THREE)
+ {
+ fprintf(stderr,"running EXAMPLE_THREE (writing five points of type 1 to LAS 1.2 file)\n");
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // get a pointer to the header of the writer so we can populate it
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_writer, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // populate the header
+
+ header->file_source_ID = 4711;
+ header->global_encoding = (1<<0); // see LAS specification for details
+ header->version_major = 1;
+ header->version_minor = 2;
+ strncpy(header->system_identifier, "LASzip DLL example 3", 32);
+ header->file_creation_day = 120;
+ header->file_creation_year = 2013;
+ header->point_data_format = 1;
+ header->point_data_record_length = 28;
+ header->number_of_point_records = 5;
+ header->number_of_points_by_return[0] = 3;
+ header->number_of_points_by_return[1] = 2;
+ header->max_x = 630499.95;
+ header->min_x = 630498.56;
+ header->max_y = 4834749.66;
+ header->min_y = 4834748.73;
+ header->max_z = 63.68;
+ header->min_z = 61.33;
+
+ // optional: use the bounding box and the scale factor to create a "good" offset
+
+ if (laszip_auto_offset(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: during automatic offset creation\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data before adding funny VLR is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // add some funny VLR
+
+ if (laszip_add_vlr(laszip_writer, "funny", 12345, 0, "just a funny VLR", 0))
+ {
+ fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // create the geokeys with the projection information
+
+ laszip_geokey_struct key_entries[5];
+
+ // projected coordinates
+ key_entries[0].key_id = 1024; // GTModelTypeGeoKey
+ key_entries[0].tiff_tag_location = 0;
+ key_entries[0].count = 1;
+ key_entries[0].value_offset = 1; // ModelTypeProjected
+
+ // projection
+ key_entries[1].key_id = 3072; // ProjectedCSTypeGeoKey
+ key_entries[1].tiff_tag_location = 0;
+ key_entries[1].count = 1;
+ key_entries[1].value_offset = 32613; // PCS_WGS84_UTM_zone_13N
+
+ // horizontal units
+ key_entries[2].key_id = 3076; // ProjLinearUnitsGeoKey
+ key_entries[2].tiff_tag_location = 0;
+ key_entries[2].count = 1;
+ key_entries[2].value_offset = 9001; // meters
+
+ // vertical units
+ key_entries[3].key_id = 4099; // VerticalUnitsGeoKey
+ key_entries[3].tiff_tag_location = 0;
+ key_entries[3].count = 1;
+ key_entries[3].value_offset = 9001; // meters
+
+ // vertical datum
+ key_entries[4].key_id = 4096; // VerticalCSTypeGeoKey
+ key_entries[4].tiff_tag_location = 0;
+ key_entries[4].count = 1;
+ key_entries[4].value_offset = 5030; // WGS84
+
+ // add the geokeys (create or replace the appropriate VLR)
+
+ fprintf(stderr,"offset_to_point_data before adding projection VLR : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ if (laszip_set_geokeys(laszip_writer, 5, key_entries))
+ {
+ fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data after adding two VLRs : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // open the writer
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // get a pointer to the point of the writer that we will populate and write
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_writer, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write five points
+
+ laszip_I64 p_count = 0;
+ laszip_F64 coordinates[3];
+
+ // populate the first point
+
+ coordinates[0] = 630499.95;
+ coordinates[1] = 4834749.17;
+ coordinates[2] = 62.15;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 60;
+ point->return_number = 2;
+ point->number_of_returns = 2;
+ point->classification = 2;
+ point->scan_angle_rank = 21;
+ point->gps_time = 413162.560400;
+
+ // write the first point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the second point
+
+ coordinates[0] = 630499.83;
+ coordinates[1] = 4834748.88;
+ coordinates[2] = 62.68;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 90;
+ point->return_number = 1;
+ point->number_of_returns = 1;
+ point->classification = 1;
+ point->scan_angle_rank = 21;
+ point->gps_time = 413162.563600;
+
+ // write the second point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the third point
+
+ coordinates[0] = 630499.54;
+ coordinates[1] = 4834749.66;
+ coordinates[2] = 62.66;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 70;
+ point->return_number = 1;
+ point->number_of_returns = 1;
+ point->classification = 1;
+ point->scan_angle_rank = 22;
+ point->gps_time = 413162.566800;
+
+ // write the third point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the fourth point
+
+ coordinates[0] = 630498.56;
+ coordinates[1] = 4834749.41;
+ coordinates[2] = 63.68;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 20;
+ point->return_number = 1;
+ point->number_of_returns = 2;
+ point->classification = 3;
+ point->scan_angle_rank = 22;
+ point->gps_time = 413162.580200;
+
+ // write the fourth point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the fifth point
+
+ coordinates[0] = 630498.80;
+ coordinates[1] = 4834748.73;
+ coordinates[2] = 62.16;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 110;
+ point->return_number = 2;
+ point->number_of_returns = 2;
+ point->classification = 2;
+ point->scan_angle_rank = 22;
+ point->gps_time = 413162.580200;
+
+ // write the fifth point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // get the number of points written so far
+
+ if (laszip_get_point_count(laszip_writer, &p_count))
+ {
+ fprintf(stderr,"DLL ERROR: getting point count\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"successfully written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
+
+ } // end of EXAMPLE_THREE
+
+ if (EXAMPLE == EXAMPLE_FOUR)
+ {
+ fprintf(stderr,"running EXAMPLE_FOUR (reading area-of-interest from a file exploiting possibly existing spatial indexing information)\n");
+
+ // create the reader
+
+ laszip_POINTER laszip_reader;
+ if (laszip_create(&laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ // signal that spatial queries are coming
+
+ laszip_BOOL exploit = 1;
+ if (laszip_exploit_spatial_index(laszip_reader, exploit))
+ {
+ fprintf(stderr,"DLL ERROR: signaling laszip reader that spatial queries are coming for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // open the reader
+
+ laszip_BOOL is_compressed = 0;
+ if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+ // check whether spatial indexing information is available
+
+ laszip_BOOL is_indexed = 0;
+ laszip_BOOL is_appended = 0;
+ if (laszip_has_spatial_index(laszip_reader, &is_indexed, &is_appended))
+ {
+ fprintf(stderr,"DLL ERROR: checking laszip reader whether spatial indexing information is present for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ fprintf(stderr,"file '%s' does %shave spatial indexing information\n", file_name_in, (is_indexed ? "" : "not "));
+
+ // get a pointer to the header of the reader that was just populated
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_reader, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // how many points does the file have
+
+ laszip_I64 npoints = (header->number_of_point_records ? header->number_of_point_records : header->extended_number_of_point_records);
+
+ // report how many points the file has
+
+ fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+ // create a rectangular box enclosing a subset of points at the center of the full bounding box
+
+ const laszip_F64 sub = 0.05;
+
+ laszip_F64 mid_x = (header->min_x + header->max_x) / 2;
+ laszip_F64 mid_y = (header->min_y + header->max_y) / 2;
+
+ laszip_F64 range_x = header->max_x - header->min_x;
+ laszip_F64 range_y = header->max_y - header->min_y;
+
+ laszip_F64 sub_min_x = mid_x - sub * range_x;
+ laszip_F64 sub_min_y = mid_y - sub * range_y;
+
+ laszip_F64 sub_max_x = mid_x + sub * range_x;
+ laszip_F64 sub_max_y = mid_y + sub * range_y;
+
+ // request the reader to only read this specified rectangular subset of points
+
+ laszip_BOOL is_empty = 0;
+ if (laszip_inside_rectangle(laszip_reader, sub_min_x, sub_min_y, sub_max_x, sub_max_y, &is_empty))
+ {
+ fprintf(stderr,"DLL ERROR: requesting points inside of rectangle [%g,%g] (%g,%g) from laszip reader\n", sub_min_x, sub_min_y, sub_max_x, sub_max_y);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // get a pointer to the points that will be read
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_reader, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // initialize the header for the writer using the header of the reader
+
+ if (laszip_set_header(laszip_writer, header))
+ {
+ fprintf(stderr,"DLL ERROR: setting header for laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // open the writer
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // read the points
+
+ laszip_BOOL is_done = 0;
+ laszip_I64 p_count = 0;
+
+ while (p_count < npoints)
+ {
+ // read a point
+
+ if (laszip_read_inside_point(laszip_reader, &is_done))
+ {
+ fprintf(stderr,"DLL ERROR: reading point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // are we done reading
+
+ if (is_done)
+ {
+ break;
+ }
+
+ // copy the point
+
+ if (laszip_set_point(laszip_writer, point))
+ {
+ fprintf(stderr,"DLL ERROR: setting point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write the point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // update the inventory
+
+ if (laszip_update_inventory(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: updating inventory for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+ }
+
+ fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // close the reader
+
+ if (laszip_close_reader(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // destroy the reader
+
+ if (laszip_destroy(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+ } // end of EXAMPLE_FOUR
+
+ if (EXAMPLE == EXAMPLE_FIVE)
+ {
+ fprintf(stderr,"running EXAMPLE_FIVE (reading from one file and writing to another file while simultaneously generating a spatial index)\n");
+
+ // create the reader
+
+ laszip_POINTER laszip_reader;
+ if (laszip_create(&laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ // open the reader
+
+ laszip_BOOL is_compressed = 0;
+ if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+ // get a pointer to the header of the reader that was just populated
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_reader, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // how many points does the file have
+
+ laszip_I64 npoints = (header->number_of_point_records ? header->number_of_point_records : header->extended_number_of_point_records);
+
+ // report how many points the file has
+
+ fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+ // get a pointer to the points that will be read
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_reader, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // initialize the header for the writer using the header of the reader
+
+ if (laszip_set_header(laszip_writer, header))
+ {
+ fprintf(stderr,"DLL ERROR: setting header for laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // enable the creation of spatial indices
+
+ laszip_BOOL create = 1;
+ laszip_BOOL append = 0; /* not supported yet */
+
+ if (laszip_create_spatial_index(laszip_writer, create, append))
+ {
+ fprintf(stderr,"DLL ERROR: signaling laszip writer to create spatial indexing information\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // open the writer
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' spatially indexed and %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // read the points
+
+ laszip_I64 p_count = 0;
+
+ while (p_count < npoints)
+ {
+ // read a point
+
+ if (laszip_read_point(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: reading point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // copy the point
+
+ if (laszip_set_point(laszip_writer, point))
+ {
+ fprintf(stderr,"DLL ERROR: setting point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write the point
+
+ if (laszip_write_indexed_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing indexed point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+ }
+
+ fprintf(stderr,"successfully read and written %I64d indexed points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // close the reader
+
+ if (laszip_close_reader(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // destroy the reader
+
+ if (laszip_destroy(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for reading %scompressed and writing indexed & %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+ } // end of EXAMPLE_FIVE
+
+ if (EXAMPLE == EXAMPLE_SIX)
+ {
+ fprintf(stderr,"running EXAMPLE_SIX (writing five points of type 6 to LAS 1.4 without compatibility)\n");
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // get a pointer to the header of the writer so we can populate it
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_writer, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // populate the header
+
+ header->file_source_ID = 4711;
+ header->global_encoding = (1<<0) | (1<<4); // see LAS specification for details
+ header->version_major = 1;
+ header->version_minor = 4;
+ strncpy(header->system_identifier, "LASzip DLL example 6", 32);
+ header->file_creation_day = 30;
+ header->file_creation_year = 2015;
+ header->header_size = 375;
+ header->offset_to_point_data = 375;
+ header->point_data_format = 6;
+ header->point_data_record_length = 30;
+ header->number_of_point_records = 0; // legacy 32-bit counters should be zero for new point types > 5
+ for (i = 0; i < 5; i++)
+ {
+ header->number_of_points_by_return[i] = 0;
+ }
+ header->extended_number_of_point_records = 5;
+ header->extended_number_of_points_by_return[0] = 1;
+ header->extended_number_of_points_by_return[1] = 2;
+ header->extended_number_of_points_by_return[7] = 1;
+ header->extended_number_of_points_by_return[8] = 1;
+ header->max_x = 630499.95;
+ header->min_x = 630498.56;
+ header->max_y = 4834749.66;
+ header->min_y = 4834748.73;
+ header->max_z = 63.68;
+ header->min_z = 61.33;
+
+ // optional: use the bounding box and the scale factor to create a "good" offset
+
+ if (laszip_auto_offset(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: during automatic offset creation\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data before adding empty OGC WKT VLR is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // add intentionally empty OGC WKT
+
+ if (laszip_add_vlr(laszip_writer, "LASF_Projection", 2112, 0, "intentionally empty OGC WKT", 0))
+ {
+ fprintf(stderr,"DLL ERROR: adding intentionally empty OGC WKT VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data before adding funny VLR is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // add some funny VLR
+
+ if (laszip_add_vlr(laszip_writer, "funny", 12345, 0, "just a funny VLR", 0))
+ {
+ fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data after adding VLRs : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // open the writer
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ // this should fail if compress is true
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // get a pointer to the point of the writer that we will populate and write
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_writer, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write five points
+
+ laszip_I64 p_count = 0;
+ laszip_F64 coordinates[3];
+
+ // populate the first point
+
+ coordinates[0] = 630499.95;
+ coordinates[1] = 4834749.17;
+ coordinates[2] = 62.15;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 60;
+ point->extended_return_number = 2;
+ point->extended_number_of_returns = 2;
+ point->classification = 2; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 2;
+ point->extended_scan_angle = 3500;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 8; // overflag flag is set
+ point->gps_time = 53413162.560400;
+
+ // write the first point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the second point
+
+ coordinates[0] = 630499.83;
+ coordinates[1] = 4834748.88;
+ coordinates[2] = 62.68;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 90;
+ point->extended_return_number = 8;
+ point->extended_number_of_returns = 9;
+ point->classification = 0; // it must be set to zero as the real value is stored in the extended field
+ point->extended_classification = 41;
+ point->extended_scan_angle = 3567;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.563600;
+
+ // write the second point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the third point
+
+ coordinates[0] = 630499.54;
+ coordinates[1] = 4834749.66;
+ coordinates[2] = 62.66;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 70;
+ point->extended_return_number = 9;
+ point->extended_number_of_returns = 9;
+ point->classification = 0; // it must be set to zero as the real value is stored in the extended field
+ point->extended_classification = 42;
+ point->extended_scan_angle = 3633;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.566800;
+
+ // write the third point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the fourth point
+
+ coordinates[0] = 630498.56;
+ coordinates[1] = 4834749.41;
+ coordinates[2] = 63.68;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 20;
+ point->extended_return_number = 1;
+ point->extended_number_of_returns = 2;
+ point->classification = 5; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 5;
+ point->extended_scan_angle = 3700;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.580200;
+
+ // write the fourth point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the fifth point
+
+ coordinates[0] = 630498.80;
+ coordinates[1] = 4834748.73;
+ coordinates[2] = 62.16;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 110;
+ point->extended_return_number = 2;
+ point->extended_number_of_returns = 2;
+ point->classification = 2; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 2;
+ point->extended_scan_angle = 3767;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.580200;
+
+ // write the fifth point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // get the number of points written so far
+
+ if (laszip_get_point_count(laszip_writer, &p_count))
+ {
+ fprintf(stderr,"DLL ERROR: getting point count\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"successfully written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
+
+ } // end of EXAMPLE_SIX
+
+ if (EXAMPLE == EXAMPLE_SEVEN) // CHECK
+ {
+ fprintf(stderr,"running EXAMPLE_SEVEN (writing five points of type 6 to LAS 1.4 *with* compatibility to compressed LAZ *and* also uncompressed LAS)\n");
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // get a pointer to the header of the writer so we can populate it
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_writer, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // populate the header
+
+ header->file_source_ID = 4711;
+ header->global_encoding = (1<<0) | (1<<4); // see LAS specification for details
+ header->version_major = 1;
+ header->version_minor = 4;
+ strncpy(header->system_identifier, "LASzip DLL example 7", 32);
+ header->file_creation_day = 30;
+ header->file_creation_year = 2015;
+ header->header_size = 375;
+ header->offset_to_point_data = 375;
+ header->point_data_format = 6;
+ header->point_data_record_length = 30;
+ header->number_of_point_records = 0; // legacy 32-bit counters should be zero for new point types > 5
+ for (i = 0; i < 5; i++)
+ {
+ header->number_of_points_by_return[i] = 0;
+ }
+ header->extended_number_of_point_records = 5;
+ header->extended_number_of_points_by_return[0] = 1;
+ header->extended_number_of_points_by_return[1] = 2;
+ header->extended_number_of_points_by_return[7] = 1;
+ header->extended_number_of_points_by_return[8] = 1;
+ header->max_x = 630499.95;
+ header->min_x = 630498.56;
+ header->max_y = 4834749.66;
+ header->min_y = 4834748.73;
+ header->max_z = 63.68;
+ header->min_z = 61.33;
+
+ // optional: use the bounding box and the scale factor to create a "good" offset
+
+ if (laszip_auto_offset(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: during automatic offset creation\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data before adding empty OGC WKT VLR is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // add intentionally empty OGC WKT
+
+ if (laszip_add_vlr(laszip_writer, "LASF_Projection", 2112, 0, "intentionally empty OGC WKT", 0))
+ {
+ fprintf(stderr,"DLL ERROR: adding intentionally empty OGC WKT VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data before adding funny VLR is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // add some funny VLR
+
+ if (laszip_add_vlr(laszip_writer, "funny", 12345, 0, "just a funny VLR", 0))
+ {
+ fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data after adding VLRs : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // enable the compatibility mode
+
+ laszip_BOOL request = 1;
+ if (laszip_request_compatibility_mode(laszip_writer, request))
+ {
+ fprintf(stderr,"DLL ERROR: enabling laszip LAS 1.4 compatibility mode\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // open the writer
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // get a pointer to the point of the writer that we will populate and write
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_writer, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write five points
+
+ laszip_I64 p_count = 0;
+ laszip_F64 coordinates[3];
+
+ // populate the first point
+
+ coordinates[0] = 630499.95;
+ coordinates[1] = 4834749.17;
+ coordinates[2] = 62.15;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 60;
+ point->extended_return_number = 2;
+ point->extended_number_of_returns = 2;
+ point->classification = 2; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 2;
+ point->extended_scan_angle = 3500;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 8; // overflag flag is set
+ point->gps_time = 53413162.560400;
+
+ // write the first point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the second point
+
+ coordinates[0] = 630499.83;
+ coordinates[1] = 4834748.88;
+ coordinates[2] = 62.68;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 90;
+ point->extended_return_number = 8;
+ point->extended_number_of_returns = 9;
+ point->classification = 0; // it must be set to zero as the real value is stored in the extended field
+ point->extended_classification = 41;
+ point->extended_scan_angle = 3567;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.563600;
+
+ // write the second point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the third point
+
+ coordinates[0] = 630499.54;
+ coordinates[1] = 4834749.66;
+ coordinates[2] = 62.66;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 70;
+ point->extended_return_number = 9;
+ point->extended_number_of_returns = 9;
+ point->classification = 0; // it must be set to zero as the real value is stored in the extended field
+ point->extended_classification = 42;
+ point->extended_scan_angle = 3633;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.566800;
+
+ // write the third point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the fourth point
+
+ coordinates[0] = 630498.56;
+ coordinates[1] = 4834749.41;
+ coordinates[2] = 63.68;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 20;
+ point->extended_return_number = 1;
+ point->extended_number_of_returns = 2;
+ point->classification = 5; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 5;
+ point->extended_scan_angle = 3700;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.580200;
+
+ // write the fourth point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the fifth point
+
+ coordinates[0] = 630498.80;
+ coordinates[1] = 4834748.73;
+ coordinates[2] = 62.16;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 110;
+ point->extended_return_number = 2;
+ point->extended_number_of_returns = 2;
+ point->classification = 2; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 2;
+ point->extended_scan_angle = 3767;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.580200;
+
+ // write the fifth point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+
+ // get the number of points written so far
+
+ if (laszip_get_point_count(laszip_writer, &p_count))
+ {
+ fprintf(stderr,"DLL ERROR: getting point count\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"successfully written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
+
+ } // end of EXAMPLE_SEVEN
+
+ if (EXAMPLE == EXAMPLE_EIGHT)
+ {
+ fprintf(stderr,"running EXAMPLE_EIGHT (always *with* compatibility mode when reading but when writing *only* for compressed output)\n");
+
+ // create the reader
+
+ laszip_POINTER laszip_reader;
+ if (laszip_create(&laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ // request compatibility mode for the reader
+
+ laszip_BOOL request_reader = 1;
+ if (laszip_request_compatibility_mode(laszip_reader, request_reader))
+ {
+ fprintf(stderr,"DLL ERROR: enabling laszip LAS 1.4 compatibility mode for the reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // open the reader
+
+ laszip_BOOL is_compressed = 0;
+ if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+ // get a pointer to the header of the reader that was just populated
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_reader, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // how many points does the file have
+
+ laszip_I64 npoints = (header->number_of_point_records ? header->number_of_point_records : header->extended_number_of_point_records);
+
+ // report how many points the file has
+
+ fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+ // get a pointer to the points that will be read
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_reader, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // check if the output is compressed
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ // *only* enable the compatibility mode for the writer for compressed output
+
+ if (compress)
+ {
+ laszip_BOOL request_writer = 1;
+ if (laszip_request_compatibility_mode(laszip_writer, request_writer))
+ {
+ fprintf(stderr,"DLL ERROR: enabling laszip LAS 1.4 compatibility mode for the writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+ }
+
+ // initialize the header for the writer using the header of the reader
+
+ if (laszip_set_header(laszip_writer, header))
+ {
+ fprintf(stderr,"DLL ERROR: setting header for laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // open the writer
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // read the points
+
+ laszip_I64 p_count = 0;
+
+ while (p_count < npoints)
+ {
+ // read a point
+
+ if (laszip_read_point(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: reading point %I64\n", p_count);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // copy the point
+
+ if (laszip_set_point(laszip_writer, point))
+ {
+ fprintf(stderr,"DLL ERROR: setting point %I64\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write the point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+ }
+
+ fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // close the reader
+
+ if (laszip_close_reader(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // destroy the reader
+
+ if (laszip_destroy(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+ } // end of EXAMPLE_EIGHT
+
+ if (EXAMPLE == EXAMPLE_NINE)
+ {
+ fprintf(stderr,"running EXAMPLE_NINE (writing LAS 1.4 points with \"extra bytes\" *with* compatibility to compressed LAZ *and* also uncompressed LAS)\n");
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // get a pointer to the header of the writer so we can populate it
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_writer, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // populate the header
+
+ header->file_source_ID = 4711;
+ header->global_encoding = (1<<0) | (1<<4); // see LAS specification for details
+ header->version_major = 1;
+ header->version_minor = 4;
+ strncpy(header->system_identifier, "LASzip DLL example 9", 32);
+ header->file_creation_day = 30;
+ header->file_creation_year = 2015;
+ header->header_size = 375;
+ header->offset_to_point_data = 375;
+ header->point_data_format = 6;
+ header->point_data_record_length = 30 + 2 + 1; // three "extra bytes" per point store two additional attributes
+ header->number_of_point_records = 0; // legacy 32-bit counters should be zero for new point types > 5
+ for (i = 0; i < 5; i++)
+ {
+ header->number_of_points_by_return[i] = 0;
+ }
+ header->extended_number_of_point_records = 5;
+ header->extended_number_of_points_by_return[0] = 1;
+ header->extended_number_of_points_by_return[1] = 2;
+ header->extended_number_of_points_by_return[7] = 1;
+ header->extended_number_of_points_by_return[8] = 1;
+ header->max_x = 630499.95;
+ header->min_x = 630498.56;
+ header->max_y = 4834749.66;
+ header->min_y = 4834748.73;
+ header->max_z = 63.68;
+ header->min_z = 61.33;
+
+ // optional: use the bounding box and the scale factor to create a "good" offset
+
+ if (laszip_auto_offset(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: during automatic offset creation\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // add description for the two attributes in the three "extra bytes"
+
+ fprintf(stderr,"offset_to_point_data before adding 'height above ground' is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ if (laszip_add_attribute(laszip_writer, 3, "height above ground", "quantized to 5 cm above 1s SRTM", 0.05, 0.0))
+ {
+ fprintf(stderr,"DLL ERROR: adding 'height above ground' attribute\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data before adding 'coverage count' is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ if (laszip_add_attribute(laszip_writer, 0, "coverage count", "by 0.5 m radius of high returns", 1.0, 0.0))
+ {
+ fprintf(stderr,"DLL ERROR: adding 'coverage count' attribute\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data before adding empty OGC WKT VLR is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // add intentionally empty OGC WKT
+
+ if (laszip_add_vlr(laszip_writer, "LASF_Projection", 2112, 0, "intentionally empty OGC WKT", 0))
+ {
+ fprintf(stderr,"DLL ERROR: adding intentionally empty OGC WKT VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data before adding funny VLR is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // add some funny VLR
+
+ if (laszip_add_vlr(laszip_writer, "funny", 12345, 0, "just a funny VLR", 0))
+ {
+ fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data after adding VLRs : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // enable the compatibility mode
+
+ laszip_BOOL request = 1;
+ if (laszip_request_compatibility_mode(laszip_writer, request))
+ {
+ fprintf(stderr,"DLL ERROR: enabling laszip LAS 1.4 compatibility mode\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // open the writer
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // get a pointer to the point of the writer that we will populate and write
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_writer, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write five points
+
+ laszip_I64 p_count = 0;
+ laszip_F64 coordinates[3];
+
+ // populate the first point
+
+ coordinates[0] = 630499.95;
+ coordinates[1] = 4834749.17;
+ coordinates[2] = 62.15;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 60;
+ point->extended_return_number = 2;
+ point->extended_number_of_returns = 2;
+ point->classification = 2; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 2;
+ point->extended_scan_angle = 3500;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 8; // overflag flag is set
+ point->gps_time = 53413162.560400;
+
+ // set attribute 'height above ground' quantized to 0.05 m
+ *((laszip_I16*)(point->extra_bytes + 0)) = (laszip_I16)(12.50 / 0.05);
+
+ // set attribute 'coverage count'
+ *((laszip_U8*)(point->extra_bytes + 2)) = 3;
+
+ // write the first point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the second point
+
+ coordinates[0] = 630499.83;
+ coordinates[1] = 4834748.88;
+ coordinates[2] = 62.68;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 90;
+ point->extended_return_number = 8;
+ point->extended_number_of_returns = 9;
+ point->classification = 0; // it must be set to zero as the real value is stored in the extended field
+ point->extended_classification = 41;
+ point->extended_scan_angle = 3567;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.563600;
+
+ // set attribute 'height above ground' quantized to 0.05 m
+ *((laszip_I16*)(point->extra_bytes + 0)) = (laszip_I16)(9.32 / 0.05);
+
+ // set attribute 'coverage count'
+ *((laszip_U8*)(point->extra_bytes + 2)) = 5;
+
+ // write the second point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the third point
+
+ coordinates[0] = 630499.54;
+ coordinates[1] = 4834749.66;
+ coordinates[2] = 62.66;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 70;
+ point->extended_return_number = 9;
+ point->extended_number_of_returns = 9;
+ point->classification = 0; // it must be set to zero as the real value is stored in the extended field
+ point->extended_classification = 42;
+ point->extended_scan_angle = 3633;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.566800;
+
+ // set attribute 'height above ground' quantized to 0.05 m
+ *((laszip_I16*)(point->extra_bytes + 0)) = (laszip_I16)(23.50 / 0.05);
+
+ // set attribute 'coverage count'
+ *((laszip_U8*)(point->extra_bytes + 2)) = 0;
+
+ // write the third point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the fourth point
+
+ coordinates[0] = 630498.56;
+ coordinates[1] = 4834749.41;
+ coordinates[2] = 63.68;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 20;
+ point->extended_return_number = 1;
+ point->extended_number_of_returns = 2;
+ point->classification = 5; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 5;
+ point->extended_scan_angle = 3700;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.580200;
+
+ // set attribute 'height above ground' quantized to 0.05 m
+ *((laszip_I16*)(point->extra_bytes + 0)) = (laszip_I16)(8.65 / 0.05);
+
+ // set attribute 'coverage count'
+ *((laszip_U8*)(point->extra_bytes + 2)) = 6;
+
+ // write the fourth point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the fifth point
+
+ coordinates[0] = 630498.80;
+ coordinates[1] = 4834748.73;
+ coordinates[2] = 62.16;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 110;
+ point->extended_return_number = 2;
+ point->extended_number_of_returns = 2;
+ point->classification = 2; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 2;
+ point->extended_scan_angle = 3767;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.580200;
+
+ // set attribute 'height above ground' quantized to 0.05 m
+ *((laszip_I16*)(point->extra_bytes + 0)) = (laszip_I16)(16.13 / 0.05);
+
+ // set attribute 'coverage count'
+ *((laszip_U8*)(point->extra_bytes + 2)) = 2;
+
+ // write the fifth point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // get the number of points written so far
+
+ if (laszip_get_point_count(laszip_writer, &p_count))
+ {
+ fprintf(stderr,"DLL ERROR: getting point count\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"successfully written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
+
+ } // end of EXAMPLE_NINE
+
+ if (EXAMPLE == EXAMPLE_TEN)
+ {
+ fprintf(stderr,"running EXAMPLE_TEN (read LAS 1.0-1.3 file, upconvert old to new point types, write LAS 1.4 compatibility mode *only* for compressed output)\n");
+
+ // create the reader
+
+ laszip_POINTER laszip_reader;
+ if (laszip_create(&laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ // enable the compatibility mode for the reader
+
+ laszip_BOOL request_reader = 1;
+ if (laszip_request_compatibility_mode(laszip_reader, request_reader))
+ {
+ fprintf(stderr,"DLL ERROR: enabling laszip LAS 1.4 compatibility mode for the reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // open the reader
+
+ laszip_BOOL is_compressed = 0;
+ if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+ // get a pointer to the header of the reader that was just populated
+
+ laszip_header* header_read;
+
+ if (laszip_get_header_pointer(laszip_reader, &header_read))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // make sure it is LAS 1.0, LAS 1.1, LAS 1.2, or LAS 1.3
+
+ if (header_read->version_minor > 3)
+ {
+ fprintf(stderr,"USER ERROR: input should be LAS 1.0 to LAS 1.3\n");
+ byebye(true, argc==1);
+ }
+
+ // how many points does the LAS 1.x (x < 4) file have
+
+ laszip_I64 npoints = header_read->number_of_point_records;
+
+ // report how many points the file has
+
+ fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+ // get a pointer to the points that will be read
+
+ laszip_point* point_read;
+
+ if (laszip_get_point_pointer(laszip_reader, &point_read))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // check if the output is compressed
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ // *only* enable the compatibility mode for the writer for compressed output
+
+ if (compress)
+ {
+ laszip_BOOL request_writer = 1;
+ if (laszip_request_compatibility_mode(laszip_writer, request_writer))
+ {
+ fprintf(stderr,"DLL ERROR: enabling laszip LAS 1.4 compatibility mode for the writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+ }
+
+ // get a pointer to the header of the writer so we can populate it
+
+ laszip_header* header_write;
+
+ if (laszip_get_header_pointer(laszip_writer, &header_write))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // copy entries from the reader header to the writer header
+
+ header_write->file_source_ID = header_read->file_source_ID;
+ header_write->global_encoding = header_read->global_encoding;
+ header_write->project_ID_GUID_data_1 = header_read->project_ID_GUID_data_1;
+ header_write->project_ID_GUID_data_2 = header_read->project_ID_GUID_data_2;
+ header_write->project_ID_GUID_data_3 = header_read->project_ID_GUID_data_3;
+ memcpy(header_write->project_ID_GUID_data_4, header_read->project_ID_GUID_data_4, 8);
+ header_write->version_major = header_read->version_major;
+ header_write->version_minor = header_read->version_minor;
+ memcpy(header_write->system_identifier, header_read->system_identifier, 32);
+ memcpy(header_write->generating_software, header_read->generating_software, 32);
+ header_write->file_creation_day = header_read->file_creation_day;
+ header_write->file_creation_year = header_read->file_creation_year;
+ header_write->header_size = header_read->header_size;
+ header_write->offset_to_point_data = header_read->header_size; /* note !!! */
+ header_write->number_of_variable_length_records = header_read->number_of_variable_length_records;
+ header_write->point_data_format = header_read->point_data_format;
+ header_write->point_data_record_length = header_read->point_data_record_length;
+ header_write->number_of_point_records = header_read->number_of_point_records;
+ for (i = 0; i < 5; i++)
+ {
+ header_write->number_of_points_by_return[i] = header_read->number_of_points_by_return[i];
+ }
+ header_write->x_scale_factor = header_read->x_scale_factor;
+ header_write->y_scale_factor = header_read->y_scale_factor;
+ header_write->z_scale_factor = header_read->z_scale_factor;
+ header_write->x_offset = header_read->x_offset;
+ header_write->y_offset = header_read->y_offset;
+ header_write->z_offset = header_read->z_offset;
+ header_write->max_x = header_read->max_x;
+ header_write->min_x = header_read->min_x;
+ header_write->max_y = header_read->max_y;
+ header_write->min_y = header_read->min_y;
+ header_write->max_z = header_read->max_z;
+ header_write->min_z = header_read->min_z;
+
+ // LAS 1.3 and higher only
+ header_write->start_of_waveform_data_packet_record = header_read->start_of_waveform_data_packet_record;
+
+ // we may modify output because we omit any user defined data that may be *before* the header
+
+ header_write->user_data_in_header_size = 0;
+ if (header_read->user_data_in_header_size)
+ {
+ header_write->header_size -= header_read->user_data_in_header_size;
+ header_write->offset_to_point_data -= header_read->user_data_in_header_size;
+ fprintf(stderr,"omitting %d bytes of user_data_in_header\n", header_read->user_data_after_header_size);
+ }
+
+ // add all the VLRs
+
+ if (header_read->number_of_variable_length_records)
+ {
+ fprintf(stderr,"offset_to_point_data before adding %u VLRs is : %d\n", header_read->number_of_variable_length_records, (laszip_I32)header_write->offset_to_point_data);
+ for (i = 0; i < header_read->number_of_variable_length_records; i++)
+ {
+ if (laszip_add_vlr(laszip_writer, header_read->vlrs[i].user_id, header_read->vlrs[i].record_id, header_read->vlrs[i].record_length_after_header, header_read->vlrs[i].description, header_read->vlrs[i].data))
+ {
+ fprintf(stderr,"DLL ERROR: adding VLR %u of %u to the header of the laszip writer\n", i+i, header_read->number_of_variable_length_records);
+ byebye(true, argc==1, laszip_writer);
+ }
+ fprintf(stderr,"offset_to_point_data after adding VLR number %u is : %d\n", i+1, (laszip_I32)header_write->offset_to_point_data);
+ }
+ }
+
+ // we may modify output because we omit any user defined data that may be *after* the header
+
+ header_write->user_data_after_header_size = 0;
+ if (header_read->user_data_after_header_size)
+ {
+ fprintf(stderr,"omitting %d bytes of user_data_after_header\n", header_read->user_data_after_header_size);
+ }
+
+ // upgrade the header and the points to LAS 1.4
+
+ header_write->version_minor = 4;
+ if (header_read->version_minor == 3)
+ {
+ header_write->header_size += 140;
+ header_write->offset_to_point_data += 140;
+ }
+ else
+ {
+ header_write->header_size += 148;
+ header_write->offset_to_point_data += 148;
+ }
+
+ if (header_read->point_data_format == 0)
+ {
+ header_write->point_data_format = 6;
+ header_write->point_data_record_length += 10;
+ }
+ else if (header_read->point_data_format == 1)
+ {
+ header_write->point_data_format = 6;
+ header_write->point_data_record_length += 2;
+ }
+ else if (header_read->point_data_format == 2)
+ {
+ header_write->point_data_format = 7;
+ header_write->point_data_record_length += 10;
+ }
+ else if (header_read->point_data_format == 3)
+ {
+ header_write->point_data_format = 7;
+ header_write->point_data_record_length += 2;
+ }
+ else
+ {
+ fprintf(stderr,"USER ERROR: input point type should be 0 to 3 and not %d\n", header_read->point_data_format);
+ byebye(true, argc==1);
+ }
+
+ // we do not add EVLRs
+ header_write->start_of_first_extended_variable_length_record = 0;
+ header_write->number_of_extended_variable_length_records = 0;
+
+ // zero the legacy counters
+ header_write->number_of_point_records = 0;
+ for (i = 0; i < 5; i++)
+ {
+ header_write->number_of_points_by_return[i] = 0;
+ }
+
+ // populate the extended counters
+ header_write->extended_number_of_point_records = header_read->number_of_point_records;
+ for (i = 0; i < 5; i++)
+ {
+ header_write->extended_number_of_points_by_return[i] = header_read->number_of_points_by_return[i];
+ }
+ for (i = 5; i < 15; i++)
+ {
+ header_write->extended_number_of_points_by_return[i] = 0;
+ }
+
+ // open the writer
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // get a pointer to the point of the writer that we will populate and write
+
+ laszip_point* point_write;
+
+ if (laszip_get_point_pointer(laszip_writer, &point_write))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // read the points
+
+ laszip_I64 p_count = 0;
+
+ while (p_count < npoints)
+ {
+ // read a point
+
+ if (laszip_read_point(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: reading point %I64\n", p_count);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // copy the point
+
+ point_write->X = point_read->X;
+ point_write->Y = point_read->Y;
+ point_write->Z = point_read->Z;
+ point_write->intensity = point_read->intensity;
+ point_write->scan_direction_flag = point_read->scan_direction_flag;
+ point_write->edge_of_flight_line = point_read->edge_of_flight_line;
+ point_write->user_data = point_read->user_data;
+ point_write->point_source_ID = point_read->point_source_ID;
+
+ point_write->gps_time = point_read->gps_time;
+ memcpy(point_write->rgb, point_read->rgb, 8);
+
+ point_write->extended_scanner_channel = 0;
+ point_write->extended_classification_flags = (point_read->withheld_flag << 2) | (point_read->keypoint_flag << 1) | (point_read->synthetic_flag << 0);;
+ point_write->extended_classification = point_read->classification;
+ point_write->extended_return_number = point_read->return_number;
+ point_write->extended_number_of_returns = point_read->number_of_returns;
+ point_write->extended_scan_angle = (laszip_I16)( (point_read->scan_angle_rank > 0) ? ((1.0 / 0.006 * point_read->scan_angle_rank) + 0.5) : ((1.0 / 0.006 * point_read->scan_angle_rank) - 0.5) );
+
+ if (point_read->num_extra_bytes)
+ {
+ memcpy(point_write->extra_bytes, point_read->extra_bytes, point_read->num_extra_bytes);
+ }
+
+ // write the point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+ }
+
+ fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // close the reader
+
+ if (laszip_close_reader(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // destroy the reader
+
+ if (laszip_destroy(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+ } // end of EXAMPLE_TEN
+
+ if (EXAMPLE == EXAMPLE_ELEVEN)
+ {
+ fprintf(stderr,"running EXAMPLE_ELEVEN (writing points to LAS 1.4 without a-priori knowlegde of bounding box or point count (compatibility only for LAZ))\n");
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // get a pointer to the header of the writer so we can populate it
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_writer, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // populate the header
+
+ header->file_source_ID = 4711;
+ header->global_encoding = (1<<0) | (1<<4); // see LAS specification for details
+ header->version_major = 1;
+ header->version_minor = 4;
+ strncpy(header->system_identifier, "LASzip DLL example 7", 32);
+ header->file_creation_day = 30;
+ header->file_creation_year = 2015;
+ header->header_size = 375;
+ header->offset_to_point_data = 375;
+ header->point_data_format = 6;
+ header->point_data_record_length = 30;
+ header->number_of_point_records = 0; // legacy 32-bit counters should be zero for new point types > 5
+ for (i = 0; i < 5; i++)
+ {
+ header->number_of_points_by_return[i] = 0; // legacy 32-bit counters should be zero for new point types > 5
+ }
+ header->extended_number_of_point_records = 0; // a-priori unknown number of points
+ for (i = 0; i < 15; i++)
+ {
+ header->extended_number_of_points_by_return[i] = 0;
+ }
+ header->max_x = 0.0; // a-priori unknown bounding box
+ header->min_x = 0.0;
+ header->max_y = 0.0;
+ header->min_y = 0.0;
+ header->max_z = 0.0;
+ header->min_z = 0.0;
+
+ fprintf(stderr,"offset_to_point_data before adding empty OGC WKT VLR is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // add intentionally empty OGC WKT
+
+ if (laszip_add_vlr(laszip_writer, "LASF_Projection", 2112, 0, "intentionally empty OGC WKT", 0))
+ {
+ fprintf(stderr,"DLL ERROR: adding intentionally empty OGC WKT VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data before adding funny VLR is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // add some funny VLR
+
+ if (laszip_add_vlr(laszip_writer, "funny", 12345, 0, "just a funny VLR", 0))
+ {
+ fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data after adding VLRs : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // compressed output or not?
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ // if compressed output was requested enable the compatibility mode
+
+ if (compress)
+ {
+ laszip_BOOL request = 1;
+ if (laszip_request_compatibility_mode(laszip_writer, request))
+ {
+ fprintf(stderr,"DLL ERROR: enabling laszip LAS 1.4 compatibility mode\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+ }
+
+ // open the writer
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // get a pointer to the point of the writer that we will populate and write
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_writer, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write five points
+
+ laszip_I64 p_count = 0;
+ laszip_F64 coordinates[3];
+
+ // populate the first point
+
+ coordinates[0] = 630499.95;
+ coordinates[1] = 4834749.17;
+ coordinates[2] = 62.15;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 60;
+ point->extended_return_number = 2;
+ point->extended_number_of_returns = 2;
+ point->classification = 2; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 2;
+ point->extended_scan_angle = 3500;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 8; // overflag flag is set
+ point->gps_time = 53413162.560400;
+
+ // write the first point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // update inventory with first point
+
+ if (laszip_update_inventory(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: updating inventory for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+
+ // populate the second point
+
+ coordinates[0] = 630499.83;
+ coordinates[1] = 4834748.88;
+ coordinates[2] = 62.68;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 90;
+ point->extended_return_number = 8;
+ point->extended_number_of_returns = 9;
+ point->classification = 0; // it must be set to zero as the real value is stored in the extended field
+ point->extended_classification = 41;
+ point->extended_scan_angle = 3567;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.563600;
+
+ // write the second point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // update inventory with second point
+
+ if (laszip_update_inventory(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: updating inventory for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+
+ // populate the third point
+
+ coordinates[0] = 630499.54;
+ coordinates[1] = 4834749.66;
+ coordinates[2] = 62.66;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 70;
+ point->extended_return_number = 9;
+ point->extended_number_of_returns = 9;
+ point->classification = 0; // it must be set to zero as the real value is stored in the extended field
+ point->extended_classification = 42;
+ point->extended_scan_angle = 3633;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.566800;
+
+ // write the third point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // update inventory with third point
+
+ if (laszip_update_inventory(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: updating inventory for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+
+ // populate the fourth point
+
+ coordinates[0] = 630498.56;
+ coordinates[1] = 4834749.41;
+ coordinates[2] = 63.68;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 20;
+ point->extended_return_number = 1;
+ point->extended_number_of_returns = 2;
+ point->classification = 5; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 5;
+ point->extended_scan_angle = 3700;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.580200;
+
+ // write the fourth point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // update inventory with fourth point
+
+ if (laszip_update_inventory(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: updating inventory for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+
+ // populate the fifth point
+
+ coordinates[0] = 630498.80;
+ coordinates[1] = 4834748.73;
+ coordinates[2] = 62.16;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 110;
+ point->extended_return_number = 2;
+ point->extended_number_of_returns = 2;
+ point->classification = 2; // it must be set because it "fits" in 5 bits
+ point->extended_classification = 2;
+ point->extended_scan_angle = 3767;
+ point->extended_scanner_channel = 1;
+ point->extended_classification_flags = 0; // no flag is not set
+ point->gps_time = 53413162.580200;
+
+ // write the fifth point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // update inventory with fifth point
+
+ if (laszip_update_inventory(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: updating inventory for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+
+ // get the number of points written so far
+
+ if (laszip_get_point_count(laszip_writer, &p_count))
+ {
+ fprintf(stderr,"DLL ERROR: getting point count\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"successfully written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
+
+ } // end of EXAMPLE_ELEVEN
+
+ if (EXAMPLE == EXAMPLE_TWELVE)
+ {
+ fprintf(stderr,"running EXAMPLE_TWELVE (changing chunk size to 5000 *with* compatibility when writing *only* for compressed output)\n");
+
+ // create the reader
+
+ laszip_POINTER laszip_reader;
+ if (laszip_create(&laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ // enable the compatibility mode for the reader
+
+ laszip_BOOL request_reader = 1;
+ if (laszip_request_compatibility_mode(laszip_reader, request_reader))
+ {
+ fprintf(stderr,"DLL ERROR: enabling laszip LAS 1.4 compatibility mode for the reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // open the reader
+
+ laszip_BOOL is_compressed = 0;
+ if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+ // get a pointer to the header of the reader that was just populated
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_reader, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // how many points does the file have
+
+ laszip_I64 npoints = (header->number_of_point_records ? header->number_of_point_records : header->extended_number_of_point_records);
+
+ // report how many points the file has
+
+ fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+ // get a pointer to the points that will be read
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_reader, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // check if the output is compressed
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ // *only* enable the compatibility mode for the writer for compressed output
+
+ if (compress)
+ {
+ laszip_BOOL request_writer = 1;
+ if (laszip_request_compatibility_mode(laszip_writer, request_writer))
+ {
+ fprintf(stderr,"DLL ERROR: enabling laszip LAS 1.4 compatibility mode for the writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+ }
+
+ // initialize the header for the writer using the header of the reader
+
+ if (laszip_set_header(laszip_writer, header))
+ {
+ fprintf(stderr,"DLL ERROR: setting header for laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // change the chunk size from the default value to 50000
+
+ if (laszip_set_chunk_size(laszip_writer, 5000))
+ {
+ fprintf(stderr,"DLL ERROR: setting chunk size 5000 for laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // open the writer
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // read the points
+
+ laszip_I64 p_count = 0;
+
+ while (p_count < npoints)
+ {
+ // read a point
+
+ if (laszip_read_point(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: reading point %I64\n", p_count);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // copy the point
+
+ if (laszip_set_point(laszip_writer, point))
+ {
+ fprintf(stderr,"DLL ERROR: setting point %I64\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write the point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+ }
+
+ fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // close the reader
+
+ if (laszip_close_reader(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // destroy the reader
+
+ if (laszip_destroy(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+ } // end of EXAMPLE_TWELVE
+
+ if (EXAMPLE == EXAMPLE_THIRTEEN)
+ {
+ fprintf(stderr,"running EXAMPLE_THIRTEEN (*with* compatibility mode when reading compressed LAS 1.4 and *with* native extension when writing compressed LAS 1.4)\n");
+
+ // create the reader
+
+ laszip_POINTER laszip_reader;
+ if (laszip_create(&laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ // request compatibility mode for the reader
+
+ laszip_BOOL request_compatibility = 1;
+ if (laszip_request_compatibility_mode(laszip_reader, request_compatibility))
+ {
+ fprintf(stderr,"DLL ERROR: requesting LAS 1.4 compatibility mode for the reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // open the reader
+
+ laszip_BOOL is_compressed = 0;
+ if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+ // get a pointer to the header of the reader that was just populated
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_reader, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // how many points does the file have
+
+ laszip_I64 npoints = (header->number_of_point_records ? header->number_of_point_records : header->extended_number_of_point_records);
+
+ // report how many points the file has
+
+ fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+ // get a pointer to the points that will be read
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_reader, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // request native extension for the writer
+
+ laszip_BOOL request_native = 1;
+ if (laszip_request_native_extension(laszip_writer, request_native))
+ {
+ fprintf(stderr,"DLL ERROR: requesting native LAS 1.4 extension for the writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // initialize the header for the writer using the header of the reader
+
+ if (laszip_set_header(laszip_writer, header))
+ {
+ fprintf(stderr,"DLL ERROR: setting header for laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // check if the output is compressed
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ // open the writer
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // read the points
+
+ laszip_I64 p_count = 0;
+
+ while (p_count < npoints)
+ {
+ // read a point
+
+ if (laszip_read_point(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: reading point %I64\n", p_count);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // copy the point
+
+ if (laszip_set_point(laszip_writer, point))
+ {
+ fprintf(stderr,"DLL ERROR: setting point %I64\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write the point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+ }
+
+ fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // close the reader
+
+ if (laszip_close_reader(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // destroy the reader
+
+ if (laszip_destroy(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+ } // end of EXAMPLE_THIRTEEN
+
+ if (EXAMPLE == EXAMPLE_FOURTEEN)
+ {
+ fprintf(stderr,"running EXAMPLE_FOURTEEN (selective decompression of XYZ when reading native compressed LAS 1.4\n");
+
+ // create the reader
+
+ laszip_POINTER laszip_reader;
+ if (laszip_create(&laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ // request compatibility mode for the reader
+
+ laszip_BOOL request_compatibility = 1;
+ if (laszip_request_compatibility_mode(laszip_reader, request_compatibility))
+ {
+ fprintf(stderr,"DLL ERROR: requesting LAS 1.4 compatibility mode for the reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // request compatibility mode for the reader
+
+ laszip_U32 decompress_selective = laszip_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY | laszip_DECOMPRESS_SELECTIVE_Z;
+ if (laszip_decompress_selective(laszip_reader, decompress_selective))
+ {
+ fprintf(stderr,"DLL ERROR: decompressing XYZ selectively for the reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // open the reader
+
+ laszip_BOOL is_compressed = 0;
+ if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+ // get a pointer to the header of the reader that was just populated
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_reader, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // how many points does the file have
+
+ laszip_I64 npoints = (header->number_of_point_records ? header->number_of_point_records : header->extended_number_of_point_records);
+
+ // report how many points the file has
+
+ fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+ // get a pointer to the points that will be read
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_reader, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // request native extension for the writer
+
+ laszip_BOOL request_native = 1;
+ if (laszip_request_native_extension(laszip_writer, request_native))
+ {
+ fprintf(stderr,"DLL ERROR: requesting native LAS 1.4 extension for the writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // initialize the header for the writer using the header of the reader
+
+ if (laszip_set_header(laszip_writer, header))
+ {
+ fprintf(stderr,"DLL ERROR: setting header for laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // check if the output is compressed
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ // open the writer
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // read the points
+
+ laszip_I64 p_count = 0;
+
+ while (p_count < npoints)
+ {
+ // read a point
+
+ if (laszip_read_point(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: reading point %I64\n", p_count);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // copy the point
+
+ if (laszip_set_point(laszip_writer, point))
+ {
+ fprintf(stderr,"DLL ERROR: setting point %I64\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write the point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+ }
+
+ fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // close the reader
+
+ if (laszip_close_reader(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // destroy the reader
+
+ if (laszip_destroy(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+ } // end of EXAMPLE_FOURTEEN
+
+ if (EXAMPLE == EXAMPLE_FIFTEEN)
+ {
+ fprintf(stderr,"running EXAMPLE_FIFETEEN (reading and writing native compressed LAS 1.4 by copying the points)\n");
+
+ // create the reader
+
+ laszip_POINTER laszip_reader;
+ if (laszip_create(&laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ // request compatibility mode for the reader
+
+ laszip_BOOL request_compatibility = 1;
+ if (laszip_request_compatibility_mode(laszip_reader, request_compatibility))
+ {
+ fprintf(stderr,"DLL ERROR: requesting LAS 1.4 compatibility mode for the reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // open the reader
+
+ laszip_BOOL is_compressed = 0;
+ if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+ // get a pointer to the header of the reader that was just populated
+
+ laszip_header* header_read;
+
+ if (laszip_get_header_pointer(laszip_reader, &header_read))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // how many points does the file have
+
+ laszip_I64 npoints = (header_read->number_of_point_records ? header_read->number_of_point_records : header_read->extended_number_of_point_records);
+
+ // report how many points the file has
+
+ fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+ // get a pointer to the points that will be read
+
+ laszip_point* point_read;
+
+ if (laszip_get_point_pointer(laszip_reader, &point_read))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // get a pointer to the header of the writer so we can populate it
+
+ laszip_header* header_write;
+
+ if (laszip_get_header_pointer(laszip_writer, &header_write))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // populate the header
+
+ header_write->file_source_ID = header_read->file_source_ID;
+ header_write->global_encoding = header_read->global_encoding;
+ header_write->version_major = header_read->version_major;
+ header_write->version_minor = header_read->version_minor;
+ strncpy(header_write->system_identifier, "LASzip DLL example 15", 32);
+ header_write->file_creation_day = header_read->file_creation_day;
+ header_write->file_creation_year = header_read->file_creation_year;
+ header_write->header_size = header_read->header_size;
+ header_write->offset_to_point_data = header_read->header_size; // real offset_to_point_data is calculated when adding VLRs
+ header_write->point_data_format = header_read->point_data_format;
+ header_write->point_data_record_length = header_read->point_data_record_length;
+ if ((header_read->point_data_format > 5) || (header_read->extended_number_of_point_records > (2<<32-1)))
+ {
+ // legacy 32-bit counters should be zero for new point types > 5 or if there are more than 2<<32-1 points
+ header_write->number_of_point_records = 0;
+ for (i = 0; i < 5; i++)
+ {
+ header_write->number_of_points_by_return[i] = 0;
+ }
+ }
+ else
+ {
+ // legacy 32-bit counters should be populated
+ header_write->number_of_point_records = (header_read->number_of_point_records ? header_read->number_of_point_records : (laszip_U32)(header_read->extended_number_of_point_records));
+ for (i = 0; i < 5; i++)
+ {
+ header_write->number_of_points_by_return[i] = (header_read->number_of_points_by_return[i] ? header_read->number_of_points_by_return[i] : (laszip_U32)(header_read->extended_number_of_points_by_return[i]));
+ }
+ }
+ header_write->extended_number_of_point_records = header_read->extended_number_of_point_records;
+ for (i = 0; i < 15; i++)
+ {
+ header_write->extended_number_of_points_by_return[i] = header_read->extended_number_of_points_by_return[i];
+ }
+ header_write->x_scale_factor = header_read->x_scale_factor;
+ header_write->y_scale_factor = header_read->y_scale_factor;
+ header_write->z_scale_factor = header_read->z_scale_factor;
+ header_write->x_offset = header_read->x_offset;
+ header_write->y_offset = header_read->y_offset;
+ header_write->z_offset = header_read->z_offset;
+ header_write->max_x = header_read->max_x;
+ header_write->min_x = header_read->min_x;
+ header_write->max_y = header_read->max_y;
+ header_write->min_y = header_read->min_y;
+ header_write->max_z = header_read->max_z;
+ header_write->min_z = header_read->min_z;
+
+ // extended VLRs or Waveforms are not supported yet
+
+ header_write->start_of_waveform_data_packet_record = 0;
+ header_write->number_of_extended_variable_length_records = 0;
+ header_write->start_of_first_extended_variable_length_record = 0;
+
+ // add VLRs
+
+ for (i = 0; i < header_read->number_of_variable_length_records; i++)
+ {
+ if (laszip_add_vlr(laszip_writer, header_read->vlrs[i].user_id, header_read->vlrs[i].record_id, header_read->vlrs[i].record_length_after_header, header_read->vlrs[i].description, header_read->vlrs[i].data))
+ {
+ fprintf(stderr,"DLL ERROR: adding VLR[%d] to the header\n", i);
+ byebye(true, argc==1, laszip_writer);
+ }
+ fprintf(stderr,"offset_to_point_data after adding VLR[%d] : %d\n", i, (laszip_I32)header_write->offset_to_point_data);
+ }
+
+ // open the writer
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // get a pointer to the point of the writer that we will populate and write
+
+ laszip_point* point_write;
+
+ if (laszip_get_point_pointer(laszip_writer, &point_write))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // read and write all the points
+
+ laszip_I64 p_count = 0;
+
+ while (p_count < npoints)
+ {
+ // read a point
+
+ if (laszip_read_point(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: reading point %I64\n", p_count);
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // copy the point
+
+ point_write->X = point_read->X;
+ point_write->Y = point_read->Y;
+ point_write->Z = point_read->Z;
+ point_write->intensity = point_read->intensity;
+ point_write->scan_direction_flag = point_read->scan_direction_flag;
+ point_write->edge_of_flight_line = point_read->edge_of_flight_line;
+ point_write->withheld_flag = point_read->withheld_flag;
+ point_write->keypoint_flag = point_read->keypoint_flag;
+ point_write->synthetic_flag = point_read->synthetic_flag;
+ point_write->classification = point_read->classification;
+ point_write->user_data = point_read->user_data;
+ point_write->point_source_ID = point_read->point_source_ID;
+
+ point_write->gps_time = point_read->gps_time;
+ memcpy(point_write->rgb, point_read->rgb, 8);
+
+ if (point_write->extended_point_type)
+ {
+ point_write->extended_scanner_channel = point_read->extended_scanner_channel;
+ point_write->extended_classification_flags = point_read->extended_classification_flags;
+ point_write->extended_classification = point_read->extended_classification;
+ point_write->extended_return_number = point_read->extended_return_number;
+ point_write->extended_number_of_returns = point_read->extended_number_of_returns;
+ point_write->extended_scan_angle = point_read->extended_scan_angle;
+ }
+ else
+ {
+ point_write->return_number = point_read->return_number;
+ point_write->number_of_returns = point_read->number_of_returns;
+ point_write->scan_angle_rank = point_read->scan_angle_rank;
+ }
+
+ if (point_read->num_extra_bytes)
+ {
+ memcpy(point_write->extra_bytes, point_read->extra_bytes, point_read->num_extra_bytes);
+ }
+
+ // write the point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ p_count++;
+ }
+
+ fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // close the reader
+
+ if (laszip_close_reader(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+ byebye(true, argc==1, laszip_reader);
+ }
+
+ // destroy the reader
+
+ if (laszip_destroy(laszip_reader))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+ } // end of EXAMPLE_FIFTEEN
+
+ if (EXAMPLE == EXAMPLE_SIXTEEN)
+ {
+ fprintf(stderr,"running EXAMPLE_SIXTEEN (writing three points of type 6 to LAS 1.4 file)\n");
+
+ // create the writer
+
+ laszip_POINTER laszip_writer;
+ if (laszip_create(&laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ // get a pointer to the header of the writer so we can populate it
+
+ laszip_header* header;
+
+ if (laszip_get_header_pointer(laszip_writer, &header))
+ {
+ fprintf(stderr,"DLL ERROR: getting header pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // populate the header
+
+ header->file_source_ID = 4711;
+ header->global_encoding = 0x0001; // time stamps are in adjusted standard GPS time
+ header->version_major = 1;
+ header->version_minor = 4;
+ strncpy(header->system_identifier, "LASzip DLL example 16", 32);
+ header->file_creation_day = 120;
+ header->file_creation_year = 2018;
+ header->header_size = 375; // must be 375 for LAS 1.4
+ header->offset_to_point_data = 375; // must be at least 375 for LAS 1.4
+ header->number_of_variable_length_records = 0;
+ header->point_data_format = 6;
+ header->point_data_record_length = 30;
+ header->number_of_point_records = 0; // must be zero for point type 6 or higher
+ header->number_of_points_by_return[0] = 0; // must be zero for point type 6 or higher
+ header->number_of_points_by_return[1] = 0; // must be zero for point type 6 or higher
+ header->number_of_points_by_return[2] = 0; // must be zero for point type 6 or higher
+ header->number_of_points_by_return[3] = 0; // must be zero for point type 6 or higher
+ header->number_of_points_by_return[4] = 0; // must be zero for point type 6 or higher
+ header->max_x = 630499.95;
+ header->min_x = 630498.56;
+ header->max_y = 4834749.66;
+ header->min_y = 4834748.73;
+ header->max_z = 63.68;
+ header->min_z = 61.33;
+ header->extended_number_of_point_records = 3;
+ header->extended_number_of_points_by_return[0] = 2;
+ header->extended_number_of_points_by_return[1] = 1;
+ header->extended_number_of_points_by_return[2] = 0;
+ header->extended_number_of_points_by_return[3] = 0;
+ header->extended_number_of_points_by_return[4] = 0;
+ header->extended_number_of_points_by_return[5] = 0;
+ header->extended_number_of_points_by_return[6] = 0;
+ header->extended_number_of_points_by_return[7] = 0;
+ header->extended_number_of_points_by_return[8] = 0;
+ header->extended_number_of_points_by_return[9] = 0;
+ header->extended_number_of_points_by_return[10] = 0;
+ header->extended_number_of_points_by_return[11] = 0;
+ header->extended_number_of_points_by_return[12] = 0;
+ header->extended_number_of_points_by_return[13] = 0;
+ header->extended_number_of_points_by_return[14] = 0;
+
+ // optional: use the bounding box and the scale factor to create a "good" offset
+
+ if (laszip_auto_offset(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: during automatic offset creation\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data before adding funny VLR is : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // add some funny VLR
+
+ if (laszip_add_vlr(laszip_writer, "funny", 12345, 0, "just a funny VLR", 0))
+ {
+ fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // create the geokeys with the projection information
+
+ laszip_geokey_struct key_entries[5];
+
+ // projected coordinates
+ key_entries[0].key_id = 1024; // GTModelTypeGeoKey
+ key_entries[0].tiff_tag_location = 0;
+ key_entries[0].count = 1;
+ key_entries[0].value_offset = 1; // ModelTypeProjected
+
+ // projection
+ key_entries[1].key_id = 3072; // ProjectedCSTypeGeoKey
+ key_entries[1].tiff_tag_location = 0;
+ key_entries[1].count = 1;
+ key_entries[1].value_offset = 32613; // PCS_WGS84_UTM_zone_13N
+
+ // horizontal units
+ key_entries[2].key_id = 3076; // ProjLinearUnitsGeoKey
+ key_entries[2].tiff_tag_location = 0;
+ key_entries[2].count = 1;
+ key_entries[2].value_offset = 9001; // meters
+
+ // vertical units
+ key_entries[3].key_id = 4099; // VerticalUnitsGeoKey
+ key_entries[3].tiff_tag_location = 0;
+ key_entries[3].count = 1;
+ key_entries[3].value_offset = 9001; // meters
+
+ // vertical datum
+ key_entries[4].key_id = 4096; // VerticalCSTypeGeoKey
+ key_entries[4].tiff_tag_location = 0;
+ key_entries[4].count = 1;
+ key_entries[4].value_offset = 5030; // WGS84
+
+ // add the geokeys (create or replace the appropriate VLR)
+
+ fprintf(stderr,"offset_to_point_data before adding projection VLR : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ if (laszip_set_geokeys(laszip_writer, 5, key_entries))
+ {
+ fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"offset_to_point_data after adding two VLRs : %d\n", (laszip_I32)header->offset_to_point_data);
+
+ // open the writer
+
+ laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+ if (laszip_open_writer(laszip_writer, file_name_out, compress))
+ {
+ fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+ // get a pointer to the point of the writer that we will populate and write
+
+ laszip_point* point;
+
+ if (laszip_get_point_pointer(laszip_writer, &point))
+ {
+ fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // write three points
+
+ laszip_I64 p_count = 0;
+ laszip_F64 coordinates[3];
+
+ // populate the first point
+
+ coordinates[0] = 630499.95;
+ coordinates[1] = 4834749.17;
+ coordinates[2] = 63.15;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 60;
+ point->extended_return_number = 1;
+ point->extended_number_of_returns = 2;
+ point->extended_classification = 1;
+ point->extended_classification_flags = 0; // none
+ point->extended_scan_angle = (laszip_I16)((21.0/0.006) + 0.5);
+ point->gps_time = 1132762996.478024;
+
+ // write the first point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the second point
+
+ coordinates[0] = 630499.83;
+ coordinates[1] = 4834748.88;
+ coordinates[2] = 62.18;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 90;
+ point->extended_return_number = 2;
+ point->extended_number_of_returns = 2;
+ point->extended_classification = 1;
+ point->extended_classification_flags = 0x4 | 0x2 | 0x1; // withheld, keypoint, synthetic flag
+ point->extended_scan_angle = (laszip_I16)((21.0/0.006) + 0.5);
+ point->gps_time = 1132762996.478024;
+
+ // write the second point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // populate the third point
+
+ coordinates[0] = 630499.54;
+ coordinates[1] = 4834749.66;
+ coordinates[2] = 62.66;
+
+ if (laszip_set_coordinates(laszip_writer, coordinates))
+ {
+ fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ point->intensity = 70;
+ point->extended_return_number = 1;
+ point->extended_number_of_returns = 1;
+ point->extended_classification = 2;
+ point->extended_classification_flags = 0x8 | 0x4 | 0x2 | 0x1; // overlap, withheld, keypoint, synthetic flag
+ point->extended_scan_angle = (laszip_I16)((21.25/0.006) + 0.5);
+ point->gps_time = 1132762996.476224;
+
+ // write the third point
+
+ if (laszip_write_point(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+ byebye(true, argc==1, laszip_writer);
+ }
+ p_count++;
+
+ // get the number of points written so far
+
+ if (laszip_get_point_count(laszip_writer, &p_count))
+ {
+ fprintf(stderr,"DLL ERROR: getting point count\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ fprintf(stderr,"successfully written %I64d points\n", p_count);
+
+ // close the writer
+
+ if (laszip_close_writer(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+ byebye(true, argc==1, laszip_writer);
+ }
+
+ // destroy the writer
+
+ if (laszip_destroy(laszip_writer))
+ {
+ fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+ byebye(true, argc==1);
+ }
+
+ fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
+
+ } // end of EXAMPLE_SIXTEEN
+
+ // unload LASzip DLL
+
+ if (laszip_unload_dll())
+ {
+ fprintf(stderr,"DLL ERROR: unloading LASzip DLL\n");
+ byebye(true, argc==1);
+ }
+
+ return 0;
+}
diff --git a/libs/laszip/example/laszipdllexample.dsp b/libs/laszip/example/laszipdllexample.dsp
new file mode 100644
index 0000000..2b3e284
--- /dev/null
+++ b/libs/laszip/example/laszipdllexample.dsp
@@ -0,0 +1,120 @@
+# Microsoft Developer Studio Project File - Name="laszipdllexample" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=laszipdllexample - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "laszipdllexample.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "laszipdllexample.mak" CFG="laszipdllexample - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "laszipdllexample - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "laszipdllexample - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "laszipdllexample - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /w /W0 /GX /O2 /I "..\dll" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=copy Release\laszipdllexample.exe ..\dll\laszipdllexample.exe
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "laszipdllexample - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\dll" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=copy Debug\laszipdllexample.exe ..\dll\laszipdllexample.exe
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "laszipdllexample - Win32 Release"
+# Name "laszipdllexample - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\dll\laszip_api.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\laszipdllexample.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\dll\laszip_api.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/libs/laszip/laszip_api.h b/libs/laszip/laszip_api.h
new file mode 100644
index 0000000..7336e8e
--- /dev/null
+++ b/libs/laszip/laszip_api.h
@@ -0,0 +1,621 @@
+/*
+===============================================================================
+
+ FILE: laszip_api.h
+
+ CONTENTS:
+
+ A simple DLL interface to LASzip
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 22 August 2017 -- Add version info.
+ 4 August 2017 -- 'laszip_set_point_type_and_size()' as minimal setup for ostream writer
+ 3 August 2017 -- new 'laszip_create_laszip_vlr()' gets VLR as C++ std::vector
+ 29 July 2017 -- integrating minimal stream-based reading/writing into branch
+ 20 July 2017 -- Andrew Bell adds support for stream-based reading/writing.
+ 28 May 2017 -- support for "LAS 1.4 selective decompression" added into DLL API
+ 25 April 2017 -- adding initial support for new "native LAS 1.4 extension"
+ 8 January 2017 -- name change from 'laszip_dll.h' and integration Hobu's changes for Unix
+ 7 January 2017 -- set reserved field in LASzip VLR from 0xAABB to 0x0
+ 7 January 2017 -- make scan angle quantization in compatibility mode consistent with LIB
+ 7 January 2017 -- compatibility mode *decompression* fix for points with waveforms
+ 23 September 2015 -- correct update of bounding box and counters from inventory on closing
+ 22 September 2015 -- bug fix for not overwriting description of pre-existing "extra bytes"
+ 5 September 2015 -- "LAS 1.4 compatibility mode" now allows pre-existing "extra bytes"
+ 3 August 2015 -- incompatible DLL change for QSI-sponsored "LAS 1.4 compatibility mode"
+ 8 July 2015 -- adding support for NOAA-sponsored "LAS 1.4 compatibility mode"
+ 1 April 2015 -- adding exploitation and creation of spatial indexing information
+ 8 August 2013 -- added laszip_get_coordinates() and laszip_set_coordinates()
+ 6 August 2013 -- added laszip_auto_offset() and laszip_check_for_integer_overflow()
+ 31 July 2013 -- added laszip_get_point_count() for FUSION integration
+ 29 July 2013 -- reorganized to create an easy to use LASzip DLL
+
+===============================================================================
+*/
+
+#ifndef LASZIP_API_H
+#define LASZIP_API_H
+
+#ifdef LASZIP_API_VERSION
+#include
+#endif
+
+#ifdef _WIN32
+# ifdef LASZIP_DYN_LINK
+# ifdef LASZIP_SOURCE
+# define LASZIP_API __declspec(dllexport)
+# else
+# define LASZIP_API __declspec(dllimport)
+# endif
+# else
+# define LASZIP_API
+# endif
+#else
+# define LASZIP_API
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include
+
+/*---------------------------------------------------------------------------*/
+/*--------------- DLL variables to pass data to/from LASzip -----------------*/
+/*---------------------------------------------------------------------------*/
+
+#ifdef _WIN32
+typedef int laszip_BOOL;
+typedef unsigned char laszip_U8;
+typedef unsigned short laszip_U16;
+typedef unsigned int laszip_U32;
+typedef unsigned __int64 laszip_U64;
+typedef char laszip_I8;
+typedef short laszip_I16;
+typedef int laszip_I32;
+typedef __int64 laszip_I64;
+typedef char laszip_CHAR;
+typedef float laszip_F32;
+typedef double laszip_F64;
+typedef void* laszip_POINTER;
+#else
+#include
+typedef int laszip_BOOL;
+typedef uint8_t laszip_U8;
+typedef uint16_t laszip_U16;
+typedef uint32_t laszip_U32;
+typedef uint64_t laszip_U64;
+typedef int8_t laszip_I8;
+typedef int16_t laszip_I16;
+typedef int32_t laszip_I32;
+typedef int64_t laszip_I64;
+typedef char laszip_CHAR;
+typedef float laszip_F32;
+typedef double laszip_F64;
+typedef void* laszip_POINTER;
+#endif
+
+typedef struct laszip_geokey
+{
+ laszip_U16 key_id;
+ laszip_U16 tiff_tag_location;
+ laszip_U16 count;
+ laszip_U16 value_offset;
+} laszip_geokey_struct;
+
+typedef struct laszip_vlr
+{
+ laszip_U16 reserved;
+ laszip_CHAR user_id[16];
+ laszip_U16 record_id;
+ laszip_U16 record_length_after_header;
+ laszip_CHAR description[32];
+ laszip_U8* data;
+} laszip_vlr_struct;
+
+typedef struct laszip_header
+{
+ laszip_U16 file_source_ID;
+ laszip_U16 global_encoding;
+ laszip_U32 project_ID_GUID_data_1;
+ laszip_U16 project_ID_GUID_data_2;
+ laszip_U16 project_ID_GUID_data_3;
+ laszip_CHAR project_ID_GUID_data_4[8];
+ laszip_U8 version_major;
+ laszip_U8 version_minor;
+ laszip_CHAR system_identifier[32];
+ laszip_CHAR generating_software[32];
+ laszip_U16 file_creation_day;
+ laszip_U16 file_creation_year;
+ laszip_U16 header_size;
+ laszip_U32 offset_to_point_data;
+ laszip_U32 number_of_variable_length_records;
+ laszip_U8 point_data_format;
+ laszip_U16 point_data_record_length;
+ laszip_U32 number_of_point_records;
+ laszip_U32 number_of_points_by_return[5];
+ laszip_F64 x_scale_factor;
+ laszip_F64 y_scale_factor;
+ laszip_F64 z_scale_factor;
+ laszip_F64 x_offset;
+ laszip_F64 y_offset;
+ laszip_F64 z_offset;
+ laszip_F64 max_x;
+ laszip_F64 min_x;
+ laszip_F64 max_y;
+ laszip_F64 min_y;
+ laszip_F64 max_z;
+ laszip_F64 min_z;
+
+ // LAS 1.3 and higher only
+ laszip_U64 start_of_waveform_data_packet_record;
+
+ // LAS 1.4 and higher only
+ laszip_U64 start_of_first_extended_variable_length_record;
+ laszip_U32 number_of_extended_variable_length_records;
+ laszip_U64 extended_number_of_point_records;
+ laszip_U64 extended_number_of_points_by_return[15];
+
+ // optional
+ laszip_U32 user_data_in_header_size;
+ laszip_U8* user_data_in_header;
+
+ // optional VLRs
+ laszip_vlr_struct* vlrs;
+
+ // optional
+ laszip_U32 user_data_after_header_size;
+ laszip_U8* user_data_after_header;
+
+} laszip_header_struct;
+
+typedef struct laszip_point
+{
+ laszip_I32 X;
+ laszip_I32 Y;
+ laszip_I32 Z;
+ laszip_U16 intensity;
+ laszip_U8 return_number : 3;
+ laszip_U8 number_of_returns : 3;
+ laszip_U8 scan_direction_flag : 1;
+ laszip_U8 edge_of_flight_line : 1;
+ laszip_U8 classification : 5;
+ laszip_U8 synthetic_flag : 1;
+ laszip_U8 keypoint_flag : 1;
+ laszip_U8 withheld_flag : 1;
+ laszip_I8 scan_angle_rank;
+ laszip_U8 user_data;
+ laszip_U16 point_source_ID;
+
+ // LAS 1.4 only
+ laszip_I16 extended_scan_angle;
+ laszip_U8 extended_point_type : 2;
+ laszip_U8 extended_scanner_channel : 2;
+ laszip_U8 extended_classification_flags : 4;
+ laszip_U8 extended_classification;
+ laszip_U8 extended_return_number : 4;
+ laszip_U8 extended_number_of_returns : 4;
+
+ // for 8 byte alignment of the GPS time
+ laszip_U8 dummy[7];
+
+ laszip_F64 gps_time;
+ laszip_U16 rgb[4];
+ laszip_U8 wave_packet[29];
+
+ laszip_I32 num_extra_bytes;
+ laszip_U8* extra_bytes;
+
+} laszip_point_struct;
+
+/*---------------------------------------------------------------------------*/
+/*------ DLL constants for selective decompression via LASzip DLL -----------*/
+/*---------------------------------------------------------------------------*/
+
+#define laszip_DECOMPRESS_SELECTIVE_ALL 0xFFFFFFFF
+
+#define laszip_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY 0x00000000
+#define laszip_DECOMPRESS_SELECTIVE_Z 0x00000001
+#define laszip_DECOMPRESS_SELECTIVE_CLASSIFICATION 0x00000002
+#define laszip_DECOMPRESS_SELECTIVE_FLAGS 0x00000004
+#define laszip_DECOMPRESS_SELECTIVE_INTENSITY 0x00000008
+#define laszip_DECOMPRESS_SELECTIVE_SCAN_ANGLE 0x00000010
+#define laszip_DECOMPRESS_SELECTIVE_USER_DATA 0x00000020
+#define laszip_DECOMPRESS_SELECTIVE_POINT_SOURCE 0x00000040
+#define laszip_DECOMPRESS_SELECTIVE_GPS_TIME 0x00000080
+#define laszip_DECOMPRESS_SELECTIVE_RGB 0x00000100
+#define laszip_DECOMPRESS_SELECTIVE_NIR 0x00000200
+#define laszip_DECOMPRESS_SELECTIVE_WAVEPACKET 0x00000400
+#define laszip_DECOMPRESS_SELECTIVE_BYTE0 0x00010000
+#define laszip_DECOMPRESS_SELECTIVE_BYTE1 0x00020000
+#define laszip_DECOMPRESS_SELECTIVE_BYTE2 0x00040000
+#define laszip_DECOMPRESS_SELECTIVE_BYTE3 0x00080000
+#define laszip_DECOMPRESS_SELECTIVE_BYTE4 0x00100000
+#define laszip_DECOMPRESS_SELECTIVE_BYTE5 0x00200000
+#define laszip_DECOMPRESS_SELECTIVE_BYTE6 0x00400000
+#define laszip_DECOMPRESS_SELECTIVE_BYTE7 0x00800000
+#define laszip_DECOMPRESS_SELECTIVE_EXTRA_BYTES 0xFFFF0000
+
+/*---------------------------------------------------------------------------*/
+/*---------------- DLL functions to manage the LASzip DLL -------------------*/
+/*---------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_get_version
+(
+ laszip_U8* version_major
+ , laszip_U8* version_minor
+ , laszip_U16* version_revision
+ , laszip_U32* version_build
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_create(
+ laszip_POINTER* pointer
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_get_error
+(
+ laszip_POINTER pointer
+ , laszip_CHAR** error
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_get_warning
+(
+ laszip_POINTER pointer
+ , laszip_CHAR** warning
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_clean(
+ laszip_POINTER pointer
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_destroy(
+ laszip_POINTER pointer
+);
+
+/*---------------------------------------------------------------------------*/
+/*---------- DLL functions to write and read LAS and LAZ files --------------*/
+/*---------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_get_header_pointer(
+ laszip_POINTER pointer
+ , laszip_header_struct** header_pointer
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_get_point_pointer(
+ laszip_POINTER pointer
+ , laszip_point_struct** point_pointer
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_get_point_count(
+ laszip_POINTER pointer
+ , laszip_I64* count
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_set_header(
+ laszip_POINTER pointer
+ , const laszip_header_struct* header
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_set_point_type_and_size(
+ laszip_POINTER pointer
+ , laszip_U8 point_type
+ , laszip_U16 point_size
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_check_for_integer_overflow(
+ laszip_POINTER pointer
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_auto_offset(
+ laszip_POINTER pointer
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_set_point(
+ laszip_POINTER pointer
+ , const laszip_point_struct* point
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_set_coordinates(
+ laszip_POINTER pointer
+ , const laszip_F64* coordinates
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_get_coordinates(
+ laszip_POINTER pointer
+ , laszip_F64* coordinates
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_set_geokeys(
+ laszip_POINTER pointer
+ , laszip_U32 number
+ , const laszip_geokey_struct* key_entries
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_set_geodouble_params(
+ laszip_POINTER pointer
+ , laszip_U32 number
+ , const laszip_F64* geodouble_params
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_set_geoascii_params(
+ laszip_POINTER pointer
+ , laszip_U32 number
+ , const laszip_CHAR* geoascii_params
+);
+
+/*---------------------------------------------------------------------------*/
+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
+);
+
+/*---------------------------------------------------------------------------*/
+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
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_remove_vlr(
+ laszip_POINTER pointer
+ , const laszip_CHAR* user_id
+ , laszip_U16 record_id
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_create_spatial_index(
+ laszip_POINTER pointer
+ , const laszip_BOOL create
+ , const laszip_BOOL append
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_preserve_generating_software(
+ laszip_POINTER pointer
+ , const laszip_BOOL preserve
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_request_native_extension(
+ laszip_POINTER pointer
+ , const laszip_BOOL request
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_request_compatibility_mode(
+ laszip_POINTER pointer
+ , const laszip_BOOL request
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_set_chunk_size(
+ laszip_POINTER pointer
+ , const laszip_U32 chunk_size
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_open_writer(
+ laszip_POINTER pointer
+ , const laszip_CHAR* file_name
+ , laszip_BOOL compress
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_write_point(
+ laszip_POINTER pointer
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_write_indexed_point(
+ laszip_POINTER pointer
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_update_inventory(
+ laszip_POINTER pointer
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_close_writer(
+ laszip_POINTER pointer
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_exploit_spatial_index(
+ laszip_POINTER pointer
+ , const laszip_BOOL exploit
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_decompress_selective(
+ laszip_POINTER pointer
+ , const laszip_U32 decompress_selective
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_open_reader(
+ laszip_POINTER pointer
+ , const laszip_CHAR* file_name
+ , laszip_BOOL* is_compressed
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_has_spatial_index(
+ laszip_POINTER pointer
+ , laszip_BOOL* is_indexed
+ , laszip_BOOL* is_appended
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_inside_rectangle(
+ laszip_POINTER pointer
+ , laszip_F64 min_x
+ , laszip_F64 min_y
+ , laszip_F64 max_x
+ , laszip_F64 max_y
+ , laszip_BOOL* is_empty
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_seek_point(
+ laszip_POINTER pointer
+ , laszip_I64 index
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_read_point(
+ laszip_POINTER pointer
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_read_inside_point(
+ laszip_POINTER pointer
+ , laszip_BOOL* is_done
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_close_reader(
+ laszip_POINTER pointer
+);
+
+/*---------------------------------------------------------------------------*/
+/*---------------- DLL functions to load and unload LASzip ------------------*/
+/*---------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_load_dll
+(
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_unload_dll
+(
+);
+
+#ifdef __cplusplus
+} // extern "C"
+
+#if defined(_MSC_VER) && (_MSC_VER < 1300)
+#include
+#else
+#include
+#include
+using namespace std;
+#endif
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_open_reader_stream(
+ laszip_POINTER pointer
+ , istream& stream
+ , laszip_BOOL* is_compressed
+);
+
+/*---------------------------------------------------------------------------*/
+LASZIP_API laszip_I32
+laszip_open_writer_stream(
+ laszip_POINTER pointer
+ , ostream& stream
+ , laszip_BOOL compress
+ , laszip_BOOL do_not_write_header
+);
+
+/*---------------------------------------------------------------------------*/
+// make LASzip VLR for point type and point size already specified earlier
+LASZIP_API laszip_I32
+laszip_create_laszip_vlr(
+ laszip_POINTER pointer
+ , laszip_U8** vlr
+ , laszip_U32* vlr_size
+);
+
+#endif // __cplusplus
+
+#endif /* LASZIP_API_H */
diff --git a/libs/laszip/laszip_api_version.h.in b/libs/laszip/laszip_api_version.h.in
new file mode 100644
index 0000000..642db75
--- /dev/null
+++ b/libs/laszip/laszip_api_version.h.in
@@ -0,0 +1,44 @@
+/*
+===============================================================================
+
+ FILE: laszip_api_version.h
+
+ CONTENTS:
+
+ Version information for LASzip API interface
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 22 August 2017 -- Created
+
+===============================================================================
+*/
+
+#ifndef LASZIP_API_VERSION_H
+#define LASZIP_API_VERSION_H
+
+/*
+ * version settings
+ */
+#define LASZIP_API_VERSION_MAJOR @LASZIP_API_VERSION_MAJOR@
+#define LASZIP_API_VERSION_MINOR @LASZIP_API_VERSION_MINOR@
+#define LASZIP_API_VERSION_PATCH @LASZIP_API_VERSION_PATCH@
+
+#define HAVE_UNORDERED_MAP @HAVE_UNORDERED_MAP@
+
+#endif /* LASZIP_API_VERSION_H */
diff --git a/libs/laszip/src/CMakeLists.txt b/libs/laszip/src/CMakeLists.txt
new file mode 100644
index 0000000..e6255c1
--- /dev/null
+++ b/libs/laszip/src/CMakeLists.txt
@@ -0,0 +1,37 @@
+###############################################################################
+#
+# src/CMakeLists.txt controls building of laszip library
+#
+# Copyright (c) 2009 Mateusz Loskot
+#
+###############################################################################
+set(LASZIP_SOURCES
+ arithmeticdecoder.cpp
+ arithmeticencoder.cpp
+ arithmeticmodel.cpp
+ integercompressor.cpp
+ lasindex.cpp
+ lasinterval.cpp
+ lasquadtree.cpp
+ lasreaditemcompressed_v1.cpp
+ lasreaditemcompressed_v2.cpp
+ lasreaditemcompressed_v3.cpp
+ lasreaditemcompressed_v4.cpp
+ lasreadpoint.cpp
+ laswriteitemcompressed_v1.cpp
+ laswriteitemcompressed_v2.cpp
+ laswriteitemcompressed_v3.cpp
+ laswriteitemcompressed_v4.cpp
+ laswritepoint.cpp
+ laszip.cpp
+ laszip_dll.cpp
+ mydefs.cpp
+)
+
+add_definitions(-DLASZIPDLL_EXPORTS)
+add_definitions(-DUNORDERED)
+
+if(HAVE_UNORDERED_MAP)
+ add_definitions(-DHAVE_UNORDERED_MAP=1)
+endif(HAVE_UNORDERED_MAP)
+LASZIP_ADD_LIBRARY(${LASZIP_BASE_LIB_NAME} ${LASZIP_SOURCES})
diff --git a/libs/laszip/src/arithmeticdecoder.cpp b/libs/laszip/src/arithmeticdecoder.cpp
new file mode 100644
index 0000000..23a19f2
--- /dev/null
+++ b/libs/laszip/src/arithmeticdecoder.cpp
@@ -0,0 +1,342 @@
+/*
+===============================================================================
+
+ FILE: arithmeticdecoder.cpp
+
+ CONTENTS:
+
+ A modular C++ wrapper for an adapted version of Amir Said's FastAC Code.
+ see: http://www.cipr.rpi.edu/~said/FastAC.html
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2005-2017, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ see header file
+
+===============================================================================
+*/
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// **************************** -
+// ARITHMETIC CODING EXAMPLES -
+// **************************** -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// Fast arithmetic coding implementation -
+// -> 32-bit variables, 32-bit product, periodic updates, table decoding -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// Version 1.00 - April 25, 2004 -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// WARNING -
+// ========= -
+// -
+// The only purpose of this program is to demonstrate the basic principles -
+// of arithmetic coding. The original version of this code can be found in -
+// Digital Signal Compression: Principles and Practice -
+// (Cambridge University Press, 2011, ISBN: 9780511984655) -
+// -
+// Copyright (c) 2019 by Amir Said (said@ieee.org) & -
+// William A. Pearlman (pearlw@ecse.rpi.edu) -
+// -
+// Redistribution and use in source and binary forms, with or without -
+// modification, are permitted provided that the following conditions are -
+// met: -
+// -
+// 1. Redistributions of source code must retain the above copyright notice, -
+// this list of conditions and the following disclaimer. -
+// -
+// 2. Redistributions in binary form must reproduce the above copyright -
+// notice, this list of conditions and the following disclaimer in the -
+// documentation and/or other materials provided with the distribution. -
+// -
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -
+// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER -
+// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// A description of the arithmetic coding method used here is available in -
+// -
+// Lossless Compression Handbook, ed. K. Sayood -
+// Chapter 5: Arithmetic Coding (A. Said), pp. 101-152, Academic Press, 2003 -
+// -
+// A. Said, Introduction to Arithetic Coding Theory and Practice -
+// HP Labs report HPL-2004-76 - http://www.hpl.hp.com/techreports/ -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+#include "arithmeticdecoder.hpp"
+
+#include
+#include
+
+#include "arithmeticmodel.hpp"
+
+ArithmeticDecoder::ArithmeticDecoder()
+{
+ instream = 0;
+}
+
+BOOL ArithmeticDecoder::init(ByteStreamIn* instream, BOOL really_init)
+{
+ if (instream == 0) return FALSE;
+ this->instream = instream;
+ length = AC__MaxLength;
+ if (really_init)
+ {
+ value = (instream->getByte() << 24);
+ value |= (instream->getByte() << 16);
+ value |= (instream->getByte() << 8);
+ value |= (instream->getByte());
+ }
+ return TRUE;
+}
+
+void ArithmeticDecoder::done()
+{
+ instream = 0;
+}
+
+ArithmeticBitModel* ArithmeticDecoder::createBitModel()
+{
+ ArithmeticBitModel* m = new ArithmeticBitModel();
+ return m;
+}
+
+void ArithmeticDecoder::initBitModel(ArithmeticBitModel* m)
+{
+ m->init();
+}
+
+void ArithmeticDecoder::destroyBitModel(ArithmeticBitModel* m)
+{
+ delete m;
+}
+
+ArithmeticModel* ArithmeticDecoder::createSymbolModel(U32 n)
+{
+ ArithmeticModel* m = new ArithmeticModel(n, FALSE);
+ return m;
+}
+
+void ArithmeticDecoder::initSymbolModel(ArithmeticModel* m, U32 *table)
+{
+ m->init(table);
+}
+
+void ArithmeticDecoder::destroySymbolModel(ArithmeticModel* m)
+{
+ delete m;
+}
+
+U32 ArithmeticDecoder::decodeBit(ArithmeticBitModel* m)
+{
+ assert(m);
+
+ U32 x = m->bit_0_prob * (length >> BM__LengthShift); // product l x p0
+ U32 sym = (value >= x); // decision
+ // update & shift interval
+ if (sym == 0) {
+ length = x;
+ ++m->bit_0_count;
+ }
+ else {
+ value -= x; // shifted interval base = 0
+ length -= x;
+ }
+
+ if (length < AC__MinLength) renorm_dec_interval(); // renormalization
+ if (--m->bits_until_update == 0) m->update(); // periodic model update
+
+ return sym; // return data bit value
+}
+
+U32 ArithmeticDecoder::decodeSymbol(ArithmeticModel* m)
+{
+ U32 n, sym, x, y = length;
+
+ if (m->decoder_table) { // use table look-up for faster decoding
+
+ unsigned dv = value / (length >>= DM__LengthShift);
+ unsigned t = dv >> m->table_shift;
+
+ sym = m->decoder_table[t]; // initial decision based on table look-up
+ n = m->decoder_table[t+1] + 1;
+
+ while (n > sym + 1) { // finish with bisection search
+ U32 k = (sym + n) >> 1;
+ if (m->distribution[k] > dv) n = k; else sym = k;
+ }
+ // compute products
+ x = m->distribution[sym] * length;
+ if (sym != m->last_symbol) y = m->distribution[sym+1] * length;
+ }
+
+ else { // decode using only multiplications
+
+ x = sym = 0;
+ length >>= DM__LengthShift;
+ U32 k = (n = m->symbols) >> 1;
+ // decode via bisection search
+ do {
+ U32 z = length * m->distribution[k];
+ if (z > value) {
+ n = k;
+ y = z; // value is smaller
+ }
+ else {
+ sym = k;
+ x = z; // value is larger or equal
+ }
+ } while ((k = (sym + n) >> 1) != sym);
+ }
+
+ value -= x; // update interval
+ length = y - x;
+
+ if (length < AC__MinLength) renorm_dec_interval(); // renormalization
+
+ ++m->symbol_count[sym];
+ if (--m->symbols_until_update == 0) m->update(); // periodic model update
+
+ assert(sym < m->symbols);
+
+ return sym;
+}
+
+U32 ArithmeticDecoder::readBit()
+{
+ U32 sym = value / (length >>= 1); // decode symbol, change length
+ value -= length * sym; // update interval
+
+ if (length < AC__MinLength) renorm_dec_interval(); // renormalization
+
+ if (sym >= 2)
+ {
+ throw 4711;
+ }
+
+ return sym;
+}
+
+U32 ArithmeticDecoder::readBits(U32 bits)
+{
+ assert(bits && (bits <= 32));
+
+ if (bits > 19)
+ {
+ U32 tmp = readShort();
+ bits = bits - 16;
+ U32 tmp1 = readBits(bits) << 16;
+ return (tmp1|tmp);
+ }
+
+ U32 sym = value / (length >>= bits);// decode symbol, change length
+ value -= length * sym; // update interval
+
+ if (length < AC__MinLength) renorm_dec_interval(); // renormalization
+
+ if (sym >= (1u<>= 8); // decode symbol, change length
+ value -= length * sym; // update interval
+
+ if (length < AC__MinLength) renorm_dec_interval(); // renormalization
+
+ if (sym >= (1u<<8))
+ {
+ throw 4711;
+ }
+
+ return (U8)sym;
+}
+
+U16 ArithmeticDecoder::readShort()
+{
+ U32 sym = value / (length >>= 16); // decode symbol, change length
+ value -= length * sym; // update interval
+
+ if (length < AC__MinLength) renorm_dec_interval(); // renormalization
+
+ if (sym >= (1u<<16))
+ {
+ throw 4711;
+ }
+
+ return (U16)sym;
+}
+
+U32 ArithmeticDecoder::readInt()
+{
+ U32 lowerInt = readShort();
+ U32 upperInt = readShort();
+ return (upperInt<<16)|lowerInt;
+}
+
+F32 ArithmeticDecoder::readFloat() /* danger in float reinterpretation */
+{
+ U32I32F32 u32i32f32;
+ u32i32f32.u32 = readInt();
+ return u32i32f32.f32;
+}
+
+U64 ArithmeticDecoder::readInt64()
+{
+ U64 lowerInt = readInt();
+ U64 upperInt = readInt();
+ return (upperInt<<32)|lowerInt;
+}
+
+F64 ArithmeticDecoder::readDouble() /* danger in float reinterpretation */
+{
+ U64I64F64 u64i64f64;
+ u64i64f64.u64 = readInt64();
+ return u64i64f64.f64;
+}
+
+ArithmeticDecoder::~ArithmeticDecoder()
+{
+}
+
+inline void ArithmeticDecoder::renorm_dec_interval()
+{
+ do { // read least-significant byte
+ value = (value << 8) | instream->getByte();
+ } while ((length <<= 8) < AC__MinLength); // length multiplied by 256
+}
diff --git a/libs/laszip/src/arithmeticdecoder.hpp b/libs/laszip/src/arithmeticdecoder.hpp
new file mode 100644
index 0000000..9608450
--- /dev/null
+++ b/libs/laszip/src/arithmeticdecoder.hpp
@@ -0,0 +1,109 @@
+/*
+===============================================================================
+
+ FILE: arithmeticdecoder.hpp
+
+ CONTENTS:
+
+ A modular C++ wrapper for an adapted version of Amir Said's FastAC Code.
+ see: http://www.cipr.rpi.edu/~said/FastAC.html
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 22 August 2016 -- can be used as init dummy by "native LAS 1.4 compressor"
+ 13 November 2014 -- integrity check in readBits(), readByte(), readShort()
+ 6 September 2014 -- removed the (unused) inheritance from EntropyDecoder
+ 10 January 2011 -- licensing change for LGPL release and liblas integration
+ 8 December 2010 -- unified framework for all entropy coders
+ 30 October 2009 -- refactoring Amir Said's FastAC code
+
+===============================================================================
+*/
+#ifndef ARITHMETIC_DECODER_HPP
+#define ARITHMETIC_DECODER_HPP
+
+#include "mydefs.hpp"
+#include "bytestreamin.hpp"
+
+class ArithmeticModel;
+class ArithmeticBitModel;
+
+class ArithmeticDecoder
+{
+public:
+
+/* Constructor & Destructor */
+ ArithmeticDecoder();
+ ~ArithmeticDecoder();
+
+/* Manage decoding */
+ BOOL init(ByteStreamIn* instream, BOOL really_init = TRUE);
+ void done();
+
+/* Manage an entropy model for a single bit */
+ ArithmeticBitModel* createBitModel();
+ void initBitModel(ArithmeticBitModel* model);
+ void destroyBitModel(ArithmeticBitModel* model);
+
+/* Manage an entropy model for n symbols (table optional) */
+ ArithmeticModel* createSymbolModel(U32 n);
+ void initSymbolModel(ArithmeticModel* model, U32* table=0);
+ void destroySymbolModel(ArithmeticModel* model);
+
+/* Decode a bit with modelling */
+ U32 decodeBit(ArithmeticBitModel* model);
+
+/* Decode a symbol with modelling */
+ U32 decodeSymbol(ArithmeticModel* model);
+
+/* Decode a bit without modelling */
+ U32 readBit();
+
+/* Decode bits without modelling */
+ U32 readBits(U32 bits);
+
+/* Decode an unsigned char without modelling */
+ U8 readByte();
+
+/* Decode an unsigned short without modelling */
+ U16 readShort();
+
+/* Decode an unsigned int without modelling */
+ U32 readInt();
+
+/* Decode a float without modelling */
+ F32 readFloat();
+
+/* Decode an unsigned 64 bit int without modelling */
+ U64 readInt64();
+
+/* Decode a double without modelling */
+ F64 readDouble();
+
+/* Only read from instream if ArithmeticDecoder is dummy */
+ ByteStreamIn* getByteStreamIn() const { return instream; };
+
+private:
+
+ ByteStreamIn* instream;
+
+ void renorm_dec_interval();
+ U32 value, length;
+};
+
+#endif
diff --git a/libs/laszip/src/arithmeticencoder.cpp b/libs/laszip/src/arithmeticencoder.cpp
new file mode 100644
index 0000000..4ad8c8b
--- /dev/null
+++ b/libs/laszip/src/arithmeticencoder.cpp
@@ -0,0 +1,355 @@
+/*
+===============================================================================
+
+ FILE: arithmeticencoder.cpp
+
+ CONTENTS:
+
+ A modular C++ wrapper for an adapted version of Amir Said's FastAC Code.
+ see: http://www.cipr.rpi.edu/~said/FastAC.html
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ see header file
+
+===============================================================================
+*/
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// **************************** -
+// ARITHMETIC CODING EXAMPLES -
+// **************************** -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// Fast arithmetic coding implementation -
+// -> 32-bit variables, 32-bit product, periodic updates, table decoding -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// Version 1.00 - April 25, 2004 -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// WARNING -
+// ========= -
+// -
+// The only purpose of this program is to demonstrate the basic principles -
+// of arithmetic coding. The original version of this code can be found in -
+// Digital Signal Compression: Principles and Practice -
+// (Cambridge University Press, 2011, ISBN: 9780511984655) -
+// -
+// Copyright (c) 2019 by Amir Said (said@ieee.org) & -
+// William A. Pearlman (pearlw@ecse.rpi.edu) -
+// -
+// Redistribution and use in source and binary forms, with or without -
+// modification, are permitted provided that the following conditions are -
+// met: -
+// -
+// 1. Redistributions of source code must retain the above copyright notice, -
+// this list of conditions and the following disclaimer. -
+// -
+// 2. Redistributions in binary form must reproduce the above copyright -
+// notice, this list of conditions and the following disclaimer in the -
+// documentation and/or other materials provided with the distribution. -
+// -
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -
+// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER -
+// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// A description of the arithmetic coding method used here is available in -
+// -
+// Lossless Compression Handbook, ed. K. Sayood -
+// Chapter 5: Arithmetic Coding (A. Said), pp. 101-152, Academic Press, 2003 -
+// -
+// A. Said, Introduction to Arithetic Coding Theory and Practice -
+// HP Labs report HPL-2004-76 - http://www.hpl.hp.com/techreports/ -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+#include "arithmeticencoder.hpp"
+
+#include
+#include
+
+#include
+
+FILE* file = 0;
+
+#include "arithmeticmodel.hpp"
+
+ArithmeticEncoder::ArithmeticEncoder()
+{
+ outstream = 0;
+
+ outbuffer = (U8*)malloc(sizeof(U8)*2*AC_BUFFER_SIZE);
+ endbuffer = outbuffer + 2 * AC_BUFFER_SIZE;
+}
+
+ArithmeticEncoder::~ArithmeticEncoder()
+{
+ free(outbuffer);
+}
+
+BOOL ArithmeticEncoder::init(ByteStreamOut* outstream)
+{
+ if (outstream == 0) return FALSE;
+ this->outstream = outstream;
+ base = 0;
+ length = AC__MaxLength;
+ outbyte = outbuffer;
+ endbyte = endbuffer;
+ return TRUE;
+}
+
+void ArithmeticEncoder::done()
+{
+ U32 init_base = base; // done encoding: set final data bytes
+ BOOL another_byte = TRUE;
+
+ if (length > 2 * AC__MinLength) {
+ base += AC__MinLength; // base offset
+ length = AC__MinLength >> 1; // set new length for 1 more byte
+ }
+ else {
+ base += AC__MinLength >> 1; // base offset
+ length = AC__MinLength >> 9; // set new length for 2 more bytes
+ another_byte = FALSE;
+ }
+
+ if (init_base > base) propagate_carry(); // overflow = carry
+ renorm_enc_interval(); // renormalization = output last bytes
+
+ if (endbyte != endbuffer)
+ {
+ assert(outbyte < outbuffer + AC_BUFFER_SIZE);
+ outstream->putBytes(outbuffer + AC_BUFFER_SIZE, AC_BUFFER_SIZE);
+ }
+ U32 buffer_size = (U32)(outbyte - outbuffer);
+ if (buffer_size) outstream->putBytes(outbuffer, buffer_size);
+
+ // write two or three zero bytes to be in sync with the decoder's byte reads
+ outstream->putByte(0);
+ outstream->putByte(0);
+ if (another_byte) outstream->putByte(0);
+
+ outstream = 0;
+}
+
+ArithmeticBitModel* ArithmeticEncoder::createBitModel()
+{
+ ArithmeticBitModel* m = new ArithmeticBitModel();
+ return m;
+}
+
+void ArithmeticEncoder::initBitModel(ArithmeticBitModel* m)
+{
+ m->init();
+}
+
+void ArithmeticEncoder::destroyBitModel(ArithmeticBitModel* m)
+{
+ delete m;
+}
+
+ArithmeticModel* ArithmeticEncoder::createSymbolModel(U32 n)
+{
+ ArithmeticModel* m = new ArithmeticModel(n, true);
+ return m;
+}
+
+void ArithmeticEncoder::initSymbolModel(ArithmeticModel* m, U32* table)
+{
+ m->init(table);
+}
+
+void ArithmeticEncoder::destroySymbolModel(ArithmeticModel* m)
+{
+ delete m;
+}
+
+void ArithmeticEncoder::encodeBit(ArithmeticBitModel* m, U32 sym)
+{
+ assert(m && (sym <= 1));
+
+ U32 x = m->bit_0_prob * (length >> BM__LengthShift); // product l x p0
+ // update interval
+ if (sym == 0) {
+ length = x;
+ ++m->bit_0_count;
+ }
+ else {
+ U32 init_base = base;
+ base += x;
+ length -= x;
+ if (init_base > base) propagate_carry(); // overflow = carry
+ }
+
+ if (length < AC__MinLength) renorm_enc_interval(); // renormalization
+ if (--m->bits_until_update == 0) m->update(); // periodic model update
+}
+
+void ArithmeticEncoder::encodeSymbol(ArithmeticModel* m, U32 sym)
+{
+ assert(m && (sym <= m->last_symbol));
+
+ U32 x, init_base = base;
+ // compute products
+ if (sym == m->last_symbol) {
+ x = m->distribution[sym] * (length >> DM__LengthShift);
+ base += x; // update interval
+ length -= x; // no product needed
+ }
+ else {
+ x = m->distribution[sym] * (length >>= DM__LengthShift);
+ base += x; // update interval
+ length = m->distribution[sym+1] * length - x;
+ }
+
+ if (init_base > base) propagate_carry(); // overflow = carry
+ if (length < AC__MinLength) renorm_enc_interval(); // renormalization
+
+ ++m->symbol_count[sym];
+ if (--m->symbols_until_update == 0) m->update(); // periodic model update
+}
+
+void ArithmeticEncoder::writeBit(U32 sym)
+{
+ assert(sym < 2);
+
+ U32 init_base = base;
+ base += sym * (length >>= 1); // new interval base and length
+
+ if (init_base > base) propagate_carry(); // overflow = carry
+ if (length < AC__MinLength) renorm_enc_interval(); // renormalization
+}
+
+void ArithmeticEncoder::writeBits(U32 bits, U32 sym)
+{
+ assert(bits && (bits <= 32) && (sym < (1u< 19)
+ {
+ writeShort(sym&U16_MAX);
+ sym = sym >> 16;
+ bits = bits - 16;
+ }
+
+ U32 init_base = base;
+ base += sym * (length >>= bits); // new interval base and length
+
+ if (init_base > base) propagate_carry(); // overflow = carry
+ if (length < AC__MinLength) renorm_enc_interval(); // renormalization
+}
+
+void ArithmeticEncoder::writeByte(U8 sym)
+{
+ U32 init_base = base;
+ base += (U32)(sym) * (length >>= 8); // new interval base and length
+
+ if (init_base > base) propagate_carry(); // overflow = carry
+ if (length < AC__MinLength) renorm_enc_interval(); // renormalization
+}
+
+void ArithmeticEncoder::writeShort(U16 sym)
+{
+ U32 init_base = base;
+ base += (U32)(sym) * (length >>= 16); // new interval base and length
+
+ if (init_base > base) propagate_carry(); // overflow = carry
+ if (length < AC__MinLength) renorm_enc_interval(); // renormalization
+}
+
+void ArithmeticEncoder::writeInt(U32 sym)
+{
+ writeShort((U16)(sym & 0xFFFF)); // lower 16 bits
+ writeShort((U16)(sym >> 16)); // UPPER 16 bits
+}
+
+void ArithmeticEncoder::writeFloat(F32 sym) /* danger in float reinterpretation */
+{
+ U32I32F32 u32i32f32;
+ u32i32f32.f32 = sym;
+ writeInt(u32i32f32.u32);
+}
+
+void ArithmeticEncoder::writeInt64(U64 sym)
+{
+ writeInt((U32)(sym & 0xFFFFFFFF)); // lower 32 bits
+ writeInt((U32)(sym >> 32)); // UPPER 32 bits
+}
+
+void ArithmeticEncoder::writeDouble(F64 sym) /* danger in float reinterpretation */
+{
+ U64I64F64 u64i64f64;
+ u64i64f64.f64 = sym;
+ writeInt64(u64i64f64.u64);
+}
+
+inline void ArithmeticEncoder::propagate_carry()
+{
+ U8 * p;
+ if (outbyte == outbuffer)
+ p = endbuffer - 1;
+ else
+ p = outbyte - 1;
+ while (*p == 0xFFU)
+ {
+ *p = 0;
+ if (p == outbuffer)
+ p = endbuffer - 1;
+ else
+ p--;
+ assert(outbuffer <= p);
+ assert(p < endbuffer);
+ assert(outbyte < endbuffer);
+ }
+ ++*p;
+}
+
+inline void ArithmeticEncoder::renorm_enc_interval()
+{
+ do { // output and discard top byte
+ assert(outbuffer <= outbyte);
+ assert(outbyte < endbuffer);
+ assert(outbyte < endbyte);
+ *outbyte++ = (U8)(base >> 24);
+ if (outbyte == endbyte) manage_outbuffer();
+ base <<= 8;
+ } while ((length <<= 8) < AC__MinLength); // length multiplied by 256
+}
+
+inline void ArithmeticEncoder::manage_outbuffer()
+{
+ if (outbyte == endbuffer) outbyte = outbuffer;
+ outstream->putBytes(outbyte, AC_BUFFER_SIZE);
+ endbyte = outbyte + AC_BUFFER_SIZE;
+ assert(endbyte > outbyte);
+ assert(outbyte < endbuffer);
+}
diff --git a/libs/laszip/src/arithmeticencoder.hpp b/libs/laszip/src/arithmeticencoder.hpp
new file mode 100644
index 0000000..4891611
--- /dev/null
+++ b/libs/laszip/src/arithmeticencoder.hpp
@@ -0,0 +1,114 @@
+/*
+===============================================================================
+
+ FILE: arithmeticencoder.hpp
+
+ CONTENTS:
+
+ A modular C++ wrapper for an adapted version of Amir Said's FastAC Code.
+ see: http://www.cipr.rpi.edu/~said/FastAC.html
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 1 July 2016 -- can be used as init dummy by "native LAS 1.4 compressor"
+ 6 September 2014 -- removed the (unused) inheritance from EntropyEncoder
+ 10 January 2011 -- licensing change for LGPL release and liblas integration
+ 8 December 2010 -- unified framework for all entropy coders
+ 30 October 2009 -- refactoring Amir Said's FastAC code
+
+===============================================================================
+*/
+#ifndef ARITHMETIC_ENCODER_HPP
+#define ARITHMETIC_ENCODER_HPP
+
+#include "mydefs.hpp"
+#include "bytestreamout.hpp"
+
+class ArithmeticModel;
+class ArithmeticBitModel;
+
+class ArithmeticEncoder
+{
+public:
+
+/* Constructor & Destructor */
+ ArithmeticEncoder();
+ ~ArithmeticEncoder();
+
+/* Manage encoding */
+ BOOL init(ByteStreamOut* outstream);
+ void done();
+
+/* Manage an entropy model for a single bit */
+ ArithmeticBitModel* createBitModel();
+ void initBitModel(ArithmeticBitModel* model);
+ void destroyBitModel(ArithmeticBitModel* model);
+
+/* Manage an entropy model for n symbols (table optional) */
+ ArithmeticModel* createSymbolModel(U32 n);
+ void initSymbolModel(ArithmeticModel* model, U32 *table=0);
+ void destroySymbolModel(ArithmeticModel* model);
+
+/* Encode a bit with modelling */
+ void encodeBit(ArithmeticBitModel* model, U32 sym);
+
+/* Encode a symbol with modelling */
+ void encodeSymbol(ArithmeticModel* model, U32 sym);
+
+/* Encode a bit without modelling */
+ void writeBit(U32 sym);
+
+/* Encode bits without modelling */
+ void writeBits(U32 bits, U32 sym);
+
+/* Encode an unsigned char without modelling */
+ void writeByte(U8 sym);
+
+/* Encode an unsigned short without modelling */
+ void writeShort(U16 sym);
+
+/* Encode an unsigned int without modelling */
+ void writeInt(U32 sym);
+
+/* Encode a float without modelling */
+ void writeFloat(F32 sym);
+
+/* Encode an unsigned 64 bit int without modelling */
+ void writeInt64(U64 sym);
+
+/* Encode a double without modelling */
+ void writeDouble(F64 sym);
+
+/* Only write to outstream if ArithmeticEncoder is dummy */
+ ByteStreamOut* getByteStreamOut() const { return outstream; };
+
+private:
+
+ ByteStreamOut* outstream;
+
+ void propagate_carry();
+ void renorm_enc_interval();
+ void manage_outbuffer();
+ U8* outbuffer;
+ U8* endbuffer;
+ U8* outbyte;
+ U8* endbyte;
+ U32 base, length;
+};
+
+#endif
diff --git a/libs/laszip/src/arithmeticmodel.cpp b/libs/laszip/src/arithmeticmodel.cpp
new file mode 100644
index 0000000..6d88b83
--- /dev/null
+++ b/libs/laszip/src/arithmeticmodel.cpp
@@ -0,0 +1,212 @@
+/*
+===============================================================================
+
+ FILE: arithmeticmodel.cpp
+
+ CONTENTS:
+
+ A modular C++ wrapper for an adapted version of Amir Said's FastAC Code.
+ see: http://www.cipr.rpi.edu/~said/FastAC.html
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ see header file
+
+===============================================================================
+*/
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// Fast arithmetic coding implementation -
+// -> 32-bit variables, 32-bit product, periodic updates, table decoding -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// Version 1.00 - April 25, 2004 -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// WARNING -
+// ========= -
+// -
+// The only purpose of this program is to demonstrate the basic principles -
+// of arithmetic coding. It is provided as is, without any express or -
+// implied warranty, without even the warranty of fitness for any particular -
+// purpose, or that the implementations are correct. -
+// -
+// Permission to copy and redistribute this code is hereby granted, provided -
+// that this warning and copyright notices are not removed or altered. -
+// -
+// Copyright (c) 2004 by Amir Said (said@ieee.org) & -
+// William A. Pearlman (pearlw@ecse.rpi.edu) -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -
+// A description of the arithmetic coding method used here is available in -
+// -
+// Lossless Compression Handbook, ed. K. Sayood -
+// Chapter 5: Arithmetic Coding (A. Said), pp. 101-152, Academic Press, 2003 -
+// -
+// A. Said, Introduction to Arithetic Coding Theory and Practice -
+// HP Labs report HPL-2004-76 - http://www.hpl.hp.com/techreports/ -
+// -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+#include "arithmeticmodel.hpp"
+
+#include
+#include
+
+ArithmeticModel::ArithmeticModel(U32 symbols, BOOL compress)
+{
+ this->symbols = symbols;
+ this->compress = compress;
+ distribution = 0;
+}
+
+ArithmeticModel::~ArithmeticModel()
+{
+ if (distribution) delete [] distribution;
+}
+
+I32 ArithmeticModel::init(U32* table)
+{
+ if (distribution == 0)
+ {
+ if ( (symbols < 2) || (symbols > (1 << 11)) )
+ {
+ return -1; // invalid number of symbols
+ }
+ last_symbol = symbols - 1;
+ if ((!compress) && (symbols > 16))
+ {
+ U32 table_bits = 3;
+ while (symbols > (1U << (table_bits + 2))) ++table_bits;
+ table_size = 1 << table_bits;
+ table_shift = DM__LengthShift - table_bits;
+ distribution = new U32[2*symbols+table_size+2];
+ decoder_table = distribution + 2 * symbols;
+ }
+ else // small alphabet: no table needed
+ {
+ decoder_table = 0;
+ table_size = table_shift = 0;
+ distribution = new U32[2*symbols];
+ }
+ if (distribution == 0)
+ {
+ return -1; // "cannot allocate model memory");
+ }
+ symbol_count = distribution + symbols;
+ }
+
+ total_count = 0;
+ update_cycle = symbols;
+ if (table)
+ for (U32 k = 0; k < symbols; k++) symbol_count[k] = table[k];
+ else
+ for (U32 k = 0; k < symbols; k++) symbol_count[k] = 1;
+
+ update();
+ symbols_until_update = update_cycle = (symbols + 6) >> 1;
+
+ return 0;
+}
+
+void ArithmeticModel::update()
+{
+ // halve counts when a threshold is reached
+ if ((total_count += update_cycle) > DM__MaxCount)
+ {
+ total_count = 0;
+ for (U32 n = 0; n < symbols; n++)
+ {
+ total_count += (symbol_count[n] = (symbol_count[n] + 1) >> 1);
+ }
+ }
+
+ // compute cumulative distribution, decoder table
+ U32 k, sum = 0, s = 0;
+ U32 scale = 0x80000000U / total_count;
+
+ if (compress || (table_size == 0))
+ {
+ for (k = 0; k < symbols; k++)
+ {
+ distribution[k] = (scale * sum) >> (31 - DM__LengthShift);
+ sum += symbol_count[k];
+ }
+ }
+ else
+ {
+ for (k = 0; k < symbols; k++)
+ {
+ distribution[k] = (scale * sum) >> (31 - DM__LengthShift);
+ sum += symbol_count[k];
+ U32 w = distribution[k] >> table_shift;
+ while (s < w) decoder_table[++s] = k - 1;
+ }
+ decoder_table[0] = 0;
+ while (s <= table_size) decoder_table[++s] = symbols - 1;
+ }
+
+ // set frequency of model updates
+ update_cycle = (5 * update_cycle) >> 2;
+ U32 max_cycle = (symbols + 6) << 3;
+ if (update_cycle > max_cycle) update_cycle = max_cycle;
+ symbols_until_update = update_cycle;
+}
+
+ArithmeticBitModel::ArithmeticBitModel()
+{
+ init();
+}
+
+ArithmeticBitModel::~ArithmeticBitModel()
+{
+}
+
+void ArithmeticBitModel::init()
+{
+ // initialization to equiprobable model
+ bit_0_count = 1;
+ bit_count = 2;
+ bit_0_prob = 1U << (BM__LengthShift - 1);
+ // start with frequent updates
+ update_cycle = bits_until_update = 4;
+}
+
+void ArithmeticBitModel::update()
+{
+ // halve counts when a threshold is reached
+ if ((bit_count += update_cycle) > BM__MaxCount)
+ {
+ bit_count = (bit_count + 1) >> 1;
+ bit_0_count = (bit_0_count + 1) >> 1;
+ if (bit_0_count == bit_count) ++bit_count;
+ }
+
+ // compute scaled bit 0 probability
+ U32 scale = 0x80000000U / bit_count;
+ bit_0_prob = (bit_0_count * scale) >> (31 - BM__LengthShift);
+
+ // set frequency of model updates
+ update_cycle = (5 * update_cycle) >> 2;
+ if (update_cycle > 64) update_cycle = 64;
+ bits_until_update = update_cycle;
+}
diff --git a/libs/laszip/src/arithmeticmodel.hpp b/libs/laszip/src/arithmeticmodel.hpp
new file mode 100644
index 0000000..36cbe52
--- /dev/null
+++ b/libs/laszip/src/arithmeticmodel.hpp
@@ -0,0 +1,92 @@
+/*
+===============================================================================
+
+ FILE: arithmeticmodel.hpp
+
+ CONTENTS:
+
+ A modular C++ wrapper for an adapted version of Amir Said's FastAC Code.
+ see: http://www.cipr.rpi.edu/~said/FastAC.html
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 11 April 2019 -- 1024 AC_BUFFER_SIZE to 4096 for propagate_carry() overflow
+ 10 January 2011 -- licensing change for LGPL release and liblas integration
+ 8 December 2010 -- unified framework for all entropy coders
+ 30 October 2009 -- refactoring Amir Said's FastAC code
+
+===============================================================================
+*/
+#ifndef ARITHMETIC_MODEL_HPP
+#define ARITHMETIC_MODEL_HPP
+
+#include
+#include
+
+#include "mydefs.hpp"
+
+/* this header byte needs to change in case incompatible change happen */
+#define AC_HEADER_BYTE 2
+#define AC_BUFFER_SIZE 4096
+
+const U32 AC__MinLength = 0x01000000U; // threshold for renormalization
+const U32 AC__MaxLength = 0xFFFFFFFFU; // maximum AC interval length
+
+ // Maximum values for binary models
+const U32 BM__LengthShift = 13; // length bits discarded before mult.
+const U32 BM__MaxCount = 1 << BM__LengthShift; // for adaptive models
+
+ // Maximum values for general models
+const U32 DM__LengthShift = 15; // length bits discarded before mult.
+const U32 DM__MaxCount = 1 << DM__LengthShift; // for adaptive models
+
+class ArithmeticModel
+{
+public:
+ ArithmeticModel(U32 symbols, BOOL compress);
+ ~ArithmeticModel();
+
+ I32 init(U32* table=0);
+
+private:
+ void update();
+ U32 * distribution, * symbol_count, * decoder_table;
+ U32 total_count, update_cycle, symbols_until_update;
+ U32 symbols, last_symbol, table_size, table_shift;
+ BOOL compress;
+ friend class ArithmeticEncoder;
+ friend class ArithmeticDecoder;
+};
+
+class ArithmeticBitModel
+{
+public:
+ ArithmeticBitModel();
+ ~ArithmeticBitModel();
+
+ void init();
+
+private:
+ void update();
+ U32 update_cycle, bits_until_update;
+ U32 bit_0_prob, bit_0_count, bit_count;
+ friend class ArithmeticEncoder;
+ friend class ArithmeticDecoder;
+};
+
+#endif
diff --git a/libs/laszip/src/bytestreamin.hpp b/libs/laszip/src/bytestreamin.hpp
new file mode 100644
index 0000000..b11509f
--- /dev/null
+++ b/libs/laszip/src/bytestreamin.hpp
@@ -0,0 +1,92 @@
+/*
+===============================================================================
+
+ FILE: bytestreamin.hpp
+
+ CONTENTS:
+
+ Abstract base class for input streams with endian handling.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 2 January 2013 -- new functions for reading a stream of groups of bits
+ 1 October 2011 -- added 64 bit file support in MSVC 6.0 at McCafe at Hbf Linz
+ 10 January 2011 -- licensing change for LGPL release and liblas integration
+ 12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-;
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_IN_HPP
+#define BYTE_STREAM_IN_HPP
+
+#include "mydefs.hpp"
+
+class ByteStreamIn
+{
+public:
+/* write single bits */
+ inline U32 getBits(U32 num_bits)
+ {
+ if (num_buffer < num_bits)
+ {
+ U32 input_bits;
+ get32bitsLE((U8*)&input_bits);
+ bit_buffer = bit_buffer | (((U64)input_bits) << num_buffer);
+ num_buffer = num_buffer + 32;
+ }
+ U32 new_bits = (U32)(bit_buffer & ((1 << num_bits) - 1));
+ bit_buffer = bit_buffer >> num_bits;
+ num_buffer = num_buffer - num_bits;
+ return new_bits;
+ };
+/* read a single byte */
+ virtual U32 getByte() = 0;
+/* read an array of bytes */
+ virtual void getBytes(U8* bytes, const U32 num_bytes) = 0;
+/* read 16 bit low-endian field */
+ virtual void get16bitsLE(U8* bytes) = 0;
+/* read 32 bit low-endian field */
+ virtual void get32bitsLE(U8* bytes) = 0;
+/* read 64 bit low-endian field */
+ virtual void get64bitsLE(U8* bytes) = 0;
+/* read 16 bit big-endian field */
+ virtual void get16bitsBE(U8* bytes) = 0;
+/* read 32 bit big-endian field */
+ virtual void get32bitsBE(U8* bytes) = 0;
+/* read 64 bit big-endian field */
+ virtual void get64bitsBE(U8* bytes) = 0;
+/* is the stream seekable (e.g. stdin is not) */
+ virtual BOOL isSeekable() const = 0;
+/* get current position of stream */
+ virtual I64 tell() const = 0;
+/* seek to this position in the stream */
+ virtual BOOL seek(const I64 position) = 0;
+/* seek to the end of the file */
+ virtual BOOL seekEnd(const I64 distance=0) = 0;
+/* seek to the end of the file */
+ virtual BOOL skipBytes(const U32 num_bytes) { I64 curr = tell(); return seek(curr + num_bytes); };
+/* constructor */
+ inline ByteStreamIn() { bit_buffer = 0; num_buffer = 0; };
+/* destructor */
+ virtual ~ByteStreamIn() {};
+private:
+ U64 bit_buffer;
+ U32 num_buffer;
+};
+
+#endif
diff --git a/libs/laszip/src/bytestreamin_array.hpp b/libs/laszip/src/bytestreamin_array.hpp
new file mode 100644
index 0000000..0b43d17
--- /dev/null
+++ b/libs/laszip/src/bytestreamin_array.hpp
@@ -0,0 +1,292 @@
+/*
+===============================================================================
+
+ FILE: bytestreamin_array.hpp
+
+ CONTENTS:
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 23 June 2016 -- alternative init option for "native LAS 1.4 compressor"
+ 19 July 2015 -- moved from LASlib to LASzip for "compatibility mode" in DLL
+ 9 April 2012 -- created after cooking Zuccini/Onion/Potatoe dinner for Mara
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_IN_ARRAY_H
+#define BYTE_STREAM_IN_ARRAY_H
+
+#include "bytestreamin.hpp"
+
+#include
+#include
+
+class ByteStreamInArray : public ByteStreamIn
+{
+public:
+ ByteStreamInArray();
+ ByteStreamInArray(const U8* data, I64 size);
+/* init the array */
+ BOOL init(const U8* data, I64 size);
+/* read a single byte */
+ U32 getByte();
+/* read an array of bytes */
+ void getBytes(U8* bytes, const U32 num_bytes);
+/* is the stream seekable (e.g. stdin is not) */
+ BOOL isSeekable() const;
+/* get current position of stream */
+ I64 tell() const;
+/* seek to this position in the stream */
+ BOOL seek(const I64 position);
+/* seek to the end of the stream */
+ BOOL seekEnd(const I64 distance=0);
+/* destructor */
+ ~ByteStreamInArray(){};
+protected:
+ const U8* data;
+ I64 size;
+ I64 curr;
+};
+
+class ByteStreamInArrayLE : public ByteStreamInArray
+{
+public:
+ ByteStreamInArrayLE();
+ ByteStreamInArrayLE(const U8* data, I64 size);
+/* read 16 bit low-endian field */
+ void get16bitsLE(U8* bytes);
+/* read 32 bit low-endian field */
+ void get32bitsLE(U8* bytes);
+/* read 64 bit low-endian field */
+ void get64bitsLE(U8* bytes);
+/* read 16 bit big-endian field */
+ void get16bitsBE(U8* bytes);
+/* read 32 bit big-endian field */
+ void get32bitsBE(U8* bytes);
+/* read 64 bit big-endian field */
+ void get64bitsBE(U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+class ByteStreamInArrayBE : public ByteStreamInArray
+{
+public:
+ ByteStreamInArrayBE();
+ ByteStreamInArrayBE(const U8* data, I64 size);
+/* read 16 bit low-endian field */
+ void get16bitsLE(U8* bytes);
+/* read 32 bit low-endian field */
+ void get32bitsLE(U8* bytes);
+/* read 64 bit low-endian field */
+ void get64bitsLE(U8* bytes);
+/* read 16 bit big-endian field */
+ void get16bitsBE(U8* bytes);
+/* read 32 bit big-endian field */
+ void get32bitsBE(U8* bytes);
+/* read 64 bit big-endian field */
+ void get64bitsBE(U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+inline ByteStreamInArray::ByteStreamInArray()
+{
+ this->data = 0;
+ this->size = 0;
+ this->curr = 0;
+}
+
+inline ByteStreamInArray::ByteStreamInArray(const U8* data, I64 size)
+{
+ init(data, size);
+}
+
+inline BOOL ByteStreamInArray::init(const U8* data, I64 size)
+{
+ this->curr = 0;
+ if (data)
+ {
+ this->data = data;
+ this->size = size;
+ }
+ else
+ {
+ this->data = 0;
+ this->size = 0;
+ if (size) return FALSE;
+ }
+ return TRUE;
+}
+
+inline U32 ByteStreamInArray::getByte()
+{
+ if (curr == size)
+ {
+ throw EOF;
+ }
+ U32 byte = data[curr];
+ curr++;
+ return byte;
+}
+
+inline void ByteStreamInArray::getBytes(U8* bytes, const U32 num_bytes)
+{
+ if ((curr + num_bytes) > size)
+ {
+ throw EOF;
+ }
+ memcpy((void*)bytes, (void*)(data+curr), num_bytes);
+ curr += num_bytes;
+}
+
+inline BOOL ByteStreamInArray::isSeekable() const
+{
+ return TRUE;
+}
+
+inline I64 ByteStreamInArray::tell() const
+{
+ return curr;
+}
+
+inline BOOL ByteStreamInArray::seek(const I64 position)
+{
+ if ((0 <= position) && (position <= size))
+ {
+ curr = position;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+inline BOOL ByteStreamInArray::seekEnd(const I64 distance)
+{
+ if ((0 <= distance) && (distance <= size))
+ {
+ curr = size - distance;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+inline ByteStreamInArrayLE::ByteStreamInArrayLE() : ByteStreamInArray()
+{
+}
+
+inline ByteStreamInArrayLE::ByteStreamInArrayLE(const U8* data, I64 size) : ByteStreamInArray(data, size)
+{
+}
+
+inline void ByteStreamInArrayLE::get16bitsLE(U8* bytes)
+{
+ getBytes(bytes, 2);
+}
+
+inline void ByteStreamInArrayLE::get32bitsLE(U8* bytes)
+{
+ getBytes(bytes, 4);
+}
+
+inline void ByteStreamInArrayLE::get64bitsLE(U8* bytes)
+{
+ getBytes(bytes, 8);
+}
+
+inline void ByteStreamInArrayLE::get16bitsBE(U8* bytes)
+{
+ getBytes(swapped, 2);
+ bytes[0] = swapped[1];
+ bytes[1] = swapped[0];
+}
+
+inline void ByteStreamInArrayLE::get32bitsBE(U8* bytes)
+{
+ getBytes(swapped, 4);
+ bytes[0] = swapped[3];
+ bytes[1] = swapped[2];
+ bytes[2] = swapped[1];
+ bytes[3] = swapped[0];
+}
+
+inline void ByteStreamInArrayLE::get64bitsBE(U8* bytes)
+{
+ getBytes(swapped, 8);
+ bytes[0] = swapped[7];
+ bytes[1] = swapped[6];
+ bytes[2] = swapped[5];
+ bytes[3] = swapped[4];
+ bytes[4] = swapped[3];
+ bytes[5] = swapped[2];
+ bytes[6] = swapped[1];
+ bytes[7] = swapped[0];
+}
+
+inline ByteStreamInArrayBE::ByteStreamInArrayBE() : ByteStreamInArray()
+{
+}
+
+inline ByteStreamInArrayBE::ByteStreamInArrayBE(const U8* data, I64 size) : ByteStreamInArray(data, size)
+{
+}
+
+inline void ByteStreamInArrayBE::get16bitsLE(U8* bytes)
+{
+ getBytes(swapped, 2);
+ bytes[0] = swapped[1];
+ bytes[1] = swapped[0];
+}
+
+inline void ByteStreamInArrayBE::get32bitsLE(U8* bytes)
+{
+ getBytes(swapped, 4);
+ bytes[0] = swapped[3];
+ bytes[1] = swapped[2];
+ bytes[2] = swapped[1];
+ bytes[3] = swapped[0];
+}
+
+inline void ByteStreamInArrayBE::get64bitsLE(U8* bytes)
+{
+ getBytes(swapped, 8);
+ bytes[0] = swapped[7];
+ bytes[1] = swapped[6];
+ bytes[2] = swapped[5];
+ bytes[3] = swapped[4];
+ bytes[4] = swapped[3];
+ bytes[5] = swapped[2];
+ bytes[6] = swapped[1];
+ bytes[7] = swapped[0];
+}
+
+inline void ByteStreamInArrayBE::get16bitsBE(U8* bytes)
+{
+ getBytes(bytes, 2);
+}
+
+inline void ByteStreamInArrayBE::get32bitsBE(U8* bytes)
+{
+ getBytes(bytes, 4);
+}
+
+inline void ByteStreamInArrayBE::get64bitsBE(U8* bytes)
+{
+ getBytes(bytes, 8);
+}
+
+#endif
diff --git a/libs/laszip/src/bytestreamin_file.hpp b/libs/laszip/src/bytestreamin_file.hpp
new file mode 100644
index 0000000..a403eb5
--- /dev/null
+++ b/libs/laszip/src/bytestreamin_file.hpp
@@ -0,0 +1,268 @@
+/*
+===============================================================================
+
+ FILE: bytestreamin_file.hpp
+
+ CONTENTS:
+
+ Class for FILE*-based input streams with endian handling.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 1 October 2011 -- added 64 bit file support in MSVC 6.0 at McCafe at Hbf Linz
+ 10 January 2011 -- licensing change for LGPL release and liblas integration
+ 12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-;
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_IN_FILE_H
+#define BYTE_STREAM_IN_FILE_H
+
+#include "bytestreamin.hpp"
+
+#include
+
+#if defined(_MSC_VER) && (_MSC_VER < 1300)
+extern "C" __int64 _cdecl _ftelli64(FILE*);
+extern "C" int _cdecl _fseeki64(FILE*, __int64, int);
+#endif
+
+class ByteStreamInFile : public ByteStreamIn
+{
+public:
+ ByteStreamInFile(FILE* file);
+/* read a single byte */
+ U32 getByte();
+/* read an array of bytes */
+ void getBytes(U8* bytes, const U32 num_bytes);
+/* is the stream seekable (e.g. stdin is not) */
+ BOOL isSeekable() const;
+/* get current position of stream */
+ I64 tell() const;
+/* seek to this position in the stream */
+ BOOL seek(const I64 position);
+/* seek to the end of the file */
+ BOOL seekEnd(const I64 distance=0);
+/* destructor */
+ ~ByteStreamInFile(){};
+protected:
+ FILE* file;
+};
+
+class ByteStreamInFileLE : public ByteStreamInFile
+{
+public:
+ ByteStreamInFileLE(FILE* file);
+/* read 16 bit low-endian field */
+ void get16bitsLE(U8* bytes);
+/* read 32 bit low-endian field */
+ void get32bitsLE(U8* bytes);
+/* read 64 bit low-endian field */
+ void get64bitsLE(U8* bytes);
+/* read 16 bit big-endian field */
+ void get16bitsBE(U8* bytes);
+/* read 32 bit big-endian field */
+ void get32bitsBE(U8* bytes);
+/* read 64 bit big-endian field */
+ void get64bitsBE(U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+class ByteStreamInFileBE : public ByteStreamInFile
+{
+public:
+ ByteStreamInFileBE(FILE* file);
+/* read 16 bit low-endian field */
+ void get16bitsLE(U8* bytes);
+/* read 32 bit low-endian field */
+ void get32bitsLE(U8* bytes);
+/* read 64 bit low-endian field */
+ void get64bitsLE(U8* bytes);
+/* read 16 bit big-endian field */
+ void get16bitsBE(U8* bytes);
+/* read 32 bit big-endian field */
+ void get32bitsBE(U8* bytes);
+/* read 64 bit big-endian field */
+ void get64bitsBE(U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+inline ByteStreamInFile::ByteStreamInFile(FILE* file)
+{
+ this->file = file;
+}
+
+inline U32 ByteStreamInFile::getByte()
+{
+ int byte = getc(file);
+ if (byte == EOF)
+ {
+ throw EOF;
+ }
+ return (U32)byte;
+}
+
+inline void ByteStreamInFile::getBytes(U8* bytes, const U32 num_bytes)
+{
+ if (fread(bytes, 1, num_bytes, file) != num_bytes)
+ {
+ throw EOF;
+ }
+}
+
+inline BOOL ByteStreamInFile::isSeekable() const
+{
+ return (file != stdin);
+}
+
+inline I64 ByteStreamInFile::tell() const
+{
+#if defined _WIN32 && ! defined (__MINGW32__)
+ return _ftelli64(file);
+#elif defined (__MINGW32__)
+ return (I64)ftello64(file);
+#else
+ return (I64)ftello(file);
+#endif
+}
+
+inline BOOL ByteStreamInFile::seek(const I64 position)
+{
+ if (tell() != position)
+ {
+#if defined _WIN32 && ! defined (__MINGW32__)
+ return !(_fseeki64(file, position, SEEK_SET));
+#elif defined (__MINGW32__)
+ return !(fseeko64(file, (off_t)position, SEEK_SET));
+#else
+ return !(fseeko(file, (off_t)position, SEEK_SET));
+#endif
+ }
+ return TRUE;
+}
+
+inline BOOL ByteStreamInFile::seekEnd(const I64 distance)
+{
+#if defined _WIN32 && ! defined (__MINGW32__)
+ return !(_fseeki64(file, -distance, SEEK_END));
+#elif defined (__MINGW32__)
+ return !(fseeko64(file, (off_t)-distance, SEEK_END));
+#else
+ return !(fseeko(file, (off_t)-distance, SEEK_END));
+#endif
+}
+
+inline ByteStreamInFileLE::ByteStreamInFileLE(FILE* file) : ByteStreamInFile(file)
+{
+}
+
+inline void ByteStreamInFileLE::get16bitsLE(U8* bytes)
+{
+ getBytes(bytes, 2);
+}
+
+inline void ByteStreamInFileLE::get32bitsLE(U8* bytes)
+{
+ getBytes(bytes, 4);
+}
+
+inline void ByteStreamInFileLE::get64bitsLE(U8* bytes)
+{
+ getBytes(bytes, 8);
+}
+
+inline void ByteStreamInFileLE::get16bitsBE(U8* bytes)
+{
+ getBytes(swapped, 2);
+ bytes[0] = swapped[1];
+ bytes[1] = swapped[0];
+}
+
+inline void ByteStreamInFileLE::get32bitsBE(U8* bytes)
+{
+ getBytes(swapped, 4);
+ bytes[0] = swapped[3];
+ bytes[1] = swapped[2];
+ bytes[2] = swapped[1];
+ bytes[3] = swapped[0];
+}
+
+inline void ByteStreamInFileLE::get64bitsBE(U8* bytes)
+{
+ getBytes(swapped, 8);
+ bytes[0] = swapped[7];
+ bytes[1] = swapped[6];
+ bytes[2] = swapped[5];
+ bytes[3] = swapped[4];
+ bytes[4] = swapped[3];
+ bytes[5] = swapped[2];
+ bytes[6] = swapped[1];
+ bytes[7] = swapped[0];
+}
+
+inline ByteStreamInFileBE::ByteStreamInFileBE(FILE* file) : ByteStreamInFile(file)
+{
+}
+
+inline void ByteStreamInFileBE::get16bitsLE(U8* bytes)
+{
+ getBytes(swapped, 2);
+ bytes[0] = swapped[1];
+ bytes[1] = swapped[0];
+}
+
+inline void ByteStreamInFileBE::get32bitsLE(U8* bytes)
+{
+ getBytes(swapped, 4);
+ bytes[0] = swapped[3];
+ bytes[1] = swapped[2];
+ bytes[2] = swapped[1];
+ bytes[3] = swapped[0];
+}
+
+inline void ByteStreamInFileBE::get64bitsLE(U8* bytes)
+{
+ getBytes(swapped, 8);
+ bytes[0] = swapped[7];
+ bytes[1] = swapped[6];
+ bytes[2] = swapped[5];
+ bytes[3] = swapped[4];
+ bytes[4] = swapped[3];
+ bytes[5] = swapped[2];
+ bytes[6] = swapped[1];
+ bytes[7] = swapped[0];
+}
+
+inline void ByteStreamInFileBE::get16bitsBE(U8* bytes)
+{
+ getBytes(bytes, 2);
+}
+
+inline void ByteStreamInFileBE::get32bitsBE(U8* bytes)
+{
+ getBytes(bytes, 4);
+}
+
+inline void ByteStreamInFileBE::get64bitsBE(U8* bytes)
+{
+ getBytes(bytes, 8);
+}
+
+#endif
diff --git a/libs/laszip/src/bytestreamin_istream.hpp b/libs/laszip/src/bytestreamin_istream.hpp
new file mode 100644
index 0000000..577b504
--- /dev/null
+++ b/libs/laszip/src/bytestreamin_istream.hpp
@@ -0,0 +1,250 @@
+/*
+===============================================================================
+
+ FILE: bytestreamin_istream.hpp
+
+ CONTENTS:
+
+ Class for istream-based input streams with endian handling.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2018, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 10 July 2018 -- because it's hard to determine seek-ability, user must set it
+ 1 October 2011 -- added 64 bit file support in MSVC 6.0 at McCafe at Hbf Linz
+ 10 January 2011 -- licensing change for LGPL release and liblas integration
+ 12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-;
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_IN_ISTREAM_H
+#define BYTE_STREAM_IN_ISTREAM_H
+
+#include "bytestreamin.hpp"
+
+#ifdef LZ_WIN32_VC6
+#include
+#else
+#include
+#include
+using namespace std;
+#endif
+
+class ByteStreamInIstream : public ByteStreamIn
+{
+public:
+ ByteStreamInIstream(istream& stream, BOOL seekable=TRUE);
+/* read a single byte */
+ U32 getByte();
+/* read an array of bytes */
+ void getBytes(U8* bytes, const U32 num_bytes);
+/* is the stream seekable (e.g. stdin is not) */
+ BOOL isSeekable() const { return seekable; };
+/* get current position of stream */
+ I64 tell() const;
+/* seek to this position in the stream */
+ BOOL seek(const I64 position);
+/* seek to the end of the file */
+ BOOL seekEnd(const I64 distance=0);
+/* destructor */
+ ~ByteStreamInIstream(){};
+protected:
+ istream& stream;
+ BOOL seekable;
+};
+
+class ByteStreamInIstreamLE : public ByteStreamInIstream
+{
+public:
+ ByteStreamInIstreamLE(istream& stream, BOOL seekable=TRUE);
+/* read 16 bit low-endian field */
+ void get16bitsLE(U8* bytes);
+/* read 32 bit low-endian field */
+ void get32bitsLE(U8* bytes);
+/* read 64 bit low-endian field */
+ void get64bitsLE(U8* bytes);
+/* read 16 bit big-endian field */
+ void get16bitsBE(U8* bytes);
+/* read 32 bit big-endian field */
+ void get32bitsBE(U8* bytes);
+/* read 64 bit big-endian field */
+ void get64bitsBE(U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+class ByteStreamInIstreamBE : public ByteStreamInIstream
+{
+public:
+ ByteStreamInIstreamBE(istream& stream, BOOL seekable=TRUE);
+/* read 16 bit low-endian field */
+ void get16bitsLE(U8* bytes);
+/* read 32 bit low-endian field */
+ void get32bitsLE(U8* bytes);
+/* read 64 bit low-endian field */
+ void get64bitsLE(U8* bytes);
+/* read 16 bit big-endian field */
+ void get16bitsBE(U8* bytes);
+/* read 32 bit big-endian field */
+ void get32bitsBE(U8* bytes);
+/* read 64 bit big-endian field */
+ void get64bitsBE(U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+inline ByteStreamInIstream::ByteStreamInIstream(istream& stream_param, BOOL seekable_param) : stream(stream_param), seekable(seekable_param)
+{
+}
+
+inline U32 ByteStreamInIstream::getByte()
+{
+ int byte = stream.get();
+ if (stream.eof())
+ {
+ throw EOF;
+ }
+ return (U32)byte;
+}
+
+inline void ByteStreamInIstream::getBytes(U8* bytes, const U32 num_bytes)
+{
+ stream.read((char*)bytes, num_bytes);
+ if (!stream.good())
+ {
+ throw EOF;
+ }
+}
+
+inline I64 ByteStreamInIstream::tell() const
+{
+ return (I64)stream.tellg();
+}
+
+inline BOOL ByteStreamInIstream::seek(const I64 position)
+{
+ if (tell() != position)
+ {
+ stream.seekg(static_cast(position));
+ return stream.good();
+ }
+ return TRUE;
+}
+
+inline BOOL ByteStreamInIstream::seekEnd(const I64 distance)
+{
+ stream.seekg(static_cast(-distance), ios::end);
+ return stream.good();
+}
+
+inline ByteStreamInIstreamLE::ByteStreamInIstreamLE(istream& stream, BOOL seekable) : ByteStreamInIstream(stream, seekable)
+{
+}
+
+inline void ByteStreamInIstreamLE::get16bitsLE(U8* bytes)
+{
+ getBytes(bytes, 2);
+}
+
+inline void ByteStreamInIstreamLE::get32bitsLE(U8* bytes)
+{
+ getBytes(bytes, 4);
+}
+
+inline void ByteStreamInIstreamLE::get64bitsLE(U8* bytes)
+{
+ getBytes(bytes, 8);
+}
+
+inline void ByteStreamInIstreamLE::get16bitsBE(U8* bytes)
+{
+ getBytes(swapped, 2);
+ bytes[0] = swapped[1];
+ bytes[1] = swapped[0];
+}
+
+inline void ByteStreamInIstreamLE::get32bitsBE(U8* bytes)
+{
+ getBytes(swapped, 4);
+ bytes[0] = swapped[3];
+ bytes[1] = swapped[2];
+ bytes[2] = swapped[1];
+ bytes[3] = swapped[0];
+}
+
+inline void ByteStreamInIstreamLE::get64bitsBE(U8* bytes)
+{
+ getBytes(swapped, 8);
+ bytes[0] = swapped[7];
+ bytes[1] = swapped[6];
+ bytes[2] = swapped[5];
+ bytes[3] = swapped[4];
+ bytes[4] = swapped[3];
+ bytes[5] = swapped[2];
+ bytes[6] = swapped[1];
+ bytes[7] = swapped[0];
+}
+
+inline ByteStreamInIstreamBE::ByteStreamInIstreamBE(istream& stream, BOOL seekable) : ByteStreamInIstream(stream, seekable)
+{
+}
+
+inline void ByteStreamInIstreamBE::get16bitsLE(U8* bytes)
+{
+ getBytes(swapped, 2);
+ bytes[0] = swapped[1];
+ bytes[1] = swapped[0];
+}
+
+inline void ByteStreamInIstreamBE::get32bitsLE(U8* bytes)
+{
+ getBytes(swapped, 4);
+ bytes[0] = swapped[3];
+ bytes[1] = swapped[2];
+ bytes[2] = swapped[1];
+ bytes[3] = swapped[0];
+}
+
+inline void ByteStreamInIstreamBE::get64bitsLE(U8* bytes)
+{
+ getBytes(swapped, 8);
+ bytes[0] = swapped[7];
+ bytes[1] = swapped[6];
+ bytes[2] = swapped[5];
+ bytes[3] = swapped[4];
+ bytes[4] = swapped[3];
+ bytes[5] = swapped[2];
+ bytes[6] = swapped[1];
+ bytes[7] = swapped[0];
+}
+
+inline void ByteStreamInIstreamBE::get16bitsBE(U8* bytes)
+{
+ getBytes(bytes, 2);
+}
+
+inline void ByteStreamInIstreamBE::get32bitsBE(U8* bytes)
+{
+ getBytes(bytes, 4);
+}
+
+inline void ByteStreamInIstreamBE::get64bitsBE(U8* bytes)
+{
+ getBytes(bytes, 8);
+}
+
+#endif
diff --git a/libs/laszip/src/bytestreaminout.hpp b/libs/laszip/src/bytestreaminout.hpp
new file mode 100644
index 0000000..475981b
--- /dev/null
+++ b/libs/laszip/src/bytestreaminout.hpp
@@ -0,0 +1,45 @@
+/*
+===============================================================================
+
+ FILE: bytestreaminout.hpp
+
+ CONTENTS:
+
+ Abstract base class for streams that both input and output with endian handling.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 29 December 2013 -- created after helping a client to QA their Optech LiDAR
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_INOUT_HPP
+#define BYTE_STREAM_INOUT_HPP
+
+#include "mydefs.hpp"
+#include "bytestreamin.hpp"
+#include "bytestreamout.hpp"
+
+class ByteStreamInOut : public ByteStreamIn, ByteStreamOut
+{
+public:
+/* destructor */
+ virtual ~ByteStreamInOut() {};
+};
+
+#endif
diff --git a/libs/laszip/src/bytestreaminout_file.hpp b/libs/laszip/src/bytestreaminout_file.hpp
new file mode 100644
index 0000000..88d43e3
--- /dev/null
+++ b/libs/laszip/src/bytestreaminout_file.hpp
@@ -0,0 +1,57 @@
+/*
+===============================================================================
+
+ FILE: bytestreaminout_file.hpp
+
+ CONTENTS:
+
+ Class for FILE*-based streams that both input and output with endian handling.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 29 December 2013 -- created after helping a client to QA their Optech LiDAR
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_INOUT_FILE_HPP
+#define BYTE_STREAM_INOUT_FILE_HPP
+
+#include "bytestreamin_file.hpp"
+#include "bytestreamout_file.hpp"
+
+class ByteStreamInOutFileLE : public ByteStreamInFileLE, public ByteStreamOutFileLE
+{
+public:
+ ByteStreamInOutFileLE(FILE* file);
+};
+
+class ByteStreamInOutFileBE : public ByteStreamInFileBE, public ByteStreamOutFileBE
+{
+public:
+ ByteStreamInOutFileBE(FILE* file);
+};
+
+inline ByteStreamInOutFileLE::ByteStreamInOutFileLE(FILE* file) : ByteStreamInFileLE(file), ByteStreamOutFileLE(file)
+{
+}
+
+inline ByteStreamInOutFileBE::ByteStreamInOutFileBE(FILE* file) : ByteStreamInFileBE(file), ByteStreamOutFileBE(file)
+{
+}
+
+#endif
diff --git a/libs/laszip/src/bytestreamout.hpp b/libs/laszip/src/bytestreamout.hpp
new file mode 100644
index 0000000..d809314
--- /dev/null
+++ b/libs/laszip/src/bytestreamout.hpp
@@ -0,0 +1,103 @@
+/*
+===============================================================================
+
+ FILE: bytestreamout.hpp
+
+ CONTENTS:
+
+ Abstract base class for output streams with endian handling.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 2 January 2013 -- new functions for writing a stream of groups of bits
+ 1 October 2011 -- added 64 bit file support in MSVC 6.0 at McCafe at Hbf Linz
+ 10 January 2011 -- licensing change for LGPL release and liblas integration
+ 12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-;
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_OUT_HPP
+#define BYTE_STREAM_OUT_HPP
+
+#include "mydefs.hpp"
+
+class ByteStreamOut
+{
+public:
+/* write single bits */
+ inline BOOL putBits(U32 bits, U32 num_bits)
+ {
+ U64 new_bits = bits;
+ bit_buffer |= (new_bits << num_buffer);
+ num_buffer += num_bits;
+ if (num_buffer >= 32)
+ {
+ U32 output_bits = (U32)(bit_buffer & U32_MAX);
+ bit_buffer = bit_buffer >> 32;
+ num_buffer = num_buffer - 32;
+ return put32bitsLE((U8*)&output_bits);
+ }
+ return TRUE;
+ };
+/* called after writing bits before closing or writing bytes */
+ inline BOOL flushBits()
+ {
+ if (num_buffer)
+ {
+ U32 num_zero_bits = 32 - num_buffer;
+ U32 output_bits = (U32)(bit_buffer >> num_zero_bits);
+ bit_buffer = 0;
+ num_buffer = 0;
+ return put32bitsLE((U8*)&output_bits);
+ }
+ return TRUE;
+ };
+/* write a single byte */
+ virtual BOOL putByte(U8 byte) = 0;
+/* write an array of bytes */
+ virtual BOOL putBytes(const U8* bytes, U32 num_bytes) = 0;
+/* write 16 bit low-endian field */
+ virtual BOOL put16bitsLE(const U8* bytes) = 0;
+/* write 32 bit low-endian field */
+ virtual BOOL put32bitsLE(const U8* bytes) = 0;
+/* write 64 bit low-endian field */
+ virtual BOOL put64bitsLE(const U8* bytes) = 0;
+/* write 16 bit big-endian field */
+ virtual BOOL put16bitsBE(const U8* bytes) = 0;
+/* write 32 bit big-endian field */
+ virtual BOOL put32bitsBE(const U8* bytes) = 0;
+/* write 64 bit big-endian field */
+ virtual BOOL put64bitsBE(const U8* bytes) = 0;
+/* is the stream seekable (e.g. standard out is not) */
+ virtual BOOL isSeekable() const = 0;
+/* get current position of stream */
+ virtual I64 tell() const = 0;
+/* seek to this position in the stream */
+ virtual BOOL seek(const I64 position) = 0;
+/* seek to the end of the file */
+ virtual BOOL seekEnd() = 0;
+/* constructor */
+ inline ByteStreamOut() { bit_buffer = 0; num_buffer = 0; };
+/* destructor */
+ virtual ~ByteStreamOut() {};
+private:
+ U64 bit_buffer;
+ U32 num_buffer;
+};
+
+#endif
diff --git a/libs/laszip/src/bytestreamout_array.hpp b/libs/laszip/src/bytestreamout_array.hpp
new file mode 100644
index 0000000..f2ca2d1
--- /dev/null
+++ b/libs/laszip/src/bytestreamout_array.hpp
@@ -0,0 +1,284 @@
+/*
+===============================================================================
+
+ FILE: bytestreamout_array.hpp
+
+ CONTENTS:
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 11 April 2019 -- increase default alloc from 1024 bytes to 4096 bytes
+ 10 April 2019 -- fix potential memory leak found by Connor Manning's valgrind
+ 22 June 2016 -- access to current size for "native LAS 1.4 compressor"
+ 19 July 2015 -- moved from LASlib to LASzip for "compatibility mode" in DLL
+ 9 April 2012 -- created after cooking Zuccini/Onion/Potatoe dinner for Mara
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_OUT_ARRAY_HPP
+#define BYTE_STREAM_OUT_ARRAY_HPP
+
+#include "bytestreamout.hpp"
+
+#include
+#include
+
+class ByteStreamOutArray : public ByteStreamOut
+{
+public:
+ ByteStreamOutArray(I64 alloc=4096);
+/* write a single byte */
+ BOOL putByte(U8 byte);
+/* write an array of bytes */
+ BOOL putBytes(const U8* bytes, U32 num_bytes);
+/* is the stream seekable (e.g. standard out is not) */
+ BOOL isSeekable() const;
+/* get current position of stream */
+ I64 tell() const;
+/* seek to this position in the stream */
+ BOOL seek(const I64 position);
+/* seek to the end of the file */
+ BOOL seekEnd();
+/* destructor */
+ ~ByteStreamOutArray() { if (data) free(data); };
+/* get access to data */
+ inline I64 getSize() const { return size; };
+ inline I64 getCurr() const { return curr; };
+ inline const U8* getData() const { return data; };
+ inline U8* takeData() { U8* d = data; data = 0; alloc = 0; size = 0; curr = 0; return d; };
+protected:
+ U8* data;
+ I64 alloc;
+ I64 size;
+ I64 curr;
+};
+
+class ByteStreamOutArrayLE : public ByteStreamOutArray
+{
+public:
+ ByteStreamOutArrayLE(I64 alloc=4096);
+/* write 16 bit low-endian field */
+ BOOL put16bitsLE(const U8* bytes);
+/* write 32 bit low-endian field */
+ BOOL put32bitsLE(const U8* bytes);
+/* write 64 bit low-endian field */
+ BOOL put64bitsLE(const U8* bytes);
+/* write 16 bit big-endian field */
+ BOOL put16bitsBE(const U8* bytes);
+/* write 32 bit big-endian field */
+ BOOL put32bitsBE(const U8* bytes);
+/* write 64 bit big-endian field */
+ BOOL put64bitsBE(const U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+class ByteStreamOutArrayBE : public ByteStreamOutArray
+{
+public:
+ ByteStreamOutArrayBE(I64 alloc=4096);
+/* write 16 bit low-endian field */
+ BOOL put16bitsLE(const U8* bytes);
+/* write 32 bit low-endian field */
+ BOOL put32bitsLE(const U8* bytes);
+/* write 64 bit low-endian field */
+ BOOL put64bitsLE(const U8* bytes);
+/* write 16 bit big-endian field */
+ BOOL put16bitsBE(const U8* bytes);
+/* write 32 bit big-endian field */
+ BOOL put32bitsBE(const U8* bytes);
+/* write 64 bit big-endian field */
+ BOOL put64bitsBE(const U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+inline ByteStreamOutArray::ByteStreamOutArray(I64 alloc)
+{
+ this->data = (U8*)malloc((U32)alloc);
+ this->alloc = alloc;
+ this->size = 0;
+ this->curr = 0;
+}
+
+inline BOOL ByteStreamOutArray::putByte(U8 byte)
+{
+ if (curr == alloc)
+ {
+ alloc += 4096;
+ data = (U8*)realloc(data, (U32)alloc);
+ if (data == 0)
+ {
+ return FALSE;
+ }
+ }
+ data[curr] = byte;
+ if (curr == size) size++;
+ curr++;
+ return TRUE;
+}
+
+inline BOOL ByteStreamOutArray::putBytes(const U8* bytes, U32 num_bytes)
+{
+ if ((curr+num_bytes) > alloc)
+ {
+ alloc += (4096+num_bytes);
+ data = (U8*)realloc(data, (U32)alloc);
+ if (data == 0)
+ {
+ return FALSE;
+ }
+ }
+ memcpy((void*)(data+curr), bytes, num_bytes);
+ curr += num_bytes;
+ if (curr > size) size = curr;
+ return TRUE;
+}
+
+inline BOOL ByteStreamOutArray::isSeekable() const
+{
+ return TRUE;
+}
+
+inline I64 ByteStreamOutArray::tell() const
+{
+ return curr;
+}
+
+inline BOOL ByteStreamOutArray::seek(I64 position)
+{
+ if ((0 <= position) && (position <= size))
+ {
+ curr = position;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+inline BOOL ByteStreamOutArray::seekEnd()
+{
+ curr = size;
+ return TRUE;
+
+/*
+ if ((0 <= distance) && (distance <= size))
+ {
+ curr = size - distance;
+ return TRUE;
+ }
+ return FALSE;
+*/
+}
+
+inline ByteStreamOutArrayLE::ByteStreamOutArrayLE(I64 alloc) : ByteStreamOutArray(alloc)
+{
+}
+
+inline BOOL ByteStreamOutArrayLE::put16bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 2);
+}
+
+inline BOOL ByteStreamOutArrayLE::put32bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 4);
+}
+
+inline BOOL ByteStreamOutArrayLE::put64bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 8);
+}
+
+inline BOOL ByteStreamOutArrayLE::put16bitsBE(const U8* bytes)
+{
+ swapped[0] = bytes[1];
+ swapped[1] = bytes[0];
+ return putBytes(swapped, 2);
+}
+
+inline BOOL ByteStreamOutArrayLE::put32bitsBE(const U8* bytes)
+{
+ swapped[0] = bytes[3];
+ swapped[1] = bytes[2];
+ swapped[2] = bytes[1];
+ swapped[3] = bytes[0];
+ return putBytes(swapped, 4);
+}
+
+inline BOOL ByteStreamOutArrayLE::put64bitsBE(const U8* bytes)
+{
+ swapped[0] = bytes[7];
+ swapped[1] = bytes[6];
+ swapped[2] = bytes[5];
+ swapped[3] = bytes[4];
+ swapped[4] = bytes[3];
+ swapped[5] = bytes[2];
+ swapped[6] = bytes[1];
+ swapped[7] = bytes[0];
+ return putBytes(swapped, 8);
+}
+
+inline ByteStreamOutArrayBE::ByteStreamOutArrayBE(I64 alloc) : ByteStreamOutArray(alloc)
+{
+}
+
+inline BOOL ByteStreamOutArrayBE::put16bitsLE(const U8* bytes)
+{
+ swapped[0] = bytes[1];
+ swapped[1] = bytes[0];
+ return putBytes(swapped, 2);
+}
+
+inline BOOL ByteStreamOutArrayBE::put32bitsLE(const U8* bytes)
+{
+ swapped[0] = bytes[3];
+ swapped[1] = bytes[2];
+ swapped[2] = bytes[1];
+ swapped[3] = bytes[0];
+ return putBytes(swapped, 4);
+}
+
+inline BOOL ByteStreamOutArrayBE::put64bitsLE(const U8* bytes)
+{
+ swapped[0] = bytes[7];
+ swapped[1] = bytes[6];
+ swapped[2] = bytes[5];
+ swapped[3] = bytes[4];
+ swapped[4] = bytes[3];
+ swapped[5] = bytes[2];
+ swapped[6] = bytes[1];
+ swapped[7] = bytes[0];
+ return putBytes(swapped, 8);
+}
+
+inline BOOL ByteStreamOutArrayBE::put16bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 2);
+}
+
+inline BOOL ByteStreamOutArrayBE::put32bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 4);
+}
+
+inline BOOL ByteStreamOutArrayBE::put64bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 8);
+}
+
+#endif
diff --git a/libs/laszip/src/bytestreamout_file.hpp b/libs/laszip/src/bytestreamout_file.hpp
new file mode 100644
index 0000000..d8c5132
--- /dev/null
+++ b/libs/laszip/src/bytestreamout_file.hpp
@@ -0,0 +1,265 @@
+/*
+===============================================================================
+
+ FILE: bytestreamout_file.hpp
+
+ CONTENTS:
+
+ Class for FILE*-based output streams with endian handling.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 1 October 2011 -- added 64 bit file support in MSVC 6.0 at McCafe at Hbf Linz
+ 10 January 2011 -- licensing change for LGPL release and liblas integration
+ 12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-;
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_OUT_FILE_H
+#define BYTE_STREAM_OUT_FILE_H
+
+#include "bytestreamout.hpp"
+
+#include
+
+#if defined(_MSC_VER) && (_MSC_VER < 1300)
+extern "C" int _cdecl _fseeki64(FILE*, __int64, int);
+extern "C" __int64 _cdecl _ftelli64(FILE*);
+#endif
+
+class ByteStreamOutFile : public ByteStreamOut
+{
+public:
+ ByteStreamOutFile(FILE* file);
+/* replace a closed FILE* with a reopened FILE* in "ab" mode */
+ BOOL refile(FILE* file);
+/* write a single byte */
+ BOOL putByte(U8 byte);
+/* write an array of bytes */
+ BOOL putBytes(const U8* bytes, U32 num_bytes);
+/* is the stream seekable (e.g. standard out is not) */
+ BOOL isSeekable() const;
+/* get current position of stream */
+ I64 tell() const;
+/* seek to this position in the stream */
+ BOOL seek(const I64 position);
+/* seek to the end of the file */
+ BOOL seekEnd();
+/* destructor */
+ ~ByteStreamOutFile(){};
+protected:
+ FILE* file;
+};
+
+class ByteStreamOutFileLE : public ByteStreamOutFile
+{
+public:
+ ByteStreamOutFileLE(FILE* file);
+/* write 16 bit low-endian field */
+ BOOL put16bitsLE(const U8* bytes);
+/* write 32 bit low-endian field */
+ BOOL put32bitsLE(const U8* bytes);
+/* write 64 bit low-endian field */
+ BOOL put64bitsLE(const U8* bytes);
+/* write 16 bit big-endian field */
+ BOOL put16bitsBE(const U8* bytes);
+/* write 32 bit big-endian field */
+ BOOL put32bitsBE(const U8* bytes);
+/* write 64 bit big-endian field */
+ BOOL put64bitsBE(const U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+class ByteStreamOutFileBE : public ByteStreamOutFile
+{
+public:
+ ByteStreamOutFileBE(FILE* file);
+/* write 16 bit low-endian field */
+ BOOL put16bitsLE(const U8* bytes);
+/* write 32 bit low-endian field */
+ BOOL put32bitsLE(const U8* bytes);
+/* write 64 bit low-endian field */
+ BOOL put64bitsLE(const U8* bytes);
+/* write 16 bit big-endian field */
+ BOOL put16bitsBE(const U8* bytes);
+/* write 32 bit big-endian field */
+ BOOL put32bitsBE(const U8* bytes);
+/* write 64 bit big-endian field */
+ BOOL put64bitsBE(const U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+inline ByteStreamOutFile::ByteStreamOutFile(FILE* file)
+{
+ this->file = file;
+}
+
+inline BOOL ByteStreamOutFile::refile(FILE* file)
+{
+ if (file == 0) return FALSE;
+ this->file = file;
+ return TRUE;
+}
+
+inline BOOL ByteStreamOutFile::putByte(U8 byte)
+{
+ return (fputc(byte, file) == byte);
+}
+
+inline BOOL ByteStreamOutFile::putBytes(const U8* bytes, U32 num_bytes)
+{
+ return (fwrite(bytes, 1, num_bytes, file) == num_bytes);
+}
+
+inline BOOL ByteStreamOutFile::isSeekable() const
+{
+ return (file != stdout);
+}
+
+inline I64 ByteStreamOutFile::tell() const
+{
+#if defined _WIN32 && ! defined (__MINGW32__)
+ return _ftelli64(file);
+#elif defined (__MINGW32__)
+ return (I64)ftello64(file);
+#else
+ return (I64)ftello(file);
+#endif
+}
+
+inline BOOL ByteStreamOutFile::seek(I64 position)
+{
+#if defined _WIN32 && ! defined (__MINGW32__)
+ return !(_fseeki64(file, position, SEEK_SET));
+#elif defined (__MINGW32__)
+ return !(fseeko64(file, (off_t)position, SEEK_SET));
+#else
+ return !(fseeko(file, (off_t)position, SEEK_SET));
+#endif
+}
+
+inline BOOL ByteStreamOutFile::seekEnd()
+{
+#if defined _WIN32 && ! defined (__MINGW32__)
+ return !(_fseeki64(file, 0, SEEK_END));
+#elif defined (__MINGW32__)
+ return !(fseeko64(file, (off_t)0, SEEK_END));
+#else
+ return !(fseeko(file, (off_t)0, SEEK_END));
+#endif
+}
+
+inline ByteStreamOutFileLE::ByteStreamOutFileLE(FILE* file) : ByteStreamOutFile(file)
+{
+}
+
+inline BOOL ByteStreamOutFileLE::put16bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 2);
+}
+
+inline BOOL ByteStreamOutFileLE::put32bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 4);
+}
+
+inline BOOL ByteStreamOutFileLE::put64bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 8);
+}
+
+inline BOOL ByteStreamOutFileLE::put16bitsBE(const U8* bytes)
+{
+ swapped[0] = bytes[1];
+ swapped[1] = bytes[0];
+ return putBytes(swapped, 2);
+}
+
+inline BOOL ByteStreamOutFileLE::put32bitsBE(const U8* bytes)
+{
+ swapped[0] = bytes[3];
+ swapped[1] = bytes[2];
+ swapped[2] = bytes[1];
+ swapped[3] = bytes[0];
+ return putBytes(swapped, 4);
+}
+
+inline BOOL ByteStreamOutFileLE::put64bitsBE(const U8* bytes)
+{
+ swapped[0] = bytes[7];
+ swapped[1] = bytes[6];
+ swapped[2] = bytes[5];
+ swapped[3] = bytes[4];
+ swapped[4] = bytes[3];
+ swapped[5] = bytes[2];
+ swapped[6] = bytes[1];
+ swapped[7] = bytes[0];
+ return putBytes(swapped, 8);
+}
+
+inline ByteStreamOutFileBE::ByteStreamOutFileBE(FILE* file) : ByteStreamOutFile(file)
+{
+}
+
+inline BOOL ByteStreamOutFileBE::put16bitsLE(const U8* bytes)
+{
+ swapped[0] = bytes[1];
+ swapped[1] = bytes[0];
+ return putBytes(swapped, 2);
+}
+
+inline BOOL ByteStreamOutFileBE::put32bitsLE(const U8* bytes)
+{
+ swapped[0] = bytes[3];
+ swapped[1] = bytes[2];
+ swapped[2] = bytes[1];
+ swapped[3] = bytes[0];
+ return putBytes(swapped, 4);
+}
+
+inline BOOL ByteStreamOutFileBE::put64bitsLE(const U8* bytes)
+{
+ swapped[0] = bytes[7];
+ swapped[1] = bytes[6];
+ swapped[2] = bytes[5];
+ swapped[3] = bytes[4];
+ swapped[4] = bytes[3];
+ swapped[5] = bytes[2];
+ swapped[6] = bytes[1];
+ swapped[7] = bytes[0];
+ return putBytes(swapped, 8);
+}
+
+inline BOOL ByteStreamOutFileBE::put16bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 2);
+}
+
+inline BOOL ByteStreamOutFileBE::put32bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 4);
+}
+
+inline BOOL ByteStreamOutFileBE::put64bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 8);
+}
+
+#endif
diff --git a/libs/laszip/src/bytestreamout_nil.hpp b/libs/laszip/src/bytestreamout_nil.hpp
new file mode 100644
index 0000000..cd28a7d
--- /dev/null
+++ b/libs/laszip/src/bytestreamout_nil.hpp
@@ -0,0 +1,141 @@
+/*
+===============================================================================
+
+ FILE: bytestreamout_.hpilp
+
+ CONTENTS:
+
+ Class for a black hole that only counts the bytes.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 1 October 2011 -- added 64 bit file support in MSVC 6.0 at McCafe at Hbf Linz
+ 10 January 2011 -- licensing change for LGPL release and liblas integration
+ 12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-;
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_OUT_NIL_H
+#define BYTE_STREAM_OUT_NIL_H
+
+#include "bytestreamout.hpp"
+
+#include
+
+class ByteStreamOutNil : public ByteStreamOut
+{
+public:
+ ByteStreamOutNil();
+/* write a single byte */
+ BOOL putByte(U8 byte);
+/* write an array of bytes */
+ BOOL putBytes(const U8* bytes, U32 num_bytes);
+/* write 16 bit low-endian field */
+ BOOL put16bitsLE(const U8* bytes);
+/* write 32 bit low-endian field */
+ BOOL put32bitsLE(const U8* bytes);
+/* write 64 bit low-endian field */
+ BOOL put64bitsLE(const U8* bytes);
+/* write 16 bit big-endian field */
+ BOOL put16bitsBE(const U8* bytes);
+/* write 32 bit big-endian field */
+ BOOL put32bitsBE(const U8* bytes);
+/* write 64 bit big-endian field */
+ BOOL put64bitsBE(const U8* bytes);
+/* is the stream seekable (e.g. standard out is not) */
+ BOOL isSeekable() const;
+/* get current position of stream */
+ I64 tell() const;
+/* seek to this position in the stream */
+ BOOL seek(const I64 position);
+/* seek to the end of the file */
+ BOOL seekEnd();
+/* destructor */
+ ~ByteStreamOutNil(){};
+private:
+ I64 num_bytes;
+};
+
+inline ByteStreamOutNil::ByteStreamOutNil()
+{
+ num_bytes = 0;
+}
+
+inline BOOL ByteStreamOutNil::putByte(U8 byte)
+{
+ num_bytes++;
+ return TRUE;
+}
+
+inline BOOL ByteStreamOutNil::putBytes(const U8* bytes, U32 num_bytes)
+{
+ this->num_bytes += num_bytes;
+ return TRUE;
+}
+
+inline BOOL ByteStreamOutNil::put16bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 2);
+}
+
+inline BOOL ByteStreamOutNil::put32bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 4);
+}
+
+inline BOOL ByteStreamOutNil::put64bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 8);
+}
+
+inline BOOL ByteStreamOutNil::put16bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 2);
+}
+
+inline BOOL ByteStreamOutNil::put32bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 4);
+}
+
+inline BOOL ByteStreamOutNil::put64bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 8);
+}
+
+inline BOOL ByteStreamOutNil::isSeekable() const
+{
+ return TRUE;
+}
+
+inline I64 ByteStreamOutNil::tell() const
+{
+ return num_bytes;
+}
+
+inline BOOL ByteStreamOutNil::seek(I64 position)
+{
+ return TRUE;
+}
+
+inline BOOL ByteStreamOutNil::seekEnd()
+{
+ return TRUE;
+}
+
+#endif
diff --git a/libs/laszip/src/bytestreamout_ostream.hpp b/libs/laszip/src/bytestreamout_ostream.hpp
new file mode 100644
index 0000000..a138319
--- /dev/null
+++ b/libs/laszip/src/bytestreamout_ostream.hpp
@@ -0,0 +1,241 @@
+/*
+===============================================================================
+
+ FILE: bytestreamout_ostream.hpp
+
+ Class for ostream-based output streams with endian handling.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 1 October 2011 -- added 64 bit file support in MSVC 6.0 at McCafe at Hbf Linz
+ 10 January 2011 -- licensing change for LGPL release and liblas integration
+ 12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-;
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_OUT_OSTREAM_H
+#define BYTE_STREAM_OUT_OSTREAM_H
+
+#include "bytestreamout.hpp"
+
+#ifdef LZ_WIN32_VC6
+#include
+#else
+#include
+#include
+using namespace std;
+#endif
+
+class ByteStreamOutOstream : public ByteStreamOut
+{
+public:
+ ByteStreamOutOstream(ostream& stream);
+/* write a single byte */
+ BOOL putByte(U8 byte);
+/* write an array of bytes */
+ BOOL putBytes(const U8* bytes, U32 num_bytes);
+/* is the stream seekable (e.g. standard out is not) */
+ BOOL isSeekable() const;
+/* get current position of stream */
+ I64 tell() const;
+/* seek to this position in the stream */
+ BOOL seek(const I64 position);
+/* seek to the end of the file */
+ BOOL seekEnd();
+/* destructor */
+ ~ByteStreamOutOstream(){};
+protected:
+ ostream& stream;
+};
+
+class ByteStreamOutOstreamLE : public ByteStreamOutOstream
+{
+public:
+ ByteStreamOutOstreamLE(ostream& stream);
+/* write 16 bit low-endian field */
+ BOOL put16bitsLE(const U8* bytes);
+/* write 32 bit low-endian field */
+ BOOL put32bitsLE(const U8* bytes);
+/* write 64 bit low-endian field */
+ BOOL put64bitsLE(const U8* bytes);
+/* write 16 bit big-endian field */
+ BOOL put16bitsBE(const U8* bytes);
+/* write 32 bit big-endian field */
+ BOOL put32bitsBE(const U8* bytes);
+/* write 64 bit big-endian field */
+ BOOL put64bitsBE(const U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+class ByteStreamOutOstreamBE : public ByteStreamOutOstream
+{
+public:
+ ByteStreamOutOstreamBE(ostream& stream);
+/* write 16 bit low-endian field */
+ BOOL put16bitsLE(const U8* bytes);
+/* write 32 bit low-endian field */
+ BOOL put32bitsLE(const U8* bytes);
+/* write 64 bit low-endian field */
+ BOOL put64bitsLE(const U8* bytes);
+/* write 16 bit big-endian field */
+ BOOL put16bitsBE(const U8* bytes);
+/* write 32 bit big-endian field */
+ BOOL put32bitsBE(const U8* bytes);
+/* write 64 bit big-endian field */
+ BOOL put64bitsBE(const U8* bytes);
+private:
+ U8 swapped[8];
+};
+
+inline ByteStreamOutOstream::ByteStreamOutOstream(ostream& stream_param) :
+ stream(stream_param)
+{
+}
+
+inline BOOL ByteStreamOutOstream::putByte(U8 byte)
+{
+ stream.put(byte);
+ return stream.good();
+}
+
+inline BOOL ByteStreamOutOstream::putBytes(const U8* bytes, U32 num_bytes)
+{
+ stream.write((const char*)bytes, num_bytes);
+ return stream.good();
+}
+
+inline BOOL ByteStreamOutOstream::isSeekable() const
+{
+ return !!(static_cast(stream));
+}
+
+inline I64 ByteStreamOutOstream::tell() const
+{
+ return (I64)stream.tellp();
+}
+
+inline BOOL ByteStreamOutOstream::seek(I64 position)
+{
+ stream.seekp(static_cast(position));
+ return stream.good();
+}
+
+inline BOOL ByteStreamOutOstream::seekEnd()
+{
+ stream.seekp(0, ios::end);
+ return stream.good();
+}
+
+inline ByteStreamOutOstreamLE::ByteStreamOutOstreamLE(ostream& stream) : ByteStreamOutOstream(stream)
+{
+}
+
+inline BOOL ByteStreamOutOstreamLE::put16bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 2);
+}
+
+inline BOOL ByteStreamOutOstreamLE::put32bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 4);
+}
+
+inline BOOL ByteStreamOutOstreamLE::put64bitsLE(const U8* bytes)
+{
+ return putBytes(bytes, 8);
+}
+
+inline BOOL ByteStreamOutOstreamLE::put16bitsBE(const U8* bytes)
+{
+ swapped[0] = bytes[1];
+ swapped[1] = bytes[0];
+ return putBytes(swapped, 2);
+}
+
+inline BOOL ByteStreamOutOstreamLE::put32bitsBE(const U8* bytes)
+{
+ swapped[0] = bytes[3];
+ swapped[1] = bytes[2];
+ swapped[2] = bytes[1];
+ swapped[3] = bytes[0];
+ return putBytes(swapped, 4);
+}
+
+inline BOOL ByteStreamOutOstreamLE::put64bitsBE(const U8* bytes)
+{
+ swapped[0] = bytes[7];
+ swapped[1] = bytes[6];
+ swapped[2] = bytes[5];
+ swapped[3] = bytes[4];
+ swapped[4] = bytes[3];
+ swapped[5] = bytes[2];
+ swapped[6] = bytes[1];
+ swapped[7] = bytes[0];
+ return putBytes(swapped, 8);
+}
+
+inline ByteStreamOutOstreamBE::ByteStreamOutOstreamBE(ostream& stream) : ByteStreamOutOstream(stream)
+{
+}
+
+inline BOOL ByteStreamOutOstreamBE::put16bitsLE(const U8* bytes)
+{
+ swapped[0] = bytes[1];
+ swapped[1] = bytes[0];
+ return putBytes(swapped, 2);
+}
+
+inline BOOL ByteStreamOutOstreamBE::put32bitsLE(const U8* bytes)
+{
+ swapped[0] = bytes[3];
+ swapped[1] = bytes[2];
+ swapped[2] = bytes[1];
+ swapped[3] = bytes[0];
+ return putBytes(swapped, 4);
+}
+
+inline BOOL ByteStreamOutOstreamBE::put64bitsLE(const U8* bytes)
+{
+ swapped[0] = bytes[7];
+ swapped[1] = bytes[6];
+ swapped[2] = bytes[5];
+ swapped[3] = bytes[4];
+ swapped[4] = bytes[3];
+ swapped[5] = bytes[2];
+ swapped[6] = bytes[1];
+ swapped[7] = bytes[0];
+ return putBytes(swapped, 8);
+}
+
+inline BOOL ByteStreamOutOstreamBE::put16bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 2);
+}
+
+inline BOOL ByteStreamOutOstreamBE::put32bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 4);
+}
+
+inline BOOL ByteStreamOutOstreamBE::put64bitsBE(const U8* bytes)
+{
+ return putBytes(bytes, 8);
+}
+
+#endif
diff --git a/libs/laszip/src/endian.hpp b/libs/laszip/src/endian.hpp
new file mode 100644
index 0000000..d4332ec
--- /dev/null
+++ b/libs/laszip/src/endian.hpp
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * $Id$
+ *
+ * Project: liblas - http://liblas.org - A BSD library for LAS format data.
+ * Purpose: Endian macros
+ * Author: Mateusz Loskot, mateusz@loskot.net
+ *
+ * This file has been stolen from and
+ * modified for libLAS purposes.
+ *
+ * (C) Copyright Mateusz Loskot 2007, mateusz@loskot.net
+ * (C) Copyright Caleb Epstein 2005
+ * (C) Copyright John Maddock 2006
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * Revision History
+ * 06 Feb 2006 - Initial Revision
+ * 09 Nov 2006 - fixed variant and version bits for v4 guids
+ * 13 Nov 2006 - added serialization
+ * 17 Nov 2006 - added name-based guid creation
+ * 20 Nov 2006 - add fixes for gcc (from Tim Blechmann)
+ * 07 Mar 2007 - converted to header only
+ * 20 Jan 2008 - removed dependency of Boost and modified for LASZIP (by Mateusz Loskot)
+ ******************************************************************************
+ *
+ * Copyright (c) 1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ *
+ * Copyright notice reproduced from , from
+ * which this code was originally taken.
+ *
+ * Modified by Caleb Epstein to use with GNU libc and to
+ * defined the BOOST_ENDIAN macro.
+ ****************************************************************************/
+
+#ifndef LASZIP_DETAIL_ENDIAN_HPP_INCLUDED
+#define LASZIP_DETAIL_ENDIAN_HPP_INCLUDED
+
+// GNU libc offers the helpful header which defines
+// __BYTE_ORDER
+
+#if defined (__GLIBC__)
+# include
+# if (__BYTE_ORDER == __LITTLE_ENDIAN)
+# define LASZIP_LITTLE_ENDIAN
+# elif (__BYTE_ORDER == __BIG_ENDIAN)
+# define LASZIP_BIG_ENDIAN
+# elif (__BYTE_ORDER == __PDP_ENDIAN)
+# define LASZIP_PDP_ENDIAN
+# else
+# error Unknown machine endianness detected.
+# endif
+# define LASZIP_BYTE_ORDER __BYTE_ORDER
+#elif defined(_BIG_ENDIAN)
+# define LASZIP_BIG_ENDIAN
+# define LASZIP_BYTE_ORDER 4321
+#elif defined(_LITTLE_ENDIAN)
+# define LASZIP_LITTLE_ENDIAN
+# define LASZIP_BYTE_ORDER 1234
+
+#elif defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN)
+# define LASZIP_LITTLE_ENDIAN
+# define LASZIP_BYTE_ORDER 1234
+
+#elif defined(__sparc) || defined(__sparc__) \
+ || defined(_POWER) || defined(__powerpc__) \
+ || defined(__ppc__) || defined(__hpux) \
+ || defined(_MIPSEB) || defined(_POWER) \
+ || defined(__s390__)
+# define LASZIP_BIG_ENDIAN
+# define LASZIP_BYTE_ORDER 4321
+#elif defined(__i386__) || defined(__alpha__) \
+ || defined(__ia64) || defined(__ia64__) \
+ || defined(_M_IX86) || defined(_M_IA64) \
+ || defined(_M_ALPHA) || defined(__amd64) \
+ || defined(__amd64__) || defined(_M_AMD64) \
+ || defined(__x86_64) || defined(__x86_64__) \
+ || defined(_M_X64)
+
+# define LASZIP_LITTLE_ENDIAN
+# define LASZIP_BYTE_ORDER 1234
+#else
+# error The file src/endian.hpp needs to be set up for your CPU type.
+#endif
+
+
+#if defined(LASZIP_BIG_ENDIAN)
+# error LASzip is not currently big endian safe. Please contact the authors on the liblas-devel mailing list for more information
+#endif
+
+
+#endif // LASZIP_DETAIL_ENDIAN_HPP_INCLUDED
+
diff --git a/libs/laszip/src/integercompressor.cpp b/libs/laszip/src/integercompressor.cpp
new file mode 100644
index 0000000..25bc640
--- /dev/null
+++ b/libs/laszip/src/integercompressor.cpp
@@ -0,0 +1,548 @@
+/*
+===============================================================================
+
+ FILE: integercompressor.cpp
+
+ CONTENTS:
+
+ see corresponding header file
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ see corresponding header file
+
+===============================================================================
+*/
+#include "integercompressor.hpp"
+
+#define COMPRESS_ONLY_K
+#undef COMPRESS_ONLY_K
+
+#define CREATE_HISTOGRAMS
+#undef CREATE_HISTOGRAMS
+
+#include
+#include
+
+#ifdef CREATE_HISTOGRAMS
+#include
+#endif
+
+IntegerCompressor::IntegerCompressor(ArithmeticEncoder* enc, U32 bits, U32 contexts, U32 bits_high, U32 range)
+{
+ assert(enc);
+ this->enc = enc;
+ this->dec = 0;
+ this->bits = bits;
+ this->contexts = contexts;
+ this->bits_high = bits_high;
+ this->range = range;
+
+ if (range) // the corrector's significant bits and range
+ {
+ corr_bits = 0;
+ corr_range = range;
+ while (range)
+ {
+ range = range >> 1;
+ corr_bits++;
+ }
+ if (corr_range == (1u << (corr_bits-1)))
+ {
+ corr_bits--;
+ }
+ // the corrector must fall into this interval
+ corr_min = -((I32)(corr_range/2));
+ corr_max = corr_min + corr_range - 1;
+ }
+ else if (bits && bits < 32)
+ {
+ corr_bits = bits;
+ corr_range = 1u << bits;
+ // the corrector must fall into this interval
+ corr_min = -((I32)(corr_range/2));
+ corr_max = corr_min + corr_range - 1;
+ }
+ else
+ {
+ corr_bits = 32;
+ corr_range = 0;
+ // the corrector must fall into this interval
+ corr_min = I32_MIN;
+ corr_max = I32_MAX;
+ }
+
+ k = 0;
+
+ mBits = 0;
+ mCorrector = 0;
+
+#ifdef CREATE_HISTOGRAMS
+ corr_histogram = (int**)malloc(sizeof(int*) * (corr_bits+1));
+ for (int k = 0; k <= corr_bits; k++)
+ {
+ corr_histogram[k] = (int*)malloc(sizeof(int) * ((1<enc = 0;
+ this->dec = dec;
+ this->bits = bits;
+ this->contexts = contexts;
+ this->bits_high = bits_high;
+ this->range = range;
+
+ if (range) // the corrector's significant bits and range
+ {
+ corr_bits = 0;
+ corr_range = range;
+ while (range)
+ {
+ range = range >> 1;
+ corr_bits++;
+ }
+ if (corr_range == (1u << (corr_bits-1)))
+ {
+ corr_bits--;
+ }
+ // the corrector must fall into this interval
+ corr_min = -((I32)(corr_range/2));
+ corr_max = corr_min + corr_range - 1;
+ }
+ else if (bits && bits < 32)
+ {
+ corr_bits = bits;
+ corr_range = 1u << bits;
+ // the corrector must fall into this interval
+ corr_min = -((I32)(corr_range/2));
+ corr_max = corr_min + corr_range - 1;
+ }
+ else
+ {
+ corr_bits = 32;
+ corr_range = 0;
+ // the corrector must fall into this interval
+ corr_min = I32_MIN;
+ corr_max = I32_MAX;
+ }
+
+ k = 0;
+
+ mBits = 0;
+ mCorrector = 0;
+}
+
+IntegerCompressor::~IntegerCompressor()
+{
+ U32 i;
+ if (mBits)
+ {
+ for (i = 0; i < contexts; i++)
+ {
+ if (enc) enc->destroySymbolModel(mBits[i]);
+ else dec->destroySymbolModel(mBits[i]);
+ }
+ delete [] mBits;
+ }
+#ifndef COMPRESS_ONLY_K
+ if (mCorrector)
+ {
+ if (enc) enc->destroyBitModel((ArithmeticBitModel*)mCorrector[0]);
+ else dec->destroyBitModel((ArithmeticBitModel*)mCorrector[0]);
+ for (i = 1; i <= corr_bits; i++)
+ {
+ if (enc) enc->destroySymbolModel(mCorrector[i]);
+ else dec->destroySymbolModel(mCorrector[i]);
+ }
+ delete [] mCorrector;
+ }
+#endif
+
+#ifdef CREATE_HISTOGRAMS
+ if (end)
+ {
+ int total_number = 0;
+ double total_entropy = 0.0f;
+ double total_raw = 0.0f;
+ for (int k = 0; k <= corr_bits; k++)
+ {
+ int number = 0;
+ int different = 0;
+ for (int c = 0; c <= (1<createSymbolModel(corr_bits+1);
+ }
+#ifndef COMPRESS_ONLY_K
+ mCorrector = new ArithmeticModel*[corr_bits+1];
+ mCorrector[0] = (ArithmeticModel*)enc->createBitModel();
+ for (i = 1; i <= corr_bits; i++)
+ {
+ if (i <= bits_high)
+ {
+ mCorrector[i] = enc->createSymbolModel(1<createSymbolModel(1<initSymbolModel(mBits[i]);
+ }
+#ifndef COMPRESS_ONLY_K
+ enc->initBitModel((ArithmeticBitModel*)mCorrector[0]);
+ for (i = 1; i <= corr_bits; i++)
+ {
+ enc->initSymbolModel(mCorrector[i]);
+ }
+#endif
+}
+
+void IntegerCompressor::compress(I32 pred, I32 real, U32 context)
+{
+ assert(enc);
+ // the corrector will be within the interval [ - (corr_range - 1) ... + (corr_range - 1) ]
+ I32 corr = real - pred;
+ // we fold the corrector into the interval [ corr_min ... corr_max ]
+ if (corr < corr_min) corr += corr_range;
+ else if (corr > corr_max) corr -= corr_range;
+ writeCorrector(corr, mBits[context]);
+}
+
+void IntegerCompressor::initDecompressor()
+{
+ U32 i;
+
+ assert(dec);
+
+ // maybe create the models
+ if (mBits == 0)
+ {
+ mBits = new ArithmeticModel*[contexts];
+ for (i = 0; i < contexts; i++)
+ {
+ mBits[i] = dec->createSymbolModel(corr_bits+1);
+ }
+#ifndef COMPRESS_ONLY_K
+ mCorrector = new ArithmeticModel*[corr_bits+1];
+ mCorrector[0] = (ArithmeticModel*)dec->createBitModel();
+ for (i = 1; i <= corr_bits; i++)
+ {
+ if (i <= bits_high)
+ {
+ mCorrector[i] = dec->createSymbolModel(1<createSymbolModel(1<initSymbolModel(mBits[i]);
+ }
+#ifndef COMPRESS_ONLY_K
+ dec->initBitModel((ArithmeticBitModel*)mCorrector[0]);
+ for (i = 1; i <= corr_bits; i++)
+ {
+ dec->initSymbolModel(mCorrector[i]);
+ }
+#endif
+}
+
+I32 IntegerCompressor::decompress(I32 pred, U32 context)
+{
+ assert(dec);
+ I32 real = pred + readCorrector(mBits[context]);
+ if (real < 0) real += corr_range;
+ else if ((U32)(real) >= corr_range) real -= corr_range;
+ return real;
+}
+
+/*
+static const char log_table256[256] =
+{
+ -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
+};
+
+unsigned int v; // 32-bit word to find the log of
+unsigned r; // r will be lg(v)
+register unsigned int t, tt; // temporaries
+
+if (tt = v >> 16)
+{
+ r = (t = tt >> 8) ? 24 + LogTable256[t] : 16 + LogTable256[tt];
+}
+else
+{
+ r = (t = v >> 8) ? 8 + LogTable256[t] : LogTable256[v];
+}
+*/
+
+void IntegerCompressor::writeCorrector(I32 c, ArithmeticModel* mBits)
+{
+ U32 c1;
+
+ // find the tighest interval [ - (2^k - 1) ... + (2^k) ] that contains c
+
+ k = 0;
+
+ // do this by checking the absolute value of c (adjusted for the case that c is 2^k)
+
+ c1 = (c <= 0 ? -c : c-1);
+
+ // this loop could be replaced with more efficient code
+
+ while (c1)
+ {
+ c1 = c1 >> 1;
+ k = k + 1;
+ }
+
+ // the number k is between 0 and corr_bits and describes the interval the corrector falls into
+ // we can compress the exact location of c within this interval using k bits
+
+ enc->encodeSymbol(mBits, k);
+
+#ifdef COMPRESS_ONLY_K
+ if (k) // then c is either smaller than 0 or bigger than 1
+ {
+ assert((c != 0) && (c != 1));
+ if (k < 32)
+ {
+ // translate the corrector c into the k-bit interval [ 0 ... 2^k - 1 ]
+ if (c < 0) // then c is in the interval [ - (2^k - 1) ... - (2^(k-1)) ]
+ {
+ // so we translate c into the interval [ 0 ... + 2^(k-1) - 1 ] by adding (2^k - 1)
+ enc->writeBits(k, c + ((1<writeBits(k, c - 1);
+#ifdef CREATE_HISTOGRAMS
+ corr_histogram[k][c - 1]++;
+#endif
+ }
+ }
+ }
+ else // then c is 0 or 1
+ {
+ assert((c == 0) || (c == 1));
+ enc->writeBit(c);
+#ifdef CREATE_HISTOGRAMS
+ corr_histogram[0][c]++;
+#endif
+ }
+#else // COMPRESS_ONLY_K
+ if (k) // then c is either smaller than 0 or bigger than 1
+ {
+ assert((c != 0) && (c != 1));
+ if (k < 32)
+ {
+ // translate the corrector c into the k-bit interval [ 0 ... 2^k - 1 ]
+ if (c < 0) // then c is in the interval [ - (2^k - 1) ... - (2^(k-1)) ]
+ {
+ // so we translate c into the interval [ 0 ... + 2^(k-1) - 1 ] by adding (2^k - 1)
+ c += ((1<encodeSymbol(mCorrector[k], c);
+ }
+ else // for larger k we need to code the interval in two steps
+ {
+ // figure out how many lower bits there are
+ int k1 = k-bits_high;
+ // c1 represents the lowest k-bits_high+1 bits
+ c1 = c & ((1<> k1;
+ // compress the higher bits using a context table
+ enc->encodeSymbol(mCorrector[k], c);
+ // store the lower k1 bits raw
+ enc->writeBits(k1, c1);
+ }
+ }
+ }
+ else // then c is 0 or 1
+ {
+ assert((c == 0) || (c == 1));
+ enc->encodeBit((ArithmeticBitModel*)mCorrector[0],c);
+ }
+#endif // COMPRESS_ONLY_K
+}
+
+I32 IntegerCompressor::readCorrector(ArithmeticModel* mBits)
+{
+ I32 c;
+
+ // decode within which interval the corrector is falling
+
+ k = dec->decodeSymbol(mBits);
+
+ // decode the exact location of the corrector within the interval
+
+#ifdef COMPRESS_ONLY_K
+ if (k) // then c is either smaller than 0 or bigger than 1
+ {
+ if (k < 32)
+ {
+ c = dec->readBits(k);
+
+ if (c >= (1<<(k-1))) // if c is in the interval [ 2^(k-1) ... + 2^k - 1 ]
+ {
+ // so we translate c back into the interval [ 2^(k-1) + 1 ... 2^k ] by adding 1
+ c += 1;
+ }
+ else // otherwise c is in the interval [ 0 ... + 2^(k-1) - 1 ]
+ {
+ // so we translate c back into the interval [ - (2^k - 1) ... - (2^(k-1)) ] by subtracting (2^k - 1)
+ c -= ((1<readBit();
+ }
+#else // COMPRESS_ONLY_K
+ if (k) // then c is either smaller than 0 or bigger than 1
+ {
+ if (k < 32)
+ {
+ if (k <= bits_high) // for small k we can do this in one step
+ {
+ // decompress c with the range coder
+ c = dec->decodeSymbol(mCorrector[k]);
+ }
+ else
+ {
+ // for larger k we need to do this in two steps
+ int k1 = k-bits_high;
+ // decompress higher bits with table
+ c = dec->decodeSymbol(mCorrector[k]);
+ // read lower bits raw
+ int c1 = dec->readBits(k1);
+ // put the corrector back together
+ c = (c << k1) | c1;
+ }
+ // translate c back into its correct interval
+ if (c >= (1<<(k-1))) // if c is in the interval [ 2^(k-1) ... + 2^k - 1 ]
+ {
+ // so we translate c back into the interval [ 2^(k-1) + 1 ... 2^k ] by adding 1
+ c += 1;
+ }
+ else // otherwise c is in the interval [ 0 ... + 2^(k-1) - 1 ]
+ {
+ // so we translate c back into the interval [ - (2^k - 1) ... - (2^(k-1)) ] by subtracting (2^k - 1)
+ c -= ((1<decodeBit((ArithmeticBitModel*)mCorrector[0]);
+ }
+#endif // COMPRESS_ONLY_K
+
+ return c;
+}
diff --git a/libs/laszip/src/integercompressor.hpp b/libs/laszip/src/integercompressor.hpp
new file mode 100644
index 0000000..4e1dcfb
--- /dev/null
+++ b/libs/laszip/src/integercompressor.hpp
@@ -0,0 +1,103 @@
+/*
+===============================================================================
+
+ FILE: integercompressor.hpp
+
+ CONTENTS:
+
+ This compressor provides three different contexts for encoding integer
+ numbers whose range may lie anywhere between 1 and 31 bits, which is
+ specified with the SetPrecision function.
+
+ The compressor encodes two things:
+
+ (1) the number k of miss-predicted low-order bits and
+ (2) the k-bit number that corrects the missprediction
+
+ The k-bit number is usually coded broken in two chunks. The highest
+ bits are compressed using an arithmetic range table. The lower bits
+ are stored raw without predicive coding. How many of the higher bits
+ are compressed can be specified with bits_high. The default is 8.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the COPYING file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 6 September 2014 -- removed inheritance of EntropyEncoder and EntropyDecoder
+ 10 January 2011 -- licensing change for LGPL release and liblas integration
+ 10 December 2010 -- unified for all entropy coders at Baeckerei Schaefer
+ 31 October 2009 -- switched from the Rangecoder to the Entropycoder
+ 30 September 2005 -- now splitting the corrector into raw and compressed bits
+ 13 July 2005 -- created after returning with many mosquito bites from OBX
+
+===============================================================================
+*/
+#ifndef INTEGER_COMPRESSOR_HPP
+#define INTEGER_COMPRESSOR_HPP
+
+#include "arithmeticencoder.hpp"
+#include "arithmeticdecoder.hpp"
+
+class IntegerCompressor
+{
+public:
+
+ // Constructor & Deconstructor
+ IntegerCompressor(ArithmeticEncoder* enc, U32 bits=16, U32 contexts=1, U32 bits_high=8, U32 range=0);
+ IntegerCompressor(ArithmeticDecoder* dec, U32 bits=16, U32 contexts=1, U32 bits_high=8, U32 range=0);
+ ~IntegerCompressor();
+
+ // Manage Compressor
+ void initCompressor();
+ void compress(I32 iPred, I32 iReal, U32 context=0);
+
+ // Manage Decompressor
+ void initDecompressor();
+ I32 decompress(I32 iPred, U32 context=0);
+
+ // Get the k corrector bits from the last compress/decompress call
+ U32 getK() const {return k;};
+
+private:
+ void writeCorrector(I32 c, ArithmeticModel* model);
+ I32 readCorrector(ArithmeticModel* model);
+
+ U32 k;
+
+ U32 contexts;
+ U32 bits_high;
+
+ U32 bits;
+ U32 range;
+
+ U32 corr_bits;
+ U32 corr_range;
+ I32 corr_min;
+ I32 corr_max;
+
+ ArithmeticEncoder* enc;
+ ArithmeticDecoder* dec;
+
+ ArithmeticModel** mBits;
+
+ ArithmeticModel** mCorrector;
+
+#ifdef CREATE_HISTOGRAMS
+ int** corr_histogram;
+#endif
+};
+
+#endif
diff --git a/libs/laszip/src/lasattributer.hpp b/libs/laszip/src/lasattributer.hpp
new file mode 100644
index 0000000..cbcc066
--- /dev/null
+++ b/libs/laszip/src/lasattributer.hpp
@@ -0,0 +1,562 @@
+/*
+===============================================================================
+
+ FILE: lasattributer.hpp
+
+ CONTENTS:
+
+ This class assists with handling the "extra bytes" that allow storing
+ additional per point attributes.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2015, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the LICENSE.txt file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 13 September 2018 -- removed tuples and triple support from attributes
+ 19 July 2015 -- created after FOSS4GE in the train back from Lake Como
+
+===============================================================================
+*/
+#ifndef LAS_ATTRIBUTER_HPP
+#define LAS_ATTRIBUTER_HPP
+
+#include "mydefs.hpp"
+
+#define LAS_ATTRIBUTE_U8 0
+#define LAS_ATTRIBUTE_I8 1
+#define LAS_ATTRIBUTE_U16 2
+#define LAS_ATTRIBUTE_I16 3
+#define LAS_ATTRIBUTE_U32 4
+#define LAS_ATTRIBUTE_I32 5
+#define LAS_ATTRIBUTE_U64 6
+#define LAS_ATTRIBUTE_I64 7
+#define LAS_ATTRIBUTE_F32 8
+#define LAS_ATTRIBUTE_F64 9
+
+class LASattribute
+{
+public:
+ U8 reserved[2]; // 2 bytes
+ U8 data_type; // 1 byte
+ U8 options; // 1 byte
+ CHAR name[32]; // 32 bytes
+ U8 unused[4]; // 4 bytes
+ U64I64F64 no_data[3]; // 24 = 3*8 bytes
+ U64I64F64 min[3]; // 24 = 3*8 bytes
+ U64I64F64 max[3]; // 24 = 3*8 bytes
+ F64 scale[3]; // 24 = 3*8 bytes
+ F64 offset[3]; // 24 = 3*8 bytes
+ CHAR description[32]; // 32 bytes
+
+ LASattribute(U8 size)
+ {
+ if (size == 0) throw;
+ memset(this, 0, sizeof(LASattribute));
+ scale[0] = scale[1] = scale[2] = 1.0;
+ this->options = size;
+ };
+
+ LASattribute(U32 type, const CHAR* name, const CHAR* description=0)
+ {
+ if (type > LAS_ATTRIBUTE_F64) throw;
+ if (name == 0) throw;
+ memset(this, 0, sizeof(LASattribute));
+ scale[0] = scale[1] = scale[2] = 1.0;
+ this->data_type = type+1;
+ strncpy(this->name, name, 32);
+ if (description) strncpy(this->description, description, 32);
+ };
+
+ inline BOOL set_no_data(U8 no_data) { if (0 == get_type()) { this->no_data[0].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+ inline BOOL set_no_data(I8 no_data) { if (1 == get_type()) { this->no_data[0].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+ inline BOOL set_no_data(U16 no_data) { if (2 == get_type()) { this->no_data[0].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+ inline BOOL set_no_data(I16 no_data) { if (3 == get_type()) { this->no_data[0].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+ inline BOOL set_no_data(U32 no_data) { if (4 == get_type()) { this->no_data[0].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+ inline BOOL set_no_data(I32 no_data) { if (5 == get_type()) { this->no_data[0].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+ inline BOOL set_no_data(U64 no_data) { if (6 == get_type()) { this->no_data[0].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+ inline BOOL set_no_data(I64 no_data) { if (7 == get_type()) { this->no_data[0].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+ inline BOOL set_no_data(F32 no_data) { if (8 == get_type()) { this->no_data[0].f64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+ inline BOOL set_no_data(F64 no_data)
+ {
+ switch (get_type())
+ {
+ case 0:
+ case 2:
+ case 4:
+ case 6:
+ this->no_data[0].u64 = (U64)no_data;
+ options |= 0x01;
+ return TRUE;
+ case 1:
+ case 3:
+ case 5:
+ case 7:
+ this->no_data[0].i64 = (I64)no_data;
+ options |= 0x01;
+ return TRUE;
+ case 8:
+ case 9:
+ this->no_data[0].f64 = no_data;
+ options |= 0x01;
+ return TRUE;
+ }
+ return FALSE;
+ };
+
+ inline void set_min(U8* min) { this->min[0] = cast(min); options |= 0x02; };
+ inline void update_min(U8* min) { this->min[0] = smallest(cast(min), this->min[0]); };
+ inline BOOL set_min(U8 min) { if (0 == get_type()) { this->min[0].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
+ inline BOOL set_min(I8 min) { if (1 == get_type()) { this->min[0].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
+ inline BOOL set_min(U16 min) { if (2 == get_type()) { this->min[0].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
+ inline BOOL set_min(I16 min) { if (3 == get_type()) { this->min[0].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
+ inline BOOL set_min(U32 min) { if (4 == get_type()) { this->min[0].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
+ inline BOOL set_min(I32 min) { if (5 == get_type()) { this->min[0].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
+ inline BOOL set_min(U64 min) { if (6 == get_type()) { this->min[0].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
+ inline BOOL set_min(I64 min) { if (7 == get_type()) { this->min[0].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
+ inline BOOL set_min(F32 min) { if (8 == get_type()) { this->min[0].f64 = min; options |= 0x02; return TRUE; } return FALSE; };
+ inline BOOL set_min(F64 min) { if (9 == get_type()) { this->min[0].f64 = min; options |= 0x02; return TRUE; } return FALSE; };
+
+ inline void set_max(U8* max) { this->max[0] = cast(max); options |= 0x04; };
+ inline void update_max(U8* max) { this->max[0] = biggest(cast(max), this->max[0]); };
+ inline BOOL set_max(U8 max) { if (0 == get_type()) { this->max[0].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
+ inline BOOL set_max(I8 max) { if (1 == get_type()) { this->max[0].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
+ inline BOOL set_max(U16 max) { if (2 == get_type()) { this->max[0].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
+ inline BOOL set_max(I16 max) { if (3 == get_type()) { this->max[0].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
+ inline BOOL set_max(U32 max) { if (4 == get_type()) { this->max[0].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
+ inline BOOL set_max(I32 max) { if (5 == get_type()) { this->max[0].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
+ inline BOOL set_max(U64 max) { if (6 == get_type()) { this->max[0].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
+ inline BOOL set_max(I64 max) { if (7 == get_type()) { this->max[0].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
+ inline BOOL set_max(F32 max) { if (8 == get_type()) { this->max[0].f64 = max; options |= 0x04; return TRUE; } return FALSE; };
+ inline BOOL set_max(F64 max) { if (9 == get_type()) { this->max[0].f64 = max; options |= 0x04; return TRUE; } return FALSE; };
+
+ inline BOOL set_scale(F64 scale) { if (data_type) { this->scale[0] = scale; options |= 0x08; return TRUE; } return FALSE; };
+ inline BOOL set_offset(F64 offset) { if (data_type) { this->offset[0] = offset; options |= 0x10; return TRUE; } return FALSE; };
+
+ inline BOOL unset_scale() { if (data_type) { options &= (~0x08); return TRUE; } return FALSE; };
+ inline BOOL unset_offset() { if (data_type) { options &= (~0x10); return TRUE; } return FALSE; };
+
+ inline BOOL has_no_data() const { return options & 0x01; };
+ inline BOOL has_min() const { return options & 0x02; };
+ inline BOOL has_max() const { return options & 0x04; };
+ inline BOOL has_scale() const { return options & 0x08; };
+ inline BOOL has_offset() const { return options & 0x10; };
+
+ inline U32 get_size() const
+ {
+ if (data_type)
+ {
+ const U32 size_table[10] = { 1, 1, 2, 2, 4, 4, 8, 8, 4, 8 };
+ I32 type = get_type();
+ I32 dim = get_dim();
+ return size_table[type] * dim;
+ }
+ else
+ {
+ return options;
+ }
+ };
+
+ inline F64 get_value_as_float(U8* pointer) const
+ {
+ F64 cast_value;
+ I32 type = get_type();
+ if (type == 0)
+ cast_value = (F64)*((U8*)pointer);
+ else if (type == 1)
+ cast_value = (F64)*((I8*)pointer);
+ else if (type == 2)
+ cast_value = (F64)*((U16*)pointer);
+ else if (type == 3)
+ cast_value = (F64)*((I16*)pointer);
+ else if (type == 4)
+ cast_value = (F64)*((U32*)pointer);
+ else if (type == 5)
+ cast_value = (F64)*((I32*)pointer);
+ else if (type == 6)
+ cast_value = (F64)(I64)*((U64*)pointer);
+ else if (type == 7)
+ cast_value = (F64)*((I64*)pointer);
+ else if (type == 8)
+ cast_value = (F64)*((F32*)pointer);
+ else
+ cast_value = *((F64*)pointer);
+ if (options & 0x08)
+ {
+ if (options & 0x10)
+ {
+ return offset[0]+scale[0]*cast_value;
+ }
+ else
+ {
+ return scale[0]*cast_value;
+ }
+ }
+ else
+ {
+ if (options & 0x10)
+ {
+ return offset[0]+cast_value;
+ }
+ else
+ {
+ return cast_value;
+ }
+ }
+ };
+
+ inline void set_value_as_float(U8* pointer, F64 value) const
+ {
+ F64 unoffset_and_unscaled_value;
+ if (options & 0x08)
+ {
+ if (options & 0x10)
+ {
+ unoffset_and_unscaled_value = (value - offset[0])/scale[0];
+ }
+ else
+ {
+ unoffset_and_unscaled_value = value/scale[0];
+ }
+ }
+ else
+ {
+ if (options & 0x10)
+ {
+ unoffset_and_unscaled_value = value - offset[0];
+ }
+ else
+ {
+ unoffset_and_unscaled_value = value;
+ }
+ }
+ I32 type = get_type();
+ if (type == 0)
+ *((U8*)pointer) = U8_QUANTIZE(unoffset_and_unscaled_value);
+ else if (type == 1)
+ *((I8*)pointer) = I8_QUANTIZE(unoffset_and_unscaled_value);
+ else if (type == 2)
+ *((U16*)pointer) = U16_QUANTIZE(unoffset_and_unscaled_value);
+ else if (type == 3)
+ *((I16*)pointer) = I16_QUANTIZE(unoffset_and_unscaled_value);
+ else if (type == 4)
+ *((U32*)pointer) = U32_QUANTIZE(unoffset_and_unscaled_value);
+ else if (type == 5)
+ *((I32*)pointer) = U32_QUANTIZE(unoffset_and_unscaled_value);
+ else if (type == 6)
+ *((U64*)pointer) = U64_QUANTIZE(unoffset_and_unscaled_value);
+ else if (type == 7)
+ *((I64*)pointer) = I64_QUANTIZE(unoffset_and_unscaled_value);
+ else if (type == 8)
+ *((F32*)pointer) = (F32)unoffset_and_unscaled_value;
+ else
+ *((F64*)pointer) = unoffset_and_unscaled_value;
+ };
+
+private:
+ inline I32 get_type() const
+ {
+ return ((I32)data_type - 1)%10;
+ };
+ inline I32 get_dim() const // compute dimension of deprecated tuple and triple attributes
+ {
+ return ((I32)data_type - 1)/10 + 1;
+ };
+ inline U64I64F64 cast(U8* pointer) const
+ {
+ I32 type = get_type();
+ U64I64F64 cast_value;
+ if (type == 0)
+ cast_value.u64 = *((U8*)pointer);
+ else if (type == 1)
+ cast_value.i64 = *((I8*)pointer);
+ else if (type == 2)
+ cast_value.u64 = *((U16*)pointer);
+ else if (type == 3)
+ cast_value.i64 = *((I16*)pointer);
+ else if (type == 4)
+ cast_value.u64 = *((U32*)pointer);
+ else if (type == 5)
+ cast_value.i64 = *((I32*)pointer);
+ else if (type == 6)
+ cast_value.u64 = *((U64*)pointer);
+ else if (type == 7)
+ cast_value.i64 = *((I64*)pointer);
+ else if (type == 8)
+ cast_value.f64 = *((F32*)pointer);
+ else
+ cast_value.f64 = *((F64*)pointer);
+ return cast_value;
+ };
+ inline U64I64F64 smallest(U64I64F64 a, U64I64F64 b) const
+ {
+ I32 type = get_type();
+ if (type >= 8) // float compare
+ {
+ if (a.f64 < b.f64) return a;
+ else return b;
+ }
+ if (type & 1) // int compare
+ {
+ if (a.i64 < b.i64) return a;
+ else return b;
+ }
+ if (a.u64 < b.u64) return a;
+ else return b;
+ };
+ inline U64I64F64 biggest(U64I64F64 a, U64I64F64 b) const
+ {
+ I32 type = get_type();
+ if (type >= 8) // float compare
+ {
+ if (a.f64 > b.f64) return a;
+ else return b;
+ }
+ if (type & 1) // int compare
+ {
+ if (a.i64 > b.i64) return a;
+ else return b;
+ }
+ if (a.u64 > b.u64) return a;
+ else return b;
+ };
+};
+
+class LASattributer
+{
+public:
+ BOOL attributes_linked;
+ I32 number_attributes;
+ LASattribute* attributes;
+ I32* attribute_starts;
+ I32* attribute_sizes;
+
+ LASattributer()
+ {
+ attributes_linked = TRUE;
+ number_attributes = 0;
+ attributes = 0;
+ attribute_starts = 0;
+ attribute_sizes = 0;
+ };
+
+ ~LASattributer()
+ {
+ clean_attributes();
+ };
+
+ void clean_attributes()
+ {
+ if (attributes_linked)
+ {
+ if (attributes)
+ {
+ number_attributes = 0;
+ free(attributes); attributes = 0;
+ free(attribute_starts); attribute_starts = 0;
+ free(attribute_sizes); attribute_sizes = 0;
+ }
+ }
+ };
+
+ BOOL init_attributes(U32 number_attributes, LASattribute* attributes)
+ {
+ U32 i;
+ clean_attributes();
+ this->number_attributes = number_attributes;
+ this->attributes = (LASattribute*)malloc(sizeof(LASattribute)*number_attributes);
+ if (this->attributes == 0)
+ {
+ return FALSE;
+ }
+ memcpy(this->attributes, attributes, sizeof(LASattribute)*number_attributes);
+ attribute_starts = (I32*)malloc(sizeof(I32)*number_attributes);
+ if (attribute_starts == 0)
+ {
+ return FALSE;
+ }
+ attribute_sizes = (I32*)malloc(sizeof(I32)*number_attributes);
+ if (attribute_sizes == 0)
+ {
+ return FALSE;
+ }
+ attribute_starts[0] = 0;
+ attribute_sizes[0] = attributes[0].get_size();
+ for (i = 1; i < number_attributes; i++)
+ {
+ attribute_starts[i] = attribute_starts[i-1] + attribute_sizes[i-1];
+ attribute_sizes[i] = attributes[i].get_size();
+ }
+ return TRUE;
+ };
+
+ I32 add_attribute(const LASattribute attribute)
+ {
+ if (attribute.get_size())
+ {
+ if (attributes)
+ {
+ number_attributes++;
+ attributes = (LASattribute*)realloc(attributes, sizeof(LASattribute)*number_attributes);
+ if (attributes == 0)
+ {
+ return -1;
+ }
+ attribute_starts = (I32*)realloc(attribute_starts, sizeof(I32)*number_attributes);
+ if (attribute_starts == 0)
+ {
+ return -1;
+ }
+ attribute_sizes = (I32*)realloc(attribute_sizes, sizeof(I32)*number_attributes);
+ if (attribute_sizes == 0)
+ {
+ return -1;
+ }
+ attributes[number_attributes-1] = attribute;
+ attribute_starts[number_attributes-1] = attribute_starts[number_attributes-2] + attribute_sizes[number_attributes-2];
+ attribute_sizes[number_attributes-1] = attributes[number_attributes-1].get_size();
+ }
+ else
+ {
+ number_attributes = 1;
+ attributes = (LASattribute*)malloc(sizeof(LASattribute));
+ if (attributes == 0)
+ {
+ return -1;
+ }
+ attribute_starts = (I32*)malloc(sizeof(I32));
+ if (attribute_starts == 0)
+ {
+ return -1;
+ }
+ attribute_sizes = (I32*)malloc(sizeof(I32));
+ if (attribute_sizes == 0)
+ {
+ return -1;
+ }
+ attributes[0] = attribute;
+ attribute_starts[0] = 0;
+ attribute_sizes[0] = attributes[0].get_size();
+ }
+ return number_attributes-1;
+ }
+ return -1;
+ };
+
+ inline I16 get_attributes_size() const
+ {
+ return (attributes ? attribute_starts[number_attributes-1] + attribute_sizes[number_attributes-1] : 0);
+ }
+
+ I32 get_attribute_index(const CHAR* name) const
+ {
+ I32 i;
+ for (i = 0; i < number_attributes; i++)
+ {
+ if (strcmp(attributes[i].name, name) == 0)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ I32 get_attribute_start(const CHAR* name) const
+ {
+ I32 i;
+ for (i = 0; i < number_attributes; i++)
+ {
+ if (strcmp(attributes[i].name, name) == 0)
+ {
+ return attribute_starts[i];
+ }
+ }
+ return -1;
+ }
+
+ I32 get_attribute_start(I32 index) const
+ {
+ if (index < number_attributes)
+ {
+ return attribute_starts[index];
+ }
+ return -1;
+ }
+
+ I32 get_attribute_size(I32 index) const
+ {
+ if (index < number_attributes)
+ {
+ return attribute_sizes[index];
+ }
+ return -1;
+ }
+
+ const CHAR* get_attribute_name(I32 index) const
+ {
+ if (index < number_attributes)
+ {
+ return attributes[index].name;
+ }
+ return 0;
+ }
+
+ BOOL remove_attribute(I32 index)
+ {
+ if (index < 0 || index >= number_attributes)
+ {
+ return FALSE;
+ }
+ for (index = index + 1; index < number_attributes; index++)
+ {
+ attributes[index-1] = attributes[index];
+ if (index > 1)
+ {
+ attribute_starts[index-1] = attribute_starts[index-2] + attribute_sizes[index-2];
+ }
+ else
+ {
+ attribute_starts[index-1] = 0;
+ }
+ attribute_sizes[index-1] = attribute_sizes[index];
+ }
+ number_attributes--;
+ if (number_attributes)
+ {
+ attributes = (LASattribute*)realloc(attributes, sizeof(LASattribute)*number_attributes);
+ attribute_starts = (I32*)realloc(attribute_starts, sizeof(I32)*number_attributes);
+ attribute_sizes = (I32*)realloc(attribute_sizes, sizeof(I32)*number_attributes);
+ }
+ else
+ {
+ free(attributes); attributes = 0;
+ free(attribute_starts); attribute_starts = 0;
+ free(attribute_sizes); attribute_sizes = 0;
+ }
+ return TRUE;
+ }
+
+ BOOL remove_attribute(const CHAR* name)
+ {
+ I32 index = get_attribute_index(name);
+ if (index != -1)
+ {
+ return remove_attribute(index);
+ }
+ return FALSE;
+ }
+};
+
+#endif
diff --git a/libs/laszip/src/lasindex.cpp b/libs/laszip/src/lasindex.cpp
new file mode 100644
index 0000000..c16bdb4
--- /dev/null
+++ b/libs/laszip/src/lasindex.cpp
@@ -0,0 +1,701 @@
+/*
+===============================================================================
+
+ FILE: lasindex.cpp
+
+ CONTENTS:
+
+ see corresponding header file
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2011-2017, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the LICENSE.txt file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ see corresponding header file
+
+===============================================================================
+*/
+#include "lasindex.hpp"
+
+#include
+#include
+#include
+
+#include "lasquadtree.hpp"
+#include "lasinterval.hpp"
+#ifdef LASZIPDLL_EXPORTS
+#include "lasreadpoint.hpp"
+#else
+#include "lasreader.hpp"
+#endif
+#include "bytestreamin_file.hpp"
+#include "bytestreamout_file.hpp"
+
+#ifdef UNORDERED
+ // Figure out whether is in tr1
+# ifdef __has_include
+# if __has_include()
+# include
+ using namespace std;
+# define UNORDERED_FOUND
+# endif
+# endif
+# ifdef HAVE_UNORDERED_MAP
+# include
+ using namespace std;
+# elif defined(UNORDERED_FOUND)
+# include
+ using namespace std;
+ using namespace tr1;
+# endif
+typedef unordered_map my_cell_hash;
+#elif defined(LZ_WIN32_VC6)
+#include
+using namespace std;
+typedef hash_map my_cell_hash;
+#else
+#include
+using namespace std;
+typedef unordered_map my_cell_hash;
+#endif
+
+LASindex::LASindex()
+{
+ spatial = 0;
+ interval = 0;
+ have_interval = FALSE;
+ start = 0;
+ end = 0;
+ full = 0;
+ total = 0;
+ cells = 0;
+}
+
+LASindex::~LASindex()
+{
+ if (spatial) delete spatial;
+ if (interval) delete interval;
+}
+
+void LASindex::prepare(LASquadtree* spatial, I32 threshold)
+{
+ if (this->spatial) delete this->spatial;
+ this->spatial = spatial;
+ if (this->interval) delete this->interval;
+ this->interval = new LASinterval(threshold);
+}
+
+BOOL LASindex::add(const F64 x, const F64 y, const U32 p_index)
+{
+ I32 cell = spatial->get_cell_index(x, y);
+ return interval->add(p_index, cell);
+}
+
+void LASindex::complete(U32 minimum_points, I32 maximum_intervals, const BOOL verbose)
+{
+ if (verbose)
+ {
+ fprintf(stderr,"before complete %d %d\n", minimum_points, maximum_intervals);
+ print(FALSE);
+ }
+ if (minimum_points)
+ {
+ I32 hash1 = 0;
+ my_cell_hash cell_hash[2];
+ // insert all cells into hash1
+ interval->get_cells();
+ while (interval->has_cells())
+ {
+ cell_hash[hash1][interval->index] = interval->full;
+ }
+ while (cell_hash[hash1].size())
+ {
+ I32 hash2 = (hash1+1)%2;
+ cell_hash[hash2].clear();
+ // coarsen if a coarser cell will still have fewer than minimum_points (and points in all subcells)
+ BOOL coarsened = FALSE;
+ U32 i, full;
+ I32 coarser_index;
+ U32 num_indices;
+ U32 num_filled;
+ I32* indices;
+ my_cell_hash::iterator hash_element_inner;
+ my_cell_hash::iterator hash_element_outer = cell_hash[hash1].begin();
+ while (hash_element_outer != cell_hash[hash1].end())
+ {
+ if ((*hash_element_outer).second)
+ {
+ if (spatial->coarsen((*hash_element_outer).first, &coarser_index, &num_indices, &indices))
+ {
+ full = 0;
+ num_filled = 0;
+ for (i = 0; i < num_indices; i++)
+ {
+ if ((*hash_element_outer).first == indices[i])
+ {
+ hash_element_inner = hash_element_outer;
+ }
+ else
+ {
+ hash_element_inner = cell_hash[hash1].find(indices[i]);
+ }
+ if (hash_element_inner != cell_hash[hash1].end())
+ {
+ full += (*hash_element_inner).second;
+ (*hash_element_inner).second = 0;
+ num_filled++;
+ }
+ }
+ if ((full < minimum_points) && (num_filled == num_indices))
+ {
+ interval->merge_cells(num_indices, indices, coarser_index);
+ coarsened = TRUE;
+ cell_hash[hash2][coarser_index] = full;
+ }
+ }
+ }
+ hash_element_outer++;
+ }
+ if (!coarsened) break;
+ hash1 = (hash1+1)%2;
+ }
+ // tell spatial about the existing cells
+ interval->get_cells();
+ while (interval->has_cells())
+ {
+ spatial->manage_cell(interval->index);
+ }
+ if (verbose)
+ {
+ fprintf(stderr,"after minimum_points %d\n", minimum_points);
+ print(FALSE);
+ }
+ }
+ if (maximum_intervals < 0)
+ {
+ maximum_intervals = -maximum_intervals*interval->get_number_cells();
+ }
+ if (maximum_intervals)
+ {
+ interval->merge_intervals(maximum_intervals, verbose);
+ if (verbose)
+ {
+ fprintf(stderr,"after maximum_intervals %d\n", maximum_intervals);
+ print(FALSE);
+ }
+ }
+}
+
+void LASindex::print(BOOL verbose)
+{
+ U32 total_cells = 0;
+ U32 total_full = 0;
+ U32 total_total = 0;
+ U32 total_intervals = 0;
+ U32 total_check;
+ U32 intervals;
+ interval->get_cells();
+ while (interval->has_cells())
+ {
+ total_check = 0;
+ intervals = 0;
+ while (interval->has_intervals())
+ {
+ total_check += interval->end-interval->start+1;
+ intervals++;
+ }
+ if (total_check != interval->total)
+ {
+ fprintf(stderr,"ERROR: total_check %d != interval->total %d\n", total_check, interval->total);
+ }
+ if (verbose) fprintf(stderr,"cell %d intervals %d full %d total %d (%.2f)\n", interval->index, intervals, interval->full, interval->total, 100.0f*interval->full/interval->total);
+ total_cells++;
+ total_full += interval->full;
+ total_total += interval->total;
+ total_intervals += intervals;
+ }
+ if (verbose) fprintf(stderr,"total cells/intervals %d/%d full %d (%.2f)\n", total_cells, total_intervals, total_full, 100.0f*total_full/total_total);
+}
+
+LASquadtree* LASindex::get_spatial() const
+{
+ return spatial;
+}
+
+LASinterval* LASindex::get_interval() const
+{
+ return interval;
+}
+
+BOOL LASindex::intersect_rectangle(const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y)
+{
+ have_interval = FALSE;
+ cells = spatial->intersect_rectangle(r_min_x, r_min_y, r_max_x, r_max_y);
+// fprintf(stderr,"%d cells of %g/%g %g/%g intersect rect %g/%g %g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), r_min_x, r_min_y, r_max_x, r_max_y);
+ if (cells)
+ return merge_intervals();
+ return FALSE;
+}
+
+BOOL LASindex::intersect_tile(const F32 ll_x, const F32 ll_y, const F32 size)
+{
+ have_interval = FALSE;
+ cells = spatial->intersect_tile(ll_x, ll_y, size);
+// fprintf(stderr,"%d cells of %g/%g %g/%g intersect tile %g/%g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), ll_x, ll_y, size);
+ if (cells)
+ return merge_intervals();
+ return FALSE;
+}
+
+BOOL LASindex::intersect_circle(const F64 center_x, const F64 center_y, const F64 radius)
+{
+ have_interval = FALSE;
+ cells = spatial->intersect_circle(center_x, center_y, radius);
+// fprintf(stderr,"%d cells of %g/%g %g/%g intersect circle %g/%g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), center_x, center_y, radius);
+ if (cells)
+ return merge_intervals();
+ return FALSE;
+}
+
+BOOL LASindex::get_intervals()
+{
+ have_interval = FALSE;
+ return interval->get_merged_cell();
+}
+
+BOOL LASindex::has_intervals()
+{
+ if (interval->has_intervals())
+ {
+ start = interval->start;
+ end = interval->end;
+ full = interval->full;
+ have_interval = TRUE;
+ return TRUE;
+ }
+ have_interval = FALSE;
+ return FALSE;
+}
+
+BOOL LASindex::read(FILE* file)
+{
+ if (file == 0) return FALSE;
+ ByteStreamIn* stream;
+ if (IS_LITTLE_ENDIAN())
+ stream = new ByteStreamInFileLE(file);
+ else
+ stream = new ByteStreamInFileBE(file);
+ if (!read(stream))
+ {
+ delete stream;
+ return FALSE;
+ }
+ delete stream;
+ return TRUE;
+}
+
+BOOL LASindex::write(FILE* file) const
+{
+ if (file == 0) return FALSE;
+ ByteStreamOut* stream;
+ if (IS_LITTLE_ENDIAN())
+ stream = new ByteStreamOutFileLE(file);
+ else
+ stream = new ByteStreamOutFileBE(file);
+ if (!write(stream))
+ {
+ delete stream;
+ return FALSE;
+ }
+ delete stream;
+ return TRUE;
+}
+
+BOOL LASindex::read(const char* file_name)
+{
+ if (file_name == 0) return FALSE;
+ char* name = LASCopyString(file_name);
+ if (strstr(file_name, ".las") || strstr(file_name, ".laz"))
+ {
+ name[strlen(name)-1] = 'x';
+ }
+ else if (strstr(file_name, ".LAS") || strstr(file_name, ".LAZ"))
+ {
+ name[strlen(name)-1] = 'X';
+ }
+ else
+ {
+ name[strlen(name)-3] = 'l';
+ name[strlen(name)-2] = 'a';
+ name[strlen(name)-1] = 'x';
+ }
+#ifdef _MSC_VER
+ wchar_t* utf16_name = UTF8toUTF16(name);
+ FILE* file = _wfopen(utf16_name, L"rb");
+ delete [] utf16_name;
+#else
+ FILE* file = fopen(name, "rb");
+#endif
+ if (file == 0)
+ {
+ free(name);
+ return FALSE;
+ }
+ if (!read(file))
+ {
+ fprintf(stderr,"ERROR (LASindex): cannot read '%s'\n", name);
+ fclose(file);
+ free(name);
+ return FALSE;
+ }
+ fclose(file);
+ free(name);
+ return TRUE;
+}
+
+BOOL LASindex::append(const char* file_name) const
+{
+#ifdef LASZIPDLL_EXPORTS
+ return FALSE;
+#else
+ LASreadOpener lasreadopener;
+
+ if (file_name == 0) return FALSE;
+
+ // open reader
+
+ LASreader* lasreader = lasreadopener.open(file_name);
+ if (lasreader == 0) return FALSE;
+ if (lasreader->header.laszip == 0) return FALSE;
+
+ // close reader
+
+ lasreader->close();
+
+#ifdef _MSC_VER
+ wchar_t* utf16_file_name = UTF8toUTF16(file_name);
+ FILE* file = _wfopen(utf16_file_name, L"rb");
+ delete [] utf16_file_name;
+#else
+ FILE* file = fopen(file_name, "rb");
+#endif
+ ByteStreamIn* bytestreamin = 0;
+ if (IS_LITTLE_ENDIAN())
+ bytestreamin = new ByteStreamInFileLE(file);
+ else
+ bytestreamin = new ByteStreamInFileBE(file);
+
+ // maybe write LASindex EVLR start position into LASzip VLR
+
+ I64 offset_laz_vlr = -1;
+
+ // where to write LASindex EVLR that will contain the LAX file
+
+ I64 number_of_special_evlrs = lasreader->header.laszip->number_of_special_evlrs;
+ I64 offset_to_special_evlrs = lasreader->header.laszip->offset_to_special_evlrs;
+
+ if ((number_of_special_evlrs == -1) && (offset_to_special_evlrs == -1))
+ {
+ bytestreamin->seekEnd();
+ number_of_special_evlrs = 1;
+ offset_to_special_evlrs = bytestreamin->tell();
+
+ // find LASzip VLR
+
+ I64 total = lasreader->header.header_size + 2;
+ U32 number_of_variable_length_records = lasreader->header.number_of_variable_length_records + 1 + (lasreader->header.vlr_lastiling != 0) + (lasreader->header.vlr_lasoriginal != 0);
+
+ for (U32 u = 0; u < number_of_variable_length_records; u++)
+ {
+ bytestreamin->seek(total);
+
+ CHAR user_id[16];
+ try { bytestreamin->getBytes((U8*)user_id, 16); } catch(...)
+ {
+ fprintf(stderr,"ERROR: reading header.vlrs[%d].user_id\n", u);
+ return FALSE;
+ }
+ if (strcmp(user_id, "laszip encoded") == 0)
+ {
+ offset_laz_vlr = bytestreamin->tell() - 18;
+ break;
+ }
+ U16 record_id;
+ try { bytestreamin->get16bitsLE((U8*)&record_id); } catch(...)
+ {
+ fprintf(stderr,"ERROR: reading header.vlrs[%d].record_id\n", u);
+ return FALSE;
+ }
+ U16 record_length_after_header;
+ try { bytestreamin->get16bitsLE((U8*)&record_length_after_header); } catch(...)
+ {
+ fprintf(stderr,"ERROR: reading header.vlrs[%d].record_length_after_header\n", u);
+ return FALSE;
+ }
+ total += (54 + record_length_after_header);
+ }
+
+ if (number_of_special_evlrs == -1) return FALSE;
+ }
+
+ delete bytestreamin;
+ fclose(file);
+
+ ByteStreamOut* bytestreamout;
+#ifdef _MSC_VER
+ utf16_file_name = UTF8toUTF16(file_name);
+ file = _wfopen(utf16_file_name, L"rb+");
+ delete [] utf16_file_name;
+#else
+ file = fopen(file_name, "rb+");
+#endif
+ if (IS_LITTLE_ENDIAN())
+ bytestreamout = new ByteStreamOutFileLE(file);
+ else
+ bytestreamout = new ByteStreamOutFileBE(file);
+ bytestreamout->seek(offset_to_special_evlrs);
+
+ LASevlr lax_evlr;
+ sprintf(lax_evlr.user_id, "LAStools");
+ lax_evlr.record_id = 30;
+ sprintf(lax_evlr.description, "LAX spatial indexing (LASindex)");
+
+ bytestreamout->put16bitsLE((const U8*)&(lax_evlr.reserved));
+ bytestreamout->putBytes((const U8*)lax_evlr.user_id, 16);
+ bytestreamout->put16bitsLE((const U8*)&(lax_evlr.record_id));
+ bytestreamout->put64bitsLE((const U8*)&(lax_evlr.record_length_after_header));
+ bytestreamout->putBytes((const U8*)lax_evlr.description, 32);
+
+ if (!write(bytestreamout))
+ {
+ fprintf(stderr,"ERROR (LASindex): cannot append LAX to '%s'\n", file_name);
+ delete bytestreamout;
+ fclose(file);
+ delete lasreader;
+ return FALSE;
+ }
+
+ // update LASindex EVLR
+
+ lax_evlr.record_length_after_header = bytestreamout->tell() - offset_to_special_evlrs - 60;
+ bytestreamout->seek(offset_to_special_evlrs + 20);
+ bytestreamout->put64bitsLE((const U8*)&(lax_evlr.record_length_after_header));
+
+ // maybe update LASzip VLR
+
+ if (number_of_special_evlrs != -1)
+ {
+ bytestreamout->seek(offset_laz_vlr + 54 + 16);
+ bytestreamout->put64bitsLE((const U8*)&number_of_special_evlrs);
+ bytestreamout->put64bitsLE((const U8*)&offset_to_special_evlrs);
+ }
+
+ // close writer
+
+ bytestreamout->seekEnd();
+ delete bytestreamout;
+ fclose(file);
+
+ // delete reader
+
+ delete lasreader;
+
+ return TRUE;
+#endif
+}
+
+BOOL LASindex::write(const char* file_name) const
+{
+ if (file_name == 0) return FALSE;
+ char* name = LASCopyString(file_name);
+ if (strstr(file_name, ".las") || strstr(file_name, ".laz"))
+ {
+ name[strlen(name)-1] = 'x';
+ }
+ else if (strstr(file_name, ".LAS") || strstr(file_name, ".LAZ"))
+ {
+ name[strlen(name)-1] = 'X';
+ }
+ else
+ {
+ name[strlen(name)-3] = 'l';
+ name[strlen(name)-2] = 'a';
+ name[strlen(name)-1] = 'x';
+ }
+#ifdef _MSC_VER
+ wchar_t* utf16_name = UTF8toUTF16(name);
+ FILE* file = _wfopen(utf16_name, L"wb");
+ delete [] utf16_name;
+#else
+ FILE* file = fopen(name, "wb");
+#endif
+ if (file == 0)
+ {
+ fprintf(stderr,"ERROR (LASindex): cannot open '%s' for write\n", name);
+ free(name);
+ return FALSE;
+ }
+ if (!write(file))
+ {
+ fprintf(stderr,"ERROR (LASindex): cannot write '%s'\n", name);
+ fclose(file);
+ free(name);
+ return FALSE;
+ }
+ fclose(file);
+ free(name);
+ return TRUE;
+}
+
+BOOL LASindex::read(ByteStreamIn* stream)
+{
+ if (spatial)
+ {
+ delete spatial;
+ spatial = 0;
+ }
+ if (interval)
+ {
+ delete interval;
+ interval = 0;
+ }
+ char signature[4];
+ try { stream->getBytes((U8*)signature, 4); } catch (...)
+ {
+ fprintf(stderr,"ERROR (LASindex): reading signature\n");
+ return FALSE;
+ }
+ if (strncmp(signature, "LASX", 4) != 0)
+ {
+ fprintf(stderr,"ERROR (LASindex): wrong signature %4s instead of 'LASX'\n", signature);
+ return FALSE;
+ }
+ U32 version;
+ try { stream->get32bitsLE((U8*)&version); } catch (...)
+ {
+ fprintf(stderr,"ERROR (LASindex): reading version\n");
+ return FALSE;
+ }
+ // read spatial quadtree
+ spatial = new LASquadtree();
+ if (!spatial->read(stream))
+ {
+ fprintf(stderr,"ERROR (LASindex): cannot read LASspatial (LASquadtree)\n");
+ return FALSE;
+ }
+ // read interval
+ interval = new LASinterval();
+ if (!interval->read(stream))
+ {
+ fprintf(stderr,"ERROR (LASindex): reading LASinterval\n");
+ return FALSE;
+ }
+ // tell spatial about the existing cells
+ interval->get_cells();
+ while (interval->has_cells())
+ {
+ spatial->manage_cell(interval->index);
+ }
+ return TRUE;
+}
+
+BOOL LASindex::write(ByteStreamOut* stream) const
+{
+ if (!stream->putBytes((const U8*)"LASX", 4))
+ {
+ fprintf(stderr,"ERROR (LASindex): writing signature\n");
+ return FALSE;
+ }
+ U32 version = 0;
+ if (!stream->put32bitsLE((const U8*)&version))
+ {
+ fprintf(stderr,"ERROR (LASindex): writing version\n");
+ return FALSE;
+ }
+ // write spatial quadtree
+ if (!spatial->write(stream))
+ {
+ fprintf(stderr,"ERROR (LASindex): cannot write LASspatial (LASquadtree)\n");
+ return FALSE;
+ }
+ // write interval
+ if (!interval->write(stream))
+ {
+ fprintf(stderr,"ERROR (LASindex): writing LASinterval\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+// seek to next interval point
+
+#ifdef LASZIPDLL_EXPORTS
+BOOL LASindex::seek_next(LASreadPoint* reader, I64 &p_count)
+{
+ if (!have_interval)
+ {
+ if (!has_intervals()) return FALSE;
+ reader->seek((U32)p_count, start);
+ p_count = start;
+ }
+ if (p_count == end)
+ {
+ have_interval = FALSE;
+ }
+ return TRUE;
+}
+#else
+BOOL LASindex::seek_next(LASreader* lasreader)
+{
+ if (!have_interval)
+ {
+ if (!has_intervals()) return FALSE;
+ lasreader->seek(start);
+ }
+ if (lasreader->p_count == end)
+ {
+ have_interval = FALSE;
+ }
+ return TRUE;
+}
+#endif
+
+// merge the intervals of non-empty cells
+BOOL LASindex::merge_intervals()
+{
+ if (spatial->get_intersected_cells())
+ {
+ U32 used_cells = 0;
+ while (spatial->has_more_cells())
+ {
+ if (interval->get_cell(spatial->current_cell))
+ {
+ interval->add_current_cell_to_merge_cell_set();
+ used_cells++;
+ }
+ }
+// fprintf(stderr,"LASindex: used %d cells of total %d\n", used_cells, interval->get_number_cells());
+ if (used_cells)
+ {
+ BOOL r = interval->merge();
+ full = interval->full;
+ total = interval->total;
+ interval->clear_merge_cell_set();
+ return r;
+ }
+ }
+ return FALSE;
+}
diff --git a/libs/laszip/src/lasindex.hpp b/libs/laszip/src/lasindex.hpp
new file mode 100644
index 0000000..4890f17
--- /dev/null
+++ b/libs/laszip/src/lasindex.hpp
@@ -0,0 +1,113 @@
+/*
+===============================================================================
+
+ FILE: lasindex.hpp
+
+ CONTENTS:
+
+ This class can create a spatial indexing, store a spatial indexing, write
+ a spatial indexing to file, read a spatial indexing from file, and - most
+ importantly - it can be used together with a lasreader for efficient access
+ to a particular spatial region of a LAS file or a LAZ file.
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the LICENSE.txt file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ 7 September 2018 -- replaced calls to _strdup with calls to the LASCopyString macro
+ 7 January 2017 -- add read(FILE* file) for Trimble LASzip DLL improvement
+ 2 April 2015 -- add seek_next(LASreadPoint* reader, I64 &p_count) for DLL
+ 2 April 2015 -- delete read_next(LASreader* lasreader) that was not used
+ 31 March 2015 -- remove unused LASquadtree inheritance of abstract LASspatial
+ 29 April 2011 -- created after cable outage during the royal wedding (-:
+
+===============================================================================
+*/
+#ifndef LAS_INDEX_HPP
+#define LAS_INDEX_HPP
+
+#include
+
+#include "mydefs.hpp"
+
+class LASquadtree;
+class LASinterval;
+#ifdef LASZIPDLL_EXPORTS
+class LASreadPoint;
+#else
+class LASreader;
+#endif
+class ByteStreamIn;
+class ByteStreamOut;
+
+class LASLIB_DLL LASindex
+{
+public:
+ LASindex();
+ ~LASindex();
+
+ // create spatial index
+ void prepare(LASquadtree* spatial, I32 threshold=1000);
+ BOOL add(const F64 x, const F64 y, const U32 index);
+ void complete(U32 minimum_points=100000, I32 maximum_intervals=-1, const BOOL verbose=TRUE);
+
+ // read from file or write to file
+ BOOL read(FILE* file);
+ BOOL write(FILE* file) const;
+ BOOL read(const char* file_name);
+ BOOL append(const char* file_name) const;
+ BOOL write(const char* file_name) const;
+ BOOL read(ByteStreamIn* stream);
+ BOOL write(ByteStreamOut* stream) const;
+
+ // intersect
+ BOOL intersect_rectangle(const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y);
+ BOOL intersect_tile(const F32 ll_x, const F32 ll_y, const F32 size);
+ BOOL intersect_circle(const F64 center_x, const F64 center_y, const F64 radius);
+
+ // access the intersected intervals
+ BOOL get_intervals();
+ BOOL has_intervals();
+
+ U32 start;
+ U32 end;
+ U32 full;
+ U32 total;
+ U32 cells;
+
+ // seek to next interval
+#ifdef LASZIPDLL_EXPORTS
+ BOOL seek_next(LASreadPoint* reader, I64 &p_count);
+#else
+ BOOL seek_next(LASreader* lasreader);
+#endif
+
+ // for debugging
+ void print(BOOL verbose);
+
+ // for visualization
+ LASquadtree* get_spatial() const;
+ LASinterval* get_interval() const;
+
+private:
+ BOOL merge_intervals();
+
+ LASquadtree* spatial;
+ LASinterval* interval;
+ BOOL have_interval;
+};
+
+#endif
diff --git a/libs/laszip/src/lasinterval.cpp b/libs/laszip/src/lasinterval.cpp
new file mode 100644
index 0000000..b80f41d
--- /dev/null
+++ b/libs/laszip/src/lasinterval.cpp
@@ -0,0 +1,733 @@
+/*
+===============================================================================
+
+ FILE: lasinterval.cpp
+
+ CONTENTS:
+
+ see corresponding header file
+
+ PROGRAMMERS:
+
+ martin.isenburg@rapidlasso.com - http://rapidlasso.com
+
+ COPYRIGHT:
+
+ (c) 2011-2015, martin isenburg, rapidlasso - fast tools to catch reality
+
+ This is free software; you can redistribute and/or modify it under the
+ terms of the GNU Lesser General Licence as published by the Free Software
+ Foundation. See the LICENSE.txt file for more information.
+
+ This software is distributed WITHOUT ANY WARRANTY and without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ CHANGE HISTORY:
+
+ see corresponding header file
+
+===============================================================================
+*/
+#include "lasinterval.hpp"
+#include "laszip.hpp"
+
+#include "bytestreamin.hpp"
+#include "bytestreamout.hpp"
+
+#include
+#include
+#include
+#include
+
+#include