From 4c6b47432bc1661b8834cf5c7b58abd9cdca29f0 Mon Sep 17 00:00:00 2001 From: ChenX Date: Mon, 19 Dec 2022 16:52:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=E6=94=B9=E8=BF=9B=E5=B8=83?= =?UTF-8?q?=E5=B0=94=E7=9A=84=E7=B2=BE=E5=BA=A6=E6=95=B0=E5=80=BC,?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E6=8E=92=E9=92=BB=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Booloperate/__snapshots__/bool6.test.ts.snap | 3 +++ __test__/Booloperate/bool6.test.ts | 16 ++++++++++++++++ src/DatabaseServices/Contour.ts | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 __test__/Booloperate/__snapshots__/bool6.test.ts.snap create mode 100644 __test__/Booloperate/bool6.test.ts diff --git a/__test__/Booloperate/__snapshots__/bool6.test.ts.snap b/__test__/Booloperate/__snapshots__/bool6.test.ts.snap new file mode 100644 index 000000000..1639f3b05 --- /dev/null +++ b/__test__/Booloperate/__snapshots__/bool6.test.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`无法求到交集 1`] = `6966`; diff --git a/__test__/Booloperate/bool6.test.ts b/__test__/Booloperate/bool6.test.ts new file mode 100644 index 000000000..aa5164440 --- /dev/null +++ b/__test__/Booloperate/bool6.test.ts @@ -0,0 +1,16 @@ +import { BoolOpeartionType } from "../../src/GraphicsSystem/BoolOperateUtils"; +import { LoadRegionsFromFileData } from "../Utils/LoadEntity.util"; + +// file.only + +test('无法求到交集', () => +{ + let d = { "file": [2, "Region", 8, 2, 138, false, 1, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 402.7349980402736, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 402.7349980402736, 0, 0, 1], 0, 1, 1, 1, 1, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 402.7349980402736, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 402.7349980402736, 0, 0, 1], 0, 2, 4, [0, 0], 0, [387, 0], 0, [387, 18], 0, [0, 18], 0, true, 0, "Region", 8, 2, 139, false, 1, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 377.7349980402736, -38.99960000002761, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 377.7349980402736, -38.99960000002761, 0, 1], 0, 1, 1, 1, 1, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 377.7349980402736, -38.99960000002761, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 377.7349980402736, -764.0012000002525, 0, 1], 0, 2, 6, [412, 725.0016000002249], 0, [0, 725.0016000002249], 0, [0, 0], 0, [25, 0], 0, [25, -56.998399999775074], 0, [412, -56.998399999775074], 0, true, 0], "basePt": { "x": 377.7349980402736, "y": -764.0012000002525, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + + let [reg1, reg2] = LoadRegionsFromFileData(d); + + let reg = reg1.Clone(); + reg.BooleanOper(reg2.Clone(), BoolOpeartionType.Intersection); + + expect(reg.Area).toMatchSnapshot(); +}); diff --git a/src/DatabaseServices/Contour.ts b/src/DatabaseServices/Contour.ts index c90e2b82e..706941682 100644 --- a/src/DatabaseServices/Contour.ts +++ b/src/DatabaseServices/Contour.ts @@ -278,7 +278,7 @@ export class Contour for (let i = 0; i < targetCus.length; i++) { let cu = targetCus[i]; - hasEqualCus = fastEqualCurve(cu, pl); + hasEqualCus = fastEqualCurve(cu, pl, COMBINE_FUZZ); if (hasEqualCus) { //方向相同 @@ -592,7 +592,7 @@ export class Contour /** * 对于轮廓切割后的曲线判断相同,使用这个函数进行快速判断 */ -function fastEqualCurve(c1: Curve, c2: Curve, tolerance = 1e-3) +function fastEqualCurve(c1: Curve, c2: Curve, tolerance = 5e-3) { let sp1 = c1.StartPoint; let ep1 = c1.EndPoint;