feat: add RowFillStrategy and ColumnFillStrategy with registry integration
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenNest.Engine.Fill;
|
||||||
|
|
||||||
|
namespace OpenNest.Engine.Strategies;
|
||||||
|
|
||||||
|
public class ColumnFillStrategy : IFillStrategy
|
||||||
|
{
|
||||||
|
public string Name => "Column";
|
||||||
|
public NestPhase Phase => NestPhase.Custom;
|
||||||
|
public int Order => 160;
|
||||||
|
|
||||||
|
public List<Part> Fill(FillContext context)
|
||||||
|
{
|
||||||
|
var filler = new StripeFiller(context, NestDirection.Vertical);
|
||||||
|
return filler.Fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenNest.Engine.Fill;
|
||||||
|
|
||||||
|
namespace OpenNest.Engine.Strategies;
|
||||||
|
|
||||||
|
public class RowFillStrategy : IFillStrategy
|
||||||
|
{
|
||||||
|
public string Name => "Row";
|
||||||
|
public NestPhase Phase => NestPhase.Custom;
|
||||||
|
public int Order => 150;
|
||||||
|
|
||||||
|
public List<Part> Fill(FillContext context)
|
||||||
|
{
|
||||||
|
var filler = new StripeFiller(context, NestDirection.Horizontal);
|
||||||
|
return filler.Fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ public class FillPipelineTests
|
|||||||
|
|
||||||
engine.Fill(item, plate.WorkArea(), null, System.Threading.CancellationToken.None);
|
engine.Fill(item, plate.WorkArea(), null, System.Threading.CancellationToken.None);
|
||||||
|
|
||||||
Assert.True(engine.PhaseResults.Count >= 4,
|
Assert.True(engine.PhaseResults.Count >= 6,
|
||||||
$"Expected phase results from all strategies, got {engine.PhaseResults.Count}");
|
$"Expected phase results from all strategies, got {engine.PhaseResults.Count}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,8 @@ public class FillPipelineTests
|
|||||||
Assert.True(engine.WinnerPhase == NestPhase.Pairs ||
|
Assert.True(engine.WinnerPhase == NestPhase.Pairs ||
|
||||||
engine.WinnerPhase == NestPhase.Linear ||
|
engine.WinnerPhase == NestPhase.Linear ||
|
||||||
engine.WinnerPhase == NestPhase.RectBestFit ||
|
engine.WinnerPhase == NestPhase.RectBestFit ||
|
||||||
engine.WinnerPhase == NestPhase.Extents);
|
engine.WinnerPhase == NestPhase.Extents ||
|
||||||
|
engine.WinnerPhase == NestPhase.Custom);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Linq;
|
||||||
using OpenNest.Engine.Strategies;
|
using OpenNest.Engine.Strategies;
|
||||||
|
|
||||||
namespace OpenNest.Tests.Strategies;
|
namespace OpenNest.Tests.Strategies;
|
||||||
@@ -9,11 +10,13 @@ public class FillStrategyRegistryTests
|
|||||||
{
|
{
|
||||||
var strategies = FillStrategyRegistry.Strategies;
|
var strategies = FillStrategyRegistry.Strategies;
|
||||||
|
|
||||||
Assert.True(strategies.Count >= 4, $"Expected at least 4 built-in strategies, got {strategies.Count}");
|
Assert.True(strategies.Count >= 6, $"Expected at least 6 built-in strategies, got {strategies.Count}");
|
||||||
Assert.Contains(strategies, s => s.Name == "Pairs");
|
Assert.Contains(strategies, s => s.Name == "Pairs");
|
||||||
Assert.Contains(strategies, s => s.Name == "RectBestFit");
|
Assert.Contains(strategies, s => s.Name == "RectBestFit");
|
||||||
Assert.Contains(strategies, s => s.Name == "Extents");
|
Assert.Contains(strategies, s => s.Name == "Extents");
|
||||||
Assert.Contains(strategies, s => s.Name == "Linear");
|
Assert.Contains(strategies, s => s.Name == "Linear");
|
||||||
|
Assert.Contains(strategies, s => s.Name == "Row");
|
||||||
|
Assert.Contains(strategies, s => s.Name == "Column");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -34,4 +37,19 @@ public class FillStrategyRegistryTests
|
|||||||
|
|
||||||
Assert.Equal("Linear", last.Name);
|
Assert.Equal("Linear", last.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Registry_RowAndColumnOrderedBetweenPairsAndRectBestFit()
|
||||||
|
{
|
||||||
|
var strategies = FillStrategyRegistry.Strategies;
|
||||||
|
var pairsOrder = strategies.First(s => s.Name == "Pairs").Order;
|
||||||
|
var rectOrder = strategies.First(s => s.Name == "RectBestFit").Order;
|
||||||
|
var rowOrder = strategies.First(s => s.Name == "Row").Order;
|
||||||
|
var colOrder = strategies.First(s => s.Name == "Column").Order;
|
||||||
|
|
||||||
|
Assert.True(rowOrder > pairsOrder, "Row should run after Pairs");
|
||||||
|
Assert.True(colOrder > pairsOrder, "Column should run after Pairs");
|
||||||
|
Assert.True(rowOrder < rectOrder, "Row should run before RectBestFit");
|
||||||
|
Assert.True(colOrder < rectOrder, "Column should run before RectBestFit");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user