From 2af02096e0b864968cb6f5a839d0eb7ce723d36e Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sun, 15 Mar 2026 13:30:39 -0400 Subject: [PATCH] fix(engine): pass progress through FillExact binary search iterations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The binary search was passing null for progress, so the NestProgressForm showed all dashes during the entire search (potentially minutes). Now each iteration reports progress — the user sees phases, part counts, and density updating as the search runs. Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest.Engine/NestEngine.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenNest.Engine/NestEngine.cs b/OpenNest.Engine/NestEngine.cs index 4bb8792..67a36a0 100644 --- a/OpenNest.Engine/NestEngine.cs +++ b/OpenNest.Engine/NestEngine.cs @@ -121,9 +121,9 @@ namespace OpenNest // Binary search: try shrinking each dimension. Debug.WriteLine($"[FillExact] Starting binary search (capacity={capacity} > target={item.Quantity})"); - var (lengthFound, lengthDim) = BinarySearchFill(item, workArea, shrinkWidth: false, token); + var (lengthFound, lengthDim) = BinarySearchFill(item, workArea, shrinkWidth: false, progress, token); Debug.WriteLine($"[FillExact] Shrink-length: found={lengthFound}, dim={lengthDim:F1}"); - var (widthFound, widthDim) = BinarySearchFill(item, workArea, shrinkWidth: true, token); + var (widthFound, widthDim) = BinarySearchFill(item, workArea, shrinkWidth: true, progress, token); Debug.WriteLine($"[FillExact] Shrink-width: found={widthFound}, dim={widthDim:F1}"); // Pick winner by smallest test box area. Tie-break: prefer shrink-length. @@ -159,7 +159,7 @@ namespace OpenNest /// private (bool found, double usedDim) BinarySearchFill( NestItem item, Box workArea, bool shrinkWidth, - CancellationToken token) + IProgress progress, CancellationToken token) { var quantity = item.Quantity; var partBox = item.Drawing.Program.BoundingBox(); @@ -204,7 +204,7 @@ namespace OpenNest // Fill with unlimited qty to get the true count for this box size. // After the first iteration, angle pruning kicks in and makes this fast. var searchItem = new NestItem { Drawing = item.Drawing, Quantity = 0 }; - var result = Fill(searchItem, testBox, null, token); + var result = Fill(searchItem, testBox, progress, token); if (result.Count >= quantity) {