pub struct Mesh { /* private fields */ }Expand description
Triangle mesh geometry decoded from, or prepared for, a Draco bitstream.
A mesh owns triangle topology and dereferences to its underlying
PointCloud, where attributes and metadata are stored.
Implementations§
Source§impl Mesh
impl Mesh
Sourcepub fn set_face(&mut self, face_id: FaceIndex, face: Face)
pub fn set_face(&mut self, face_id: FaceIndex, face: Face)
Sets a face, growing the face list with zeroed faces when needed.
Sourcepub fn set_faces_from_flat_indices(&mut self, indices: &[u32])
pub fn set_faces_from_flat_indices(&mut self, indices: &[u32])
Bulk-set all faces from a flat u32 index array (3 indices per face).
Assumes set_num_faces has already been called with the right count.
Sourcepub fn set_faces_from_u8_indices(&mut self, bytes: &[u8])
pub fn set_faces_from_u8_indices(&mut self, bytes: &[u8])
Bulk-set all faces from tightly packed u8 indices.
Assumes set_num_faces has already been called with the right count.
Sourcepub fn set_faces_from_le_u16_indices(&mut self, bytes: &[u8])
pub fn set_faces_from_le_u16_indices(&mut self, bytes: &[u8])
Bulk-set all faces from tightly packed little-endian u16 indices.
Assumes set_num_faces has already been called with the right count.
Sourcepub fn set_faces_from_le_u32_indices(&mut self, bytes: &[u8])
pub fn set_faces_from_le_u32_indices(&mut self, bytes: &[u8])
Bulk-set all faces from tightly packed little-endian u32 indices.
Assumes set_num_faces has already been called with the right count.
Sourcepub fn set_face_from_indices(&mut self, face_id: usize, indices: [u32; 3])
pub fn set_face_from_indices(&mut self, face_id: usize, indices: [u32; 3])
Sets one face from raw u32 point ids.
Sourcepub fn set_num_faces(&mut self, num_faces: usize)
pub fn set_num_faces(&mut self, num_faces: usize)
Resizes the face list, filling new faces with point index zero.
Sourcepub fn try_set_num_faces(&mut self, num_faces: usize) -> Status
pub fn try_set_num_faces(&mut self, num_faces: usize) -> Status
Fallibly resizes the face list.
Sourcepub fn deduplicate_point_ids(&mut self)
pub fn deduplicate_point_ids(&mut self)
Deduplicate point IDs to match C++ Draco behavior.
This function remaps point indices such that:
- Points are assigned new IDs in the order they’re first encountered in faces
- Face indices are updated to use the new point IDs
- Attribute point mappings are updated accordingly
This is needed for binary compatibility with C++ Draco, which internally creates separate points for each face corner during OBJ loading and then deduplicates them in face-traversal order.
Methods from Deref<Target = PointCloud>§
Sourcepub fn set_num_points(&mut self, num_points: usize)
pub fn set_num_points(&mut self, num_points: usize)
Sets the number of logical points.
Sourcepub fn add_attribute(&mut self, attribute: PointAttribute) -> i32
pub fn add_attribute(&mut self, attribute: PointAttribute) -> i32
Adds an attribute and assigns it a unique id matching its attribute id.
Sourcepub fn add_attribute_preserve_unique_id(
&mut self,
attribute: PointAttribute,
) -> i32
pub fn add_attribute_preserve_unique_id( &mut self, attribute: PointAttribute, ) -> i32
Adds an attribute while preserving its existing unique id.
Sourcepub fn set_attribute(&mut self, att_id: i32, attribute: PointAttribute)
pub fn set_attribute(&mut self, att_id: i32, attribute: PointAttribute)
Places an attribute at att_id, growing the attribute list if needed.
Mirrors C++ PointCloud::SetAttribute: the attribute’s unique id is set
to att_id. Any vacancies created when growing the list are filled with
empty attributes.
Sourcepub fn num_attributes(&self) -> i32
pub fn num_attributes(&self) -> i32
Returns the number of attributes.
Sourcepub fn attribute_id_by_unique_id(&self, unique_id: u32) -> i32
pub fn attribute_id_by_unique_id(&self, unique_id: u32) -> i32
Returns the attribute id for the given Draco unique id, or -1.
Mirrors C++ PointCloud::GetAttributeIdByUniqueId.
Sourcepub fn attribute_by_unique_id(&self, unique_id: u32) -> Option<&PointAttribute>
pub fn attribute_by_unique_id(&self, unique_id: u32) -> Option<&PointAttribute>
Returns the attribute with the given Draco unique id.
Mirrors C++ PointCloud::GetAttributeByUniqueId.
Sourcepub fn attribute(&self, att_id: i32) -> &PointAttribute
pub fn attribute(&self, att_id: i32) -> &PointAttribute
Returns an attribute by attribute id.
Sourcepub fn try_attribute(&self, att_id: i32) -> Result<&PointAttribute, DracoError>
pub fn try_attribute(&self, att_id: i32) -> Result<&PointAttribute, DracoError>
Fallibly returns an attribute by attribute id.
Sourcepub fn attribute_mut(&mut self, att_id: i32) -> &mut PointAttribute
pub fn attribute_mut(&mut self, att_id: i32) -> &mut PointAttribute
Returns a mutable attribute by attribute id.
Sourcepub fn try_attribute_mut(
&mut self,
att_id: i32,
) -> Result<&mut PointAttribute, DracoError>
pub fn try_attribute_mut( &mut self, att_id: i32, ) -> Result<&mut PointAttribute, DracoError>
Fallibly returns a mutable attribute by attribute id.
Sourcepub fn named_attribute_id(&self, att_type: GeometryAttributeType) -> i32
pub fn named_attribute_id(&self, att_type: GeometryAttributeType) -> i32
Returns the first attribute id with the requested semantic type, or -1.
Sourcepub fn named_attribute(
&self,
att_type: GeometryAttributeType,
) -> Option<&PointAttribute>
pub fn named_attribute( &self, att_type: GeometryAttributeType, ) -> Option<&PointAttribute>
Returns the first attribute with the requested semantic type.
Sourcepub fn num_points(&self) -> usize
pub fn num_points(&self) -> usize
Returns the number of logical points.
Sourcepub fn metadata(&self) -> Option<&GeometryMetadata>
pub fn metadata(&self) -> Option<&GeometryMetadata>
Returns geometry metadata, if present.
Sourcepub fn metadata_mut(&mut self) -> Option<&mut GeometryMetadata>
pub fn metadata_mut(&mut self) -> Option<&mut GeometryMetadata>
Returns mutable geometry metadata, if present.
Sourcepub fn metadata_or_insert(&mut self) -> &mut GeometryMetadata
pub fn metadata_or_insert(&mut self) -> &mut GeometryMetadata
Returns geometry metadata, inserting an empty block when absent.
Sourcepub fn set_metadata(&mut self, metadata: Option<GeometryMetadata>)
pub fn set_metadata(&mut self, metadata: Option<GeometryMetadata>)
Replaces geometry metadata.
Sourcepub fn attribute_metadata_by_unique_id(
&self,
attribute_unique_id: u32,
) -> Option<&AttributeMetadata>
pub fn attribute_metadata_by_unique_id( &self, attribute_unique_id: u32, ) -> Option<&AttributeMetadata>
Finds per-attribute metadata by Draco attribute unique id.
Sourcepub fn attribute_metadata_by_string_entry(
&self,
entry_name: &str,
entry_value: &str,
) -> Option<&AttributeMetadata>
pub fn attribute_metadata_by_string_entry( &self, entry_name: &str, entry_value: &str, ) -> Option<&AttributeMetadata>
Finds per-attribute metadata by a string metadata entry.
Sourcepub fn set_attribute_metadata(
&mut self,
att_id: i32,
metadata: Metadata,
) -> Result<(), DracoError>
pub fn set_attribute_metadata( &mut self, att_id: i32, metadata: Metadata, ) -> Result<(), DracoError>
Sets metadata for an attribute id.