From 48b62e953fd4a37c89ea7ac6798b1cb6d18b2c86 Mon Sep 17 00:00:00 2001 From: ZoeLeeFZ Date: Tue, 3 Nov 2020 13:51:47 +0800 Subject: [PATCH] =?UTF-8?q?!1226=20=E4=BC=98=E5=8C=96:=E5=B0=81=E8=BE=B9?= =?UTF-8?q?=E8=BD=AE=E5=BB=93=E7=9A=84=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/EdgeSealing/EdgeSealing.test.ts | 15 +++++++ .../__snapshots__/EdgeSealing.test.ts.snap | 4 ++ src/Add-on/TestFb.ts | 5 +++ src/GraphicsSystem/CalcEdgeSealing.ts | 41 +++++++++++++++---- 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/__test__/EdgeSealing/EdgeSealing.test.ts b/__test__/EdgeSealing/EdgeSealing.test.ts index f038a2c24..f484290fb 100644 --- a/__test__/EdgeSealing/EdgeSealing.test.ts +++ b/__test__/EdgeSealing/EdgeSealing.test.ts @@ -165,3 +165,18 @@ test("封边错误板件4", () => expect(con.Area).toMatchSnapshot(); }); + +test("切割残留一个封边厚度的凸角的板件封边", () => +{ + let data = { "file": [2, "Board", 8, 2, 100, false, 1, 4, 0, [0, -1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 1, 0, 0, 0, 8353.923342626775, 3430.066255566897, 54.00000000000023, 1], 0, 0, true, [1, 0, 0, 0, 0, -1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 8353.923342626775, 3430.066255566897, 54.00000000000023, 1], 0, 3, 605, 54, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 605, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1.3642420526593924e-12, 0, 1], 0, 2, 6, [1.999999999999659, -605], 0, [0, -605], 0, [0, 0], 0, [54, 0], 0, [54, -587], 0, [1.999999999999659, -587], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "右收口条", "1", "主卧飘窗柜", "", "流金岁月零度实木多层板", "", 0, 0, "不排", 2, 0, "1", "1", "1", "1", "", "", "", 6, "不排", "不排", "不排", "不排", "不排", "不排", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 119, false, 1, 4, 0, [0, -1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 1, 0, 0, 0, 8256.448416684603, 3420.712904620689, 54.000000000000114, 1], 0, 0, true, [1, 0, 0, 0, 0, -1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 8256.448416684603, 3420.712904620689, 54.000000000000114, 1], 0, 3, 605, 54, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 605, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1.3642420526593924e-12, 0, 1], 0, 2, 6, [1.999999999999659, -605], 0, [1.999999999999659, -587], 0, [54, -587], 0, [54, 0], 0, [0, 0], 0, [0, -605], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "右收口条", "1", "主卧飘窗柜", "", "流金岁月零度实木多层板", "", 0, 0, "不排", 2, 0, "1", "1", "1", "1", "", "", "", 6, "不排", "不排", "不排", "不排", "不排", "不排", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": 8256.448416684603, "y": 3420.712904620689, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let brs = LoadBoardsFromFileData(data); + + let con = GetSealedBoardContour(brs[0], false); + expect(con.IsClose).toBeTruthy(); + expect(con.Area).toMatchSnapshot(); + + con = GetSealedBoardContour(brs[1], false); + expect(con.IsClose).toBeTruthy(); + expect(con.Area).toMatchSnapshot(); + +}); diff --git a/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap index 2bdd43588..9f632c851 100644 --- a/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap +++ b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap @@ -4,6 +4,10 @@ exports[`丢失线段板件 1`] = `554052.5007766777`; exports[`丢失线段板件 2`] = `398758.8789695821`; +exports[`切割残留一个封边厚度的凸角的板件封边 1`] = `30420`; + +exports[`切割残留一个封边厚度的凸角的板件封边 2`] = `30420`; + exports[`封边错误板件 1`] = `130118.4094685434`; exports[`封边错误板件2 1`] = `779770.9650700318`; diff --git a/src/Add-on/TestFb.ts b/src/Add-on/TestFb.ts index 91bcf3475..f09762d84 100644 --- a/src/Add-on/TestFb.ts +++ b/src/Add-on/TestFb.ts @@ -25,6 +25,8 @@ export class TestFb implements Command brs.push(...e.SplitBoards); let showCus: Curve[] = []; + let errBrs: Board[] = []; + for (let br of brs) { let pl = GetSealedBoardContour(br, false); @@ -35,10 +37,13 @@ export class TestFb implements Command } else { + errBrs.push(br); app.Editor.Prompt("警告:该板件无法得到模拟封边结果!"); } } + app.Viewer.OutlinePass.selectedObjects = errBrs.map(b => b.DrawObject); + if (showCus.length === 0) return; diff --git a/src/GraphicsSystem/CalcEdgeSealing.ts b/src/GraphicsSystem/CalcEdgeSealing.ts index cc4888227..e1311fdf2 100644 --- a/src/GraphicsSystem/CalcEdgeSealing.ts +++ b/src/GraphicsSystem/CalcEdgeSealing.ts @@ -134,12 +134,31 @@ export function CalcEdgeSealing(cus: Curve[]) if (!frontLine || !laterLine) { alert("获取封边错误,请提供图纸给相关人员"); - return; + return false; } let dist = frontLine.EndPoint.distanceToSquared(laterLine.StartPoint); if (dist < LINK_FUZZ ** 2) + { + if (frontLine instanceof Line && laterLine instanceof Line) + { + if (frontLine.PtOnCurve(laterLine.EndPoint)) + { + cus.splice(laterIndex, 1); + if (laterIndex === 0) + firstLine = cus[0].Clone(); + i -= 2; + } + else if (laterLine.PtOnCurve(frontLine.StartPoint)) + { + cus.splice(i, 1); + i -= 2; + if (i < -1) + i = -1; + } + } continue; + } let refLine = oldLine ?? frontLine; let refLine2 = i === cus.length - 1 ? firstLine : laterLine; @@ -154,10 +173,10 @@ export function CalcEdgeSealing(cus: Curve[]) if (!iPt) { alert("获取封边错误,请提供图纸给相关人员"); - return; + return false; } let par = frontLine.GetParamAtPoint(iPt); - if (par < 0) + if (par < 1e-6) { cus.splice(i, 1); i -= 2; @@ -166,17 +185,25 @@ export function CalcEdgeSealing(cus: Curve[]) } else frontLine.EndPoint = iPt; - oldLine = equalv3(iPt, laterLine.EndPoint) ? laterLine.Clone() : null; par = laterLine.GetParamAtPoint(iPt); - if (par > 1) + if (par > 1 - 1e-6) { cus.splice(laterIndex, 1); - i -= 1; + if (laterIndex === 0) + { + firstLine = cus[0].Clone(); + i -= 2; + } + else + i--; + if (i < -1) + i = -1; } else laterLine.StartPoint = iPt; } + return true; } export function GetBoardHighSeal(br: Board, sealcus: Curve[]) @@ -305,7 +332,7 @@ export function GetSealedBoardContour(br: Board, hasSealing: boolean): Polyline if (offsetCus.length === 1 && offsetCus[0] instanceof Circle) return offsetCus[0] as Circle; - CalcEdgeSealing(offsetCus); + if (!CalcEdgeSealing(offsetCus)) return; let pl = Polyline.Combine(offsetCus, LINK_FUZZ); if (dir < 0) pl.Reverse();