From 7192dfc5f96ef1571faf96b3d08f056914c35171 Mon Sep 17 00:00:00 2001 From: ChenX Date: Thu, 10 Aug 2023 16:10:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=E5=B0=81=E8=BE=B9=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E5=A4=B1=E8=B4=A5=E5=AF=BC=E8=87=B4=E6=AD=BB=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/seal.test.ts.snap | 69 +++++++++++++++++++ __test__/EdgeSealing/seal.test.ts | 15 ++++ src/GraphicsSystem/CalcEdgeSealing.ts | 4 ++ src/GraphicsSystem/OffsetPolyline.ts | 8 ++- 4 files changed, 93 insertions(+), 3 deletions(-) diff --git a/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap b/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap index d9322e9fe..69e3125c2 100644 --- a/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap +++ b/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap @@ -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, + }, + ], +} +`; diff --git a/__test__/EdgeSealing/seal.test.ts b/__test__/EdgeSealing/seal.test.ts index e01030f11..0c72b3743 100644 --- a/__test__/EdgeSealing/seal.test.ts +++ b/__test__/EdgeSealing/seal.test.ts @@ -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(); + } +}); diff --git a/src/GraphicsSystem/CalcEdgeSealing.ts b/src/GraphicsSystem/CalcEdgeSealing.ts index 23a12d14c..dd0c75c60 100644 --- a/src/GraphicsSystem/CalcEdgeSealing.ts +++ b/src/GraphicsSystem/CalcEdgeSealing.ts @@ -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]; diff --git a/src/GraphicsSystem/OffsetPolyline.ts b/src/GraphicsSystem/OffsetPolyline.ts index 61b9f6aaa..01f053b1c 100644 --- a/src/GraphicsSystem/OffsetPolyline.ts +++ b/src/GraphicsSystem/OffsetPolyline.ts @@ -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; }