Skip to main content

Module fill

Module fill 

Source
Expand description

Post-grow fill pass: interior holes + line extrapolation.

fill_grid_holes is the pattern-agnostic “booster” pass that runs after a component-assembly + validate pass has converged. It enumerates (i, j) cells inside the labelled bounding box that are still empty, plus ±1 cells immediately outside each row / column boundary, and tries to attach a candidate at each one using the same per-cell ladder as the crate::shared::grow candidate search.

§Precision contract

Fill attachments must obey the same invariants as BFS-grow attachments. The policy’s existing gates (is_eligible, required_label_at, label_of, accept_candidate) are reused verbatim; the edge check delegates to SquareAttachPolicy::fill_edge_ok which, by default, forwards to SquareAttachPolicy::edge_ok.

§Pattern extension points

Two optional methods on SquareAttachPolicy let pattern crates customise the fill pass without touching this module:

  • SquareAttachPolicy::eligible_for_fill — widen the admissible candidate set during the booster pass (e.g. admit near-cluster corners that the precision core dropped by a hair).
  • SquareAttachPolicy::fill_edge_ok — replace the scalar-cell_size edge-length check with a labelled-set-aware (e.g. directional median) variant. Useful when a component is strongly anisotropic before final recovery has filled the boundary.

Patterns whose precision core is strict enough that the booster pass should not relax anything need not override either method — the defaults forward to is_eligible and edge_ok.

§Iteration

The pass iterates until a full scan attaches zero new corners, capped at max_iters. Each iteration rebuilds the KD-tree over eligible_for_fill candidates because the previous iteration’s attachments shrink the eligible set.

Structs§

FillParams
Tunables for fill_grid_holes.
FillStats
Counters returned by fill_grid_holes.

Functions§

fill_grid_holes
Run the unified fill pass: interior gap fill + line extrapolation.