mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-04 05:19:24 -05:00
Curved leads turned with the contour winding, which is backwards on outside perimeters: arc lead-ins arrived against the cut, and Line + Arc / arc lead-outs went the long way round on one winding. LeadTurn now gives the arc's turn direction for emission, the pierce-zone check and the preview, and the arc geometry mirrors with it. At convex outside corners, curved lead-ins use the first-cut edge's normal and arc lead-outs the last-cut edge's, whichever edge was picked. ArcLeadIn gains SweepAngle (degrees, (0, 180], default 180) in the cutting panel, settings, nest files and cut pins; older files read as 180. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using OpenNest.Geometry;
|
|
using OpenNest.Math;
|
|
|
|
namespace OpenNest.CNC.CuttingStrategy
|
|
{
|
|
public class LineLeadIn : LeadIn
|
|
{
|
|
public double Length { get; set; }
|
|
public double ApproachAngle { get; set; } = 90.0;
|
|
|
|
public override List<ICode> Generate(
|
|
Vector contourStartPoint,
|
|
double contourNormalAngle,
|
|
RotationType winding = RotationType.CW
|
|
)
|
|
{
|
|
var piercePoint = GetPiercePoint(contourStartPoint, contourNormalAngle);
|
|
|
|
return new List<ICode>
|
|
{
|
|
new RapidMove(piercePoint),
|
|
new LinearMove(contourStartPoint) { Layer = LayerType.Leadin },
|
|
};
|
|
}
|
|
|
|
public override Vector GetPiercePoint(Vector contourStartPoint, double contourNormalAngle,
|
|
RotationType winding = RotationType.CW)
|
|
{
|
|
var approachAngle = contourNormalAngle - Angle.HalfPI + Angle.ToRadians(ApproachAngle);
|
|
return new Vector(
|
|
contourStartPoint.X + Length * System.Math.Cos(approachAngle),
|
|
contourStartPoint.Y + Length * System.Math.Sin(approachAngle)
|
|
);
|
|
}
|
|
|
|
public override LeadIn Scale(double factor) =>
|
|
new LineLeadIn { Length = Length * factor, ApproachAngle = ApproachAngle };
|
|
}
|
|
}
|