pub struct Attribute { /* private fields */ }Expand description
Represents an attribute in a mesh. An attribute can be an array of values representing potisions
of vertices, or it can be an array of values representing normals of vertices or corners, or faces.
Note that the struct does not have the static type information, so the attribute value can be a
vector of any type of any dimension, as long as it implements the Vector trait. The information about
the type of the attribute, component type, and the number of components is stored in dynamically.
Implementations§
Source§impl Attribute
impl Attribute
pub fn new<Data, const N: usize>(
data: Vec<Data>,
att_type: AttributeType,
domain: AttributeDomain,
parents: Vec<AttributeId>,
) -> Selfwhere
Data: Vector<N>,
pub fn new_empty( id: AttributeId, att_type: AttributeType, domain: AttributeDomain, component_type: ComponentDataType, num_components: usize, ) -> Self
pub fn from<Data, const N: usize>(
id: AttributeId,
data: Vec<Data>,
att_type: AttributeType,
domain: AttributeDomain,
parents: Vec<AttributeId>,
) -> Selfwhere
Data: Vector<N>,
pub fn from_without_removing_duplicates<Data, const N: usize>(
id: AttributeId,
data: Vec<Data>,
att_type: AttributeType,
domain: AttributeDomain,
parents: Vec<AttributeId>,
) -> Selfwhere
Data: Vector<N>,
pub fn get<Data, const N: usize>(&self, p_idx: PointIdx) -> Data
pub fn get_unique_val<Data, const N: usize>( &self, val_idx: AttributeValueIdx, ) -> Data
pub fn get_component_type(&self) -> ComponentDataType
pub fn set_component_type(&mut self, component_type: ComponentDataType)
pub fn set_num_components(&mut self, num_components: usize)
pub fn get_data_as_bytes(&self) -> &[u8] ⓘ
pub fn get_as_bytes(&self, i: usize) -> &[u8] ⓘ
pub fn set_point_to_att_val_map( &mut self, point_to_att_val_map: Option<VecPointIdx<AttributeValueIdx>>, )
pub fn take_point_to_att_val_map(self) -> Option<VecPointIdx<AttributeValueIdx>>
pub fn get_id(&self) -> AttributeId
pub fn get_num_components(&self) -> usize
pub fn get_attribute_type(&self) -> AttributeType
pub fn get_domain(&self) -> AttributeDomain
pub fn get_parents(&self) -> &Vec<AttributeId>
pub fn num_unique_values(&self) -> usize
pub fn get_unique_val_idx(&self, idx: PointIdx) -> AttributeValueIdx
pub fn set_name(&mut self, name: String)
pub fn get_name(&self) -> Option<&String>
Sourcepub fn unique_vals_as_slice<Data>(&self) -> &[Data]
pub fn unique_vals_as_slice<Data>(&self) -> &[Data]
returns the data values as a slice of values casted to the given type.
Sourcepub fn unique_vals_as_slice_mut<Data>(&mut self) -> &mut [Data]
pub fn unique_vals_as_slice_mut<Data>(&mut self) -> &mut [Data]
returns the data values as a mutable slice of values casted to the given type.
Sourcepub unsafe fn unique_vals_as_slice_unchecked<Data>(&self) -> &[Data]
pub unsafe fn unique_vals_as_slice_unchecked<Data>(&self) -> &[Data]
returns the data values as a slice of values casted to the given type.
§Safety:
This function assumes that the buffer’s data is properly aligned and matches the type Data.
Sourcepub unsafe fn unique_vals_as_slice_unchecked_mut<Data>(&mut self) -> &mut [Data]
pub unsafe fn unique_vals_as_slice_unchecked_mut<Data>(&mut self) -> &mut [Data]
returns the data values as a mutable slice of values casted to the given type.
§Safety:
This function assumes that the buffer’s data is properly aligned and matches the type Data.
Sourcepub fn permute(&mut self, indices: &[usize])
pub fn permute(&mut self, indices: &[usize])
permutes the data in the buffer according to the given indices, i.e.
i-th element in the buffer will be moved to indices[i]-th position.
Sourcepub fn permute_unchecked(&mut self, indices: &[usize])
pub fn permute_unchecked(&mut self, indices: &[usize])
permutes the data in the buffer according to the given indices, i.e.
i-th element in the buffer will be moved to indices[i]-th position.
§Safety:
This function assumes that the indices are valid, i.e. they are within the bounds of the buffer.
Sourcepub fn swap(&mut self, i: usize, j: usize)
pub fn swap(&mut self, i: usize, j: usize)
swaps the elements at indices i and j in the buffer.
pub fn take_values<Data, const N: usize>(self) -> Vec<Data>where
Data: Vector<N>,
pub fn into_parts<Data, const N: usize>(
self,
) -> (Vec<Data>, Option<VecPointIdx<AttributeValueIdx>>, Self)where
Data: Vector<N>,
pub fn set_values<Data, const N: usize>(&mut self, data: Vec<Data>)where
Data: Vector<N>,
pub fn remove_duplicate_values<Data, const N: usize>(&mut self)where
Data: Vector<N>,
pub fn remove<Data, const N: usize>(&mut self, p_idx: PointIdx)
pub fn remove_dyn(&mut self, p_idx: PointIdx)
pub fn remove_unique_val<Data, const N: usize>( &mut self, val_idx: AttributeValueIdx, )
pub fn remove_unique_val_dyn(&mut self, val_idx: usize)
Sourcepub fn retain_points_dyn(&mut self, keep_point_indices: &[usize])
pub fn retain_points_dyn(&mut self, keep_point_indices: &[usize])
Retains only points at the given sorted indices. O(n) instead of O(n^2).
keep_point_indices must be sorted in ascending order.