fix(io): handle flipped OCS normal on DXF ellipse import
Ellipses with extrusion direction Z=-1 had their parametric direction reversed, causing the curve to appear mirrored. Negate start/end parameters when Normal.Z < 0 to correct the minor-axis traversal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -181,13 +181,22 @@ namespace OpenNest.IO
|
||||
{
|
||||
var center = new Vector(ellipse.Center.X, ellipse.Center.Y);
|
||||
var majorAxis = new Vector(ellipse.MajorAxisEndPoint.X, ellipse.MajorAxisEndPoint.Y);
|
||||
var semiMajor = System.Math.Sqrt(majorAxis.X * majorAxis.X + majorAxis.Y * majorAxis.Y);
|
||||
var semiMinor = semiMajor * ellipse.RadiusRatio;
|
||||
var rotation = System.Math.Atan2(majorAxis.Y, majorAxis.X);
|
||||
|
||||
var startParam = ellipse.StartParameter;
|
||||
var endParam = ellipse.EndParameter;
|
||||
|
||||
if (ellipse.Normal.Z < 0)
|
||||
{
|
||||
var newStart = OpenNest.Math.Angle.TwoPI - endParam;
|
||||
var newEnd = OpenNest.Math.Angle.TwoPI - startParam;
|
||||
startParam = newStart;
|
||||
endParam = newEnd;
|
||||
}
|
||||
|
||||
var semiMajor = System.Math.Sqrt(majorAxis.X * majorAxis.X + majorAxis.Y * majorAxis.Y);
|
||||
var semiMinor = semiMajor * ellipse.RadiusRatio;
|
||||
var rotation = System.Math.Atan2(majorAxis.Y, majorAxis.X);
|
||||
|
||||
var layer = ellipse.Layer.ToOpenNest();
|
||||
var color = ellipse.ResolveColor();
|
||||
var lineTypeName = ellipse.ResolveLineTypeName();
|
||||
|
||||
Reference in New Issue
Block a user