pub struct PointCloud { /* private fields */ }Expand description
Point cloud geometry with typed attributes and optional metadata.
Implementations§
Source§impl PointCloud
impl PointCloud
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Drops every attribute, point and the metadata, keeping the allocated capacity of the attribute list and the attributes’ own storage.
What a decode does to the cloud it is given, so that decoding into one
that already holds geometry replaces it rather than adding to it. The
values and the explicit maps of the dropped attributes are kept empty
and handed to the next attributes added, so the caller decoding many
files into one cloud reuses the allocations of the last one; the cloud
therefore holds the memory of the largest geometry it has decoded until
release_spare_storage or drop.
Sourcepub fn release_spare_storage(&mut self)
pub fn release_spare_storage(&mut self)
Frees the storage clear retained from earlier
attributes.
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 deduplicate_attribute_values(&mut self) -> Status
pub fn deduplicate_attribute_values(&mut self) -> Status
Returns the number of logical points. Merges bit-identical values in every attribute.
Port of upstream’s PointCloud::DeduplicateAttributeValues, which its
OBJ and PLY readers and its TriangleSoupMeshBuilder all run before
the encoder sees the geometry. Fails on an attribute whose type
upstream’s own switch does not cover, which is what upstream does too.
Sourcepub fn deduplicate_point_ids(&mut self)
pub fn deduplicate_point_ids(&mut self)
Merges points whose attribute values all coincide, keeping the order in which they first appear.
Port of upstream’s PointCloud::DeduplicatePointIds. Two points are the
same point when every attribute maps them to the same value, which is
why deduplicate_attribute_values
runs first: without it two vertices carrying equal bytes still hold
distinct value indices and nothing merges.
pub fn num_points(&self) -> usize
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.