geop_ops_step/import/mod.rs
1//! Reading the bodies of a STEP file (AP203, AP214, AP242 — the B-rep
2//! geometry they share) as descriptions the kernel builds.
3//!
4//! - [`structure`] finds the bodies — every `MANIFOLD_SOLID_BREP`,
5//! `BREP_WITH_VOIDS` and `SHELL_BASED_SURFACE_MODEL` of every product —
6//! with their units and, in an assembly, where each part is placed.
7//! - [`geometry`] reads curves and surfaces and builds their NURBS.
8//! - [`body`] reads each body's topology and turns it into a geop body.
9//!
10//! What it cannot read it refuses, naming the entity by type and `#id`
11//! and saying why.
12
13pub mod body;
14pub mod geometry;
15pub mod midpoints;
16pub mod reader;
17pub mod structure;
18
19use geop_core_math::geop_error::GeopResult;
20
21pub use body::{Healing, ImportedBody};
22
23use crate::part21::Exchange;
24
25/// Every body of the STEP file `text`, in the order the file has them.
26pub fn read_step(text: &str) -> GeopResult<Vec<ImportedBody>> {
27 let exchange = Exchange::parse(text)?;
28 read_exchange(&exchange)
29}
30
31/// Every body of the exchange file `exchange`.
32pub fn read_exchange(exchange: &Exchange) -> GeopResult<Vec<ImportedBody>> {
33 let reader = reader::Reader { exchange };
34 let items = reader.bodies()?;
35 items
36 .iter()
37 .map(|item| {
38 body::read_body(reader, item).map_err(|e| {
39 e.with_context(format!("reading the body #{} ({})", item.id, item.label))
40 })
41 })
42 .collect()
43}