Skip to main content

geop_ops_assembly/
lib.rs

1//! Assemblies: parts placed in a part ([`placed`]) — another program
2//! file's part, loaded through the runner and placed by [`AddPart`] at a
3//! pose its program's state holds — and mated to what is already there
4//! ([`mates`]). Where every placed part is, is the program's state, which
5//! the editor settles after every edit ([`Settler`], solving the mates:
6//! [`mechanism`], [`solving`]); the step placing a part drags it as far as
7//! its mates let it (see [`editor`]), and so does the drag tool
8//! ([`DragTool`]) with no step edited — in hand by default, so a press and
9//! a move on a placed part drag it. The joints panel ([`JointsPanel`])
10//! sets a joint's coordinates, and says how free the placed parts are and
11//! which constraints conflict. [`PartPattern`] places copies of a placed
12//! part in a row or round an axis. [`Explode`] moves placed parts off
13//! where they are assembled, one move of an exploded view per step, and
14//! [`Drive`] drives joints by a time table, played and checked for
15//! collisions in the motion panel ([`MotionPanel`]) and written frame by
16//! frame ([`MotionExport`]).
17//! A part derived from another brings its bodies in ([`DerivedPart`]),
18//! mirrored or not ([`MirrorPart`]); a mirrored component is placed so
19//! ([`AddPartArgs::mirror`]).
20//!
21//! Also what is exported of an assembly: an STL file of a part with the
22//! parts placed in it ([`Stl`]), and its mechanism as a robot description
23//! ([`urdf`]); and how the placed parts are drawn and listed
24//! ([`AssemblyDrawer`]). What a placed part is to what reads it is
25//! [`geop_ops_model::placed`]'s.
26
27mod add_part;
28mod add_part_derived;
29mod drag_tool;
30mod draw;
31#[cfg(test)]
32mod draw_tests;
33pub mod editor;
34#[cfg(test)]
35mod editor_tests;
36#[cfg(any(test, feature = "examples"))]
37pub mod examples;
38mod explode;
39#[cfg(test)]
40mod frame_tests;
41mod icons;
42#[cfg(test)]
43mod joint_tests;
44pub mod joints;
45#[cfg(test)]
46mod kept_tests;
47pub mod mates;
48pub mod mechanism;
49mod motion;
50mod panel;
51mod part_pattern;
52pub mod placed;
53#[cfg(test)]
54mod program_tests;
55#[cfg(test)]
56mod regression_tests;
57pub mod residuals;
58#[cfg(test)]
59mod scale_tests;
60mod settle;
61pub mod solving;
62mod stl;
63#[cfg(any(test, feature = "testing"))]
64#[allow(clippy::expect_used, reason = "tests' helpers fail where a test would")]
65pub mod testing;
66pub mod urdf;
67
68use std::rc::Rc;
69
70use geop_core_editor::registry::Registry;
71use geop_core_math::geop_error::GeopResult;
72
73pub use add_part::{AddPart, AddPartArgs};
74pub use add_part_derived::{DerivedPart, DerivedPartArgs, MIRRORED, MirrorPart, MirrorPartArgs};
75pub use drag_tool::DragTool;
76pub use draw::AssemblyDrawer;
77pub use explode::{Direction, Explode, ExplodeArgs};
78pub use mates::{
79    Anchor, CouplingKind, Joint, JointKind, Kind, Limits, MOTIONS, Mate, MateKind, Motion, On,
80    Resolved, Transmission, foot_parameter, joint_parameter, mate, mate_name,
81};
82pub use mechanism::mates_resolved;
83pub use motion::{
84    Checked, Collision, Drive, MotionArgs, MotionCommand, MotionExport, MotionOptions, MotionPanel,
85    MotionState, StudyState,
86};
87pub use panel::{JointsCommand, JointsPanel, JointsState};
88pub use part_pattern::{PartPattern, PartPatternArgs};
89pub use placed::define_placed;
90pub use settle::Settler;
91pub use stl::{Stl, StlOptions};
92pub use urdf::Urdf;
93
94/// Adds what assemblies offer an editor to `r`: placing parts and patterns
95/// of them, parts derived from others and mirrored, the STL of a part with its placed parts and the URDF of its
96/// mechanism, how placed parts are drawn, the joints panel, the drag tool,
97/// what settles the program's state after every edit, and the examples of
98/// assemblies.
99pub fn register(r: Registry) -> GeopResult<Registry> {
100    let settled = Rc::new(settle::Settled::default());
101    let r = r
102        .operation(AddPart)?
103        .operation(PartPattern)?
104        .operation(Explode)?
105        .operation(Drive)?
106        .operation(DerivedPart)?
107        .operation(MirrorPart)?
108        .exporter(Stl)?
109        .exporter(Urdf)?
110        .exporter(MotionExport)?
111        .drawer(AssemblyDrawer)?
112        .panel(JointsPanel::new(settled.clone()))?
113        .panel(MotionPanel::default())?
114        .tool(DragTool::INFO, DragTool::default())?
115        // A press and a move on a placed part drag it, with no step edited.
116        .idle_tool(DragTool::INFO.key)?
117        .settler(Settler { settled })?;
118    #[cfg(any(test, feature = "examples"))]
119    let r = r.examples(examples::set())?;
120    Ok(r)
121}