MAGMA

Magma Tri-hex Pattern — Design Note (locked)

Third Magma infill pattern, after Triangle and Rectilinear. This note is the implementation reference; the design below is settled.

Terminology: a tri-hex injection unit is a manifold — one hub + N equal-length vent legs. The U-tube (triangle/square) is the degenerate 1-leg manifold.

1. Lattice — trihexagonal tiling

2. Injection model — the manifold

3. Solver — UNCHANGED

4. Extra-vent sweep — NEW, per vent, runs after the solver

Goal: maximize filled vent volume by adding extra legs to the already-scheduled hub-tubes. Runs after greedy and after CP-SAT (same code either way).

For each vent V:

  1. Unavailable mask = layers where V is geometry-absent (part blocks the cell) ∪ layers already claimed by the solver’s primary matching. Both are treated identically.
  2. Candidates = the bordering hub-tubes’ ranges [start, cap].
  3. Delete any candidate that crosses an unavailable layer — a block/claim inside the range would trap air (no escape) → infeasible.
  4. The surviving available layers form present-runs. Per run:
    • candidates = hub-tubes fully contained in the run,
    • pick the non-overlapping subset covering the most layers = weighted interval scheduling (exact; sort-by-cap + DP, or brute-force the handful of candidates),
    • tiebreak toward the least-loaded hub (evenness; minor — legs are low-volume),
    • assign V (those layers) as legs of the chosen hub-tubes. - Per vent independent (hubs are uncapped). A vent may be a leg of multiple stacked hub-tubes at different (non-overlapping) heights — each fed from its own tube’s bottom window, which lines up with the plug below by construction.

The sweep is purely additive: feasibility was already secured by the solver’s matching, so it can never strand a hub.

5. Finalize

6. Data model

7. Geometry / misc

8. New vs reused