dotbim_rust

Crates.iodotbim_rust
lib.rsdotbim_rust
version0.1.1
sourcesrc
created_at2024-08-18 22:11:47.232566
updated_at2024-08-18 22:46:47.43998
descriptionOpen-source Rust library for dotbim file format.
homepagehttps://dotbim.net/
repositoryhttps://github.com/paireks/dotbim_rust
max_upload_size
id1343070
size68,052
(paireks2)

documentation

README

dotbim_rust Crates.io Version

Description

Open-source Rust library for dotbim file format.

Read more about dotbim here: https://github.com/paireks/dotbim

dotbim's website: https://dotbim.net/

Here you can find small manual for developers regarding development of tools that will work with .bim file format: https://github.com/paireks/dotbim/blob/master/DeveloperTips.md

Installation

https://crates.io/crates/dotbim_rust

Run the following command:

cargo add dotbim_rust

Examples

Generally you can check the unit-tests to see multiple examples. However below is one of them:

Pyramid example

let mesh = Mesh::new(
    0,
    vec![
        // Base
        0.0,0.0,0.0,
        10.0,0.0,0.0,
        10.0,10.0,0.0,
        0.0,10.0,0.0,

        // Top
        5.0,5.0,4.0
    ],
    vec![
        // Base faces
        0,1,2,
        0,2,3,

        // Side faces
        0,1,4,
        1,2,4,
        2,3,4,
        3,0,4
    ]
);

let mut info: HashMap<String, String> = HashMap::new();
info.insert(String::from("Name"), String::from("Pyramid"));

let mut file_info: HashMap<String, String> = HashMap::new();
file_info.insert(String::from("Author"), String::from("John Doe"));
file_info.insert(String::from("Date"), String::from("28.09.1999"));

let element = Element::new(
    0,
    Vector::new(0.,0.,0.),
    Rotation::new(0., 0., 0., 1.),
    String::from("76e051c1-1bd7-44fc-8e2e-db2b64055068"),
    String::from("Structure"),
    Color::new(255,255,0,255),
    None,
    info,
);

let file: File = File::new(String::from("1.0.0"),
                     vec![mesh],
                     vec![element],
                     file_info);

let file_serialized = to_string(&file);

let file_serialized_string = file_serialized.ok().unwrap();

let path = "created_files/Pyramid.bim";

fs::write(path, file_serialized_string).expect("Unable to write the file");

Then you can check if file saved looks correct in one of the existing viewers or thanks to connectors.

It should be like that:

image

Libraries used

Commit count: 0

cargo fmt