libsdfio 1.0.0
Reader and writer for ISO 25178-71 SDF surface data files in C
Loading...
Searching...
No Matches
libsdfio

libsdfio is a C11 library without dependencies that reads and writes the SDF surface data files of ISO 25178-71. An SDF file contains the heights of a profile or of an areal surface measurement on a rectangular grid. It is used as a software measurement standard, a set of reference data with which the software of surface texture measuring instruments is verified, and as an interchange format for topography data.

Features

  • Implemented according to ISO 25178-71:2026, with the revisions ISO-1.0 and ISO-2.0.
  • Access to the data as heights in metres or as the coded values of the file.
  • Application-side buffers with arbitrary strides.
  • Custom allocators.
  • Files, blocks of memory and streams, including pipes, as sources and sinks.
  • Thread support: the library keeps no global state, so threads use handles of their own at the same time.

Limitations

  • A handle must not be shared between threads.
  • The locale must not be changed while a call is in progress.
  • Rows can be read only once and in the order of the file.
  • A failure in the middle of the data area causes the handle to refuse further reads and writes.
  • The library and the program that calls it have to be built with the same width of time_t, see Building and Installing.
  • Files of the format BCR-1.0, the predecessor of ISO-1.0, are not supported.

Building and Installing

cmake -S . -B build
cmake --build build
ctest --test-dir build
cmake --install build --prefix /path/to/prefix

With Visual Studio, configure with -A x64 (or Win32, ARM64) and name the configuration in the other commands: --config Release, and -C Release for ctest.

These CMake options control which components are built:

OptionDefaultBuilds
SDFIO_BUILD_EXAMPLESOFFThe examples.
SDFIO_BUILD_EXTERNAL_EXAMPLESOFFThe examples that use OpenCV, VTK and Eigen, which must be found.
SDFIO_BUILD_DOCSOFFThis API reference, with Doxygen, as the target docs.

Dates are time_t values in seconds since 1970-01-01 00:00:00 UTC. The library and the program must use the same width of time_t. On a 32-bit host, a 64-bit time_t is needed for dates beyond 2038, for example with glibc:

cmake -S . -B build -DCMAKE_C_FLAGS="-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64"

Using

An installed library provides the CMake target sdfio::sdfio:

find_package(sdfio CONFIG REQUIRED)
add_executable(main main.c)
target_link_libraries(main PRIVATE sdfio::sdfio)

Source files that use the library include <sdfio/sdfio.h>, and <sdfio/file.h> for the functions that open files. See Examples for typical uses. Without CMake, compile and link with the flags that pkg-config reports:

cc main.c $(pkg-config --cflags --libs sdfio) -o main