|
VLink
2.0.0
A high-performance communication middleware
|
Zero-copy, schema-aware 3-D point cloud container with per-field type protocol. 更多...
#include <cstdint>#include <iostream>#include <string>#include <string_view>#include <type_traits>#include <unordered_map>#include <vector>#include "../base/bytes.h"#include "../base/quantize.h"#include "./header.h"命名空间 | |
| vlink | |
| vlink::zerocopy | |
Zero-copy, schema-aware 3-D point cloud container with per-field type protocol.
PointCloud carries a contiguous array of fixed-size point records together with a compact, self-describing schema (the embedded Protocol). Schemas are encoded as two uint64_t nibble-packed integers plus a comma-separated 152-byte name string, so a receiver can introspect every field without sharing an external IDL. The 40-byte Header prefix carries sequencing and dual-timestamp metadata.
| Enum | C++ type | Bytes |
|---|---|---|
kBoolType | bool | 1 |
kInt8Type | int8_t | 1 |
kUint8Type | uint8_t | 1 |
kInt16Type | int16_t | 2 |
kUint16Type | uint16_t | 2 |
kInt32Type | int32_t | 4 |
kUint32Type | uint32_t | 4 |
kInt64Type | int64_t | 8 |
kUint64Type | uint64_t | 8 |
kFloatType | float | 4 |
kDoubleType | double | 8 |
| Member | Type | Purpose |
|---|---|---|
size_num | uint64_t | Per-field byte sizes packed in nibbles |
type_num | uint64_t | Per-field Type tags packed in nibbles |
names[152] | char[] | Comma-separated field names (3..16 fields) |
PointCloud is POD; memcpy of the struct snapshot plus the packed point buffer forms the wire payload. The sizeof value is locked by static_assert and forms a permanent contract: vlink::zerocopy::* containers offer NO forward and NO backward binary compatibility – every field, including reserved bytes and the Protocol descriptor, is part of the wire contract. reserved_buf_ (offset 232), reserved_buf2_ (offset 236) and reserved_buf3_ (offset 245) are wire-locked padding bytes. They travel through the wire format unchanged but MUST NOT be repurposed by application code because future library revisions may bind them to real fields. The uint8_t downsample_ at offset 244 records the voxel-grid downsampling level applied to the payload (see downsample()): 0 disables downsampling, 255 is the most aggressive.extent and vertical create options trade fidelity for footprint along two independent axes. When extent_ > 0 the three leading XYZ coordinates are linearly quantised with Quantize::encode<int16_t>(extent, value) and restored with Quantize::decode<float/double>(extent, stored), halving (or better) their in-memory footprint; the embedded schema is rewritten so the XYZ fields advertise kInt16Type and get_value_v3f() / get_value_v3d() transparently dequantise back to floating point. The generic get_value<int16_t>() returns the raw int16_t storage, whereas get_value<float>() / get_value<double>() also dequantise (matching v3f / v3d). Points whose XYZ fall outside (-extent, +extent) cannot be represented and are discarded on insert rather than saturated. When vertical_ is true the serialised wire payload is emitted in structure-of-arrays order (xx..x yy..y zz..z, one field column after another) which packs better under a downstream entropy coder; the in-memory buffer stays interleaved (row-major) and operator<< restores that layout, so the field accessors are unaffected.downsample() collapses spatially-close points by mapping each point's quantised XYZ onto a voxel grid and keeping the first point seen in each voxel, compacting the survivors to the front of the buffer and shrinking size(). It applies only to quantised clouds (extent_ > 0) and records the requested level into the downsample_ marker, which get_downsample() reports. The marker is producer-set, not an automatically maintained invariant: freshly created clouds record 0, and clear() resets it to 0; it is NOT recomputed when points are subsequently added or modified.