优化:避免椭圆转多段线失败

pull/2693/head
ChenX 6 months ago
parent ea75b0f610
commit 1a6a0bd193

@ -29,3 +29,12 @@ test('任意轴坐标系椭圆', () =>
expect(dxfel).toMatchSnapshot();
}
});
test('椭圆转换失败', () =>
{
let d =
{ "file": [1, "Ellipse", 10, 2, 100, 0, 1, 1, 71, [1, 0, 0, 0, 0, -1.8369701987210297e-16, 1, 0, 0, -1, -1.8369701987210297e-16, 0, 1773.6340891544241, 1.26299050262124e-15, -67.1038026928436, 1], 0, 0, 1, [1, 0, 0, 0, 0, -1.8369701987210297e-16, 1, 0, 0, -1, -1.8369701987210297e-16, 0, -623492.8962939418, 2.0719830672442248e-11, -112853.73309240425, 1], 0, 0, 1, 1, 13.610857868193955, 13.610857866349484, 0.7853981633974483, 6.027332289796344, 12.31051759697593], "basePt": { "x": 1785.3807617847342, "y": -4.409732460185456e-28, "z": -60.22840262646787 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] };
let el = LoadEntityFromFileData(d.file)[0] as Ellipse;
el.Convert2Polyline();
});

@ -539,7 +539,9 @@ export class Ellipse extends Curve
}
}
}
Convert2Polyline(count = 0)
Convert2Polyline(count = 0): Polyline
{
const MIN_LEN = 80;
const par = this.TotalAngle / Math.PI * 0.5;
@ -558,6 +560,13 @@ export class Ellipse extends Curve
if (this.IsClose)
pts.pop();
//忽略空多段线怎么样?
if (pts.length < 2)
{
let pl = new Polyline;
return pl;
}
let pl = Pts2Polyline(pts, this.IsClose);
pl.ColorIndex = this.ColorIndex;
pl.ApplyMatrix(this.OCS);

Loading…
Cancel
Save