Skip to main content

Module doc

Module doc 

Source
Expand description

Typed sketch JSON shared with the 2D constraint solver.

Documents contain points, geometries, constraints, and optional diagnostics. Flattened serde fields preserve unmodeled geometry and constraint data across load/save, including solver bookkeeping.

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
Shared solver key for sketch entity and mobility-map lookups. Canonical sketch entity key. Numeric IDs normalize integral floats and signed zero; string IDs are preserved. Other JSON values use their JSON spelling.