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>
60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using OpenNest.Geometry;
|
|
using OpenNest.Math;
|
|
|
|
namespace OpenNest.CNC.CuttingStrategy
|
|
{
|
|
public class LineLineLeadIn : LeadIn
|
|
{
|
|
public double Length1 { get; set; }
|
|
public double ApproachAngle1 { get; set; } = 90.0;
|
|
public double Length2 { get; set; }
|
|
public double ApproachAngle2 { get; set; } = 90.0;
|
|
|
|
public override List<ICode> Generate(
|
|
Vector contourStartPoint,
|
|
double contourNormalAngle,
|
|
RotationType winding = RotationType.CW
|
|
)
|
|
{
|
|
var piercePoint = GetPiercePoint(contourStartPoint, contourNormalAngle);
|
|
|
|
var secondAngle = contourNormalAngle - Angle.HalfPI + Angle.ToRadians(ApproachAngle1);
|
|
var midPoint = new Vector(
|
|
contourStartPoint.X + Length2 * System.Math.Cos(secondAngle),
|
|
contourStartPoint.Y + Length2 * System.Math.Sin(secondAngle)
|
|
);
|
|
|
|
return new List<ICode>
|
|
{
|
|
new RapidMove(piercePoint),
|
|
new LinearMove(midPoint) { Layer = LayerType.Leadin },
|
|
new LinearMove(contourStartPoint) { Layer = LayerType.Leadin },
|
|
};
|
|
}
|
|
|
|
public override Vector GetPiercePoint(Vector contourStartPoint, double contourNormalAngle,
|
|
RotationType winding = RotationType.CW)
|
|
{
|
|
var secondAngle = contourNormalAngle - Angle.HalfPI + Angle.ToRadians(ApproachAngle1);
|
|
var midX = contourStartPoint.X + Length2 * System.Math.Cos(secondAngle);
|
|
var midY = contourStartPoint.Y + Length2 * System.Math.Sin(secondAngle);
|
|
|
|
var firstAngle = secondAngle + Angle.ToRadians(ApproachAngle2);
|
|
return new Vector(
|
|
midX + Length1 * System.Math.Cos(firstAngle),
|
|
midY + Length1 * System.Math.Sin(firstAngle)
|
|
);
|
|
}
|
|
|
|
public override LeadIn Scale(double factor) =>
|
|
new LineLineLeadIn
|
|
{
|
|
Length1 = Length1 * factor,
|
|
ApproachAngle1 = ApproachAngle1,
|
|
Length2 = Length2 * factor,
|
|
ApproachAngle2 = ApproachAngle2,
|
|
};
|
|
}
|
|
}
|