geop_ops_sheetmetal/lib.rs
1//! Sheet metal: bodies of one thickness, flat faces joined by bends —
2//! brackets and enclosures — and the flat blanks they are cut from.
3//!
4//! - [`BaseFlange`] starts a body from a sketch: a plate from its area, or
5//! a bent strip from a chain of lines and arcs, with the body's
6//! [`SheetMetalRules`] (thickness, bend radius, K-factor, reliefs).
7//! - [`EdgeFlange`] bends a flange up from a straight edge of the body,
8//! cutting reliefs beside it and keeping a gap at corners; [`Hem`] folds
9//! an edge right back on itself.
10//! - [`SheetCut`] cuts holes and notches through the body, across its bends
11//! unrolled.
12//! - [`FlatPattern`] unfolds the body: each bend laid flat as long as its
13//! developed length, with its bend lines; [`FlatPatternDxf`] writes it
14//! for laser cutting.
15//!
16//! Each operation records the body's [`Sheet`] for the solid it builds, in
17//! the part's target [`sheets`]: which faces are flat and which are bends,
18//! and how they join, so that the next flange and the flat pattern work
19//! from what the body is made of rather than guessing it from its
20//! geometry. The solid itself is built from the sheet in one go (see
21//! [`thicken`]).
22
23pub mod base_flange;
24pub mod body;
25pub mod cut;
26pub mod cutting;
27pub mod edge_flange;
28pub mod flat_pattern;
29mod fold;
30pub mod hem;
31pub mod layout;
32pub mod sheet;
33pub mod thicken;
34
35#[cfg(any(test, feature = "examples"))]
36pub mod examples;
37mod icons;
38
39#[cfg(test)]
40mod editor_tests;
41#[cfg(test)]
42mod program_tests;
43#[cfg(test)]
44mod regression_tests;
45
46pub use base_flange::{BaseFlange, BaseFlangeArgs};
47pub use body::{SheetBody, Sheets, sheet_body, sheets};
48pub use cut::{FlatFaceRef, SheetCut, SheetCutArgs};
49pub use cutting::{FlatPatternDxf, FlatPatternOptions, cutting_sheet};
50pub use edge_flange::{
51 Corner, EdgeFlange, EdgeFlangeArgs, EdgeRef, FlangePosition, LengthReference, edge,
52};
53pub use flat_pattern::{BendLine, FlatPattern, FlatPatternArgs, FlatPatternData, SolidRef};
54pub use hem::{Hem, HemArgs, HemKind};
55pub use sheet::{Relief, Sheet, SheetMetalRules};
56
57use geop_core_editor::registry::Registry;
58use geop_core_math::geop_error::GeopResult;
59
60/// Adds what this crate offers an editor to `r`: sheet metal: flanges,
61/// hems, cuts, the flat pattern and its DXF, and the examples of them.
62pub fn register(r: Registry) -> GeopResult<Registry> {
63 let r = r
64 .operation(BaseFlange)?
65 .operation(EdgeFlange)?
66 .operation(Hem)?
67 .operation(SheetCut)?
68 .operation(FlatPattern)?
69 .exporter(FlatPatternDxf)?;
70 #[cfg(any(test, feature = "examples"))]
71 let r = r.examples(examples::set())?;
72 Ok(r)
73}