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); + } + } } }