Skip to main content

PointCloud

Type Alias PointCloud 

Source
pub type PointCloud = WrappedDracoObject<PointCloud>;

Aliased Type§

pub struct PointCloud(/* private fields */);

Implementations§

Source§

impl PointCloud

Source

pub fn new() -> Self

Source

pub fn get_point<T>( &mut self, attr_id: AttrId, point_index: impl Into<PointIndex>, point_container: &mut [T], )
where T: Default + Copy,

Examples found in repository?
examples/encode_decode.rs (line 26)
23fn print_pc(pc: &mut PointCloud, attr_id: AttrId) {
24    let mut container: [f64; 3] = [0.0; 3];
25    for i in 0..pc.len() {
26        pc.get_point(attr_id, i, &mut container);
27        println!("Point {}: {:?}", i, container);
28    }
29}
Source

pub fn get_point_alloc<T, const N: usize>( &mut self, attr_id: AttrId, point_index: impl Into<PointIndex>, ) -> [T; N]
where T: Default + Copy,

Source

pub fn num_named_attributes(&self, attr_type: GeometryAttribute_Type) -> i32

Source

pub fn get_named_attribute_id( &self, attr_type: GeometryAttribute_Type, i: i32, ) -> Option<AttrId>

Source

pub fn num_points(&self) -> u32

Source

pub fn len(&self) -> u32

Examples found in repository?
examples/encode_decode.rs (line 25)
23fn print_pc(pc: &mut PointCloud, attr_id: AttrId) {
24    let mut container: [f64; 3] = [0.0; 3];
25    for i in 0..pc.len() {
26        pc.get_point(attr_id, i, &mut container);
27        println!("Point {}: {:?}", i, container);
28    }
29}
Source

pub fn is_empty(&self) -> bool

Source

pub fn to_buffer(&self, encoder: &mut Encoder) -> DracoStatusType<EncoderBuffer>

Encode the point cloud to an encoder buffer

Examples found in repository?
examples/encode_decode.rs (line 56)
31fn main() -> io::Result<()> {
32    let points = gen_points();
33
34    ////////// BUINDING //////////
35    let mut builder = PointCloudBuilder::new(points.len() as u32);
36
37    let attr_id = builder.add_attribute(
38        ffi::draco::GeometryAttribute_Type::POSITION,
39        3,
40        ffi::draco::DataType::DT_FLOAT64,
41    );
42
43    for (i, point) in points.iter().enumerate() {
44        builder.add_point(attr_id, i, point);
45    }
46    let mut pc = builder.build(false);
47
48    println!("after building");
49    print_pc(&mut pc, attr_id);
50
51    ////////// ENCODE //////////
52    let mut encoder = Encoder::new()
53        .set_speed_options(5, 5)
54        .set_attribute_quantization(ffi::draco::GeometryAttribute_Type::POSITION, 14);
55
56    if let Ok(mut buffer) = pc.to_buffer(&mut encoder) {
57        ////////// DECODE //////////
58        let mut buf = DecoderBuffer::from_encoder_buffer(&mut buffer);
59        let pc_decoded = PointCloud::from_buffer(&mut Decoder::new(), &mut buf);
60
61        if let Ok(mut pc_decoded) = pc_decoded {
62            println!("after decoding");
63            print_pc(&mut pc_decoded, attr_id);
64        } else {
65            println!("Failed to decode point cloud");
66        }
67    }
68    Ok(())
69}
Source

pub fn from_buffer( decoder: &mut Decoder, buffer: &mut DecoderBuffer, ) -> DracoStatusType<Self>

Decode a point cloud from a decoder buffer

§Safety

The decoder buffer must contains valid memory

Examples found in repository?
examples/encode_decode.rs (line 59)
31fn main() -> io::Result<()> {
32    let points = gen_points();
33
34    ////////// BUINDING //////////
35    let mut builder = PointCloudBuilder::new(points.len() as u32);
36
37    let attr_id = builder.add_attribute(
38        ffi::draco::GeometryAttribute_Type::POSITION,
39        3,
40        ffi::draco::DataType::DT_FLOAT64,
41    );
42
43    for (i, point) in points.iter().enumerate() {
44        builder.add_point(attr_id, i, point);
45    }
46    let mut pc = builder.build(false);
47
48    println!("after building");
49    print_pc(&mut pc, attr_id);
50
51    ////////// ENCODE //////////
52    let mut encoder = Encoder::new()
53        .set_speed_options(5, 5)
54        .set_attribute_quantization(ffi::draco::GeometryAttribute_Type::POSITION, 14);
55
56    if let Ok(mut buffer) = pc.to_buffer(&mut encoder) {
57        ////////// DECODE //////////
58        let mut buf = DecoderBuffer::from_encoder_buffer(&mut buffer);
59        let pc_decoded = PointCloud::from_buffer(&mut Decoder::new(), &mut buf);
60
61        if let Ok(mut pc_decoded) = pc_decoded {
62            println!("after decoding");
63            print_pc(&mut pc_decoded, attr_id);
64        } else {
65            println!("Failed to decode point cloud");
66        }
67    }
68    Ok(())
69}

Trait Implementations§

Source§

impl Default for PointCloud

Source§

fn default() -> Self

Returns the “default value” for a type. Read more