#file-format #dotbim #bim #aec

dotbim_rust

Open-source Rust library for dotbim file format

2 releases

0.1.1 Aug 18, 2024
0.1.0 Aug 18, 2024

#116 in Data formats

Download history 208/week @ 2024-08-18 9/week @ 2024-08-25

217 downloads per month

MIT license

67KB
1.5K SLoC

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

Dependencies

~1.2–2.2MB
~44K SLoC