pub struct PointCloudEncoder { /* private fields */ }Available on crate feature
encoder only.Expand description
Encoder for Draco point cloud bitstreams.
A PointCloudEncoder takes a PointCloud plus EncoderOptions and
writes a .drc bitstream into an EncoderBuffer. Depending on the options it uses
either KD-tree or sequential attribute encoding, matching C++ Draco’s
PointCloudEncoder selection.
§Examples
use draco_core::{
DataType, DecoderBuffer, EncoderBuffer, EncoderOptions, GeometryAttributeType,
PointAttribute, PointCloud, PointCloudDecoder, PointCloudEncoder,
};
// Three points with float32 positions.
let mut pc = PointCloud::new();
let mut position = PointAttribute::new();
position.init(GeometryAttributeType::Position, 3, DataType::Float32, false, 3);
let coords: [f32; 9] = [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0];
for (i, value) in coords.iter().enumerate() {
position.buffer_mut().write(i * 4, &value.to_le_bytes());
}
pc.add_attribute(position);
// Encode, then decode it back.
let mut encoder = PointCloudEncoder::new();
encoder.set_point_cloud(pc);
let mut buffer = EncoderBuffer::new();
encoder.encode(&EncoderOptions::new(), &mut buffer)?;
let mut decoded = PointCloud::new();
PointCloudDecoder::new().decode(&mut DecoderBuffer::new(buffer.data()), &mut decoded)?;
assert_eq!(decoded.num_points(), 3);Implementations§
Source§impl PointCloudEncoder
impl PointCloudEncoder
Sourcepub fn point_cloud(&self) -> Option<&PointCloud>
pub fn point_cloud(&self) -> Option<&PointCloud>
Returns the point cloud assigned to this encoder, if any.
Sourcepub fn set_point_cloud(&mut self, pc: PointCloud)
pub fn set_point_cloud(&mut self, pc: PointCloud)
Assigns the point cloud to encode.
Sourcepub fn encode(
&mut self,
options: &EncoderOptions,
out_buffer: &mut EncoderBuffer,
) -> Status
pub fn encode( &mut self, options: &EncoderOptions, out_buffer: &mut EncoderBuffer, ) -> Status
Encodes the assigned point cloud into an output buffer.
A point cloud must have been provided with
set_point_cloud first.
§Errors
Returns an error if no point cloud was set, the options are unsupported, or attribute encoding fails.
Sourcepub fn get_geometry_type(&self) -> EncodedGeometryType
pub fn get_geometry_type(&self) -> EncodedGeometryType
Returns the geometry type produced by this encoder.
Trait Implementations§
Source§impl Default for PointCloudEncoder
impl Default for PointCloudEncoder
Source§impl GeometryEncoder for PointCloudEncoder
impl GeometryEncoder for PointCloudEncoder
Source§fn point_cloud(&self) -> Option<&PointCloud>
fn point_cloud(&self) -> Option<&PointCloud>
Returns point-cloud geometry when available.
Source§fn corner_table(&self) -> Option<&CornerTable>
fn corner_table(&self) -> Option<&CornerTable>
Returns mesh corner-table topology when available.
Source§fn options(&self) -> &EncoderOptions
fn options(&self) -> &EncoderOptions
Returns the active encoder options.
Source§fn get_geometry_type(&self) -> EncodedGeometryType
fn get_geometry_type(&self) -> EncodedGeometryType
Returns the encoded geometry type.
Source§fn get_encoding_method(&self) -> Option<i32>
fn get_encoding_method(&self) -> Option<i32>
Returns the forced encoding method, if one is active.
Source§fn get_data_to_corner_map(&self) -> Option<&[u32]>
fn get_data_to_corner_map(&self) -> Option<&[u32]>
Returns a data-to-corner map for mesh attribute prediction, if present.
Source§fn get_vertex_to_data_map(&self) -> Option<&[i32]>
fn get_vertex_to_data_map(&self) -> Option<&[i32]>
Returns a vertex-to-data map for mesh attribute prediction, if present.
Auto Trait Implementations§
impl Freeze for PointCloudEncoder
impl RefUnwindSafe for PointCloudEncoder
impl Send for PointCloudEncoder
impl Sync for PointCloudEncoder
impl Unpin for PointCloudEncoder
impl UnsafeUnpin for PointCloudEncoder
impl UnwindSafe for PointCloudEncoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more