truck_stepio/
lib.rs

1//! Reads/writes STEP files from/to truck.
2//!
3//! # Current Status
4//!
5//! It is possible to output data modeled by truck-modeling.
6//! Shapes created by set operations cannot be output yet.
7//! Input will come further down the road.
8
9#![cfg_attr(not(debug_assertions), deny(warnings))]
10#![deny(clippy::all, rust_2018_idioms)]
11#![warn(
12    missing_docs,
13    missing_debug_implementations,
14    trivial_casts,
15    trivial_numeric_casts,
16    unsafe_code,
17    unstable_features,
18    unused_import_braces,
19    unused_qualifications
20)]
21
22/// STEP input module
23/// # Example
24/// ```
25/// use truck_stepio::r#in::{*, alias::*};
26/// use ruststep::tables::EntityTable;
27/// // read file
28/// let step_string = include_str!(concat!(
29///     env!("CARGO_MANIFEST_DIR"),
30///     "/../resources/step/occt-cube.step",
31/// ));
32/// // parse step file
33/// let exchange = ruststep::parser::parse(&step_string).unwrap();
34/// // convert the parsing results to a Rust struct
35/// let table = Table::from_data_section(&exchange.data[0]);
36/// // get `CartesianPoint` registered in #102
37/// let step_point = EntityTable::<CartesianPointHolder>::get_owned(&table, 102).unwrap();
38/// // convert `CartesianPoint` in STEP to `Point3` in cgmath
39/// let cgmath_point = Point3::from(&step_point);
40/// // check parse result
41/// assert_eq!(cgmath_point, Point3::new(0.0, 10.0, 0.0));
42/// ```
43#[cfg(feature = "in")]
44pub mod r#in;
45/// STEP output module
46pub mod out;
47
48#[doc(hidden)]
49#[macro_export]
50macro_rules! impl_from {
51	($(impl From<&$refed: ty> for $converted: ty {
52		$from_func: item
53	})*) => {
54		$(impl From<&$refed> for $converted {
55			$from_func
56		}
57		impl From<$refed> for $converted {
58			fn from(x: $refed) -> Self { Self::from(&x) }
59		})*
60	};
61}
62
63#[doc(hidden)]
64#[macro_export]
65macro_rules! impl_try_from {
66	($(impl TryFrom<&$refed: ty> for $converted: ty {
67		$try_from_func: item
68	})*) => {
69		$(impl TryFrom<&$refed> for $converted {
70            type Error = ExpressParseError;
71			$try_from_func
72		}
73		impl TryFrom<$refed> for $converted {
74            type Error = ExpressParseError;
75            fn try_from(x: $refed) -> Result<Self, ExpressParseError> { Self::try_from(&x) }
76		})*
77	};
78}