refactor: standardize fill strategy progress reporting via FillContext
Strategies and fillers previously called NestEngineBase.ReportProgress directly, each constructing ProgressReport structs with phase, plate number, and work area manually. Some strategies (RectBestFit) reported nothing at all. This made progress updates inconsistent and flakey. Add FillContext.ReportProgress(parts, description) as the single standard method for intermediate progress. RunPipeline sets ActivePhase before each strategy, and the context handles common fields. Lower-level fillers (PairFiller, FillExtents, StripeFiller) now accept an Action<List<Part>, string> callback instead of raw IProgress, removing their coupling to NestEngineBase and ProgressReport. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -113,13 +113,12 @@ namespace OpenNest.Engine.Strategies
|
||||
/// <summary>
|
||||
/// Sweeps a list of angles, calling fillAtAngle for each, and returns
|
||||
/// the best result according to the context's comparer. Handles
|
||||
/// cancellation and progress reporting.
|
||||
/// cancellation and progress reporting via context.ReportProgress.
|
||||
/// </summary>
|
||||
public static List<Part> BestOverAngles(
|
||||
FillContext context,
|
||||
IReadOnlyList<double> angles,
|
||||
Func<double, List<Part>> fillAtAngle,
|
||||
NestPhase phase,
|
||||
string phaseLabel)
|
||||
{
|
||||
var workArea = context.WorkArea;
|
||||
@@ -140,14 +139,8 @@ namespace OpenNest.Engine.Strategies
|
||||
best = result;
|
||||
}
|
||||
|
||||
NestEngineBase.ReportProgress(context.Progress, new ProgressReport
|
||||
{
|
||||
Phase = phase,
|
||||
PlateNumber = context.PlateNumber,
|
||||
Parts = best,
|
||||
WorkArea = workArea,
|
||||
Description = $"{phaseLabel}: {i + 1}/{angles.Count} angles, {angleDeg:F0}° best = {best?.Count ?? 0} parts",
|
||||
});
|
||||
context.ReportProgress(best,
|
||||
$"{phaseLabel}: {i + 1}/{angles.Count} angles, {angleDeg:F0}° best = {best?.Count ?? 0} parts");
|
||||
}
|
||||
|
||||
return best ?? new List<Part>();
|
||||
|
||||
Reference in New Issue
Block a user