brep_simulation/lib.rs
1//! Motion studies for BREP assemblies.
2//!
3//! A study lives in its assembly document's `simulation` block ([`model`]).
4//! Motors are mates: the author picks distance or angle mates and drives each
5//! at a constant speed or along a motion profile, and every other part follows
6//! through the assembly solver on each frame. Clips drive the rest of the
7//! timeline (mate on/off, camera, visibility, transparency, sections, exploded
8//! views). [`sample`] turns a study at one time into what the caller applies:
9//! mate overrides for the solver and the display state. [`forms`] describes a
10//! motor's and a clip's fields for a schema-driven form. This crate needs
11//! neither the kernel nor a GPU.
12//!
13//! ```rust
14//! use brep_simulation::{Drive, Motor, Simulation};
15//!
16//! let mut sim = Simulation::default();
17//! let study_id = sim.add_study("Open the lid");
18//! let motor_id = sim.next_id("MOT");
19//! let study = sim.study_mut(&study_id).unwrap();
20//! study.motors.push(Motor {
21//! id: motor_id,
22//! constraint: "ANG1".into(),
23//! from: 0.0,
24//! to: 2.0,
25//! drive: Drive::Speed { speed: 45.0 },
26//! });
27//! // One second in, a 45 degree/s motor has moved the mate 45 degrees on from
28//! // its document value (10 here).
29//! let frame = study.sample(1.0, &|_: &str| Some(10.0));
30//! assert_eq!(frame.mates["ANG1"].value, Some(55.0));
31//! ```
32
33pub mod forms;
34pub mod model;
35pub mod sample;
36
37pub use model::{Clip, ClipBody, Drive, Motor, Simulation, Study};
38pub use sample::{FrameSample, MateOverride};