perf: remove automatic angle sweep in linear fill
Remove NeedsSweep that triggered a 5-degree sweep (36 angles) when the work area was narrower than the part. Position matters more than angle for narrow areas, and the base angles (bestRotation + 90deg) cover the useful cases. ForceFullSweep still works for training. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,7 +27,7 @@ namespace OpenNest.Engine.Fill
|
|||||||
|
|
||||||
var angles = new List<double>(baseAngles);
|
var angles = new List<double>(baseAngles);
|
||||||
|
|
||||||
if (NeedsSweep(item, bestRotation, workArea))
|
if (ForceFullSweep)
|
||||||
AddSweepAngles(angles);
|
AddSweepAngles(angles);
|
||||||
|
|
||||||
if (!ForceFullSweep && angles.Count > 2)
|
if (!ForceFullSweep && angles.Count > 2)
|
||||||
@@ -36,18 +36,6 @@ namespace OpenNest.Engine.Fill
|
|||||||
return angles;
|
return angles;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool NeedsSweep(NestItem item, double bestRotation, Box workArea)
|
|
||||||
{
|
|
||||||
var testPart = new Part(item.Drawing);
|
|
||||||
if (!bestRotation.IsEqualTo(0))
|
|
||||||
testPart.Rotate(bestRotation);
|
|
||||||
testPart.UpdateBounds();
|
|
||||||
|
|
||||||
var partLongestSide = System.Math.Max(testPart.BoundingBox.Width, testPart.BoundingBox.Length);
|
|
||||||
var workAreaShortSide = System.Math.Min(workArea.Width, workArea.Length);
|
|
||||||
return workAreaShortSide < partLongestSide || ForceFullSweep;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void AddSweepAngles(List<double> angles)
|
private static void AddSweepAngles(List<double> angles)
|
||||||
{
|
{
|
||||||
var step = Angle.ToRadians(5);
|
var step = Angle.ToRadians(5);
|
||||||
|
|||||||
@@ -29,18 +29,16 @@ public class AngleCandidateBuilderTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Build_NarrowWorkArea_ProducesMoreAngles()
|
public void Build_NarrowWorkArea_UsesBaseAnglesOnly()
|
||||||
{
|
{
|
||||||
var builder = new AngleCandidateBuilder();
|
var builder = new AngleCandidateBuilder();
|
||||||
var item = new NestItem { Drawing = MakeRectDrawing(20, 10) };
|
var item = new NestItem { Drawing = MakeRectDrawing(20, 10) };
|
||||||
var wideArea = new Box(0, 0, 100, 100);
|
|
||||||
var narrowArea = new Box(0, 0, 100, 8); // narrower than part's longest side
|
var narrowArea = new Box(0, 0, 100, 8); // narrower than part's longest side
|
||||||
|
|
||||||
var wideAngles = builder.Build(item, 0, wideArea);
|
var angles = builder.Build(item, 0, narrowArea);
|
||||||
var narrowAngles = builder.Build(item, 0, narrowArea);
|
|
||||||
|
|
||||||
Assert.True(narrowAngles.Count > wideAngles.Count,
|
// Without ForceFullSweep, narrow areas use only base angles (0° and 90°)
|
||||||
$"Narrow ({narrowAngles.Count}) should have more angles than wide ({wideAngles.Count})");
|
Assert.Equal(2, angles.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
Reference in New Issue
Block a user