From 9537d95d54de7ba39b2d4b5781504a9a17201c98 Mon Sep 17 00:00:00 2001 From: ChenX Date: Fri, 24 Jun 2022 11:05:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=E5=B0=81=E8=BE=B9=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/EdgeSealing/EdgeSealing.test.ts | 14 ++++++++ .../__snapshots__/EdgeSealing.test.ts.snap | 2 ++ src/Common/CurveUtils.ts | 34 ++++++++++--------- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/__test__/EdgeSealing/EdgeSealing.test.ts b/__test__/EdgeSealing/EdgeSealing.test.ts index e59ddf806..45b2e4969 100644 --- a/__test__/EdgeSealing/EdgeSealing.test.ts +++ b/__test__/EdgeSealing/EdgeSealing.test.ts @@ -268,3 +268,17 @@ test('封边数据个数不匹配2', () => expect(orgPtsBul.pts.length === sealData.length).toBeTruthy(); } }); + +test('封边编辑错误', () => +{ + let d = + { "file": [1, "Board", 8, 2, 100, false, 1, 2, 0, [6.123233995736766e-17, 0, 1, 0, -1, 0, 6.123233995736766e-17, 0, 0, -1, 0, 0, 1322.7570621468913, 18, -149.71751412407139, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -659.2429378531087, 18, -1044.7176374870523, 1], 0, 3, 1964, 39.999976675015674, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 39.999976675014835, 803.6000000000058, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4.547473508864641e-13, 803.6000000000058, 0, 1], 0, 2, 6, [-0.00010003799802404929, 1160.3999999999942], 0, [8.384406944863992e-13, 1160.3999999999942], 0, [-0.00010003799801694413, 1160.3999999999942], 0, [-39.999976675013876, 1160.3999999999937], 0, [-39.999976675014835, -803.6000000000058], 0, [-4.547473508864641e-13, -803.6000000000058], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "收口", "鞋柜", " 柜1", "兔宝宝烟熏橡木(灰)生态板", "生态板", "烟熏橡木(灰)", 0, 0, "不排", 2, 0, "1", "1", "1", "1", "", "", "", 6, "不排", "不排", "不排", "不排", "不排", "不排", false, false, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": -641.2429378531087, "y": 0, "z": -149.71751412407139 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] }; + + let brs = LoadBoardsFromFileData(d); + + for (let br of brs) + { + let orgContour = GetSealedBoardContour(br, true, true); + expect(orgContour.Length).toMatchNumberSnapshot(); + } +}); diff --git a/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap index c61df9793..6e0292c0d 100644 --- a/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap +++ b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap @@ -24,6 +24,8 @@ exports[`切割残留一个小于封边厚度的凸角的板件封边 3`] = `"30 exports[`切割残留一个小于封边厚度的凸角的板件封边 4`] = `"1273.00000"`; +exports[`封边编辑错误 1`] = `"4007.99985"`; + exports[`封边错误板件 1`] = `"130118.40950"`; exports[`封边错误板件2 1`] = `"779770.96110"`; diff --git a/src/Common/CurveUtils.ts b/src/Common/CurveUtils.ts index fd8f15d25..ac862a3dc 100644 --- a/src/Common/CurveUtils.ts +++ b/src/Common/CurveUtils.ts @@ -15,7 +15,7 @@ import { Orbit } from '../Geometry/Orbit'; import { PlaneExt } from '../Geometry/Plane'; import { IntersectOption, IntersectResult } from '../GraphicsSystem/IntersectWith'; import { OffsetPolyline } from '../GraphicsSystem/OffsetPolyline'; -import { arrayLast, arrayRemoveDuplicateBySort, changeArrayStartIndex, equalArray } from './ArrayExt'; +import { arrayLast, arrayRemoveDuplicateBySort, arrayRemoveIf, changeArrayStartIndex, equalArray } from './ArrayExt'; import { Status } from './Status'; import { FixIndex, LINK_FUZZ } from './Utils'; @@ -571,25 +571,27 @@ export function getRectFrom4Pts(pts: Vector3[]) export function MergeCurvelist(cus: Curve[]) { - for (let i = 0; i < cus.length; i++) + arrayRemoveIf(cus, c => c.Length < LINK_FUZZ); + + let cir: Circle; + arrayRemoveDuplicateBySort(cus, (c1, c2) => { - let c1 = cus[i]; - let nextI = FixIndex(i + 1, cus); - let c2 = cus[nextI]; + if (cir) return true; - let status = equaln(c2.Length, 0, LINK_FUZZ) ? Status.True : c1.Join(c2, false, LINK_FUZZ); - if (status === Status.True) - { - cus.splice(nextI, 1); - i--; - } - else if (status === Status.ConverToCircle) + let status = c1.Join(c2, false, LINK_FUZZ); + if (status === Status.ConverToCircle) { - cus.length = 0; - let a = c1 as Arc; - cus.push(new Circle(a.Center, a.Radius)); - break; + let arc = c1 as Arc; + cir = new Circle(arc.Center, arc.Radius); + return true; } + return status === Status.True; + }); + + if (cir) + { + cus.length = 0; + cus.push(cir); } return cus; }