Created Conan Package (#23)

* Renamed LASReaded to openE57las, removed unused dependencies from CMake

* Fixed clang-format targets, updated build action

* Added C++11 ABI support in conan profile

* Updated steps to create package

* Updated GitHub action

* Removed reference to TimeConv in OpenE57Simple

* Added the option to build missing libraries (for apple)

* Fixed compile errors in Windows code

* Removed FindBoost when building examples in CMake
This commit is contained in:
Michele Adduci
2022-02-10 04:08:50 +00:00
committed by GitHub
parent a37c5d4fb8
commit a5d213fb2b
85 changed files with 782 additions and 519 deletions

View File

@@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest]
os: [ubuntu-20.04, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
@@ -34,24 +34,14 @@ jobs:
if: matrix.os == 'ubuntu-20.04'
run: |
conan profile update settings.compiler.libcxx=libstdc++11 default
mkdir -p build && cd build
conan install .. --build=missing
cmake .. -DBUILD_EXAMPLES=ON -DBUILD_TOOLS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release --target install
conan create . -o openE57:with_examples=True -o openE57:with_tools=True --build=missing
- name: Mac build
if: matrix.os == 'macos-latest'
run: |
conan profile update settings.compiler.libcxx=libc++ default
mkdir -p build && cd build
conan install .. --build=missing
cmake .. -DBUILD_EXAMPLES=ON -DBUILD_TOOLS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release --target install
conan create . -o openE57:with_examples=True --build=missing
- name: Windows build
if: matrix.os == 'windows-latest'
run: |
md build && cd build
conan install .. --build=missing
cmake .. -DBUILD_EXAMPLES=ON -DBUILD_TOOLS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release --target install
conan create . -o openE57:with_examples=True -o openE57:with_tools=True --build=missing

2
.gitignore vendored
View File

@@ -33,5 +33,7 @@
# Build folders
build/
tmp/
bin/*
.devcontainer/
.vscode/

View File

@@ -1,5 +1,21 @@
# openE57
## [1.6.0] - 2022-02-05
## Changed
- Added conan packaging support
- Refactored project structure
- Renamed LASReader to openE57las
- Moved time_conversion to tools folder
- Updated Boost to 1.78.0 (only used if building tools)
- Fixed WIN32 code path in OpenE57simple
## Removed
- config.h template (definition passed through the compiler)
- Removed the dependency of time_conversion from openE57
- Removed the generation of time_conversion as artifact of openE57 (used only by tools)
- Disabled building of tool "e57unpack" due to issues with Boost
## [1.5.1] - 2021-12-09
## Changed

View File

@@ -1,4 +1,4 @@
# This is an update version of the CMake project file for the libe57 reference
# This is an update version of the CMake project file for the libe57 reference
# implementation, with support for Conan targets, to make the dependency
# management easier and reproducible on all the supported platforms
#
@@ -42,7 +42,7 @@ cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
# Enables the MSVC_RUNTIME_LIBRARY property on targets
cmake_policy(SET CMP0091 NEW)
project(openE57 VERSION 1.5.1 LANGUAGES C CXX DESCRIPTION "openE57 is a library for handling E57 files")
project(openE57 VERSION 1.6.0 LANGUAGES C CXX DESCRIPTION "openE57 is a library for handling E57 files")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
@@ -50,7 +50,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/redist-${PROJECT_NAME}-v${PROJECT_VERSION})
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
@@ -73,151 +72,11 @@ if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
endif()
# Set a private module find path
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR} ${CMAKE_PREFIX_PATH})
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(InstallRequiredSystemLibraries)
include(GenerateExportHeader)
include(${CMAKE_SOURCE_DIR}/cmake/compiler_options.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/dependencies.cmake)
set(CONFIG_PACKAGE_INSTALL_DIR lib/cmake/${PROJECT_NAME})
list(APPEND compiler_definitions
E57_REFIMPL_REVISION_ID=${PROJECT_NAME}-${PROJECT_VERSION})
configure_file("${PROJECT_SOURCE_DIR}/include/config.h.in"
"${PROJECT_BINARY_DIR}/include/config.h")
#
# The main library
#
add_library(
${PROJECT_NAME} ${LIBRARY_TYPE}
${CMAKE_SOURCE_DIR}/src/openE57Simple.cpp
${CMAKE_SOURCE_DIR}/src/openE57SimpleImpl.cpp
${CMAKE_SOURCE_DIR}/src/openE57.cpp
${CMAKE_SOURCE_DIR}/src/openE57Impl.cpp
${CMAKE_SOURCE_DIR}/include/openE57/impl/openE57Impl.h
${CMAKE_SOURCE_DIR}/include/openE57/impl/openE57SimpleImpl.h
${CMAKE_SOURCE_DIR}/include/openE57/openE57.h
${CMAKE_SOURCE_DIR}/include/openE57/openE57Simple.h)
generate_export_header(${PROJECT_NAME})
set_target_properties(${PROJECT_NAME} PROPERTIES
DEBUG_POSTFIX "-d"
MSVC_RUNTIME_LIBRARY "${MSVC_RUNTIME_TYPE}")
target_compile_options(${PROJECT_NAME} PUBLIC ${compiler_options})
target_compile_definitions(${PROJECT_NAME} PUBLIC ${compiler_definitions})
target_link_options(${PROJECT_NAME} PUBLIC ${linker_flags})
target_include_directories(${PROJECT_NAME}
PRIVATE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
${CMAKE_SOURCE_DIR}/include
${XML_INCLUDE_DIRS}
${Boost_INCLUDE_DIR}
)
target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARY_DIRS} ${XML_LIBRARIES})
#
# Library for LAS I/O support
#
add_library(LASReader ${LIBRARY_TYPE}
${CMAKE_SOURCE_DIR}/src/LAS/LASReader.cpp
${CMAKE_SOURCE_DIR}/include/openE57/LAS/LASReader.h)
set_target_properties(LASReader PROPERTIES
DEBUG_POSTFIX "-d"
MSVC_RUNTIME_LIBRARY "${MSVC_RUNTIME_TYPE}")
target_compile_options(LASReader PUBLIC ${compiler_options})
target_compile_definitions(LASReader PUBLIC ${compiler_definitions})
target_link_options(LASReader PUBLIC ${linker_flags})
target_include_directories(LASReader
PRIVATE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
${CMAKE_SOURCE_DIR}/include
${XML_INCLUDE_DIRS}
${Boost_INCLUDE_DIR}
)
target_link_libraries(LASReader PUBLIC ${Boost_LIBRARY_DIRS} ${XML_LIBRARIES})
#
# Time conversion utilities
#
add_library(time_conversion ${LIBRARY_TYPE}
${CMAKE_SOURCE_DIR}/src/time_conversion/time_conversion.c
${CMAKE_SOURCE_DIR}/include/openE57/time_conversion/time_conversion.h
${CMAKE_SOURCE_DIR}/include/openE57/time_conversion/basictypes.h
${CMAKE_SOURCE_DIR}/include/openE57/time_conversion/constants.h
${CMAKE_SOURCE_DIR}/include/openE57/time_conversion/gnss_error.h)
set_target_properties(time_conversion PROPERTIES
DEBUG_POSTFIX "-d"
MSVC_RUNTIME_LIBRARY "${MSVC_RUNTIME_TYPE}")
target_compile_options(time_conversion PUBLIC ${compiler_options})
target_compile_definitions(time_conversion PUBLIC ${compiler_definitions})
target_link_options(time_conversion PUBLIC ${linker_flags})
target_include_directories(time_conversion
PRIVATE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
${CMAKE_SOURCE_DIR}/include
)
target_link_libraries(time_conversion
PUBLIC
${Boost_LIBRARY_DIRS}
${XML_LIBRARIES}
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:Clang>>:dl>
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:Clang>>:m>
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:Clang>>:c>
)
if(${BUILD_EXAMPLES})
add_subdirectory(${CMAKE_SOURCE_DIR}/examples)
endif()
if(${BUILD_TESTS})
add_subdirectory(${CMAKE_SOURCE_DIR}/tests)
endif()
if(${BUILD_TOOLS})
add_subdirectory(${CMAKE_SOURCE_DIR}/tools)
endif()
#
# Add Clang Format
#
include(${CMAKE_SOURCE_DIR}/cmake/clang_format.cmake)
add_subdirectory(${CMAKE_SOURCE_DIR}/src)
#
# Install Artifacts
#
install(
TARGETS
${PROJECT_NAME}
LASReader
time_conversion
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib)
install(
FILES
${CMAKE_SOURCE_DIR}/include/openE57/openE57.h
${CMAKE_SOURCE_DIR}/include/openE57/openE57Simple.h
${CMAKE_BINARY_DIR}/opene57_export.h
DESTINATION
include/openE57)
install(FILES
${CMAKE_SOURCE_DIR}/CHANGELOG.md
DESTINATION .)

View File

@@ -2,7 +2,7 @@ MIT License
openE57
Copyright (c) 2021 Michele Adduci (adduci@tutanota.com)
Copyright (c) 2022 Michele Adduci (adduci@tutanota.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@@ -30,11 +30,7 @@ On Linux:
```shell
git clone https://github.com/madduci/openE57.git
cd open57
mkdir -p build/linux && cd build/linux
conan install ../.. --build=missing
cmake ../.. -DCMAKE_BUILD_TYPE=Release
cmake --build .
cmake --install .
conan create . --build=missing
```
On Windows:
@@ -42,19 +38,15 @@ On Windows:
```cmd
git clone https://github.com/madduci/openE57.git
cd open57
md build\windows && cd build\windows
conan install ..\.. --build=missing
cmake ..\.. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release
cmake --install . --config Release
conan create . --build=missing
```
Available CMake options (but disabled by default) are the following onews:
Available conan options (but disabled by default) are the following ones:
* BUILD_EXAMPLES
* BUILD_TOOLS
* BUILD_TESTS
* BUILD_WITH_MT (MSVC Only)
* BUILD_SHARED_LIBS (Not supported at the moment - no symbol is exported yet)
* with_examples
* with_tools
* with_tests
* mt (MSVC Only)
* shared (Not supported at the moment - no symbol is exported yet)
The dependencies are now managed with conan and integrated in CMake, without the need of compiling the required libraries by yourself.

View File

@@ -1,29 +0,0 @@
# Copyright 2020 Michele Adduci <adduci@tutanota.com>
find_program(E57_CLANG_FORMAT_BIN NAMES clang-format)
if(E57_CLANG_FORMAT_BIN)
get_target_property(openE57_files ${PROJECT_NAME} SOURCES)
get_target_property(LASReader_files LASReader SOURCES)
get_target_property(time_conversion_files time_conversion SOURCES)
add_custom_target(
format-openE57
COMMAND clang-format --style=file -i ${openE57_files}
COMMAND_EXPAND_LISTS VERBATIM)
add_custom_target(
format-lasreader
COMMAND clang-format --style=file -i ${LASReader_files}
COMMAND_EXPAND_LISTS VERBATIM)
add_custom_target(
format-timeconv
COMMAND clang-format --style=file -i ${time_conversion_files}
COMMAND_EXPAND_LISTS VERBATIM)
add_custom_target(
format
COMMENT "Running clang-format..."
DEPENDS format-openE57 format-lasreader format-timeconv)
endif()

90
conanfile.py Normal file
View File

@@ -0,0 +1,90 @@
from conans import ConanFile, CMake, tools
import os, shutil
class ConanFileDefault(ConanFile):
name = "openE57"
description = "A C++ library for reading and writing E57 files, " \
"fork of the original libE57 (http://libe57.org)"
topics = ("conan", "openE57", "e57")
version = "1.6.0"
url = "https://github.com/openE57/openE57"
homepage = "https://github.com/openE57/openE57"
license = ("MIT", "E57 Software Licenses")
exports_sources = [ "src/*", "LICENSE*", "CHANGELOG.md", "*.txt"]
generators = "cmake", "cmake_find_package"
short_paths = True
_cmake = None
@property
def _source_subfolder(self):
return "source_subfolder"
@property
def _build_subfolder(self):
return "build_subfolder"
settings = "os", "arch", "compiler", "build_type"
options = {"with_examples": [True, False],
"with_tools": [True, False],
'with_tests': [True, False],
"mt": [True, False],
"shared": [True, False]}
default_options = {
'with_examples': False,
'with_tools': False,
'with_tests': False,
'mt': False,
'shared': False}
def validate(self):
if self.options.shared == True:
raise ConanInvalidConfiguration("OpenE57 cannot be built as shared library yet")
if self.options.mt == True and self.settings.compiler != "Visual Studio":
raise ConanInvalidConfiguration("The MT compile option is only available for Visual Studio")
def build(self):
cmake = self._configure_cmake()
cmake.build()
def build_requirements(self):
if tools.cross_building(self, skip_x64_x86=True) and hasattr(self, 'settings_build'):
self.build_requires("openE57/{}".format(self.version))
if self.options.with_tools == True:
self.build_requires("boost/1.78.0")
self.options["boost"].multithreading = True
self.options["boost"].shared = False
def requirements(self):
self.requires("icu/70.1")
self.options["icu"].shared = False
self.requires("xerces-c/3.2.3")
self.options["xerces-c"].shared = False
def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["BUILD_EXAMPLES"] = self.options.with_examples
self._cmake.definitions["BUILD_TOOLS"] = self.options.with_tools
self._cmake.definitions["BUILD_TESTS"] = self.options.with_tests
self._cmake.definitions["BUILD_WITH_MT"] = self.options.mt
self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared
self._cmake.definitions["CMAKE_INSTALL_PREFIX"] = self.package_folder
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake
def package_info(self):
self.cpp_info.defines.append("E57_REFIMPL_REVISION_ID={name}-{version}".format(name=self.name, version=self.version))
self.cpp_info.defines.append("XERCES_STATIC_LIBRARY")
self.cpp_info.libs = ["openE57", "openE57las"]
def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
self.copy(pattern="LICENSE.libE57", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

View File

@@ -1,13 +0,0 @@
[requires]
boost/1.77.0
icu/70.1
xerces-c/3.2.3
[generators]
cmake_find_package
[options]
boost:multithreading=True
boost:shared=False
icu:shared=False
xerces-c:shared=False

View File

@@ -1,11 +0,0 @@
#ifndef CONFIG_H
#define CONFIG_H
#ifndef E57_REFIMPL_REVISION_ID
# define E57_REFIMPL_REVISION_ID "E57RefImpl-@E57RefImpl_MAJOR_VERSION@.@E57RefImpl_MINOR_VERSION@.@E57RefImpl_BUILD_VERSION@-@E57RefImpl_BUILD_TAG@"
#endif
#define SVN_VERSION @E57RefImpl_BUILD_VERSION@
#endif /* CONFIG_H */

38
src/CMakeLists.txt Normal file
View File

@@ -0,0 +1,38 @@
#
# Define Settings and targets
#
# Set a private module find path
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR} ${CMAKE_PREFIX_PATH})
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(InstallRequiredSystemLibraries)
include(GenerateExportHeader)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/compiler_options.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependencies.cmake)
set(CONFIG_PACKAGE_INSTALL_DIR lib/cmake/${PROJECT_NAME})
#
# Build submodules
#
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib)
if(${BUILD_EXAMPLES})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples)
endif()
if(${BUILD_TESTS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
endif()
if(${BUILD_TOOLS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools)
endif()
#
# Add Clang Format
#
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/clang_format.cmake)

View File

@@ -1,140 +0,0 @@
# $Id: E57RefImplConfig.cmake 246 2011-10-06 08:01:00Z roland_schwarz $
# This is the CMake project configuration file for using E57RefImpl.
#
# Copyright 2010-2011 Roland Schwarz, Riegl LMS GmbH
#
# Permission is hereby granted, free of charge, to any person or organization
# obtaining a copy of the software and accompanying documentation covered by
# this license (the "Software") to use, reproduce, display, distribute,
# execute, and transmit the Software, and to prepare derivative works of the
# Software, and to permit third-parties to whom the Software is furnished to
# do so, all subject to the following:
#
# The copyright notices in the Software and this entire statement, including
# the above license grant, this restriction and the following disclaimer,
# must be included in all copies of the Software, in whole or in part, and
# all derivative works of the Software, unless such copies or derivative
# works are solely in the form of machine-executable object code generated by
# a source language processor.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
# SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
# == Using E57refImpl library: ==
#
# find_package( E57RefImpl )
# add_executable( my_app
# my_app.cpp
# )
# target_link_libraries( my_app
# ${E57RefImpl_SCANLIB_LIBRARIES}
# )
#
#
# == Variables defined by this module: ==
#
# E57RefImpl_LIBRARY_DEBUG
# E57RefImpl_LIBRARY_RELEASE
# E57RefImpl_LIBRARY
# E57RefImpl_LIBRARIES
# E57RefImpl_INCLUDE_DIR
# E57RefImpl_INCLUDE_DIRS
# E57RefImpl_LIBRARY_DIRS
#
# NOTE: You will also need to include the boost and xerces libraries to your
# project.
IF (NOT "${E57RefImpl_DIR}/include" EQUAL "${E57RefImpl_INCLUDE_DIR}")
SET(E57RefImpl_LIBRARY_DEBUG E57RefImpl_LIBRARY_DEBUG-NOTFOUND)
SET(E57RefImpl_LIBRARY_RELEASE E57RefImpl_LIBRARY_RELEASE-NOTFOUND)
SET(E57RefImpl_LIBRARY E57RefImpl_LIBRARY-NOTFOUND)
SET(E57RefImpl_LIBRARIES E57RefImpl_LIBRARIES-NOTFOUND)
SET(E57RefImpl_INCLUDE_DIR E57RefImpl_INCLUDE_DIR-NOTFOUND)
SET(E57RefImpl_INCLUDE_DIRS E57RefImpl_INCLUDE_DIRS-NOTFOUND)
SET(E57RefImpl_LIBRARY_DIRS E57RefImpl_LIBRARY_DIRS-NOTFOUND)
ENDIF()
SET(E57RefImpl_FOUND TRUE)
FIND_PATH(E57RefImpl_INCLUDE_DIR
NAMES e57/E57Foundation.h
PATHS ${E57RefImpl_DIR}/include
DOC "E57 include directory"
)
FIND_LIBRARY(E57RefImpl_LIBRARY_RELEASE
NAMES libE57RefImpl
E57RefImpl
HINTS ${E57RefImpl_DIR}/lib
DOC "E57 release library"
)
FIND_LIBRARY(E57RefImpl_LIBRARY_DEBUG
NAMES libE57RefImpl-d
E57RefImpl-d
HINTS ${E57RefImpl_DIR}/lib
DOC "E57 debug library"
)
MARK_AS_ADVANCED(
E57RefImpl_INCLUDE_DIR
E57RefImpl_LIBRARY_RELEASE
E57RefImpl_LIBRARY_DEBUG
E57RefImpl_LIBRARY
)
IF (E57RefImpl_LIBRARY_DEBUG AND E57RefImpl_LIBRARY_RELEASE)
# if the generator supports configuration types then set
# optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
SET(E57RefImpl_LIBRARY optimized ${E57RefImpl_LIBRARY_RELEASE} debug ${E57RefImpl_LIBRARY_DEBUG})
ELSE()
# if there are no configuration types and CMAKE_BUILD_TYPE has no value
# then just use the release libraries
SET(E57RefImpl_LIBRARY ${E57RefImpl_LIBRARY_RELEASE} )
ENDIF()
# FIXME: This probably should be set for both cases
SET(E57RefImpl_LIBRARIES optimized ${E57RefImpl_LIBRARY_RELEASE} debug ${E57RefImpl_LIBRARY_DEBUG})
ENDIF()
# if only the release version was found, set the debug variable also to the release version
IF (E57RefImpl_LIBRARY_RELEASE AND NOT E57RefImpl_LIBRARY_DEBUG)
SET(E57RefImpl_LIBRARY_DEBUG ${E57RefImpl_LIBRARY_RELEASE})
SET(E57RefImpl_LIBRARY ${E57RefImpl_LIBRARY_RELEASE})
SET(E57RefImpl_LIBRARIES ${E57RefImpl_LIBRARY_RELEASE})
ENDIF()
# if only the debug version was found, set the release variable also to the debug version
IF (E57RefImpl_LIBRARY_DEBUG AND NOT E57RefImpl_LIBRARY_RELEASE)
SET(E57RefImpl_LIBRARY_RELEASE ${E57RefImpl_LIBRARY_DEBUG})
SET(E57RefImpl_LIBRARY ${E57RefImpl_LIBRARY_DEBUG})
SET(E57RefImpl_LIBRARIES ${E57RefImpl_LIBRARY_DEBUG})
ENDIF()
IF (E57RefImpl_LIBRARY)
set(E57RefImpl_LIBRARY ${E57RefImpl_LIBRARY} CACHE FILEPATH "The E57RefImpl library")
# Remove superfluous "debug" / "optimized" keywords from
# RiVLib_LIBRARY_DIRS
FOREACH(_E57RefImpl_my_lib ${E57RefImpl_LIBRARY})
GET_FILENAME_COMPONENT(_E57RefImpl_my_lib_path "${_E57RefImpl_my_lib}" PATH)
LIST(APPEND E57RefImpl_LIBRARY_DIRS ${_E57RefImpl_my_lib_path})
ENDFOREACH()
LIST(REMOVE_DUPLICATES E57RefImpl_LIBRARY_DIRS)
SET(E57RefImpl_LIBRARY_DIRS ${E57RefImpl_LIBRARY_DIRS} FILEPATH "E57RefImpl library directory")
SET(E57RefImpl_FOUND ON CACHE INTERNAL "Whether the E57RefImpl component was found")
SET(E57RefImpl_LIBRARIES ${E57RefImpl_LIBRARIES} ${E57RefImpl_LIBRARY})
ELSE(E57RefImpl_LIBRARY)
SET(E57RefImpl_FOUND FALSE) #FIXME: doesn't get propagated to caller
ENDIF(E57RefImpl_LIBRARY)
IF (E57RefImpl_FOUND)
SET(E57RefImpl_INCLUDE_DIRS ${E57RefImpl_INCLUDE_DIR} "E57RefImpl include directory")
ENDIF()

View File

@@ -0,0 +1,21 @@
find_program(E57_CLANG_FORMAT_BIN NAMES clang-format)
if(E57_CLANG_FORMAT_BIN)
get_target_property(openE57_files ${PROJECT_NAME} SOURCES)
get_target_property(openE57las_files ${PROJECT_NAME}las SOURCES)
add_custom_target(
format-openE57
COMMAND clang-format --style=file -i ${openE57_files}
COMMAND_EXPAND_LISTS VERBATIM)
add_custom_target(
format-openE57las
COMMAND clang-format --style=file -i ${openE57las_files}
COMMAND_EXPAND_LISTS VERBATIM)
add_custom_target(
format
COMMENT "Running clang-format..."
DEPENDS format-openE57 format-openE57las)
endif()

View File

@@ -15,8 +15,8 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
list(APPEND compiler_definitions WINDOWS)
endif()
# Find Boost (Required by Tools and Examples)
if(BUILD_TOOLS OR BUILD_EXAMPLES)
# Find Boost (Required by Tools)
if(BUILD_TOOLS)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)
set(Boost_USE_MULTITHREADED ON)

BIN
src/doc/openE57.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
src/doc/openE57_white.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

@@ -13,9 +13,8 @@ foreach(EXAMPLE ${EXAMPLES})
target_link_options(${EXAMPLE} PUBLIC ${linker_flags})
target_include_directories(${EXAMPLE} PRIVATE
${CMAKE_SOURCE_DIR}/include
${XML_INCLUDE_DIRS}
${Boost_INCLUDE_DIR})
${CMAKE_SOURCE_DIR}/src/lib/include
${XML_INCLUDE_DIRS} )
target_link_libraries(${EXAMPLE}
PRIVATE
${PROJECT_NAME}

View File

@@ -40,7 +40,7 @@ int main(int /*argc*/, char** /*argv*/)
StructureNode root = imf.root();
/// Register extension with URI=www.example.com/DemoExtension and prefix=demo
imf.extensionsAdd("demo", "http://www.example.com/DemoExtension");
imf.extensionsAdd("demo", "http://openE57.github.io/DemoExtension");
/// Set per-file properties.
/// Path names: "/formatName", "/majorVersion", "/minorVersion", "/coordinateMetadata"

74
src/lib/CMakeLists.txt Normal file
View File

@@ -0,0 +1,74 @@
list(APPEND compiler_definitions
E57_REFIMPL_REVISION_ID=${PROJECT_NAME}-${PROJECT_VERSION})
#
# The main library
#
add_library(
${PROJECT_NAME} ${LIBRARY_TYPE}
${CMAKE_CURRENT_SOURCE_DIR}/src/openE57Simple.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/openE57SimpleImpl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/openE57.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/openE57Impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/openE57/impl/openE57Impl.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openE57/impl/openE57SimpleImpl.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openE57/openE57.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openE57/openE57Simple.h)
generate_export_header(${PROJECT_NAME})
set_target_properties(${PROJECT_NAME} PROPERTIES
DEBUG_POSTFIX "-d"
MSVC_RUNTIME_LIBRARY "${MSVC_RUNTIME_TYPE}")
target_compile_options(${PROJECT_NAME} PUBLIC ${compiler_options})
target_compile_definitions(${PROJECT_NAME} PUBLIC ${compiler_definitions})
target_link_options(${PROJECT_NAME} PUBLIC ${linker_flags})
target_include_directories(${PROJECT_NAME}
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
${CMAKE_CURRENT_SOURCE_DIR}/include
${XML_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME} PUBLIC ${XML_LIBRARIES})
#
# Extension Library for LAS I/O support
#
add_library(${PROJECT_NAME}las ${LIBRARY_TYPE}
${CMAKE_CURRENT_SOURCE_DIR}/src/${PROJECT_NAME}las.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/openE57/LAS/${PROJECT_NAME}las.h)
set_target_properties(${PROJECT_NAME}las PROPERTIES
DEBUG_POSTFIX "-d"
MSVC_RUNTIME_LIBRARY "${MSVC_RUNTIME_TYPE}")
target_compile_options(${PROJECT_NAME}las PUBLIC ${compiler_options})
target_compile_definitions(${PROJECT_NAME}las PUBLIC ${compiler_definitions})
target_link_options(${PROJECT_NAME}las PUBLIC ${linker_flags})
target_include_directories(${PROJECT_NAME}las
PRIVATE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
${CMAKE_CURRENT_SOURCE_DIR}/include
${XML_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}las PUBLIC ${XML_LIBRARIES})
#
# Install Artifacts
#
install(
TARGETS
${PROJECT_NAME}
${PROJECT_NAME}las
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib)
install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/openE57/openE57.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openE57/openE57Simple.h
${CMAKE_CURRENT_BINARY_DIR}/opene57_export.h
DESTINATION
include/openE57)

