diff --git a/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap b/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap index 842c75702..994bebc31 100644 --- a/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap +++ b/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap @@ -333,3 +333,37 @@ Object { ], } `; + +exports[`正方形造型走刀点重复`] = ` +Array [ + { + "buls":Array [0,0,0,0,0,0], + "pts":Array [ + Vector2{ + "x": 87.90793650793671, + "y": 269.57777777786595 + }, + Vector2{ + "x": 87.90793650793671, + "y": 309.57777777786595 + }, + Vector2{ + "x": 127.90793650793671, + "y": 309.57777777786595 + }, + Vector2{ + "x": 127.90793650793671, + "y": 269.57777777786595 + }, + Vector2{ + "x": 87.90793650793671, + "y": 269.57777777786595 + }, + Vector2{ + "x": 107.90793650793671, + "y": 289.57777777786595 + } + ] + } +], +`; diff --git a/__test__/EdgeSealing/seal.test.ts b/__test__/EdgeSealing/seal.test.ts index 51374ff22..88aff8adc 100644 --- a/__test__/EdgeSealing/seal.test.ts +++ b/__test__/EdgeSealing/seal.test.ts @@ -166,3 +166,19 @@ test('镜像保证封边结果正确性', () => }).toMatchSnapshot(); } }); + +test('正方形造型走刀点重复', () => +{ + let d = + { "file": [1, "Board", 10, 2, 9434, 0, 1, 3, 71, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 1017.9060474906582, -865.5925005405443, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1017.9060474906582, -865.5925005405443, 0, 1], 0, 0, 1, 3, 600, 400, 18, true, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, -1.8947806286936006e-16, 0, 0, 1.8947806286936006e-16, 1, 0, 0, 600, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -1680.1168444058253, -89.46015424186737, -865.5925005405442, 1], 0, 0, 1, 2, 4, [0, -600], 0, [400, -600], 0, [400, 0], 0, [0, 0], 0, true, 1, 3, 60, 60, 5, true, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 60, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -1759.024780913762, -350.0379320197333, -865.5925005405442, 1], 0, 0, 1, 2, 4, [60, 0], 0, [0, 0], 0, [0, -60], 0, [60, -60], 0, true, 0, 10, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 1096.813983998595, -878.5925005405443, 260.57777777786595, 1], 3, 0, 0, 0, 0, 0, 13, 2, "背板", "", "", "", "", "", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null, 0, 0], "basePt": { "x": 1017.9060474906582, "y": -883.5925005405443, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 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.modeling[0].feeding + ]).toMatchSnapshot(); + } +}); diff --git a/src/GraphicsSystem/ToolPath/OptimizeToolPath.ts b/src/GraphicsSystem/ToolPath/OptimizeToolPath.ts index 6fc8f87f9..d5c37364b 100644 --- a/src/GraphicsSystem/ToolPath/OptimizeToolPath.ts +++ b/src/GraphicsSystem/ToolPath/OptimizeToolPath.ts @@ -91,7 +91,7 @@ export function OptimizeToolPath(offsetCus: Curve[], originShape: Shape, rad: nu //对多段线进行排序,按最起始点远近排序 SortPlByStartPt(plList); - let result: Curve[] = []; + let result: Polyline[] = []; let firstPl = plList[0]; firstPl.CloseMark = false; @@ -118,16 +118,20 @@ export function OptimizeToolPath(offsetCus: Curve[], originShape: Shape, rad: nu let alMat = matrixAlignCoordSys(plList[i].OCS, firstPl.OCS); let cuPtsBul = plList[i].PtsBuls; - for (let i = 0; i < cuPtsBul.pts.length; i++) + for (let j = 0; j < cuPtsBul.pts.length; j++) { //坐标系对齐 - let p = cuPtsBul.pts[i]; + let p = cuPtsBul.pts[j]; p.copy(AsVector2(AsVector3(p).applyMatrix4(alMat))); - firstPl.LineData.push({ pt: p, bul: cuPtsBul.buls[i] }); + firstPl.LineData.push({ pt: p, bul: cuPtsBul.buls[j] }); } } } result.push(firstPl); + + for (let pl of result) + pl.RemoveRepeatPos(1e-3); + return result; }