pub struct PointAttribute { /* private fields */ }Expand description
Typed attribute values attached to points in a point cloud or mesh.
Attribute data is stored in a contiguous byte buffer. Point ids either map directly to attribute value ids, or through an explicit point-to-value map when multiple points share or reorder attribute entries.
Implementations§
Source§impl PointAttribute
impl PointAttribute
Sourcepub fn init(
&mut self,
attribute_type: GeometryAttributeType,
num_components: u8,
data_type: DataType,
normalized: bool,
num_attribute_values: usize,
)
pub fn init( &mut self, attribute_type: GeometryAttributeType, num_components: u8, data_type: DataType, normalized: bool, num_attribute_values: usize, )
Initializes the attribute and allocates storage for its values.
Sourcepub fn try_init(
&mut self,
attribute_type: GeometryAttributeType,
num_components: u8,
data_type: DataType,
normalized: bool,
num_attribute_values: usize,
) -> Result<(), DracoError>
pub fn try_init( &mut self, attribute_type: GeometryAttributeType, num_components: u8, data_type: DataType, normalized: bool, num_attribute_values: usize, ) -> Result<(), DracoError>
Fallibly initializes the attribute and allocates storage for its values.
Sourcepub fn mapped_index(&self, point_index: PointIndex) -> AttributeValueIndex
pub fn mapped_index(&self, point_index: PointIndex) -> AttributeValueIndex
Maps a point id to the corresponding attribute value id.
Sourcepub fn read_f32s(&self, num_points: usize, components: usize) -> Vec<f32>
pub fn read_f32s(&self, num_points: usize, components: usize) -> Vec<f32>
Read components scalars per point as f32, in point order.
The inverse of DataBuffer::update_f32s_le:
whatever component type the attribute stores widens to f32, and the
value index mapping is followed, so an attribute with fewer unique
values than points still lands on the right one.
The output is always num_points * components long, zero-filled where
the attribute has nothing to give. That matters because the result is a
channel addressed by vertex index: returning a short row for an
attribute with fewer components than asked for would shift every vertex
after it onto the wrong values, which is worse than a zero.
The ordinary case – float32, tightly packed, identity mapping, asking for exactly what the attribute has – is converted in one pass rather than one bounds-checked read per point.
Sourcepub fn resize_unique_entries(
&mut self,
num_attribute_values: usize,
) -> Result<(), DracoError>
pub fn resize_unique_entries( &mut self, num_attribute_values: usize, ) -> Result<(), DracoError>
Resizes the unique attribute value storage.
Sourcepub fn buffer_mut(&mut self) -> &mut DataBuffer
pub fn buffer_mut(&mut self) -> &mut DataBuffer
Returns the mutable raw attribute value buffer.
Sourcepub fn attribute_type(&self) -> GeometryAttributeType
pub fn attribute_type(&self) -> GeometryAttributeType
Returns the semantic attribute type.
Sourcepub fn set_unique_id(&mut self, id: u32)
pub fn set_unique_id(&mut self, id: u32)
Sets the stable Draco unique id.
Sourcepub fn set_attribute_type(&mut self, attribute_type: GeometryAttributeType)
pub fn set_attribute_type(&mut self, attribute_type: GeometryAttributeType)
Sets the semantic attribute type.
Sourcepub fn set_data_type(&mut self, data_type: DataType)
pub fn set_data_type(&mut self, data_type: DataType)
Sets the scalar data type.
Sourcepub fn set_num_components(&mut self, num_components: u8)
pub fn set_num_components(&mut self, num_components: u8)
Sets the number of scalar components per value.
Sourcepub fn is_mapping_identity(&self) -> bool
pub fn is_mapping_identity(&self) -> bool
Returns whether point ids are used directly as attribute value ids.
The counterpart of set_identity_mapping
and set_explicit_mapping: with identity
mapping, point i reads value i, so a caller validating the mapping
answers in one comparison rather than a call to
mapped_index per point.
Sourcepub fn set_identity_mapping(&mut self)
pub fn set_identity_mapping(&mut self)
Uses point ids directly as attribute value ids.
Sourcepub fn set_explicit_mapping(&mut self, num_points: usize)
pub fn set_explicit_mapping(&mut self, num_points: usize)
Allocates an explicit point-to-attribute-value map.
Sourcepub fn explicit_mapping(&self) -> Option<&[AttributeValueIndex]>
pub fn explicit_mapping(&self) -> Option<&[AttributeValueIndex]>
The explicit point-to-attribute-value map, if one is set.
None under identity mapping. The bulk counterpart of calling
mapped_index per point, for callers that copy
the map somewhere whole.
Sourcepub fn set_explicit_mapping_from(&mut self, entries: &[AttributeValueIndex])
pub fn set_explicit_mapping_from(&mut self, entries: &[AttributeValueIndex])
Replaces the whole point-to-attribute-value map in one copy.
The bulk form of set_explicit_mapping
followed by one try_set_point_map_entry
per point: a caller that has already assembled the full map hands it
over as a slice copy instead of a fallible call per entry.
Sourcepub fn set_point_map_entry(
&mut self,
point_index: PointIndex,
entry_index: AttributeValueIndex,
)
pub fn set_point_map_entry( &mut self, point_index: PointIndex, entry_index: AttributeValueIndex, )
Sets one point-to-attribute-value map entry.
Sourcepub fn try_set_point_map_entry(
&mut self,
point_index: PointIndex,
entry_index: AttributeValueIndex,
) -> Result<(), DracoError>
pub fn try_set_point_map_entry( &mut self, point_index: PointIndex, entry_index: AttributeValueIndex, ) -> Result<(), DracoError>
Fallibly sets one point-to-attribute-value map entry.
Sourcepub fn set_attribute_transform_data(&mut self, data: AttributeTransformData)
pub fn set_attribute_transform_data(&mut self, data: AttributeTransformData)
Stores transform metadata associated with this attribute.
Sourcepub fn attribute_transform_data(&self) -> Option<&AttributeTransformData>
pub fn attribute_transform_data(&self) -> Option<&AttributeTransformData>
Returns transform metadata associated with this attribute, if present.
Sourcepub fn normalized(&self) -> bool
pub fn normalized(&self) -> bool
Returns whether integer data should be interpreted as normalized.
Sourcepub fn num_components(&self) -> u8
pub fn num_components(&self) -> u8
Returns the number of scalar components per value.
Sourcepub fn byte_stride(&self) -> i64
pub fn byte_stride(&self) -> i64
Returns the byte stride between consecutive values.