libE57Format
repository·master·Indexed 41 days ago
https://github.com/asmaloney/libe57formatA C++ library for reading and writing ASTM-standard E57 files containing 3D point clouds, attributes, and 2D images. It features an E57Simple API for common tasks and requires a C++14 compatible compiler, CMake 3.15+, and the Xerces-C++ library for XML parsing. Compatible with Linux, macOS, and Windows.
What's inside libE57Format
- libE57Format is a C++ library providing read and write support for the ASTM-standard E57 file format. It is compatible with Linux, macOS, and Windows. The library is used to handle 3D point cloud data (from laser scanners), associated attributes (such as color and intensity), and 2D images stored within E57 files.
E57Simple API
masterThe library includes anE57Simple API, which is an updated and more foolproof version of the API originally ported from the E57RefImpl reference implementation. It is designed to be easier to use for common E57 tasks.Build, install, and test libE57Format
masterTo build and install a release version of libE57Format using CMake, follow these steps:
- Configure the build: Use
-DCMAKE_BUILD_TYPE=Releaseand specify an installation prefix with-DCMAKE_INSTALL_PREFIX. - Build: Use the
--parallelflag to speed up the build process. - Install: Install the built binaries to your specified prefix.
If CMake cannot locate the
xerces-clibrary, provide the path using theCMAKE_PREFIX_PATHvariable.To run the built tests, execute the
testE57binary located in the build directory.# Build and install with defaults $ cmake -B E57-build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=E57-install libE57Format $ cmake --build E57-build --parallel $ cmake --install E57-build # Build specifying xerces-c path $ cmake -B E57-build \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=E57-install \ -DCMAKE_PREFIX_PATH=/path/to/xerces-c \ libE57Format # Run tests $ cd E57-build $ ./test/testE57- Configure the build: Use
Install dependencies for libE57Format
masterlibE57Format requires the
Xerces-C++library for XML parsing. Depending on your operating system, use the following commands to install the necessary dependencies:Ubuntu/Linux: Install
libxerces-c-devandclang-formatviaapt.macOS: Install
ccache,clang-format, andxerces-cviahomebrew.# Ubuntu $ sudo apt install libxerces-c-dev clang-format # macOS $ brew install ccache clang-format xerces-cInstall CRC++ by including the header file
masterCRC++ is a header-only library. To use it in your project, you do not need to compile a library or manage complex build settings. Simply include the
CRC.hheader file in your C++ source code. It is compatible with any reasonably compliant C++03 or C++11 compiler, though C++11 is recommended for better compile-time performance.#include "CRC.h"Build CRC++ unit tests and documentation with CMake
masterWhile CRC++ is header-only and requires no build for basic usage, you can use CMake to build the included unit tests and Doxygen documentation.
mkdir -p build cd build cmake .. [-DBUILD_DOC=ON] # Build and run unit tests make tests # Build documentation (requires Doxygen) make doxygen # Install the header file sudo make installConfigure CRC++ via preprocessor macros
masterYou can customize the behavior and types of CRC++ by defining macros before including
CRC.h.Type Customization
#define crcpp_uint8: Type for 8-bit or less CRCs (default:::std::uint8_t).#define crcpp_uint16: Type for 9-16 bit CRCs (default:::std::uint16_t).#define crcpp_uint32: Type for 17-32 bit CRCs (default:::std::uint32_t).#define crcpp_uint64: Type for 33-64 bit CRCs (default:::std::uint64_t).#define crcpp_size: Type for loop iteration and signatures (default:::std::size_t).
Feature Flags
#define CRCPP_USE_NAMESPACE: Places all code within the::CRCPPnamespace.#define CRCPP_BRANCHLESS: Enables a branchless implementation (uses integer multiplication instead of conditionals). Recommended for architectures with fast single-instruction integer multiplication.#define CRCPP_USE_CPP11: Enables C++11 features like move semantics andconstexpr.#define CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS: Includes less common CRC definitions.
Compute CRCs on non-byte-aligned bit lengths using CRC::CalculateBits()
masterIf your input data is not a multiple of
CHAR_BIT(usually 8 bits), useCRC::CalculateBits(). The second argument specifies the exact number of bits to process. Note that the input data buffer must still be a whole number of bytes; any unused bits in the final byte should be padded with zeros.const unsigned char data[] = { 0x98, 0x76, 0x54, 0x32, 0x10 }; // Compute CRC for exactly 37 bits std::uint32_t crc = CRC::CalculateBits(data, 37, CRC::CRC_32());Compute multi-part CRCs
masterYou can compute a CRC over multiple non-contiguous buffers by passing the result of the previous calculation as the final argument to the next
CRC::Calculatecall. This allows you to chain data segments together.std::uint32_t crc; // First part crc = CRC::Calculate(part1, size1, CRC::CRC_32()); // Second part (chains onto the first) crc = CRC::Calculate(part2, size2, CRC::CRC_32(), crc);Compute a basic CRC using CRC::Calculate()
masterTo compute a CRC, use the
CRC::Calculatefunction. You must provide the data buffer, the size of the buffer, and a CRC definition (e.g.,CRC::CRC_32()).#include "CRC.h" #include <cstdint> int main() { const char myString[] = { 'H', 'E', 'L', 'L', 'O' }; std::uint32_t crc = CRC::Calculate(myString, sizeof(myString), CRC::CRC_32()); return 0; }Use lookup tables for faster CRC computation
masterFor high-performance requirements, use
CRC::Table. Lookup tables are significantly faster than bit-by-bit calculation but consume more memory. A table can be reused for multiple calculations as long as it remains in scope.// Option 1: Explicitly define the table type CRC::Table<std::uint32_t, 32> table(CRC::CRC_32()); std::uint32_t crc = CRC::Calculate(data, size, table); // Option 2: Use the auto keyword with MakeTable() auto table = CRC::CRC_32().MakeTable(); std::uint32_t crc = CRC::Calculate(data, size, table);Requirements for libE57Format
masterTo build libE57Format, your environment must meet the following requirements:
- A C++14 compatible compiler.
- CMake version 3.15 or higher.
- clang-format (for code formatting).
- Xerces-C++ (dependency for XML parsing).
- (Optional) ccache to accelerate rebuilds.