Skip to main content

SquareAttachPolicy

Trait SquareAttachPolicy 

Source
pub trait SquareAttachPolicy {
    // Required methods
    fn is_eligible(&self, idx: usize) -> bool;
    fn required_label_at(&self, i: i32, j: i32) -> Option<u8>;
    fn label_of(&self, idx: usize) -> Option<u8>;
    fn accept_candidate(
        &self,
        idx: usize,
        at: (i32, i32),
        prediction: Point2<f32>,
        neighbours: &[LabelledNeighbour],
    ) -> Admit;

    // Provided methods
    fn edge_ok(
        &self,
        _candidate_idx: usize,
        _neighbour_idx: usize,
        _at_candidate: (i32, i32),
        _at_neighbour: (i32, i32),
    ) -> bool { ... }
    fn eligible_for_fill(&self, idx: usize) -> bool { ... }
    fn fill_edge_ok(&self, ctx: FillEdgeCtx<'_>) -> bool { ... }
}
Expand description

Caller-supplied attachment policy for the square-lattice growth helpers.

Implementations typically hold references to the caller’s feature data (axes, labels, strengths) plus tuning parameters, and use idx to look up the relevant per-feature record inside each callback.

Required Methods§

Source

fn is_eligible(&self, idx: usize) -> bool

Is this corner index a possible candidate at all? Called once per corner when the KD-tree is built.

Source

fn required_label_at(&self, i: i32, j: i32) -> Option<u8>

Optional caller-defined label required at grid cell (i, j). Return None for no constraint.

Source

fn label_of(&self, idx: usize) -> Option<u8>

Return the label of the corner at idx. Must agree with required_label_at at attachment time. Called during candidate filtering.

Source

fn accept_candidate( &self, idx: usize, at: (i32, i32), prediction: Point2<f32>, neighbours: &[LabelledNeighbour], ) -> Admit

Accept or reject a candidate for attachment at grid cell at given its geometric prediction and existing labelled neighbours. Called per candidate in order of increasing distance to prediction.

Provided Methods§

Source

fn edge_ok( &self, _candidate_idx: usize, _neighbour_idx: usize, _at_candidate: (i32, i32), _at_neighbour: (i32, i32), ) -> bool

Soft per-edge check: is the induced edge between the just- attached candidate and one of its cardinal-labelled neighbours admissible? At least one cardinal edge must pass for the attachment to stick; otherwise the position is marked a hole and the candidate is rolled back.

Default: accept all edges (no soft check).

Source

fn eligible_for_fill(&self, idx: usize) -> bool

Optional widened eligibility used by the fill-pass booster.

Defaults to Self::is_eligible; patterns whose precision core admits only Clustered corners but want to admit a few near-cluster corners during the booster pass override this to expand the admissible set. The fill pass calls this when building its KD-tree; the regular grow / boundary-extension passes ignore it.

Source

fn fill_edge_ok(&self, ctx: FillEdgeCtx<'_>) -> bool

Optional fill-pass edge check that has access to the full labelled set and the position table via FillEdgeCtx.

The default delegates to Self::edge_ok, ignoring the extra context. Pattern implementations that need a directional edge metric (e.g., a strongly anisotropic component where the horizontal pitch is much larger than the vertical pitch and a scalar cell_size rejects legitimate vertical extrapolations) override this to consult the labelled set when computing the expected edge length.

Only invoked by crate::shared::fill::fill_grid_holes; the regular grow and boundary-extension passes call Self::edge_ok directly.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§