Skip to main content

PointAttribute

Struct PointAttribute 

Source
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

Source

pub fn new() -> Self

Creates an empty attribute with an invalid semantic type.

Source

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.

Source

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.

Source

pub fn mapped_index(&self, point_index: PointIndex) -> AttributeValueIndex

Maps a point id to the corresponding attribute value id.

Source

pub fn size(&self) -> usize

Returns the number of unique attribute values.

Source

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.

Source

pub fn resize_unique_entries( &mut self, num_attribute_values: usize, ) -> Result<(), DracoError>

Resizes the unique attribute value storage.

Source

pub fn buffer(&self) -> &DataBuffer

Returns the raw attribute value buffer.

Source

pub fn buffer_mut(&mut self) -> &mut DataBuffer

Returns the mutable raw attribute value buffer.

Source

pub fn attribute_type(&self) -> GeometryAttributeType

Returns the semantic attribute type.

Source

pub fn unique_id(&self) -> u32

Returns the stable Draco unique id.

Source

pub fn set_unique_id(&mut self, id: u32)

Sets the stable Draco unique id.

Source

pub fn set_attribute_type(&mut self, attribute_type: GeometryAttributeType)

Sets the semantic attribute type.

Source

pub fn set_data_type(&mut self, data_type: DataType)

Sets the scalar data type.

Source

pub fn set_num_components(&mut self, num_components: u8)

Sets the number of scalar components per value.

Source

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.

Source

pub fn set_identity_mapping(&mut self)

Uses point ids directly as attribute value ids.

Source

pub fn set_explicit_mapping(&mut self, num_points: usize)

Allocates an explicit point-to-attribute-value map.

Source

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.

Source

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.

Source

pub fn set_point_map_entry( &mut self, point_index: PointIndex, entry_index: AttributeValueIndex, )

Sets one point-to-attribute-value map entry.

Source

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.

Source

pub fn set_attribute_transform_data(&mut self, data: AttributeTransformData)

Stores transform metadata associated with this attribute.

Source

pub fn attribute_transform_data(&self) -> Option<&AttributeTransformData>

Returns transform metadata associated with this attribute, if present.

Source

pub fn data_type(&self) -> DataType

Returns the scalar data type.

Source

pub fn normalized(&self) -> bool

Returns whether integer data should be interpreted as normalized.

Source

pub fn num_components(&self) -> u8

Returns the number of scalar components per value.

Source

pub fn byte_stride(&self) -> i64

Returns the byte stride between consecutive values.

Trait Implementations§

Source§

impl Clone for PointAttribute

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PointAttribute

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PointAttribute

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.