View File

Before

Width:  |  Height:  |  Size: 399 KiB

After

Width:  |  Height:  |  Size: 399 KiB

View File

@@ -1,8 +1,8 @@
/*
* lasreader.h - header for simple interface for reading LAS files.
* openE57las.h - header for simple interface for reading LAS files.
*
* Copyright (c) 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
* Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by

View File

@@ -2,7 +2,7 @@
* openE57Impl.h - private implementation header of E57 format reference implementation.
*
* Copyright (c) 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
* Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by

View File

@@ -2,7 +2,7 @@
* openE57.h - public header of E57 Foundation API for reading/writing .e57 files.
*
* Copyright (c) 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
* Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by

View File

@@ -3,7 +3,7 @@
// openE57Simple.h - public header of E57 Simple API for reading/writing .e57 files.
//
// Copyright (c) 2010 Stan Coleby (scoleby@intelisum.com)
// Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
// Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
//
// All rights reserved.
//
@@ -44,10 +44,6 @@
# include <openE57/openE57.h>
#endif
#ifndef _C_TIMECONV_H_
# include <openE57/time_conversion/time_conversion.h>
#endif
#ifndef PI
constexpr double PI{3.1415926535897932384626433832795};
#endif

View File

@@ -3,7 +3,7 @@
* Reference Implementation.
*
* Copyright (c) 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
* Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by

View File

@@ -3,7 +3,7 @@
* reference implementation.
*
* Copyright (c) 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
* Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by

View File

@@ -3,7 +3,7 @@
// openE57Simple.cpp - private implementation header of E57 format reference implementation.
//
// Copyright (c) 2010 Stan Coleby (scoleby@intelisum.com)
// Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
// Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
// All rights reserved.
//
// Permission is hereby granted, free of charge, to any person or organization

View File

@@ -3,7 +3,7 @@
// openE57SimpleImpl.cpp - private implementation header of E57 format reference implementation.
//
// Copyright (c) 2010 Stan Coleby (scoleby@intelisum.com)
// Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
// Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
// All rights reserved.
//
// Permission is hereby granted, free of charge, to any person or organization
@@ -65,7 +65,6 @@
#endif
#include <openE57/impl/openE57SimpleImpl.h>
#include <openE57/time_conversion/time_conversion.h>
#include <sstream>
#include <random>
@@ -75,6 +74,11 @@ using namespace std;
namespace e57
{
// inspired by https://stackoverflow.com/a/15764679/2369389
template <typename T>
void ignore(T &&)
{ }
// inspired by https://stackoverflow.com/a/60198074/2369389
namespace uuid {
static std::random_device rd;
@@ -143,30 +147,14 @@ void GetSystemTimeFromGPSDateTime(double gpsTime, //!< GPS Date Time
//
double e57::GetGPSTime(void)
{
#ifdef _C_TIMECONV_H_
unsigned short utc_year; //!< Universal Time Coordinated [year]
unsigned char utc_month; //!< Universal Time Coordinated [1-12 months]
unsigned char utc_day; //!< Universal Time Coordinated [1-31 days]
unsigned char utc_hour; //!< Universal Time Coordinated [hours]
unsigned char utc_minute; //!< Universal Time Coordinated [minutes]
float utc_seconds; //!< Universal Time Coordinated [s]
unsigned char utc_offset; //!< Integer seconds that GPS is ahead of UTC time, always positive [s], obtained from a look up table
double julian_date; //!< Number of days since noon Universal Time Jan 1, 4713 BCE (Julian calendar) [days]
unsigned short gps_week; //!< GPS week (0-1024+) [week]
double gps_tow; //!< GPS time of week (0-604800.0) [s]
TIMECONV_GetSystemTime(&utc_year, &utc_month, &utc_day, &utc_hour, &utc_minute, &utc_seconds, &utc_offset, &julian_date, &gps_week, &gps_tow);
double gpsTime = (gps_week * 604800.) + gps_tow;
#elif defined(WIN32)
#if defined(WIN32)
SYSTEMTIME currentSystemTime;
GetSystemTime(&currentSystemTime); // current UTC Time
double gpsTime = e57::GetGPSDateTimeFromSystemTime(currentSystemTime);
return e57::GetGPSDateTimeFromSystemTime(currentSystemTime);
#else
return 0.0;
#endif
return gpsTime;
}
#if defined(WIN32)
////////////////////////////////////////////////////////////////////
@@ -176,17 +164,6 @@ double e57::GetGPSTime(void)
double e57::GetGPSDateTimeFromSystemTime(SYSTEMTIME sysTim //!< Windows System Time
)
{
# ifdef _C_TIMECONV_H_
int utc_year = sysTim.wYear; //!< The year 1900-9999
int utc_month = sysTim.wMonth; //!< The month 0-11
int utc_day = sysTim.wDay; //!< The day 1-31
int utc_hour = sysTim.wHour; //!< The hour 0-23
int utc_minute = sysTim.wMinute; //!< The minute 0-59
float utc_seconds = sysTim.wSecond; //!< The seconds 0.0 - 59.999
utc_seconds += sysTim.wMilliseconds / 1000;
double gpsTime = e57::GetGPSDateTimeFromUTC(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_seconds);
# else
FILETIME currentFileTime;
SystemTimeToFileTime(&sysTim, &currentFileTime);
@@ -194,7 +171,7 @@ double e57::GetGPSDateTimeFromSystemTime(SYSTEMTIME sysTim //!< Windows System T
currentTime.LowPart = currentFileTime.dwLowDateTime;
currentTime.HighPart = currentFileTime.dwHighDateTime;
SYSTEMTIME gpsSystemTime = {1980, 1, 0, 6, 0, 0, 0, 0} // GPS started in Jan. 6, 1980
SYSTEMTIME gpsSystemTime = {1980, 1, 0, 6, 0, 0, 0, 0}; // GPS started in Jan. 6, 1980
FILETIME gpsFileTime;
SystemTimeToFileTime(&gpsSystemTime, &gpsFileTime);
@@ -205,7 +182,6 @@ double e57::GetGPSDateTimeFromSystemTime(SYSTEMTIME sysTim //!< Windows System T
double gpsTime = (double)(currentTime.QuadPart - gpsStartTime.QuadPart); // number of 100 nanosecond;
gpsTime /= 10000000.; // number of seconds
gpsTime += 15.; // Add utc offset leap seconds
# endif
return gpsTime;
}
////////////////////////////////////////////////////////////////////
@@ -216,37 +192,10 @@ void e57::GetSystemTimeFromGPSDateTime(double gpsTime, //!< GPS Date Time
SYSTEMTIME& sysTim //!< Windows System Time
)
{
# ifdef _C_TIMECONV_H_
int utc_year; //!< The year 1900-9999
int utc_month; //!< The month 0-11
int utc_day; //!< The day 1-31
int utc_hour; //!< The hour 0-23
int utc_minute; //!< The minute 0-59
float utc_seconds; //!< The seconds 0.0 - 59.999
e57::GetUTCFromGPSDateTime(gpsTime, utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_seconds);
double julian_date = 0;
unsigned char day_of_week = 0;
TIMECONV_GetJulianDateFromUTCTime(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_seconds, &julian_date);
TIMECONV_GetDayOfWeekFromJulianDate(julian_date, &day_of_week);
sysTim.wDayOfWeek = day_of_week;
sysTim.wYear = utc_year;
sysTim.wMonth = utc_month;
sysTim.wDay = utc_day;
sysTim.wHour = utc_hour;
sysTim.wMinute = utc_minute;
sysTim.wSecond = (WORD)(floor(utc_seconds));
sysTim.wMilliseconds = (WORD)((utc_seconds - sysTim.wSecond) * 1000);
# else
gpsTime -= 15.; // Sub utc offset leap seconds
gpsTime *= 10000000.; // convert to 100 nanoseconds;
SYSTEMTIME gpsSystemTime = {1980, 1, 0, 6, 0, 0, 0, 0} // GPS started in Jan. 6, 1980
SYSTEMTIME gpsSystemTime = {1980, 1, 0, 6, 0, 0, 0, 0}; // GPS started in Jan. 6, 1980
FILETIME gpsFileTime;
SystemTimeToFileTime(&gpsSystemTime, &gpsFileTime);
@@ -261,7 +210,6 @@ void e57::GetSystemTimeFromGPSDateTime(double gpsTime, //!< GPS Date Time
currentFileTime.dwLowDateTime = currentTime.LowPart;
currentFileTime.dwHighDateTime = currentTime.HighPart;
FileTimeToSystemTime(&currentFileTime, &sysTim);
# endif
}
#endif
////////////////////////////////////////////////////////////////////
@@ -276,34 +224,27 @@ double e57::GetGPSDateTimeFromUTC(int utc_year, //!< The year 1900-9999
float utc_seconds //!< The seconds 0.0 - 59.999
)
{
#ifdef _C_TIMECONV_H_
double julian_date; //!< Number of days since noon Universal Time Jan 1, 4713 BCE (Julian calendar) [days]
unsigned char utc_offset; //!< Integer seconds that GPS is ahead of UTC time, always positive
unsigned short gps_week; //!< GPS week (0-1024+) [week]
double gps_tow; //!< GPS time of week (0-604800.0) [s]
TIMECONV_GetJulianDateFromUTCTime(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_seconds, &julian_date);
TIMECONV_DetermineUTCOffset(julian_date, &utc_offset);
TIMECONV_GetGPSTimeFromJulianDate(julian_date, utc_offset, &gps_week, &gps_tow);
double gpsTime = (gps_week * 604800.) + gps_tow;
#elif defined(WIN32)
#if defined(WIN32)
SYSTEMTIME sysTim;
sysTim.wDayOfWeek = day_of_week;
sysTim.wDayOfWeek = 1;
sysTim.wYear = utc_year;
sysTim.wMonth = utc_month;
sysTim.wDay = utc_day;
sysTim.wHour = utc_hour;
sysTim.wMinute = utc_minute;
sysTim.wSecond = (WORD)(floor(utc_seconds));
sysTim.wMilliseconds = (WORD)((utc_seconds - t.wSecond) * 1000);
sysTim.wMilliseconds = (WORD)((utc_seconds) * 1000);
double gpsTime = e57::GetGPSDateTimeFromSystemTime(sysTim);
return e57::GetGPSDateTimeFromSystemTime(sysTim);
#else
ignore(utc_year);
ignore(utc_month);
ignore(utc_day);
ignore(utc_hour);
ignore(utc_minute);
ignore(utc_seconds);
return 0;
#endif
return gpsTime;
}
////////////////////////////////////////////////////////////////////
//
@@ -318,39 +259,26 @@ void e57::GetUTCFromGPSDateTime(double gpsTime, //!< GPS Date Time
float& utc_seconds //!< The seconds 0.0 - 59.999
)
{
#ifdef _C_TIMECONV_H_
unsigned short utc_year; //!< Universal Time Coordinated [year]
unsigned char utc_month; //!< Universal Time Coordinated [1-12 months]
unsigned char utc_day; //!< Universal Time Coordinated [1-31 days]
unsigned char utc_hour; //!< Universal Time Coordinated [hours]
unsigned char utc_minute; //!< Universal Time Coordinated [minutes]
unsigned short gps_week; //!< GPS week (0-1024+) [week]
double gps_tow; //!< GPS time of week (0-604800.0) [s]
gps_week = ((int)floor(gpsTime)) / 604800;
gps_tow = gpsTime - gps_week * 604800.;
TIMECONV_GetUTCTimeFromGPSTime(gps_week, gps_tow, &utc_year, &utc_month, &utc_day, &utc_hour, &utc_minute, &utc_seconds);
utc_Year = utc_year;
utc_Month = utc_month;
utc_Day = utc_day;
utc_Hour = utc_hour;
utc_Minute = utc_minute;
#elif defined(WIN32)
#if defined(WIN32)
SYSTEMTIME sysTim;
e57::GetSystemTimeFromGPSDateTime(gpsTime, sysTim);
utc_year = sysTim.wYear; //!< The year 1900-9999
utc_month = sysTim.wMonth; //!< The month 0-11
utc_day = sysTim.wDay; //!< The day 1-31
utc_hour = sysTim.wHour; //!< The hour 0-23
utc_minute = sysTim.wMinute; //!< The minute 0-59
utc_Year = sysTim.wYear; //!< The year 1900-9999
utc_Month = sysTim.wMonth; //!< The month 0-11
utc_Day = sysTim.wDay; //!< The day 1-31
utc_Hour = sysTim.wHour; //!< The hour 0-23
utc_Minute = sysTim.wMinute; //!< The minute 0-59
utc_seconds = sysTim.wSecond; //!< The seconds 0.0 - 59.999
utc_seconds += sysTim.wMilliseconds / 1000;
#else
ignore(gpsTime);
utc_Year = 2022; //!< The year 1900-9999
utc_Month = 1; //!< The month 0-11
utc_Day = 1; //!< The day 1-31
utc_Hour = 0; //!< The hour 0-23
utc_Minute = 0; //!< The minute 0-59
utc_seconds = 0.0; //!< The seconds 0.0 - 59.999
#endif
return;
}
////////////////////////////////////////////////////////////////////
//

View File

@@ -2,7 +2,7 @@
* lasreader.cpp - simple routines for reading LAS files.
*
* Copyright (c) 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
* Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
@@ -26,7 +26,7 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <openE57/LAS/LASReader.h>
#include <openE57/LAS/openE57las.h>
#include <openE57/impl/openE57Impl.h>
#include <algorithm>

View File

@@ -1,6 +1,40 @@
#
# Time conversion utilities
#
add_library(time_conversion ${LIBRARY_TYPE}
${CMAKE_CURRENT_SOURCE_DIR}/time_conversion/time_conversion.c
${CMAKE_CURRENT_SOURCE_DIR}/time_conversion/time_conversion.h
${CMAKE_CURRENT_SOURCE_DIR}/time_conversion/basictypes.h
${CMAKE_CURRENT_SOURCE_DIR}/time_conversion/constants.h
${CMAKE_CURRENT_SOURCE_DIR}/time_conversion/gnss_error.h)
set_target_properties(time_conversion PROPERTIES
DEBUG_POSTFIX "-d"
MSVC_RUNTIME_LIBRARY "${MSVC_RUNTIME_TYPE}")
target_compile_options(time_conversion PUBLIC ${compiler_options})
target_compile_definitions(time_conversion PUBLIC ${compiler_definitions})
target_link_options(time_conversion PUBLIC ${linker_flags})
target_include_directories(time_conversion
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/time_conversion
)
target_link_libraries(time_conversion
PUBLIC
${Boost_LIBRARY_DIRS}
${XML_LIBRARIES}
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:Clang>>:dl>
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:Clang>>:m>
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:Clang>>:c>
)
#
# Build executables
#
list(APPEND TOOLS
e57fields
e57unpack
#e57unpack
e57validate
e57xmldump
)
@@ -16,8 +50,8 @@ foreach(TOOL ${TOOLS})
target_link_options(${TOOL} PUBLIC ${linker_flags})
target_include_directories(${TOOL}
PRIVATE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
${CMAKE_SOURCE_DIR}/include
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
${CMAKE_SOURCE_DIR}/src/lib/include
${XML_INCLUDE_DIRS}
${Boost_INCLUDE_DIR}
)
@@ -31,7 +65,9 @@ foreach(TOOL ${TOOLS})
)
endforeach()
#
# Handle las2e57 differently
#
add_executable(las2e57 ${CMAKE_CURRENT_SOURCE_DIR}/las2e57.cpp)
set_target_properties(las2e57 PROPERTIES
@@ -43,8 +79,8 @@ target_link_options(las2e57 PUBLIC ${linker_flags})
target_include_directories(las2e57
PRIVATE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
${CMAKE_SOURCE_DIR}/include
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
${CMAKE_SOURCE_DIR}/src/lib/include
${XML_INCLUDE_DIRS}
${Boost_INCLUDE_DIR}
)
@@ -52,7 +88,7 @@ target_include_directories(las2e57
target_link_libraries(las2e57
PRIVATE
${PROJECT_NAME}
LASReader
${PROJECT_NAME}las
time_conversion
${XML_LIBRARIES}
${Boost_LIBRARIES}
@@ -63,7 +99,7 @@ install(
TARGETS
e57fields
e57xmldump
e57unpack
#e57unpack
e57validate
las2e57
RUNTIME DESTINATION bin

View File

@@ -2,7 +2,7 @@
* e57fields.cpp - print summary statistics of field use in an E57 file.
*
* Copyright (c) 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
* Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by

View File

@@ -1,14 +1,12 @@
// $Id: e57unpack.cpp 338 2013-09-03 12:36:09Z roland_schwarz $
#include <config.h>
#define PROGRAM_NAME "e57unpack"
#define PROGRAM_VERSION "1.0"
#ifndef SVN_VERSION
# define SVN_VERSION unknown
#ifndef E57_REFIMPL_REVISION_ID
# define E57_REFIMPL_REVISION_ID unknown
#endif
#define STRING_HELPER2(a) #a
#define STRING_HELPER1(a) STRING_HELPER2(a)
#define BUILD_VERSION STRING_HELPER1(SVN_VERSION)
#define BUILD_VERSION STRING_HELPER1(E57_REFIMPL_REVISION_ID)
#include <openE57/openE57.h>
using e57::BlobNode;

View File

@@ -2,7 +2,7 @@
* Validator for ASTM Standard E57 format v1.0.
*
* Copyright (c) 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
* Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by

View File

@@ -2,7 +2,7 @@
* e57xmldump.cpp - print XML section of E57 file to stdout.
*
* Copyright (c) 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
* Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by

View File

@@ -2,7 +2,7 @@
* las2e57.cpp - convert LAS format file to E57 format.
*
* Copyright (c) 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Copyright (c) 2020 Michele Adduci (adduci@tutanota.com)
* Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
@@ -26,9 +26,9 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <openE57/LAS/LASReader.h>
#include <openE57/LAS/openE57las.h>
#include <openE57/openE57.h>
#include <openE57/time_conversion/time_conversion.h> // code from Essential GNSS Project
#include <time_conversion/time_conversion.h> // code from Essential GNSS Project
#include <fstream> // std::ifstream
#include <iomanip>

View File

@@ -44,9 +44,9 @@ SUCH DAMAGE.
*/
#include <math.h> /* for fmod() */
#include <openE57/time_conversion/constants.h>
#include <openE57/time_conversion/gnss_error.h>
#include <openE57/time_conversion/time_conversion.h>
#include <constants.h>
#include <gnss_error.h>
#include <time_conversion.h>
#include <sys/timeb.h>
#include <time.h>

