refactor: simplify MultiPlateNester by converting to instance class

- Convert static class to instance with private constructor; shared
  parameters (template, plateOptions, salvageRate, minRemnantSize,
  progress, token) become fields, eliminating parameter threading
  across all private methods (10→3 params on Nest entry point stays
  unchanged; private methods drop from 7-9 params to 1-2)
- Extract FillAndPlace helper consolidating the repeated
  clone→fill→add-to-plate→deduct-quantity pattern (was duplicated
  in 4 call sites)
- Merge FindScrapZones/FindViableRemnants (98% duplicate) into single
  FindRemnants(plate, minRemnantSize, scrapOnly) method
- Extract ScoreZone helper and collapse duplicate normal/rotated
  orientation checks into single conditional
- Extract CreateNewPlateResult helper for repeated PlateResult
  construction + PlateOption lookup pattern

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-06 16:08:44 -04:00
parent 1f88453d4c
commit 62d9dce0b1
2 changed files with 321 additions and 384 deletions

View File

@@ -140,7 +140,7 @@ public class MultiPlateNesterTests
}
[Fact]
public void FindScrapZones_ReturnsOnlyScrapRemnants()
public void FindRemnants_ScrapOnly_ReturnsOnlyScrapRemnants()
{
// 96x48 plate with a 70x40 part placed at origin
var plate = new Plate(96, 48) { PartSpacing = 0.25 };
@@ -148,7 +148,7 @@ public class MultiPlateNesterTests
var part = new Part(drawing);
plate.Parts.Add(part);
var scrap = MultiPlateNester.FindScrapZones(plate, 12.0);
var scrap = MultiPlateNester.FindRemnants(plate, 12.0, scrapOnly: true);
// All returned zones should have both dims < 12
foreach (var zone in scrap)