using System;
using System.Collections.Generic;
namespace OpenNest.Engine.Fill
{
///
/// Wraps an IProgress to prepend previously placed parts to each report,
/// so the UI shows the full picture during incremental fills.
///
internal 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);
}
}
}