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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//! # `monstertruck`
//!
//! A Rust CAD kernel -- B-rep modeling, NURBS curves and surfaces, meshing,
//! and GPU rendering. Forked from
//! [`ricosjp/truck`](https://github.com/ricosjp/truck) and renamed.
//!
//! This is a meta-crate: it re-exports the workspace's `monstertruck-*`
//! sub-crates behind feature flags so downstream code can pull in exactly
//! the surface area it needs.
//!
//! ```toml
//! [dependencies]
//! monstertruck = { version = "0.3", features = ["full"] }
//! ```
//!
//! # Architecture
//!
//! The kernel is split along the classic B-rep stack -- numerical primitives
//! at the bottom, topology and modeling in the middle, file I/O and rendering
//! at the top.
//!
//! ## Numerical core
//!
//! - [`core`] -- `f64`-only linear algebra, tolerance helpers, bounding
//! boxes, and the [`derivatives`] family used to evaluate B-spline /
//! NURBS bases.
//! - [`traits`] -- the kernel's trait family
//! ([`ParametricCurve`](traits::ParametricCurve),
//! [`ParametricSurface`](traits::ParametricSurface),
//! [`SearchParameter`](traits::SearchParameter), etc.) together with the
//! scalar-generic v2 successor under
//! [`traits::v2`](traits::v2).
//! - [`derive`] -- proc-macros (`#[derive(StepFormat)]`, `#[derive(StepLength)]`)
//! for the STEP back-end.
//!
//! ## Geometry and topology
//!
//! - [`geometry`] -- concrete curves and surfaces: Bezier, B-spline, NURBS,
//! conics, the [`Processor`](geometry::decorators::Processor) decorator,
//! the new offset family
//! ([`OffsetCurve`](geometry::decorators::OffsetCurve),
//! [`OffsetSurface`](geometry::decorators::OffsetSurface),
//! [`NormalOffsetField`](geometry::decorators::NormalOffsetField)),
//! and analytic specifieds such as
//! [`Sphere`](geometry::specifieds::Sphere).
//! - [`topology`] -- the B-rep graph: [`Vertex`](topology::Vertex),
//! [`Edge`](topology::Edge), [`Wire`](topology::Wire),
//! [`Face`](topology::Face), [`Shell`](topology::Shell),
//! [`Solid`](topology::Solid), plus their `Compressed*` flattened forms
//! used for serialisation and file I/O.
//!
//! ## Meshing
//!
//! - [`mesh`] -- `PolygonMesh`, `StructuredMesh`, and the OBJ / STL
//! serialisers.
//! - [`meshing`] -- tessellation algorithms that turn B-rep
//! [`Shell`](topology::Shell) / [`Solid`](topology::Solid) into
//! triangle soups for rendering or 3D printing.
//!
//! ## Modeling and boolean ops
//!
//! - [`modeling`] -- the high-level builder
//! ([`modeling::builder`](modeling::builder)) for vertices, edges, wires,
//! sweeps ([`extrude`](modeling::builder::extrude),
//! [`revolve`](modeling::builder::revolve)), tangent arcs, and primitive
//! shapes ([`modeling::primitive::cuboid`](modeling::primitive::cuboid)
//! etc.).
//! - [`solid`] -- shape operators
//! ([`and`](solid::and), [`or`](solid::or)) for boolean combinations of
//! solids, plus edge filleting.
//! - [`assembly`] -- DAG-structured assemblies (`Node` / `Edge`) that group
//! parts and the rigid transforms between them.
//!
//! ## File I/O and rendering
//!
//! - [`step`] -- STEP (ISO 10303-21) reader and writer for parts and
//! assemblies.
//! - [`gpu`] -- `wgpu` device wrapper used by the renderer.
//! - [`render`] -- a small forward renderer that draws meshes produced by
//! [`meshing`].
//!
//! # Example: subtract a cylinder from a box, then export STEP
//!
//! Build a cuboid and a cylinder, subtract the cylinder via boolean `AND`
//! against its inverse, and emit the result as a STEP string.
//!
//! ```
//! # #[cfg(not(all(feature = "step", feature = "solid")))]
//! # fn main() {}
//! # #[cfg(all(feature = "step", feature = "solid"))]
//! # fn main() -> anyhow::Result<()> {
//! use monstertruck::modeling::*;
//! use monstertruck::solid;
//! use monstertruck::step::save::{CompleteStepDisplay, StepHeaderDescriptor, StepModel};
//!
//! // Unit cuboid centred on the origin.
//! let cube: Solid = primitive::cuboid(BoundingBox::from_iter([
//! Point3::new(-0.5, -0.5, 0.0),
//! Point3::new(0.5, 0.5, 1.0),
//! ]));
//!
//! // Cylinder of radius 0.3, axis along +Z, that pierces the cube top to bottom.
//! let seed = builder::vertex(Point3::new(0.3, 0.0, -0.1));
//! let rim = builder::revolve(
//! &seed,
//! Point3::new(0.0, 0.0, -0.1),
//! Vector3::unit_z(),
//! builder::SweepAngle::Closed,
//! 4,
//! );
//! let base = builder::try_attach_plane(&[rim])?;
//! let mut cylinder: Solid = builder::extrude(&base, Vector3::unit_z() * 1.2);
//!
//! // Invert the cylinder so `and` performs a subtraction.
//! cylinder.not();
//! let punched = solid::and(&cube, &cylinder, 0.05)?;
//!
//! // Flatten the topology and render as STEP.
//! let compressed = punched.compress();
//! let step = CompleteStepDisplay::new(
//! StepModel::from(&compressed),
//! StepHeaderDescriptor {
//! organization_system: "monstertruck-doc".to_owned(),
//! ..Default::default()
//! },
//! )
//! .to_string();
//!
//! assert!(step.starts_with("ISO-10303-21;"));
//! assert!(step.contains("MANIFOLD_SOLID_BREP"));
//! # Ok(())
//! # }
//! ```
//!
//! # Feature flags
//!
//! Each sub-crate is gated behind a feature with the same name. Convenience
//! groups:
//!
//! - `default` -- `modeling` + `meshing`.
//! - `full` -- everything except `gpu` and `wasm` glue.
//! - `rkyv` -- enables zero-copy serialisation in
//! [`core`] and [`topology`].
pub use monstertruck_core as core;
pub use monstertruck_traits as traits;
pub use monstertruck_derive as derive;
pub use monstertruck_geometry as geometry;
pub use monstertruck_topology as topology;
pub use monstertruck_mesh as mesh;
pub use monstertruck_modeling as modeling;
pub use monstertruck_meshing as meshing;
pub use monstertruck_solid as solid;
pub use monstertruck_assembly as assembly;
pub use monstertruck_step as step;
pub use monstertruck_gpu as gpu;
pub use monstertruck_render as render;