pub struct Attribute<T: NumericPrimitive, S: AttributeShape> { /* private fields */ }Expand description
A typed numeric geometry attribute handle.
T determines the numeric primitive storage and S determines whether the
attribute is fixed-tuple or jagged. The handle retains its node, part,
owner, and name identity. Data operations use cached metadata so they do not
add a hidden HAPI query to hot paths.
Implementations§
Source§impl<T: NumericPrimitive, S: AttributeShape> Attribute<T, S>
impl<T: NumericPrimitive, S: AttributeShape> Attribute<T, S>
Sourcepub fn info(&self) -> &AttributeInfo
pub fn info(&self) -> &AttributeInfo
Returns the currently cached metadata.
Sourcepub fn owner(&self) -> AttributeOwner
pub fn owner(&self) -> AttributeOwner
Returns the element owner of this attribute.
Sourcepub fn storage(&self) -> StorageType
pub fn storage(&self) -> StorageType
Returns the HAPI storage implied by T and S.
Sourcepub fn refresh(&mut self) -> Result<()>
pub fn refresh(&mut self) -> Result<()>
Refreshes cached metadata from HAPI.
Call this after cooking or otherwise changing geometry when the
attribute’s count, tuple size, or array element total may have changed.
The cache is updated only if the attribute still exists and retains the
numeric storage implied by T and S.
Source§impl<T: NumericPrimitive> Attribute<T, Fixed>
impl<T: NumericPrimitive> Attribute<T, Fixed>
Sourcepub fn get(&self) -> Result<Vec<T>>
pub fn get(&self) -> Result<Vec<T>>
Reads the complete fixed-tuple attribute as a flat vector.
The result length is count * tuple_size using cached metadata.
Sourcepub fn read_into(&self, data: &mut Vec<T>) -> Result<()>
pub fn read_into(&self, data: &mut Vec<T>) -> Result<()>
Reads the complete attribute into a reusable vector.
data is resized to count * tuple_size before the HAPI call.
Sourcepub fn get_range(&self, range: Range<usize>) -> Result<Vec<T>>
pub fn get_range(&self, range: Range<usize>) -> Result<Vec<T>>
Reads a range of owned elements as flattened tuples.
Sourcepub fn read_range_into(
&self,
range: Range<usize>,
data: &mut Vec<T>,
) -> Result<()>
pub fn read_range_into( &self, range: Range<usize>, data: &mut Vec<T>, ) -> Result<()>
Reads a range of owned elements into a reusable flattened vector.
Sourcepub fn set(&self, data: &[T]) -> Result<()>
pub fn set(&self, data: &[T]) -> Result<()>
Replaces the complete fixed-tuple attribute.
Returns an error unless data.len() == count * tuple_size.
Sourcepub fn set_range(&self, range: Range<usize>, data: &[T]) -> Result<()>
pub fn set_range(&self, range: Range<usize>, data: &[T]) -> Result<()>
Replaces a range of owned elements from flattened tuples.
Sourcepub fn set_unique(&self, value: &[T]) -> Result<()>
pub fn set_unique(&self, value: &[T]) -> Result<()>
Assigns the same tuple value to every element of the attribute.
value must contain exactly tuple_size numeric values.
Source§impl<T: NumericPrimitive> Attribute<T, Jagged>
impl<T: NumericPrimitive> Attribute<T, Jagged>
Sourcepub fn get(&self) -> Result<JaggedArrayData<T>>
pub fn get(&self) -> Result<JaggedArrayData<T>>
Reads the complete HAPI array attribute.
Sourcepub fn set(&self, values: &JaggedArrayData<T>) -> Result<()>
pub fn set(&self, values: &JaggedArrayData<T>) -> Result<()>
Replaces the complete HAPI array attribute.
The number of sizes must equal the cached attribute count. The
JaggedArrayData constructor additionally guarantees that sizes are
nonnegative and sum to the flattened data length.