Skip to main content

geop_ops_model/
lib.rs

1//! The vocabulary every operation shares: every target a step of one
2//! operation reads of another, the references into it, and how it is
3//! drawn. An operation crate depends on `core/`, `lib/` and this crate
4//! alone, so what one operation reads of another lives here, and the
5//! operation that produces it keeps only its arguments, form and editor.
6//!
7//! A part's topology: the one [`NamedModel`] its steps build, revised by
8//! each in turn ([`model`]) — every vertex, edge, face and solid with a
9//! stable name ([`Namer`]), and the features the steps made — and the
10//! kinds of element a step refers to in it ([`elements`]): vertices,
11//! edges, faces, solids, each picked as a dialog asks for it — and what
12//! they are used as ([`geometry`]): points, lines, planes, circles,
13//! curves, bodies. A step that builds into the model is a
14//! [`ModelOperation`]; one that builds a tool says how it meets the solid
15//! it is for with a [`Combine`], and how far it goes with an [`Extent`].
16//!
17//! The other targets of a part: its sketches ([`sketch`]) and 3-D sketches
18//! ([`sketch3d`]), its datums ([`datums`]), its parameters and properties
19//! ([`parameters`]), the parts placed in it with their solids and bill of
20//! materials ([`placed`]); and what every operation picks and lays out
21//! alike: any element of the part ([`selection`]), an element of a placed
22//! part with its frame ([`mate_entity`]), instances in a row ([`spacing`]).
23//!
24//! # Topological naming
25//!
26//! A name says *how an entity came to be*, never *when*: it is built only
27//! from inputs that stay the same when a part is rebuilt after an edit
28//! upstream — operation ids, sketch element ids, the names of the entities
29//! an operation consumed, and positions counted along those. Never from an
30//! internal id or the order in which an algorithm happened to create
31//! things. So a program that refers to `extrude(box,end)` keeps meaning the
32//! same face when the box gets taller, and names are stable text that diffs
33//! well.
34//!
35//! Every name has the form `kind(operation,arg,...)` (see [`Namer`]):
36//! `kind` is the operation that created the entity, `operation` the id of
37//! the program step that ran it, and the arguments identify the entity
38//! within that step. Operation ids are restricted to
39//! [`validate_operation_id`](geop_core_program::program::validate_operation_id)'s
40//! alphabet, so the arguments of a name — which
41//! may themselves be names — can always be told apart.
42
43// Library code reports what goes wrong as an error, never by panicking;
44// tests may unwrap.
45#![cfg_attr(
46    not(test),
47    deny(
48        clippy::unwrap_used,
49        clippy::expect_used,
50        clippy::panic,
51        clippy::todo,
52        clippy::unimplemented,
53        clippy::unreachable
54    )
55)]
56
57mod build;
58mod combine;
59pub mod curves;
60pub mod datums;
61mod describe;
62mod draw;
63mod edit;
64pub mod elements;
65mod extent;
66mod feature;
67pub mod geometry;
68mod ids;
69mod kept;
70pub mod mate_entity;
71mod mesh;
72mod named_model;
73mod names;
74pub mod notes;
75pub mod parameters;
76pub mod placed;
77pub mod records;
78mod resolve;
79pub mod selection;
80pub mod sketch;
81pub mod sketch3d;
82pub mod spacing;
83pub mod tangent;
84#[cfg(any(test, feature = "testing"))]
85pub mod testing;
86pub mod threads;
87
88pub use build::{ModelOperation, build_model};
89pub use combine::{Combine, SolidRef, Tool, solid};
90pub use curves::{Chain, ChainCurve, Profile};
91pub use describe::{EdgeDescription, FaceDescription, PartDescription};
92pub use draw::ModelDrawer;
93pub use edit::BodyNames;
94pub use elements::{ChainElement, Edge, EdgeChain, Face, ModelElement, Solid, Vertex, read_model};
95pub use extent::{End, Extent, face_hull, hull, reach_past, spread_along};
96pub use feature::{
97    BooleanOp, Feature, FeatureElement, FeatureFaces, FeatureRef, FeatureTool, ToolReach, feature,
98};
99pub use geometry::{
100    Body, Circle, Curve, Line, Path, PathRef, Plane, Point, Round, frame_along, resolve_bodies,
101};
102pub use ids::RefId;
103pub use mesh::{STL_QUALITY, SolidMeshes, stl_bytes};
104pub use named_model::{NamedModel, element, model};
105pub use names::{LONGEST_ARGUMENT, NameRegistry, Namer, digest, operation_of, origin_of};
106pub use notes::{CutWire, SolidNote, SolidNotes, notes_of, solid_notes};
107pub use records::Records;
108pub use threads::{CosmeticThread, Threads, draw_threads, read_threads, threads};
109
110use geop_core_editor::registry::Registry;
111use geop_core_math::geop_error::GeopResult;
112
113/// Adds what the model offers an editor to `r`: the part's model drawn, and
114/// its solids and faces listed ([`ModelDrawer`]); its datums drawn and
115/// listed ([`datums::DatumsDrawer`]); its sketches drawn and listed
116/// ([`sketch::SketchDrawer`]); the steps defining its parameters,
117/// tables and properties, and the part drawn in its colour (see
118/// [`parameters`]), and the panel switching its configurations
119/// ([`parameters::ConfigurationsPanel`]).
120pub fn register(r: Registry) -> GeopResult<Registry> {
121    r.drawer(ModelDrawer::default())?
122        .drawer(datums::DatumsDrawer)?
123        .drawer(sketch::SketchDrawer)?
124        .operation(parameters::DefineParameters)?
125        .operation(parameters::LookupTable)?
126        .operation(parameters::PartProperties)?
127        .drawer(parameters::PartColor)?
128        .panel(parameters::ConfigurationsPanel)
129}