mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-22 02:07:40 -05:00
feat: add LeadInAssigner for auto-assigning lead-ins to plate parts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
a2a19938d3
commit
f34dce95da
2 files changed
+138
No files matched your search
@@ -0,0 +1,40 @@
|
||||
using OpenNest.Engine.Sequencing;
|
||||
using OpenNest.Geometry;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenNest.Engine
|
||||
{
|
||||
public class LeadInAssigner
|
||||
{
|
||||
public IPartSequencer Sequencer { get; set; }
|
||||
|
||||
public void Assign(Plate plate)
|
||||
{
|
||||
var parameters = plate.CuttingParameters;
|
||||
if (parameters == null)
|
||||
return;
|
||||
|
||||
var sequenced = Sequencer.Sequence(plate.Parts.ToList(), plate);
|
||||
var currentPoint = PlateHelper.GetExitPoint(plate);
|
||||
|
||||
foreach (var sp in sequenced)
|
||||
{
|
||||
var part = sp.Part;
|
||||
|
||||
if (part.LeadInsLocked)
|
||||
{
|
||||
currentPoint = part.Location;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (part.HasManualLeadIns)
|
||||
part.RemoveLeadIns();
|
||||
|
||||
var localApproach = currentPoint - part.Location;
|
||||
part.ApplyLeadIns(parameters, localApproach);
|
||||
|
||||
currentPoint = part.Location;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user