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:
40
OpenNest.Engine/LeadInAssigner.cs
Normal file
40
OpenNest.Engine/LeadInAssigner.cs
Normal file
@@ -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