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§
- Sketch
Constraint - 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. - Sketch
Diagnostics - 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_keystrings. - Sketch
Doc - The editable sketch document — a typed mirror of the solver’s
{points, geometries, constraints}. Unknown top-level keys (e.g. the solved output’sdiagnostics) are ignored on load;crate::sketch::solvepulls diagnostics out intoSketchDiagnosticsseparately. - Sketch
Geometry - 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. - Sketch
Point - 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.rssolve output).
Functions§
- id_key
- Canonical string key for a point/geometry id — a faithful port of the solver’s
fmt_id/fmt_numberso 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/0collapse to"0".