Skip to main content

Module doc

Module doc 

Source
Expand description

SketchDoc — the engine-native mirror of the 2D solver’s sketch JSON.

The Rust 2D constraint solver (brep_kernel::solve_sketch) consumes and emits a sketch object shaped {points, geometries, constraints} (plus a read-only diagnostics block on the solved output). This module is the typed serde mirror of that shape, so the engine-native sketcher can hold, solve, and render a sketch WITHOUT a JSON round-trip through the previous app.

Faithful round-trip is a hard requirement (S0 test): a document deserialized from the solver’s output and re-serialized must equal the original JSON. To that end the passthrough-heavy sub-objects keep an #[serde(flatten)] bag of any fields this slice does not model explicitly (geometry construction flag, the solver’s constraint bookkeeping — status, previousPointValues, the _distance* fields, …), so nothing is lost across a load/save.

Structs§

SketchConstraint
A sketch constraint. The solver mutates constraints with a large amount of bookkeeping (status, error, previousPointValues, _previousSolveValue, the _distance* slide state, …) that must persist between solves EXACTLY, so the whole object is kept as a transparent map rather than a lossy typed struct. Typed accessors (ctype, points) read the fields this slice needs.
SketchDiagnostics
The solver’s read-only constraint diagnostics: degrees of freedom, over/under status, and per-point / per-geometry mobility (movable vs locked) derived from the constraint-Jacobian null space. Keys in the mobility maps are id_key strings.
SketchDoc
The editable sketch document — a typed mirror of the solver’s {points, geometries, constraints}. Unknown top-level keys (e.g. the solved output’s diagnostics) are ignored on load; crate::sketch::solve pulls diagnostics out into SketchDiagnostics separately.
SketchGeometry
A sketch geometry: line = [p0,p1], circle = [center,radiusPoint], arc = [center,start,end] (CCW start→end), ellipse = [center,majEnd,minEnd], bezier = [p0,p1,p2,p3,…] (every 3 ids a new cubic span). Point semantics are the ground truth from the sketch feature’s edge builder.
SketchPoint
A sketch point: a solved 2D coordinate in the plane’s (u, v) frame, plus the three role flags the solver tracks. Emitted by the solver as exactly these six fields (solvers/sketch_solver.rs solve output).

Functions§

id_key
Canonical string key for a point/geometry id — a faithful port of the solver’s fmt_id/fmt_number so mobility-map lookups (keyed by that formatting) and point matching agree byte-for-byte. Integral floats print without a decimal point (10.0 -> "10"), -0/0 collapse to "0".