ReadIterGaussian

Trait ReadIterGaussian 

Source
pub trait ReadIterGaussian: IterGaussian {
    // Required method
    fn read_from(reader: &mut impl BufRead) -> Result<Self>;

    // Provided method
    fn read_from_file(path: impl AsRef<Path>) -> Result<Self> { ... }
}
Expand description

A trait of representing a IterGaussian that can be read from a buffer.

Required Methods§

Source

fn read_from(reader: &mut impl BufRead) -> Result<Self>

Read from a buffer.

Provided Methods§

Source

fn read_from_file(path: impl AsRef<Path>) -> Result<Self>

Read from a file.

Examples found in repository?
examples/read_ply.rs (line 38)
15async fn main() {
16    let model_path = std::env::args()
17        .nth(1)
18        .unwrap_or_else(|| "examples/model.ply".to_string());
19
20    let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor::default());
21
22    let adapter = instance
23        .request_adapter(&wgpu::RequestAdapterOptions::default())
24        .await
25        .expect("adapter");
26
27    let (device, _) = adapter
28        .request_device(&wgpu::DeviceDescriptor {
29            label: Some("Device"),
30            required_limits: adapter.limits(),
31            ..Default::default()
32        })
33        .await
34        .expect("device");
35
36    println!("Reading gaussians from {}", model_path);
37
38    let gaussians = gs::PlyGaussians::read_from_file(&model_path).expect("gaussians");
39
40    let gaussians_buffer = gs::GaussiansBuffer::<GaussianPod>::new(&device, &gaussians);
41
42    println!(
43        "Loaded {} gaussians ({:.3} KB) into GPU buffer.",
44        gaussians_buffer.len(),
45        gaussians_buffer.buffer().size() as f32 / 1024.0,
46    );
47}
More examples
Hide additional examples
examples/read_spz.rs (line 38)
15async fn main() {
16    let model_path = std::env::args()
17        .nth(1)
18        .unwrap_or_else(|| "examples/model.spz".to_string());
19
20    let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor::default());
21
22    let adapter = instance
23        .request_adapter(&wgpu::RequestAdapterOptions::default())
24        .await
25        .expect("adapter");
26
27    let (device, _) = adapter
28        .request_device(&wgpu::DeviceDescriptor {
29            label: Some("Device"),
30            required_limits: adapter.limits(),
31            ..Default::default()
32        })
33        .await
34        .expect("device");
35
36    println!("Reading gaussians from {}", model_path);
37
38    let gaussians = gs::SpzGaussians::read_from_file(&model_path).expect("gaussians");
39
40    println!("Header: {:?}", gaussians.header);
41
42    let gaussians_buffer = gs::GaussiansBuffer::<GaussianPod>::new(&device, &gaussians);
43
44    println!(
45        "Loaded {} gaussians ({:.3} KB) into GPU buffer.",
46        gaussians_buffer.len(),
47        gaussians_buffer.buffer().size() as f32 / 1024.0,
48    );
49}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§