SBF

From CloudCompareWiki
Jump to navigation Jump to search

Introduction

The SBF (Simple Binary File) format, is meant to ease the export and external processing of big point clouds.

While the BIN format of CloudCompare can store about anything created or loaded in CloudCompare, it is highly complex to decode (as it is a serialized stream of what is loaded in the memory - the only way to properly open a BIN file is to use QCC_DB_LIB).

Thus, the SBF format has been created to store 3D points and scalar field values in a binary file with a very simple structure (+ some more meta-data in a text file next to the binary file).

The file structure is always like this:

- myfile.sbf (text file with meta-data)
- myfile.sbf.data (binary file)

Specifications

Ascii file

This section describes the contents of the text file (.sbf)

It has the same structure as a Windows INI file:

[SBF]
Points=362315
GlobalShift=-462500.000000, -5640400.000000, 0.000000
SFCount=10
SF1=name of scalar field, s=shift value, p=precision
SF2=name of scalar field, s=shift value, p=precision
...
SF10=name of scalar field, s=shift value, p=precision

Notes:

  • the 'p' and 's' options for the scalar fields are optional
  • the 'p' option is simply stored as meta-data and restored when exporting the cloud to SBF
  • all values should be float/decimal

Binary file

This section describes the contents of the binary file (.sbf.data)

Header

Total length: 64 bytes

Bytes Description Value / comment
0-1 SBF header flag 42 42
2-9 Point count (Np) 8 bytes unsigned integer
10-11 Scalar field count (Ns) 2 bytes unsigned integer
12-19 X coordinate shift (should be added to all 32bit coordinates stored in the file) 64bit floating point value ('double')
20-27 Y coordinate shift (should be added to all 32bit coordinates stored in the file) 64bit floating point value ('double')
28-35 Z coordinate shift (should be added to all 32bit coordinates stored in the file) 64bit floating point value ('double')
36-63 Reserved for later 0

Notes: with Python, the following snippet can be used to create the header:

struct.pack('>2BQH3d28x', 42, 42, no_pt, no_sf, offset_x, offset_y, offset_z)

Body

For each point (1-Np):

Bytes Description Value / comment
0-3 X coordinate 32bit floating point value ('float')
4-7 Y coordinate 32bit floating point value ('float')
8-11 Z coordinate 32bit floating point value ('float')
12-15 Scalar value (SF #1) 32bit floating point value ('float')
16-19 Scalar value (SF #2) 32bit floating point value ('float')
... ...
12-15 + k * 4 (k in [0 ; Ns[) Scalar value (SF #k) 32bit floating point value ('float')