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

Layout of a buffer in memory. More...

#include <sdfio/sdfio_export.h>
#include <sdfio/types.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  sdfio_layout
 Description of a buffer of the caller for heights or for the values of the data area: the type of its elements, and how the matrix lies in memory. More...

Typedefs

typedef struct sdfio_layout sdfio_layout
 Description of a buffer of the caller for heights or for the values of the data area: the type of its elements, and how the matrix lies in memory.

Functions

void sdfio_layout_init (sdfio_layout *layout)
 Initializes a layout of a plain array of float elements: the elements follow each other and the rows follow each other.
const sdfio_layout * sdfio_layout_packed (sdfio_data_type type)
 Returns the layout of a plain array: the elements follow each other and the rows follow each other.

Detailed Description

Layout of a buffer in memory.

A layout lets the functions transfer a matrix in place when it is part of something else: a member of a structure, a column-major matrix or a matrix upside down.

Typedef Documentation

◆ sdfio_layout

typedef struct sdfio_layout sdfio_layout

Description of a buffer of the caller for heights or for the values of the data area: the type of its elements, and how the matrix lies in memory.

The element (y, x) is at data + y * row_stride + x * element_stride. Both strides can be negative. They must keep the elements apart: either the rows or the columns must not overlap. This allows heights and values to be read or written in place where they are not contiguous, for example the z member of an array of points, one channel of an interleaved image or a column-major matrix. sdfio_layout_packed() describes a plain array. Without an initializer, call sdfio_layout_init() before assigning fields.

The structure is frozen for the major version: it has these three fields and a new property of a buffer is a new function.

Function Documentation

◆ sdfio_layout_init()

void sdfio_layout_init ( sdfio_layout * layout)

Initializes a layout of a plain array of float elements: the elements follow each other and the rows follow each other.

The caller sets the type and every other field that differs.

Parameters
[out]layoutThe layout to initialize.

◆ sdfio_layout_packed()

const sdfio_layout * sdfio_layout_packed ( sdfio_data_type type)

Returns the layout of a plain array: the elements follow each other and the rows follow each other.

The layout is a constant of the library, valid for the life of the program, and the same for every thread. Other strides require a copy of it, or sdfio_layout_init().

Parameters
typeThe type of the elements: SDFIO_TYPE_FLOAT or SDFIO_TYPE_DOUBLE for heights, and the data type of the file for the values of the data area.
Returns
The layout, or null if type is not a data type.
Examples
custom_timezone.c, eigen.cpp, opencv.cpp, read_coded.c, read_heights.c, read_stream.c, vtk.cpp, write_coded.c, write_heights.c, and write_memory.c.