From 01bc6f47331397262285b0cf01600440556adb4e Mon Sep 17 00:00:00 2001 From: ChenX Date: Wed, 8 May 2024 08:17:34 +0000 Subject: [PATCH] =?UTF-8?q?!2737=20=E4=BF=AE=E5=A4=8D:=E5=88=87=E5=89=B2?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/board_circle.test.ts.snap | 2 +- .../Booloperate/__snapshots__/bool6.test.ts.snap | 2 ++ __test__/Booloperate/bool6.test.ts | 13 ++++++++++++- src/DatabaseServices/Entity/Extrude.ts | 8 +++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/__test__/Booloperate/__snapshots__/board_circle.test.ts.snap b/__test__/Booloperate/__snapshots__/board_circle.test.ts.snap index 583ddf88a..d74a0b20a 100644 --- a/__test__/Booloperate/__snapshots__/board_circle.test.ts.snap +++ b/__test__/Booloperate/__snapshots__/board_circle.test.ts.snap @@ -8,4 +8,4 @@ exports[`同心圆 3`] = `"220857.82072"`; exports[`造型里面有重复的圆造型 1`] = `2782`; -exports[`造型里面有重复的圆造型 2`] = `30`; +exports[`造型里面有重复的圆造型 2`] = `20`; diff --git a/__test__/Booloperate/__snapshots__/bool6.test.ts.snap b/__test__/Booloperate/__snapshots__/bool6.test.ts.snap index 9c98a27d2..f0e93ae6c 100644 --- a/__test__/Booloperate/__snapshots__/bool6.test.ts.snap +++ b/__test__/Booloperate/__snapshots__/bool6.test.ts.snap @@ -1,5 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`同深度造型槽并集错误 1`] = `"6362640.00000"`; + exports[`并集错误 1`] = `"580529.02133"`; exports[`并集错误 2`] = `1`; diff --git a/__test__/Booloperate/bool6.test.ts b/__test__/Booloperate/bool6.test.ts index ec86c2b83..6c33c8e5c 100644 --- a/__test__/Booloperate/bool6.test.ts +++ b/__test__/Booloperate/bool6.test.ts @@ -1,7 +1,8 @@ +import { CuttingBoard } from "../../src/Add-on/BoardCutting/CuttingUtils"; import { Board } from "../../src/DatabaseServices/Entity/Board"; import { Region } from "../../src/DatabaseServices/Entity/Region"; import { BoolOpeartionType } from "../../src/GraphicsSystem/BoolOperateUtils"; -import { LoadEntityFromFileData, LoadRegionsFromFileData } from "../Utils/LoadEntity.util"; +import { LoadBoardsFromFileData, LoadEntityFromFileData, LoadRegionsFromFileData } from "../Utils/LoadEntity.util"; import "../Utils/jest.util"; test('无法求到交集', () => @@ -43,3 +44,13 @@ test('并集错误', () => expect(regs[0].ShapeManager.ShapeList.length).toMatchSnapshot(); }); + +test('同深度造型槽并集错误', () => +{ + let d = { "file": [2, "Board", 10, 2, 100, 0, 1, 3, 71, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 78, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 78, 0, 1], 0, 0, 1, 3, 600, 600.0000000000001, 18, true, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, -2.1316282072803007e-16, 0, 0, 2.1316282072803007e-16, 1, 0, 0, 600, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -930.925507900677, 2.257336342893268, 78.00000000000013, 1], 0, 0, 1, 2, 4, [0, -600], 0, [600.0000000000001, -600], 0, [600.0000000000001, 0], 0, [0, 0], 0, true, 1, 3, 220, 120, 10, true, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 220, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -1102.8668171557558, -172.16704288961245, 78, 1], 0, 0, 1, 2, 4, [0, -220], 0, [120, -220], 0, [120, 0], 0, [0, 0], 0, true, 1, 3, 200, 100, 10, true, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 200, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -1112.8668171557558, -182.16704288961245, 78, 1], 0, 0, 1, 2, 4, [0, -200], 0, [100, -200], 0, [100, 0], 0, [0, 0], 0, true, 0, 3, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 181.94130925507886, 69.99999999999987, 184.42437923250571, 1], 3, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 171.94130925507886, 69.99999999999987, 174.42437923250571, 1], 3, 0, 0, 0, 0, 0, 19, 2, "18背板", "", "", "", "", "", 0, 1, "三合一", 2, 0, "0.8", "0.8", "0.8", "0.8", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null, 0, 0, "", "", "", "", 0, false, 0, "", "Board", 10, 2, 101, 0, 1, 11, 71, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 227.65808219178084, 4.999999999999872, 20.290716803898704, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1643.7419178082207, 4.999999999999872, -3034.849283196101, 1], 0, 0, 1, 3, 300, 65, 18.4, true, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 321.05999999999995, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -3055.14, 0, 1], 0, 0, 1, 2, 4, [65, -321.05999999999995], 0, [65, -21.059999999999945], 0, [0, -21.059999999999945], 0, [0, -321.05999999999995], 0, true, 0, 3, 0, 0, 0, 0, 0, 19, 1, "格栅条", "", "", "", "", "", 0, 0, "三合一", 2, 0, "0.8", "0.8", "0.8", "0.8", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null, 0, 0, "", "", "", "", 0, false, 0, ""], "basePt": { "x": 0, "y": 4.999999999999872, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] }; + + let brs = LoadBoardsFromFileData(d); + let br = brs.shift(); + CuttingBoard(br, brs); + expect(br.Volume).toMatchNumberSnapshot(); +}); diff --git a/src/DatabaseServices/Entity/Extrude.ts b/src/DatabaseServices/Entity/Extrude.ts index e9b0e7869..53e4dfca1 100644 --- a/src/DatabaseServices/Entity/Extrude.ts +++ b/src/DatabaseServices/Entity/Extrude.ts @@ -609,10 +609,13 @@ export class ExtrudeSolid extends Entity let thisShape = this.Shape; let targetShape = target.Shape.ApplyMatrix(matrixToLocal).Z0(); let unionShapes = thisShape.UnionBoolOperation(targetShape, true); + if (unionShapes.length === 1) { this.WriteAllObjectRecord(); + //防止重复添加 + this.grooves = this.grooves.filter((g) => !equaln(g.thickness, target.thickness, 1e-3));//过滤掉一样的 因为已经在shape里 // [ + ] 产生网洞. for (let hole of unionShapes[0].Holes) { @@ -626,7 +629,10 @@ export class ExtrudeSolid extends Entity this.ContourCurve = unionShapes[0].Outline.Curve; - this.grooves.push(...target.grooves.map(g => g.Clone())); + for (let tg of target.grooves) + if (!equaln(tg.thickness, target.thickness, 1e-3))//过滤掉一样的 因为已经在shape里 + this.grooves.push(tg.Clone()); + MergeRelevance(); this.GrooveCheckMerge(); this.Update();