From c4d5cfd17ba4fb68c262b1ef9667e99d8dbcf032 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Wed, 18 Mar 2026 13:02:00 -0400 Subject: [PATCH] feat(engine): add PairsFillStrategy adapter Wraps PairFiller in an IFillStrategy so the pairs phase participates in the pluggable pipeline. Stores BestFitResults in SharedState for downstream strategies (Extents) to reuse. Co-Authored-By: Claude Sonnet 4.6 --- .../Strategies/PairsFillStrategy.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 OpenNest.Engine/Strategies/PairsFillStrategy.cs diff --git a/OpenNest.Engine/Strategies/PairsFillStrategy.cs b/OpenNest.Engine/Strategies/PairsFillStrategy.cs new file mode 100644 index 0000000..904c220 --- /dev/null +++ b/OpenNest.Engine/Strategies/PairsFillStrategy.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using OpenNest.Engine.BestFit; + +namespace OpenNest +{ + public class PairsFillStrategy : IFillStrategy + { + public string Name => "Pairs"; + public NestPhase Phase => NestPhase.Pairs; + public int Order => 100; + + public List Fill(FillContext context) + { + var filler = new PairFiller(context.Plate.Size, context.Plate.PartSpacing); + var result = filler.Fill(context.Item, context.WorkArea, + context.PlateNumber, context.Token, context.Progress); + + // Cache hit — PairFiller already called GetOrCompute internally. + var bestFits = BestFitCache.GetOrCompute( + context.Item.Drawing, context.Plate.Size.Length, + context.Plate.Size.Width, context.Plate.PartSpacing); + context.SharedState["BestFits"] = bestFits; + + return result; + } + } +}