From 4e747a8e6cc7b2206b43746df68d749b237cc179 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sun, 15 Mar 2026 22:31:11 -0400 Subject: [PATCH] fix: show strip + remnant parts together during progress updates Wrap IProgress with AccumulatingProgress so remnant fills prepend previously placed strip parts to each report. The UI now shows the full picture (red + purple) instead of replacing strip parts. Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest.Engine/StripNestEngine.cs | 35 +++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/OpenNest.Engine/StripNestEngine.cs b/OpenNest.Engine/StripNestEngine.cs index 2c9ad85..45d6384 100644 --- a/OpenNest.Engine/StripNestEngine.cs +++ b/OpenNest.Engine/StripNestEngine.cs @@ -229,9 +229,13 @@ namespace OpenNest .ToList(); // Fill remnant with remainder items, shrinking the available area after each. + // Wrap progress so remnant fills include the strip parts already found. if (remnantBox.Width > 0 && remnantBox.Length > 0) { var currentRemnant = remnantBox; + var remnantProgress = progress != null + ? new AccumulatingProgress(progress, allParts) + : null; foreach (var item in effectiveRemainder) { @@ -244,7 +248,7 @@ namespace OpenNest var remnantInner = new DefaultNestEngine(Plate); var remnantParts = remnantInner.Fill( new NestItem { Drawing = item.Drawing, Quantity = item.Quantity }, - currentRemnant, progress, token); + currentRemnant, remnantProgress, token); if (remnantParts != null && remnantParts.Count > 0) { @@ -268,5 +272,34 @@ namespace OpenNest } // ComputeRemainderWithin inherited from NestEngineBase + /// + /// Wraps an IProgress to prepend previously placed parts to each report, + /// so the UI shows the full picture (strip + remnant) during remnant fills. + /// + private class AccumulatingProgress : IProgress + { + private readonly IProgress inner; + private readonly List previousParts; + + public AccumulatingProgress(IProgress inner, List previousParts) + { + this.inner = inner; + this.previousParts = previousParts; + } + + public void Report(NestProgress value) + { + if (value.BestParts != null && previousParts.Count > 0) + { + var combined = new List(previousParts.Count + value.BestParts.Count); + combined.AddRange(previousParts); + combined.AddRange(value.BestParts); + value.BestParts = combined; + value.BestPartCount = combined.Count; + } + + inner.Report(value); + } + } } }