From 9a0ef8b41d1aa5e8e175a1c3f76d0cd4488c0b30 Mon Sep 17 00:00:00 2001 From: ChenX Date: Tue, 18 Apr 2023 15:52:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=E5=9C=A8=E6=9D=BF=E4=BB=B6?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=AD,=E5=A6=82=E6=9E=9C=E6=B3=95?= =?UTF-8?q?=E5=90=91=E9=87=8F=E7=9B=B8=E5=8F=8D,=E5=88=80=E6=9C=89?= =?UTF-8?q?=E6=B4=9E,=E5=AF=BC=E8=87=B4=E7=9A=84=E5=88=87=E5=89=B2?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/Board/qg.test.ts | 15 +++++++++++++++ src/DatabaseServices/Entity/Extrude.ts | 11 +++++------ 2 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 __test__/Board/qg.test.ts diff --git a/__test__/Board/qg.test.ts b/__test__/Board/qg.test.ts new file mode 100644 index 000000000..d837133e4 --- /dev/null +++ b/__test__/Board/qg.test.ts @@ -0,0 +1,15 @@ +import { Board } from "../../src/DatabaseServices/Entity/Board"; +import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; + +test('板件插件中,如果法向量相反,刀有洞,导致的切割不正确', () => +{ + let d = + { "file": [2, "Board", 10, 2, 122, 0, 1, 3, 71, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 857.3549084858569, 557.9750457173377, 0.000012982282000084666, 1], 127, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 857.3549084858569, 557.9750327173376, 0, 1], 0, 0, 1, 3, 797, 297.00000000000006, 18, true, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [6.123233995736766e-17, 1, 0, 0, -1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 297, 0, 0, 1], 0, 0, 1, 2, 4, [297, 0], 0, [0, 1.8186004967338195e-14], 0, [5.684341886080802e-14, 797], 0, [297.00000000000006, 797], 0, true, 0, 1, 1, 1, 1, 0, 1, 125, 11, 2, "金属扣线门板右", "未命名", "自由柜", "", "白色麻面-F4标板", "", 0, 0, null, 2, 4, 0.8, 0.8, 0.8, 0.8, "0.8", "0.8", "0.8", "0.8", "", "", "", 4, null, null, null, null, true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null, "Board", 10, 2, 125, 0, 1, 3, 71, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 905.8549084858569, 539.9750415173377, 748.5, 1], 126, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 904.3549084858569, 545.9750327173377, 47, 1], 0, 0, 1, 3, 700, 200.00000000000006, 6, false, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [6.123233995736766e-17, 1, 0, 0, -1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 201.5, -1.5, 0, 1], 0, 0, 1, 2, 8, [200, 0], 0, [0, 1.2434497875801753e-14], 0, [2.842170943040401e-14, 350], 0, [30.00000000000003, 350], 0, [30.00000000000003, 503], 0, [2.842170943040401e-14, 503], 0, [5.684341886080802e-14, 700], 0, [200.00000000000006, 700], 0, true, 1, 3, 194, 694, 6, false, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -4.5, -4.5, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -4.5, -4.5, 0, 1], 0, 0, 1, 2, 8, [4.5, 4.5], 0, [4.5, 198.5], 0, [348.5, 198.5], 0, [348.5, 168.5], 0, [507.5, 168.5], 0, [507.5, 198.5], 0, [698.5, 198.5], 0, [698.5, 4.5], 0, true, 0, 1.4, 0, 0, 0, 0, 0, [0, 0, -1, 0, -1, 0, 0, 0, 0, 1, 0, 0, 1102.8549084858569, 539.9750415173377, 745.5, 1], 1, 1, 1, 1, 1, 122, 0, 11, 2, "金属扣线3-辅助板", "未命名", "自由柜", "", "水曲柳(默认材质)", "", 0, 0, "无效配置", 2, 8, 1, 1, 1, 1, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 8, null, null, null, null, null, null, null, null, true, true, 0, 0, 0, 0, 0, 0, 0, 0, false, 0, 0, null], "basePt": { "x": 857.3549084858569, "y": 539.9750415173377, "z": 0.000012982282000084666 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + + let [br1, br2] = LoadEntityFromFileData(d) as [Board, Board]; + + br1.Subtract([br2]); + + expect(br1.Grooves.length).toBe(1); + expect(br1.Grooves[0].Grooves.length).toBe(1); +}); diff --git a/src/DatabaseServices/Entity/Extrude.ts b/src/DatabaseServices/Entity/Extrude.ts index 24490fb12..5e41ec0f6 100644 --- a/src/DatabaseServices/Entity/Extrude.ts +++ b/src/DatabaseServices/Entity/Extrude.ts @@ -9,7 +9,7 @@ import { CSGIntersect } from '../../Common/CSGIntersect'; import { equalCurve, PolylineSpliteRect } from "../../Common/CurveUtils"; import { DisposeThreeObj, Object3DRemoveAll } from "../../Common/Dispose"; import { Log } from "../../Common/Log"; -import { reviseMirrorMatrix, SetMtxVector, tempMatrix1, TransformVector, Vector2ApplyMatrix4 } from "../../Common/Matrix4Utils"; +import { MakeMirrorMtx, reviseMirrorMatrix, tempMatrix1, TransformVector, Vector2ApplyMatrix4 } from "../../Common/Matrix4Utils"; import { Status, UpdateDraw } from "../../Common/Status"; import { Geometry2CSG2 } from "../../csg/core/Geometry2CSG"; import { ObjectSnapMode } from "../../Editor/ObjectSnapMode"; @@ -1090,12 +1090,11 @@ export class ExtrudeSolid extends Entity target = target.Clone().ClearDraw(); if (parType === 2) { - let mtx = target._Matrix; - SetMtxVector(mtx, 2, n1); - let p = n1.setFromMatrixColumn(mtx, 3); - p.add(n2.multiplyScalar(target.thickness)); - SetMtxVector(mtx, 3, p); + let p = target.Position; + p.add(n2.clone().multiplyScalar(target.thickness * 0.5)); + target.ApplyMatrix(MakeMirrorMtx(n2, p)); } + if (this.GrooveCheckPosition(target) !== Status.True) return [];