feat: add option to round lead-in angles for circle holes
Snaps lead-in angles on ArcCircle contours to a configurable increment (default 5°), reducing unique hole variations from infinite to 72 max. Rounding happens upstream in EmitContour so the PlateView and post output stay in sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -255,7 +255,23 @@ namespace OpenNest.CNC.CuttingStrategy
|
||||
var leadOut = SelectLeadOut(contourType);
|
||||
|
||||
if (contourType == ContourType.ArcCircle && entity is Circle circle)
|
||||
{
|
||||
if (Parameters.RoundLeadInAngles && Parameters.LeadInAngleIncrement > 0)
|
||||
{
|
||||
var increment = Angle.ToRadians(Parameters.LeadInAngleIncrement);
|
||||
normal = System.Math.Round(normal / increment) * increment;
|
||||
normal = Angle.NormalizeRad(normal);
|
||||
|
||||
// Recompute contour start point on the circle at the rounded angle.
|
||||
// For ArcCircle, normal points inward (toward center), so outward = normal - PI.
|
||||
var outwardAngle = normal - System.Math.PI;
|
||||
point = new Vector(
|
||||
circle.Center.X + circle.Radius * System.Math.Cos(outwardAngle),
|
||||
circle.Center.Y + circle.Radius * System.Math.Sin(outwardAngle));
|
||||
}
|
||||
|
||||
leadIn = ClampLeadInForCircle(leadIn, circle, point, normal);
|
||||
}
|
||||
|
||||
program.Codes.AddRange(leadIn.Generate(point, normal, winding));
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@ namespace OpenNest.CNC.CuttingStrategy
|
||||
|
||||
public double PierceClearance { get; set; } = 0.0625;
|
||||
|
||||
public bool RoundLeadInAngles { get; set; }
|
||||
public double LeadInAngleIncrement { get; set; } = 5.0;
|
||||
|
||||
public double AutoTabMinSize { get; set; }
|
||||
public double AutoTabMaxSize { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user