ply-rs-bw

Crates.ioply-rs-bw
lib.rsply-rs-bw
version
sourcesrc
created_at2024-12-07 22:03:44.888379
updated_at2024-12-08 17:50:03.734911
descriptionLibrary for reading/writing ascii and binary PLY files.
homepagehttps://github.com/bourumir-wyngs/ply-rs
repositoryhttps://github.com/bourumir-wyngs/ply-rs
max_upload_size
id1475911
Cargo.toml error:TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Bourumir (bourumir-wyngs)

documentation

https://fluci.github.io/travis_docs/ply-rs/ply_rs/index.html

README

Ply-rs

GitHub crates.io GitHub Workflow Status crates.io crates.io docs.rs Dependency Vulnerabilities

This is a forked version of the ply-rs project that addresses the use of linked-hash-map to resolve CVE-2020-25573. Other small maintenance fixes may also be included.

The crate has been renamed to ply-rs-bw, and minor issues were resolved to ensure compatibility with Rust 2021 edition. Additionally, an example has been added to demonstrate how to read PLY files with diverse field types (e.g., f32 vs f64, u32 vs i32, etc.). Semantic versioning is now adopted for consistent version management.


Ply-rs is a small library built to read and write the PLY file format (also Polygon File Format, Standford Triangle Format). The library supports all three subformats: ascii, big endian, and little endian.

It focuses on two main points:

  • An easy and fast start.
  • High performance if you're willing to do some things yourself.

Getting started

Dependency

Add to your Cargo.toml:

[dependencies]
ply-rs-bw = "1.0.0"

Add to your root:

extern crate ply_rs_bw;

fn main() {}

Read a ply file

This is the easiest way to read a ply file:

extern crate ply_rs_bw;
use ply_rs_bw as ply;

/// Demonstrates simplest use case for reading from a file.
fn main() {
    // set up a reader, in this case a file.
    let path = "example_plys/greg_turk_example1_ok_ascii.ply";
    let mut f = std::fs::File::open(path).unwrap();

    // create a parser
    let p = ply::parser::Parser::<ply::ply::DefaultElement>::new();

    // use the parser: read the entire file
    let ply = p.read_ply(&mut f);

    // make sure it did work
    assert!(ply.is_ok());
    let ply = ply.unwrap();

    // proof that data has been read
    println!("Ply header: {:#?}", ply.header);
    println!("Ply data: {:?}", ply.payload);
}

Write ply file

The simplest case of writing a ply file:

extern crate ply_rs_bw;
use ply_rs_bw::ply::{ Ply, DefaultElement };
use ply_rs_bw::writer::{ Writer };

/// Demonstrates simplest use case for reading from a file.
fn main() {
    // set up a target, could also be a file
    let mut buf = Vec::<u8>::new();

    // crete a ply objet
    let mut ply = Ply::<DefaultElement>::new();

    // set up a writer
    let w = Writer::new();
    let written = w.write_ply(&mut buf, &mut ply).unwrap();
    println!("{} bytes written", written);
    println!("buffer size: {}", buf.len());

    // proof that data has been read

    // We can use `from_utf8` since PLY files only contain ascii characters
    let output = String::from_utf8(buf).unwrap();
    println!("Written data:\n{}", output);
}

For more complicated examples, please see the examples.

This implementation is mainly based on these specifications with additions from here.

Commit count: 105

cargo fmt