← hex_fit · version 0.1.5
37 public items, in source order. Generated from the registry index, which re-derives them from the package source at publish time — so a signature here is the one that version actually ships.
pub struct Draft { df_form: Form, df_d: integer, df_a: integer, df_b: integer, df_p: integer }
A form plus an embedded run, written, read and drawn as one: the form, the run's direction (df_d, -1 for none), its anchor (df_a, df_b) and its periods. draft_new, draft_read and draft_canon make one.
pub fn draft_new(f: Form, d: integer, a: integer, b: integer, p: integer) -> Draft
A stencil description: the form, plus the linework run it carries (d = -1 for none). The run is part of the value rather than something a caller keeps beside it, so a rebuild that drops it is caught by the text diff.
pub fn draft_has_run(s: Draft) -> boolean
Does this draft carry a linework run? Check before reading the run's fields, which are only meaningful when it does.
pub fn draft_write(s: Draft, name: text) -> text
The text of a stencil: the form's spelling, then — if there is one — a single wall line. One line, one record, same shape as side: the reader refuses anything else rather than repairing it (X39).
⚠ THIS IS NOT THE CANONICAL TEXT. It writes the spelling it is GIVEN, and both the form's start corner and the run's direction are choices the model does not fix — so two calls can spell one stencil two ways. A round trip diffs against draft_canon_text.
pub fn draft_read(t: text) -> Draft
Parse. The side lines go to form_read unchanged; a trailing wall line is this layer's. A malformed record yields a stencil with an empty form — REFUSED, never repaired.
It refuses exactly what draft_write cannot emit: a trailing space, an extra field, +3, 003, a field that is not a number at all, or a wall line that is not last. Repairing any of those would admit a model nobody wrote — wall d x … read as d 0 is a wall pointing somewhere else.
The rule is a RE-SPELLING IDENTITY: a field is an integer only if printing the parse reproduces the original characters, a line is a record only if it carries exactly the fields the writer emits, and the wall line is LAST because that is where the writer puts it.
pub fn draft_draw(s: Draft, cq: integer, cr: integer, cells: HexSet, edges: EdgeSet, wallmat: integer, embedmat: integer) -> integer
Draw the whole stencil into one field: the fill, its own boundary walls, and the embedded run as material on INTERIOR edges only. Returns the number of interior edges the run marked.
pub fn draft_interior(cells: HexSet, edges: EdgeSet, embedmat: integer) -> EdgeSet
The INTERIOR edges carrying embedmat, isolated — what the run reader consumes. Boundary edges (one cell out) are the stencil's own walls and are never part of a run.
pub fn draft_rebuild_text(cells: HexSet, edges: EdgeSet, name: text, embedmat: integer) -> text
REBUILD, INCLUDING THE RUN. The form comes from the cells (constructive recovery, X45); the run comes from the interior edges (wall_read_run, X60) — two recoveries reading disjoint slots. An unreadable run is REFUSED, so it is dropped loudly by a text diff rather than silently.
⚠ DIFF THIS AGAINST draft_canon_text, NOT against draft_write. What comes back is the spelling the FIELD answers with, and for the run half that is one of two — see the note there.
pub fn draft_canon(s: Draft, cells: HexSet) -> Draft
── ONE MODEL, ONE TEXT — the canonical spelling ───────────────────────────
The format's premise is that a diff means *the model changed*, which needs every model to have exactly ONE text. The form half has that: a shape has n cyclic spellings and form_canon picks the smallest, which is why rebuild_construct_text and form_canon_text agree.
THE RUN HALF HAD NO SUCH RULE, and a run has exactly TWO spellings — (d, A, p) and (d + 12, B, p) — because A-to-B and B-to-A mark the identical edges and the field stores no orientation (wall_read_run's own note). Measured over all 24 directions: the two spellings draw fields that differ in ZERO edges, and **exactly one of them survives a text round trip**, never both and never neither. So an author who wrote the wall from the other end got *the model changed* out of a byte diff on a model that had not changed at all.
The canonical spelling is therefore READ OFF THE FIELD rather than chosen by a rule — the same discipline hexfit's feature grid is built on (SPEC **L11**: consult the table that owns the answer), and the only definition that cannot drift from what draft_rebuild_text will answer, since it is that same reader.
pub fn draft_canon_text(s: Draft, cells: HexSet, name: text) -> text
The one text a round trip can be diffed against. A run that does not FIT is left as written — the canon is a spelling rule, not a doorstep, and refusing here would hide which of the two is wrong.
pub fn draft_fit_reason(code: integer) -> text
The FIT_ code as a sentence, for showing a person why a draft did not fit. Keep the code for logic and use this only at the edge, so the reason never becomes the test.
pub fn draft_fits(s: Draft, cells: HexSet) -> integer
THE DOORSTEP. cells is the form's own footprint. Returns a reason code — FIT_OK or the specific restriction, never a bare false.
pub fn draft_fit_p(s: Draft, cells: HexSet) -> integer
AND THE ALTERNATIVE THE REFUSAL OWES (K-FIT): the longest run from this anchor, in this direction, that IS admissible and fits — searching downward so the offer is never longer than what was asked for. 0 when nothing fits, which is itself a usable answer: move the anchor.
pub fn fit_reason(code: integer) -> text
One reason table for the whole doorstep — hexdraft's codes and these.
pub fn feature_grid(p: Plan, cells: HexSet, side: integer) -> vector<float>
The admissible positions on a side, in the order the run stores them — which is NOT t order (A5: index a feature by its exact t, never by its position in the SideRun).
pub fn feature_fits(p: Plan, cells: HexSet, side: integer, t: float, nedges: integer) -> integer
THE DOORSTEP. t must be exactly an edge centre of this side — no tolerance (P4), because in regime R1 an epsilon is a defect signal and not a knob.
pub fn feature_fit_t(p: Plan, cells: HexSet, side: integer, t: float) -> float
AND THE ALTERNATIVE THE REFUSAL OWES: the nearest admissible t. This is what an editor calls with a raw mouse position — the snap is EXPLICIT and returns a value the author can see, rather than happening silently inside place_opening.
pub fn feature_fit_residual(p: Plan, cells: HexSet, side: integer, t: float) -> float
The residual the editor must SHOW (K-FIT): how far the offer is from what was asked.
pub fn arc_is_shell(n24: integer) -> boolean
Does n24 land on a shell — one of the realisable values of 3k^2 + m^2 — so an arc of that radius round-trips as itself?
pub fn arc_fits(n24: integer) -> integer
Does this arc land on the grid? Answers a FIT_ code rather than a boolean, so a caller can tell the reader WHY it did not — see draft_fit_reason.
pub fn arc_fit_n(n24: integer) -> integer
The nearest realisable shell — K-FIT says *nearest*, so this can offer a LARGER disk than the author asked for (N = 11 is offered 12, not 0). That is deliberate and differs from what the unrefused value would have drawn: an off-grid N silently draws the shell BELOW it, so arc_fill would have given 0. Offering the nearest and showing the residual is the point — the author sees both candidates' cost — arc_snap_n is the other one — instead of being quietly rounded down. Ties go DOWN, to the smaller shell.
pub fn arc_fit_residual(n24: integer) -> integer
How far the arc is from the nearest fitting one. 0 means it already fits; anything else is what a warning would quote.
pub fn arc_snap_n(n24: integer) -> integer
THE OTHER CANDIDATE, and the reason the comment above can say *both*. This is the shell an UNREFUSED radius actually draws — the largest realisable one at or below n24 — so an editor can show the author what the silent snap would have cost beside what the offer costs. The two are not close: N = 35 is offered 36 at a residual of 1 and would have drawn **12**, an error of 23 in the same units, because 12 and 36 are neighbouring shells. Verified against arc_fill over every radius 0..64 rather than against the formula it shares with arc_fits.
pub fn arc_snap_residual(n24: integer) -> integer
How far snapping WOULD move it — signed, so a caller can see which way.
pub fn level_fits(lv: integer) -> integer
── LEVELS — MEASURED TO HAVE NOTHING TO REFUSE ─────────────────────────────
A level is the topological SHEET (X58), stored as an integer (ha_cy / ck_cy) and used as a FILTER BEFORE THE CUT. There is no continuous parameter here, so I-QUANT has nothing to say: nothing exists *between* two levels to be snapped to one of them. Measured over the full range an integer holds — the behaviour at ±10^6 is identical to the behaviour at 0.
This returns FIT_OK unconditionally, and that is a RESULT, not an omission. @HXI-008 keeps it honest the only way an always-true predicate can be kept honest: by showing that the SAME doorstep refuses the other parameters, so "accepts every level" is not "accepts everything".
pub fn mat_fits(m: integer) -> integer
⚠ NO OFFER, AND THAT IS THE POINT. K-FIT says a refusal offers *the nearest fitting alternative* — which presumes an ORDINAL parameter, where "nearest" means "almost what you asked for". A material id is NOMINAL: it is a name, not a magnitude. The nearest admissible id to 256 is 255, and 255 is a *different material* — offering it would be worse than a blank no, because it looks like a small correction and is not. So this refusal names its restriction and stops there. The author must pick a material, not accept a rounding.
pub fn height_units_at(z: float, scale: float) -> integer
The voxel's own value for a height, at a given quantum: what h_height would hold.
pub fn height_from_units_at(u: integer, scale: float) -> float
Grid units back to a world height at a given scale — the inverse of height_units_at.
pub fn seat_fits_at(z: float, scale: float) -> integer
THE DOORSTEP, at the caller's quantum. A height must land exactly on the voxel's grid; off it, the store truncates and X59's returned residual would be wrong by the truncation — which is the one thing SPEC **G5** says must never happen silently.
⚠ **A NON-POSITIVE QUANTUM IS REFUSED BY NAME RATHER THAN DIVIDED BY.** loft's division by zero yields null and keeps running, so an unchecked z / scale would discharge to 0.0 and this would answer *on the grid* for z = 0 and *off it* for everything else — a wrong verdict dressed as a real one, which is exactly what a doorstep exists not to produce.
pub fn seat_fit_z_at(z: float, scale: float) -> float
The offer, and the residual the editor must show — in world units.
pub fn seat_fit_residual_at(z: float, scale: float) -> float
How far a height is from the nearest seating level at a given scale. Warn on this rather than snapping, when the author's exact value matters.
pub fn height_from_units(u: integer) -> float
Grid units back to a world height at the default scale.