1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! # stepq
//!
//! Query, inspect, split and reshape STEP (ISO 10303-21) files.
//!
//! `stepq` works on the *entity graph* of a Part 21 file. It reads the
//! geometry a file states — placements, axes, radii, unit factors — but
//! never evaluates it: there is no tessellation, no volume, no healing.
//! Everything it does — splitting assemblies, extracting a bill of
//! materials, validating structure — is a graph operation over the
//! original entity instances, which are preserved byte-for-byte.
//!
//! The crate is a library first. The `stepq` command-line tool is built
//! from the same code behind the `cli` feature (enabled by default).
//! Library users can depend on it with `default-features = false`.
//!
//! ## Pipeline
//!
//! Every command is built from the same four steps: [`p21::parse`] the
//! bytes into an [`Exchange`](p21::Exchange), index its references with a
//! [`model::Graph`], ask questions through the record and parameter
//! views, and write a selection back out with a [`p21::Writer`].
//!
//! ```
//! use stepq::model::Graph;
//! use stepq::p21::{Numbering, Writer, parse};
//!
//! let src = b"ISO-10303-21;HEADER;FILE_SCHEMA(('AP242'));ENDSEC;DATA;
//! #1=PRODUCT('p1','bracket','',(#2));
//! #2=PRODUCT_CONTEXT('',#3,'mechanical');
//! #3=APPLICATION_CONTEXT('design');
//! #4=PRODUCT_DEFINITION_FORMATION('','',#1);
//! ENDSEC;END-ISO-10303-21;";
//!
//! let graph = Graph::new(parse(src)?)?;
//! let exchange = graph.exchange();
//!
//! // Find instances by type and read their attributes.
//! let product = exchange.instances_of("PRODUCT").next().unwrap();
//! let record = exchange.records(graph.instance(product)).next().unwrap();
//! let name = record.param(1).and_then(|p| p.literal()).unwrap().decode()?;
//! assert_eq!(name, "bracket");
//!
//! // Follow references backwards: the formation points at the product.
//! let users: Vec<u64> = graph
//! .referenced_by(product)
//! .iter()
//! .map(|&node| graph.instance(node).id)
//! .collect();
//! assert_eq!(users, [4]);
//!
//! // Write the product and what it refers to, renumbered from #1.
//! let mut out = Vec::new();
//! Writer::new(exchange)
//! .numbering(Numbering::Dense)
//! .write_selection([0, 1, 2], &mut out)?;
//! # Ok::<(), stepq::Error>(())
//! ```
//!
//! ## Commands and modules
//!
//! Each `stepq` command is a thin front end over a library function:
//!
//! | Command | Library |
//! |---|---|
//! | `info` | [`info::Info::new`] |
//! | `tree`, `bom` | [`model::ProductStructure`] |
//! | `split` | [`model::extract`], [`model::extract_excluding`], [`model::orphans`] |
//! | `assemble` | [`assemble::assemble`] |
//! | `lint` | [`lint::lint`], with schemas from [`express::Schema::parse`] |
//! | `refs` | [`model::Graph::references`], [`model::Graph::referenced_by`] |
//! | `query` | [`p21::Exchange::instances_of`] |
//! | `props` | [`props::properties`] |
//! | `diff` | [`diff::diff`] |
//! | `strip` | [`strip::strip`], applied by [`p21::Writer::replacements`] |
//! | `pmi` | [`pmi::pmi`]; with `--geometry`, [`pmi::AspectItems`] |
//! | none; `examples/units.rs` | [`units::ContextUnits`], [`units::unit`]: unit factors per representation context |
//! | none; `examples/geometry.rs` | [`geometry::Reader`]: points, directions, placements, elementary surfaces, lines, circles and surface curves, in mm and rad; [`geometry::Rigid`] |
//! | none; `examples/occurrences.rs` | [`model::Placements`]: each assembly usage's transform and every occurrence under a root, in mm |
//! | none; `examples/topology.rs` | [`topology::Solid`]: the shells, faces, loops, edges and vertices of a solid, as stated |
//! | none; `examples/shapes.rs` | [`model::ProductStructure::shape`]: a definition's own solids and other items, and every link not followed |
//!
//! `docs/COMMANDS.md` in the repository documents every command and option.
//!
//! ## Features
//!
//! - `cli` (default): the `stepq` binary. Implies `serde`.
//! - `serde`: `serde::Serialize` for the result types, such as
//! [`info::Info`], [`lint::Report`] and [`diff::Diff`].
//!
//! ## Status
//!
//! Pre-1.0. The public API will change. See `ROADMAP.md` in the
//! repository for what is planned and `docs/ARCHITECTURE.md` for the
//! design decisions this crate is built on.
pub use ;