修复:封边计算失败导致死循环崩溃

pull/2357/MERGE
ChenX 1 year ago
parent 6253cd8f61
commit 7192dfc5f9

@ -174,3 +174,72 @@ Object {
],
}
`;
exports[`补圆错误导致的局部偏移错误 1`] = `
Object {
"buls": Array [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
"pts": Array [
Vector2 {
"x": 0,
"y": 0,
},
Vector2 {
"x": 104.28333333333332,
"y": 0,
},
Vector2 {
"x": 104.28333333333332,
"y": 73.75000000000185,
},
Vector2 {
"x": 122.78333333333332,
"y": 73.75000000000185,
},
Vector2 {
"x": 122.78333333333332,
"y": 0,
},
Vector2 {
"x": 227.81666666666663,
"y": 1.4210854715202004e-14,
},
Vector2 {
"x": 227.81666666666663,
"y": 73.75000000000185,
},
Vector2 {
"x": 246.31666666666663,
"y": 73.75000000000185,
},
Vector2 {
"x": 246.31666666666663,
"y": 0,
},
Vector2 {
"x": 350.59999999999997,
"y": 0,
},
Vector2 {
"x": 350.5999999999999,
"y": 141.5000000000037,
},
Vector2 {
"x": 0,
"y": 141.5000000000037,
},
],
}
`;

@ -117,3 +117,18 @@ test('矩形板拆单的时候,给一个原始矩形轮廓', () =>
expect(data.outline).toMatchSnapshot();
}
});
test('补圆错误导致的局部偏移错误', () =>
{
let d =
{ "file": [1, "Board", 10, 2, 76256, 0, 1, 11, 71, [0, 0.9999999999999999, 0, 0, 0, 0, 0.9999999999999999, 0, 1, 0, 0, 0, 18791.77842986962, 0, -19079.776773990132, 1], 0, 0, 1, [1, 0, 0, 0, 0, 0.9999999999999999, 0, 0, 0, 0, 0.9999999999999999, 0, 18508.71176320296, -0.20000000000000284, -19079.776773990132, 1], 0, 0, 1, 3, 143.5000000000037, 352.59999999999997, 18, false, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, 2, 13, [0, 0], 0, [105.28333333333332, 0], 0, [105.28333333333332, 74.75000000000185], 0, [123.78333333333332, 74.75000000000185], 0, [123.78333333333332, 0], 0, [228.81666666666663, 0], 0, [228.81666666666663, 74.75000000000185], 0, [247.31666666666663, 74.75000000000185], 0, [247.31666666666663, 0], 0, [352.59999999999997, 0], 0, [352.59999999999997, 143.5000000000037], 0, [0.1, 143.5000000000037], 0.41421356237309503, [0, 143.4000000000037], 0, true, 0, 3, 0, 0, 0, 0, 0, 13, 1, "竖板1", "5", "衣帽间B", "", "鲁丽欧松", "绅士灰", 2, 0, "不排", 2, 11, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, "1", "1", "1", "1", "", "", "", 13, "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null, 0, 0], "basePt": { "x": 18791.77842986962, "y": 0, "z": -19079.776773990132 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] };
let brs = LoadEntityFromFileData(d) as Board[];
for (let br of brs)
{
br.objectId = new ObjectId(101);//创造101
let data = Production.GetBoardSplitOrderData(br);
expect(data.outline).toMatchSnapshot();
}
});

@ -384,6 +384,8 @@ export function GetSealedBoardContour(br: Board): BrSealedData | undefined
//trim Circle
if (seal.size && (j || seal.size === preSeal.size))
polylineOffset._Circles.push(new Circle(c.StartPoint, seal.size));
else
polylineOffset._Circles.push(undefined);
//offset
let offsetC = c.GetOffsetCurves(dir * -seal.size)[0];
@ -408,6 +410,8 @@ export function GetSealedBoardContour(br: Board): BrSealedData | undefined
//trim Circle
if (seal.size && seal.size === preSeal.size)
polylineOffset._Circles.push(new Circle(curve.StartPoint, seal.size));
else
polylineOffset._Circles.push(undefined);
//offset
let offsetC = curve.GetOffsetCurves(dir * -seal.size)[0];

@ -415,9 +415,11 @@ export class OffsetPolyline
for (let s = FixIndex(curveResNow.index + 1, this._Circles); ; s = FixIndex(s + 1, this._Circles))
{
let circle = this._Circles[s];
if (!circle) continue;//因为局部偏移可能未提供圆
this._TrimCircleContours.push(circle);
padCirs.push(circle);
if (circle)//因为局部偏移可能未提供圆
{
this._TrimCircleContours.push(circle);
padCirs.push(circle);
}
if (s === curveResNext.index)
break;
}

Loading…
Cancel
Save