Struct AttributedPointCloud¶
Defined in File attribute_layout.h
Struct Documentation¶
-
struct AttributedPointCloud¶
A pointcloud whose attributes keep their original types.
Returned by ouster::sdk::core::VoxelHashMap::pointcloud. The two members are parallel: row
iof xyz is positioned by rowiof attributes, whose bytes layout describes.The accessors below decode attributes into typed C++ values, checking the requested types against layout at runtime; they never convert a value, only copy its bytes, so what comes out is bit-for-bit what went in.
Public Functions
-
std::size_t size() const¶
Number of points.
- Returns:
The number of rows of xyz and attributes.
-
template<typename T>
inline void attribute(std::size_t spec_index, T *out, std::size_t out_count) const¶ Copy attribute
spec_indexof every point intoout; see AttributeLayout::unpack().- Template Parameters:
T – The C++ type the attribute is stored as, e.g.
std::uint32_tfor an AttributeType::U32 attribute. It must match exactly: a same-sized but different type (floatorstd::int32_tfor a U32) is rejected rather than reinterpreted.- Parameters:
- Throws:
std::invalid_argument – if
spec_indexis out of range,Tis not the attribute’s stored type,out_countis wrong, or xyz and attributes disagree in shape.
-
template<typename T>
inline std::vector<T> attribute(std::size_t spec_index) const¶ Attribute
spec_indexof every point, in its stored type.For a scalar attribute (
count == 1) elementibelongs to pointi; for a multi-element one, e.g. NORMALS{F32, 3}, pointi’s values are elements[i * count, (i + 1) * count).- Template Parameters:
T – The C++ type the attribute is stored as; see the overload above.
- Parameters:
spec_index[in] Which attribute of layout to read.
- Throws:
std::invalid_argument – if
spec_indexis out of range,Tis not the attribute’s stored type, or xyz and attributes disagree in shape.- Returns:
size() * countvalues.
-
template<typename AttributesT, typename ...Fields>
inline std::vector<AttributesT> attributes_as(Fields AttributesT::*... fields) const¶ Every point’s attributes as a user-defined struct, verified field by field against layout.
fieldslists the members ofAttributesTthat hold the layout’s attributes, in layout order. Each member must have the attribute’s stored type: a scalar forcount == 1, or a C array / std::array ofcountscalars otherwise. Because every value is copied into its own member,AttributesTmay have any padding or extra members:struct Attrs { std::uint32_t range; std::uint8_t reflectivity; }; auto attrs = cloud.attributes_as<Attrs>(&Attrs::range, &Attrs::reflectivity);
- Template Parameters:
AttributesT – Default-constructible struct to decode into.
- Parameters:
fields[in] One pointer-to-member per attribute of layout.
- Throws:
std::invalid_argument – if the number of fields, or any field’s type or element count, does not match layout, or xyz and attributes disagree in shape.
- Returns:
One
AttributesTper point.
-
template<typename AttributesT>
inline std::vector<AttributesT> attributes_as() const¶ Every point’s attributes as a packed struct mirroring the record.
Copies each record straight into an
AttributesT, so the struct must reproduce the record byte for byte: the layout’s attributes in order, with no padding (records are packed, so{U32, U8}is 5 bytes, while a plainstruct { std::uint32_t; std::uint8_t; }is usually 8). Declare it packed, e.g. with#pragma pack(push, 1). Only the size can be checked here; prefer the field-listing overload, which also checks every member’s type and needs no packing.- Template Parameters:
AttributesT – Trivially copyable struct of
layout.stride()bytes.- Throws:
std::invalid_argument – if
sizeof(AttributesT) != layout.stride(), or xyz and attributes disagree in shape.- Returns:
One
AttributesTper point.
Public Members
-
AttributeLayout layout¶
Layout of each row of attributes.
-
AttributeRecords attributes¶
N x
layout.stride()packed attribute records.
-
std::size_t size() const¶