View File

@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
project(openE57_example CXX)
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(openE57 REQUIRED)
add_executable(${PROJECT_NAME}
example.cpp
)
target_include_directories(${PROJECT_NAME} PRIVATE ${openE57_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${openE57_LIBRARIES})
set_target_properties( ${PROJECT_NAME}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)

21
test_package/conanfile.py Normal file
View File

@@ -0,0 +1,21 @@
import shutil,os
from conans import ConanFile, CMake, tools
class TestOpenE57Conan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package"
def build(self):
if not tools.cross_building(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if not tools.cross_building(self):
bin_path=""
if self.settings.compiler == "Visual Studio":
bin_path = os.path.join("bin", "{}".format(self.settings.build_type), "openE57_example")
else:
bin_path = os.path.join("bin", "openE57_example")
self.run(bin_path, run_environment=True)

376
test_package/example.cpp Normal file
View File

@@ -0,0 +1,376 @@
/*
* DemoWrite01.cpp - small write demo using the E57 format Foundation API.
*
* Copyright (c) 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Copyright (c) 2020 - 2022 Michele Adduci (adduci@tutanota.com)
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <openE57/openE57.h>
using namespace e57;
using namespace std;
int main(int /*argc*/, char** /*argv*/)
{
try
{
/// Open new file for writing, get the initialized root node (a Structure).
/// Path name: "/"
ImageFile imf("foo.e57", "w");
StructureNode root = imf.root();
/// Register extension with URI=www.example.com/DemoExtension and prefix=demo
imf.extensionsAdd("demo", "http://openE57.github.io/DemoExtension");
/// Set per-file properties.
/// Path names: "/formatName", "/majorVersion", "/minorVersion", "/coordinateMetadata"
root.set("formatName", StringNode(imf, "ASTM E57 3D Imaging Data File"));
root.set("guid", StringNode(imf, "3F2504E0-4F89-11D3-9A0C-0305E82C3300"));
/// Get ASTM version number supported by library, so can write it into file
int astmMajor;
int astmMinor;
ustring libraryId;
E57Utilities().getVersions(astmMajor, astmMinor, libraryId);
root.set("versionMajor", IntegerNode(imf, astmMajor));
root.set("versionMinor", IntegerNode(imf, astmMinor));
/// Save a dummy string for coordinate system.
/// Really should be a valid WKT string identifying the coordinate reference system (CRS).
root.set("coordinateMetadata", StringNode(imf, "...A WKT string here..."));
/// Create creationDateTime structure
/// Path name: "/creationDateTime
StructureNode creationDateTime = StructureNode(imf);
root.set("creationDateTime", creationDateTime);
creationDateTime.set("dateTimeValue", FloatNode(imf, 123.456)); //!!! convert time() to GPStime
/// Create 3D data area.
/// Path name: "/data3D"
VectorNode data3D = VectorNode(imf, true);
root.set("data3D", data3D);
/// Add first scan
/// Path name: "/data3D/0"
StructureNode scan0 = StructureNode(imf);
data3D.append(scan0);
/// Add guid to scan0.
/// Path name: "/data3D/0/guid".
const char* scanGuid0 = "3F2504E0-4F89-11D3-9A0C-0305E82C3301";
scan0.set("guid", StringNode(imf, scanGuid0));
/// Add an extension field as an example
scan0.set("demo:extra1", StringNode(imf, "used by demo extension"));
/// Make a prototype of datatypes that will be stored in points record.
/// This prototype will be used in creating the points CompressedVector.
/// Using this proto in a CompressedVector will define path names like:
/// "/data3D/0/points/0/cartesianX"
StructureNode proto = StructureNode(imf);
proto.set("cartesianX", ScaledIntegerNode(imf, 0, 0, 32767, 0.001, 0));
proto.set("cartesianY", ScaledIntegerNode(imf, 0, 0, 32767, 0.001, 0));
proto.set("cartesianZ", ScaledIntegerNode(imf, 0, 0, 32767, 0.001, 0));
proto.set("cartesianInvalidState", IntegerNode(imf, 0, 0, 2));
proto.set("rowIndex", IntegerNode(imf, 0, 0, 1));
proto.set("columnIndex", IntegerNode(imf, 0, 0, 4));
proto.set("returnIndex", IntegerNode(imf, 0, 0, 0));
proto.set("returnCount", IntegerNode(imf, 1, 1, 1));
proto.set("timeStamp", FloatNode(imf, 0.0, E57_DOUBLE));
proto.set("intensity", IntegerNode(imf, 0, 0, 255));
proto.set("colorRed", FloatNode(imf, 0.0, E57_SINGLE, 0.0, 1.0));
proto.set("colorGreen", FloatNode(imf, 0.0, E57_SINGLE, 0.0, 1.0));
proto.set("colorBlue", FloatNode(imf, 0.0, E57_SINGLE, 0.0, 1.0));
proto.set("demo:extra2", StringNode(imf));
/// Make empty codecs vector for use in creating points CompressedVector.
/// If this vector is empty, it is assumed that all fields will use the BitPack codec.
VectorNode codecs = VectorNode(imf, true);
/// Create CompressedVector for storing points. Path Name: "/data3D/0/points".
/// We use the prototype and empty codecs tree from above.
/// The CompressedVector will be filled by code below.
CompressedVectorNode points = CompressedVectorNode(imf, proto, codecs);
scan0.set("points", points);
/// Create pose structure for scan.
/// Path names: "/data3D/0/pose/rotation/w", etc...
/// "/data3D/0/pose/translation/x", etc...
StructureNode pose = StructureNode(imf);
scan0.set("pose", pose);
StructureNode rotation = StructureNode(imf);
pose.set("rotation", rotation);
rotation.set("w", FloatNode(imf, 1.0));
rotation.set("x", FloatNode(imf, 0.0));
rotation.set("y", FloatNode(imf, 0.0));
rotation.set("z", FloatNode(imf, 0.0));
StructureNode translation = StructureNode(imf);
pose.set("translation", translation);
translation.set("x", FloatNode(imf, 0.0));
translation.set("y", FloatNode(imf, 0.0));
translation.set("z", FloatNode(imf, 0.0));
///================
/// Add grouping scheme area
/// Path name: "/data3D/0/pointGroupingSchemes"
StructureNode pointGroupingSchemes = StructureNode(imf);
scan0.set("pointGroupingSchemes", pointGroupingSchemes);
/// Add a line grouping scheme
/// Path name: "/data3D/0/pointGroupingSchemes/groupingByLine"
StructureNode groupingByLine = StructureNode(imf);
pointGroupingSchemes.set("groupingByLine", groupingByLine);
/// Add idElementName to groupingByLine, specify a line is column oriented
/// Path name: "/data3D/0/pointGroupingSchemes/groupingByLine/idElementName"
groupingByLine.set("idElementName", StringNode(imf, "columnIndex"));
/// Make a prototype of datatypes that will be stored in LineGroupRecord.
/// This prototype will be used in creating the groups CompressedVector.
/// Will define path names like:
/// "/data3D/0/pointGroupingSchemes/groupingByLine/groups/0/idElementValue"
StructureNode lineGroupProto = StructureNode(imf);
lineGroupProto.set("idElementValue", IntegerNode(imf, 0, 0, 4));
lineGroupProto.set("startPointIndex", IntegerNode(imf, 0, 0, 9));
lineGroupProto.set("pointCount", IntegerNode(imf, 1, 1, 2));
/// Add cartesian bounds to line group prototype
/// Will define path names like:
/// "/data3D/0/pointGroupingSchemes/groupingByLine/groups/0/cartesianBounds/xMinimum"
StructureNode lineGroupBbox = StructureNode(imf);
lineGroupProto.set("cartesianBounds", lineGroupBbox);
lineGroupBbox.set("xMinimum", FloatNode(imf, 0.0));
lineGroupBbox.set("xMaximum", FloatNode(imf, 0.0));
lineGroupBbox.set("yMinimum", FloatNode(imf, 0.0));
lineGroupBbox.set("yMaximum", FloatNode(imf, 0.0));
lineGroupBbox.set("zMinimum", FloatNode(imf, 0.0));
lineGroupBbox.set("zMaximum", FloatNode(imf, 0.0));
/// Make empty codecs vector for use in creating groups CompressedVector.
/// If this vector is empty, it is assumed that all fields will use the BitPack codec.
VectorNode lineGroupCodecs = VectorNode(imf, true);
/// Create CompressedVector for storing groups.
/// Path Name: "/data3D/0/pointGroupingSchemes/groupingByLine/groups".
/// We use the prototype and empty codecs tree from above.
/// The CompressedVector will be filled by code below.
CompressedVectorNode groups = CompressedVectorNode(imf, lineGroupProto, lineGroupCodecs);
groupingByLine.set("groups", groups);
///================
/// Add name and description to scan
/// Path names: "/data3D/0/name", "/data3D/0/description".
scan0.set("name", StringNode(imf, "Station 3F"));
scan0.set("description", StringNode(imf, "An example scan"));
/// Add Cartesian bounding box to scan.
/// Path names: "/data3D/0/cartesianBounds/xMinimum", etc...
StructureNode bbox = StructureNode(imf);
bbox.set("xMinimum", FloatNode(imf, 0.0));
bbox.set("xMaximum", FloatNode(imf, 1.0));
bbox.set("yMinimum", FloatNode(imf, 0.0));
bbox.set("yMaximum", FloatNode(imf, 1.0));
bbox.set("zMinimum", FloatNode(imf, 0.0));
bbox.set("zMaximum", FloatNode(imf, 1.0));
scan0.set("cartesianBounds", bbox);
/// Add start/stop acquisition times to scan.
/// Path names: "/data3D/0/acquisitionStart/dateTimeValue",
/// "/data3D/0/acquisitionEnd/dateTimeValue"
StructureNode acquisitionStart = StructureNode(imf);
scan0.set("acquisitionStart", acquisitionStart);
acquisitionStart.set("dateTimeValue", FloatNode(imf, 1235.));
StructureNode acquisitionEnd = StructureNode(imf);
scan0.set("acquisitionEnd", acquisitionEnd);
acquisitionEnd.set("dateTimeValue", FloatNode(imf, 1235.));
/// Add various sensor and version strings to scan.
/// Path names: "/data3D/0/sensorVendor", etc...
scan0.set("sensorVendor", StringNode(imf, "Scan Co"));
scan0.set("sensorModel", StringNode(imf, "Scanmatic 2000"));
scan0.set("sensorSerialNumber", StringNode(imf, "123-321"));
scan0.set("sensorHardwareVersion", StringNode(imf, "3.3.0"));
scan0.set("sensorSoftwareVersion", StringNode(imf, "27.0.3"));
scan0.set("sensorFirmwareVersion", StringNode(imf, "27.0.3"));
/// Add temp/humidity to scan.
/// Path names: "/data3D/0/temperature", etc...
scan0.set("temperature", FloatNode(imf, 20.0));
scan0.set("relativeHumidity", FloatNode(imf, 40.0));
///================
/// Create 2D image area.
/// Path name: "/images2D"
VectorNode images2D = VectorNode(imf, true);
root.set("images2D", images2D);
/// Add a first picture area to the list.
/// Path name: "/images2D/0"
StructureNode picture0 = StructureNode(imf);
images2D.append(picture0);
/// Attach a guid to first picture.
/// Path name: "/images2D/0/guid"
picture0.set("guid", StringNode(imf, "3F2504E0-4F89-11D3-9A0C-0305E82C3302"));
/// Make an area holding pinhole projection parameters for first picture.
/// Path name: "/images2D/0/pinholeRepresentation"
StructureNode pinhole = StructureNode(imf);
picture0.set("pinholeRepresentation", pinhole);
/// Add pinhole parameters
/// Path names: "/images2D/0/pinholeRepresentation/imageWidth", etc...
pinhole.set("imageWidth", IntegerNode(imf, 1024));
pinhole.set("imageHeight", IntegerNode(imf, 1024));
pinhole.set("focalLength", FloatNode(imf, 1.0));
pinhole.set("pixelWidth", FloatNode(imf, 1e-3));
pinhole.set("pixelHeight", FloatNode(imf, 1e-3));
pinhole.set("principalPointX", FloatNode(imf, 512.0));
pinhole.set("principalPointY", FloatNode(imf, 512.0));
/// Create a toy 10 byte blob (instead of copying a big .jpg into .e57 file)
/// Path name: "/images2D/0/pinholeRepresentation/jpegImage"
BlobNode jpegImage = BlobNode(imf, 10);
pinhole.set("jpegImage", jpegImage);
/// Save some fake data in the blob
uint8_t fakeBlobData[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
jpegImage.write(fakeBlobData, 0, 10);
/// Attach a pose to picture
/// Path names: "/images2D/0/pose/rotation/w", etc...
/// "/images2D/0/pose/translation/x", etc...
StructureNode picturePose = StructureNode(imf);
picture0.set("pose", picturePose);
StructureNode pictureRotation = StructureNode(imf);
picturePose.set("rotation", pictureRotation);
pictureRotation.set("w", FloatNode(imf, 1.0));
pictureRotation.set("x", FloatNode(imf, 0.0));
pictureRotation.set("y", FloatNode(imf, 0.0));
pictureRotation.set("z", FloatNode(imf, 0.0));
StructureNode pictureTranslation = StructureNode(imf);
picturePose.set("translation", pictureTranslation);
pictureTranslation.set("x", FloatNode(imf, 0.0));
pictureTranslation.set("y", FloatNode(imf, 0.0));
pictureTranslation.set("z", FloatNode(imf, 0.0));
/// Add name, description, time, associated guid to first picture.
/// Path names: "/images2D/0/name", etc...
picture0.set("name", StringNode(imf, "pic123"));
picture0.set("description", StringNode(imf, "trial picture"));
picture0.set("associatedData3DGuid", StringNode(imf, scanGuid0));
StructureNode acquisitionDateTime = StructureNode(imf);
picture0.set("acquisitionDateTime", acquisitionDateTime);
acquisitionDateTime.set("dateTimeValue", FloatNode(imf, 123.456)); //!!! convert time() to GPStime
///================
/// Prepare vector of source buffers for writing in the CompressedVector of points
const int N = 10;
double cartesianX[N] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
double cartesianY[N] = {1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 8.1, 9.1, 10.1};
double cartesianZ[N] = {1.2, 2.2, 3.2, 4.2, 5.2, 6.2, 7.2, 8.2, 9.1, 10.2};
int32_t cartesianInvalidState[N] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int32_t rowIndex[N] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
int32_t columnIndex[N] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4};
int32_t returnIndex[N] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int32_t returnCount[N] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
double timeStamp[N] = {.1, .2, .3, .4, .5, .6, .7, .8, .9, 1.0};
int32_t intensity[N] = {1, 2, 3, 2, 1, 1, 2, 3, 2, 1};
double colorRed[N] = {.1, .2, .3, .4, .5, 6., .7, .8, .9, 1.0};
double colorGreen[N] = {.5, .5, .5, .5, .5, .5, .5, .5, .5, .5};
double colorBlue[N] = {1.0, .9, .8, .7, .6, .5, .4, .3, .2, .1};
ustring demoExtra2[N] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
vector<SourceDestBuffer> sourceBuffers;
sourceBuffers.push_back(SourceDestBuffer(imf, "cartesianX", cartesianX, N, true, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "cartesianY", cartesianY, N, true, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "cartesianZ", cartesianZ, N, true, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "cartesianInvalidState", cartesianInvalidState, N, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "rowIndex", rowIndex, N, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "columnIndex", columnIndex, N, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "returnIndex", returnIndex, N, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "returnCount", returnCount, N, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "timeStamp", timeStamp, N, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "intensity", intensity, N, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "colorRed", colorRed, N, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "colorGreen", colorGreen, N, true));
sourceBuffers.push_back(SourceDestBuffer(imf, "colorBlue", colorBlue, N, true));
/// Create a vector<ustring> from c++ array of values
vector<ustring> demoExtra2v;
for (int i = 0; i < N; i++)
demoExtra2v.push_back(demoExtra2[i]);
sourceBuffers.push_back(SourceDestBuffer(imf, "demo:extra2", &demoExtra2v));
/// Write source buffers into CompressedVector
{
CompressedVectorWriter writer = points.writer(sourceBuffers);
writer.write(N);
writer.close();
}
///================
/// Prepare vector of source buffers for writing in the CompressedVector of groups
const int NG = 5;
int32_t idElementValue[NG] = {0, 1, 2, 3, 4};
int32_t startPointIndex[NG] = {0, 2, 4, 6, 8};
int32_t pointCount[NG] = {2, 2, 2, 2, 2};
double xMinimum[NG] = {1.0, 3.0, 5.0, 7.0, 9.0};
double xMaximum[NG] = {2.0, 4.0, 6.0, 8.0, 10.0};
double yMinimum[NG] = {1.1, 3.1, 5.1, 7.1, 9.1};
double yMaximum[NG] = {2.1, 4.1, 6.1, 8.1, 10.1};
double zMinimum[NG] = {1.2, 3.2, 5.2, 7.2, 9.2};
double zMaximum[NG] = {2.2, 4.2, 6.2, 8.2, 10.2};
vector<SourceDestBuffer> groupSDBuffers;
groupSDBuffers.push_back(SourceDestBuffer(imf, "idElementValue", idElementValue, NG, true));
groupSDBuffers.push_back(SourceDestBuffer(imf, "startPointIndex", startPointIndex, NG, true));
groupSDBuffers.push_back(SourceDestBuffer(imf, "pointCount", pointCount, NG, true));
groupSDBuffers.push_back(SourceDestBuffer(imf, "cartesianBounds/xMinimum", xMinimum, NG, true));
groupSDBuffers.push_back(SourceDestBuffer(imf, "cartesianBounds/xMaximum", xMaximum, NG, true));
groupSDBuffers.push_back(SourceDestBuffer(imf, "cartesianBounds/yMinimum", yMinimum, NG, true));
groupSDBuffers.push_back(SourceDestBuffer(imf, "cartesianBounds/yMaximum", yMaximum, NG, true));
groupSDBuffers.push_back(SourceDestBuffer(imf, "cartesianBounds/zMinimum", zMinimum, NG, true));
groupSDBuffers.push_back(SourceDestBuffer(imf, "cartesianBounds/zMaximum", zMaximum, NG, true));
/// Write source buffers into CompressedVector
{
CompressedVectorWriter writer = groups.writer(groupSDBuffers);
writer.write(NG);
writer.close();
}
imf.close();
}
catch (E57Exception& ex)
{
ex.report(__FILE__, __LINE__, __FUNCTION__);
}
catch (std::exception& ex)
{
cerr << "Got an std::exception, what=" << ex.what() << endl;
}
catch (...)
{
cerr << "Got an unknown exception" << endl;
}
return (0);
}