#parser #steel #visualization #file-format #graphics #tekla

dstv

DSTV is a Rust library for parsing DSTV files and visualizing the parsed data

7 releases (breaking)

0.7.0 Nov 1, 2024
0.6.0 Oct 29, 2024
0.5.0 Nov 9, 2023
0.4.0 Oct 13, 2023
0.1.0 Jun 2, 2023

#525 in Parser implementations

Download history 3/week @ 2024-09-22 215/week @ 2024-10-27 50/week @ 2024-11-03 3/week @ 2024-11-10

268 downloads per month

MIT license

8MB
6.5K SLoC

GNU Style Assembly 2.5K SLoC // 0.1% comments C++ 2K SLoC // 0.2% comments C 1K SLoC // 0.2% comments Rust 826 SLoC // 0.0% comments Python 42 SLoC // 0.8% comments

DSTV: A Rust Crate for Parsing DSTV Files and Visualizing as SVG

Overview

Welcome to the DSTV crate repository! This Rust crate is designed to parse DSTV (NC/NC1) files and visualize them as SVG (Scalable Vector Graphics). DSTV is a format extensively used in the steel industry for exchanging data about steel parts.

Features

  • Robust DSTV Parsing: The DSTV crate can parse DSTV files quickly and accurately, tackling complex or large files with ease.
  • SVG Visualization: The parsed DSTV data can be converted into SVG for convenient and scalable visualization.
  • High Performance: Written in Rust, this crate is optimized for high performance and low resource usage.

Installation

To install DSTV, add it to your Cargo.toml file:

[dependencies]
DSTV = "0.1.0"

Then run cargo build to download and compile the DSTV crate along with your project.

Usage

Here's a basic example of how to use DSTV to parse a DSTV file and generate an SVG:

use dstv::prelude::*;
let dstv = Dstv::from_file("./tests/data/0008-SE0009.nc1");
assert_eq!(dstv.is_ok(), true);
// Declare the dstv as mutable, as `to_svg` will reorder the elements for the
// best representation
let mut dstv = dstv.unwrap();
assert_eq!(dstv.header.order_identification, "PROJECT-1");
let svg = dstv.to_svg();

To work with specific element types in a DSTV file, use the DstvElementType enum to match each element and perform type-specific actions. Once you load the DSTV file with Dstv::from_file, iterate over dstv.elements and use a match expression to handle each variant, like OuterBorder, InnerBorder, or Hole, accessing their unique fields and properties.

Here’s an example:

let dstv = Dstv::from_file("./tests/data/P1565.nc").unwrap();
for element in dstv.elements {
    match element {
        DstvElementType::OuterBorder(e) => 
        {
            assert!(e.contour.len() > 0);
        },
            DstvElementType::InnerBorder(e) => 
            {
                assert!(e.contour.len() > 0);
            },
            DstvElementType::Cut(e) => 
            {
                assert!(e.nor_vec_x > 0.0);
            },
            DstvElementType::Bend(e) => 
            {
                assert!(e.angle > 0.0);
            },
            DstvElementType::Slot(e) => 
            {
                assert!(e.angle > 0.0);
            },
            DstvElementType::Hole(e) => 
            {
                assert!(e.diameter > 0.0);
            },
            DstvElementType::Numeration(e) => 
            {
                assert_ne!(e.text, "");
            },
    }
}

Examples

Single faced plates:

image

Multi facing definitions such as rectangular tubes and U profiles

image image

Contribution

Contributions to the DSTV are welcome. If you find a bug or have a feature request, please open an issue. If you want to contribute code, please open a pull request.

License

This project is licensed under the MIT License.

Disclaimer

This library is provided as-is, and while we strive for quality, we cannot guarantee that there will never be any bugs or issues.

Contact

If you have any questions or comments about DSTV, feel free to contact us.

No runtime deps