From a62b0309fb6dd0613615258e93314b1dd3b4b332 Mon Sep 17 00:00:00 2001 From: ChenX Date: Fri, 26 Mar 2021 08:56:01 +0800 Subject: [PATCH] =?UTF-8?q?!1459=20=E4=BC=98=E5=8C=96:=E5=B9=B2=E6=B6=89?= =?UTF-8?q?=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/polyline.test.ts.snap | 2 +- .../Geometry/__snapshots__/arc.test.ts.snap | 2 +- .../__snapshots__/circle.test.ts.snap | 2 +- __test__/Interfere/interfere.test.ts | 47 +++--- .../__snapshots__/polyline.test.ts.snap | 2 +- src/Add-on/Erp/ErpCommands.ts | 6 +- src/Add-on/interfere.ts | 25 ++- src/Common/InterfereUtil.ts | 152 ++++++------------ src/DatabaseServices/3DSolid/ExtrudeHole.ts | 2 +- src/DatabaseServices/Entity/Extrude.ts | 9 +- src/Geometry/GeUtils.ts | 3 +- src/UI/Components/Modal/InterfereModal.tsx | 12 +- src/csg/core/Geometry2CSG.ts | 23 +-- src/csg/core/math/Polygon3.ts | 38 +++-- src/csg/core/trees.ts | 5 + 15 files changed, 149 insertions(+), 181 deletions(-) diff --git a/__test__/Fillet/__snapshots__/polyline.test.ts.snap b/__test__/Fillet/__snapshots__/polyline.test.ts.snap index e50b4994b..9af687144 100644 --- a/__test__/Fillet/__snapshots__/polyline.test.ts.snap +++ b/__test__/Fillet/__snapshots__/polyline.test.ts.snap @@ -18,7 +18,7 @@ exports[`双圆多段线倒角 8`] = `1200.793332200017`; exports[`多段线闭合标志首尾有弧 1`] = `1357.0494514094473`; -exports[`多段线闭合标志首尾有弧 2`] = `1357.0494514094473`; +exports[`多段线闭合标志首尾有弧 2`] = `1357.049451409447`; exports[`多段线闭合标志首尾有弧 3`] = `1357.049451409447`; diff --git a/__test__/Geometry/__snapshots__/arc.test.ts.snap b/__test__/Geometry/__snapshots__/arc.test.ts.snap index 3e51a01ce..3503cf7ff 100644 --- a/__test__/Geometry/__snapshots__/arc.test.ts.snap +++ b/__test__/Geometry/__snapshots__/arc.test.ts.snap @@ -91,7 +91,7 @@ exports[`圆弧合并 4`] = `0`; exports[`最近点 1`] = ` Vector3 { "x": 0, - "y": 0, + "y": 6.123233995736766e-16, "z": 0, } `; diff --git a/__test__/Geometry/__snapshots__/circle.test.ts.snap b/__test__/Geometry/__snapshots__/circle.test.ts.snap index 9ac1f7c2a..8ba7b6bc2 100644 --- a/__test__/Geometry/__snapshots__/circle.test.ts.snap +++ b/__test__/Geometry/__snapshots__/circle.test.ts.snap @@ -131,7 +131,7 @@ Vector3 { exports[`最近点 1`] = ` Vector3 { "x": 0, - "y": 0, + "y": 6.123233995736766e-16, "z": 0, } `; diff --git a/__test__/Interfere/interfere.test.ts b/__test__/Interfere/interfere.test.ts index 989a26d0a..57b822254 100644 --- a/__test__/Interfere/interfere.test.ts +++ b/__test__/Interfere/interfere.test.ts @@ -1,5 +1,5 @@ import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; -import { Solid3D, checkInterfereTool } from "../../src/Common/InterfereUtil"; +import { Solid3D, CheckInterfereTool } from "../../src/Common/InterfereUtil"; import { ObjectId } from "../../src/DatabaseServices/ObjectId"; async function Check(data: any, count: number) @@ -7,54 +7,63 @@ async function Check(data: any, count: number) let boards = LoadEntityFromFileData(data) as Solid3D[]; for (let i = 0; i < boards.length; i++) boards[i].objectId = new ObjectId(i); - await checkInterfereTool.Check(boards as any[]); - expect(checkInterfereTool.objMap.size).toBe(count); + await CheckInterfereTool.GetInstance().Check(boards as any[]); + expect(CheckInterfereTool.GetInstance().objMap.size).toBe(count); } describe("干涉测试", () => { - test("切割板件", () => + test("切割板件", async () => { let data = [2, "Board", 8, 2, 100, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -2231.9185171823483, -4422.281844206504, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2231.9185171823483, -4422.281844206504, 0, 1], 0, 3, 2000, 600, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 2000], 0, [0, 2000], 0, true, 4, 3, 18, 600, 9, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 18], 0, [0, 18], 0, true, 0, 3, 0, 0, 0, 0, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -2222.9185171823483, -4422.281844206504, 486.5, 1], 3, 18, 600, 6, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 18], 0, [0, 18], 0, true, 0, 3, 0, 0, 0, 0, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -2219.9185171823483, -4422.281844206504, 991, 1], 3, 1780.0698549677409, 18.000000000000455, 10, true, "Polyline", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -500.6580645161275, -219.93014503225913, 0, 1], 0, 0, true, [-1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 0, 0, 0, 1, 0, 2789.204261929938, 4347.811790451612, 0, 1], 0, 2, 4, [500.658064516128, 2000], 0, [500.6580645161275, 219.93014503225913], 0, [518.6580645161275, 219.93014503225913], 0, [518.658064516128, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -2223.9185171823483, -3921.623779690376, 219.93014503225913, 1], 3, 18, 600, 9, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 18], 0, [0, 18], 0, true, 0, 3, 0, 0, 0, 0, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -2222.9185171823483, -4422.281844206504, 50, 1], 3, 0, 0, 0, 0, 0, 9, 1, "左侧板", "主卧", "下柜", "", "", "", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 103, false, 1, 2, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -1049.9185171823483, -4422.281844206504, 486.5, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1049.9185171823483, -4422.281844206504, 486.5, 1], 0, 3, 1173, 600, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 1173], 0, [0, 1173], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 0, "层板", "主卧", "下柜", "", "", "", 0, 1, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 1, 101, 2, 3, 112, 113, 114, 3, 115, 116, 117, 0, 0, 0, 0, 0, 0, true]; - Check(data, 0); + await Check(data, 0); data = [2, "Board", 8, 2, 101, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -1049.9185171823483, -4422.281844206504, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1049.9185171823483, -4422.281844206504, 0, 1], 0, 3, 2000, 600, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 2000], 0, [0, 2000], 0, true, 1, 3, 1780.0698549677409, 18.000000000000455, 10, true, "Polyline", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -500.6580645161275, -219.93014503225913, 0, 1], 0, 0, true, [-1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 0, 0, 0, 1, 0, 2789.2042619299355, 4347.811790451612, 0, 1], 0, 2, 4, [500.658064516128, 2000], 0, [500.6580645161275, 219.93014503225913], 0, [518.6580645161275, 219.93014503225913], 0, [518.658064516128, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -1041.9185171823483, -3921.623779690376, 219.93014503225913, 1], 3, 0, 0, 0, 0, 0, 9, 1, "右侧板", "主卧", "下柜", "", "", "", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 2, 102, 2, 3, 104, 105, 106, 3, 107, 108, 109, 103, 2, 3, 112, 113, 114, 3, 115, 116, 117, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 103, false, 1, 2, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -606.3306739002, -4422.281844206504, 486.5, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1049.9185171823483, -4422.281844206504, 486.5, 1], 0, 3, 1616.5878432821482, 600, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 443.58784328214824, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 443.58784328214824, 0, 1], 0, 2, 4, [0, -443.58784328214824], 0, [600, -443.58784328214824], 0, [600, 1173], 0, [0, 1173], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 0, "层板", "主卧", "下柜", "", "", "", 0, 1, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 1, 101, 2, 3, 112, 113, 114, 3, 115, 116, 117, 0, 0, 0, 0, 0, 0, true]; - Check(data, 1); + await Check(data, 1); data = [2, "Board", 8, 2, 15731, false, 1, 12, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -17103.964135848066, 173.0236442641158, 3142.826736584199, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -17103.964135848066, -20, 3142.826736584199, 1], 0, 3, 1182, 136.9763557358842, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -193.0236442641158, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -193.0236442641158, 0, 0, 1], 0, 2, 4, [193.0236442641158, 0], 0, [330, 0], 0, [330, 1182], 0, [193.0236442641158, 1182], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "右侧板", "鞋柜", "鞋柜左柜", "", "", "", 0, 1, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 15732, false, 1, 5, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -17256.775064763995, 283, 3142.119629803012, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -18267.25702906688, 274.6553453088989, 3142.119629803012, 1], 0, 3, 59.99999365700023, 153.5180356971141, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1010.4819643028859, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1010.4819643028859, 0, 0, 1], 0, 2, 4, [1010.4819643028859, 0], 0, [1164, 0], 0, [1164, 59.99999365700023], 0, [1010.4819643028859, 59.99999365700023], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "地脚线", "鞋柜", "鞋柜左柜", "", "", "", 1, 0, "地脚线三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "地脚线三合一", "地脚线三合一", "地脚线三合一", "地脚线三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true]; - Check(data, 1); + await Check(data, 0);//上一个变更,我们对1mm以下的深度碰撞进行忽略不计 Extrude.ts Func:ConverToLocalGroove if (!(ibox.getSize(size).toArray().every(x => x > 1))) return []; + + data = [2, "Board", 8, 2, 107, false, 1, 12, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -790.2005878370492, 9217.434542891759, 0.7071067811871217, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -790.2005878370492, 9024.410898627642, 0.7071067811871217, 1], 0, 3, 1182, 136.9763557358842, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -193.0236442641158, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -193.0236442641158, 0, 0, 1], 0, 2, 4, [193.0236442641158, 0], 0, [330, 0], 0, [330, 1182], 0, [193.0236442641158, 1182], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 1, "右侧板", "鞋柜", "鞋柜左柜", "", "", "", 0, 1, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 108, false, 1, 5, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -934.0558157408685, 9327.410898627642, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1944.5377800437545, 9319.06624393654, 0, 1], 0, 3, 59.99999365700023, 153.5180356971141, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1010.4819643028859, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1010.4819643028859, 0, 0, 1], 0, 2, 4, [1010.4819643028859, 0], 0, [1164, 0], 0, [1164, 59.99999365700023], 0, [1010.4819643028859, 59.99999365700023], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "地脚线", "鞋柜", "鞋柜左柜", "", "", "", 1, 0, "地脚线三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "地脚线三合一", "地脚线三合一", "地脚线三合一", "地脚线三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0]; + await Check(data, 1); }); - test("五金孔", () => + test("五金孔", async () => { let data = { "file": [2, "Board", 8, 2, 9087, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 36291.119983889046, -362.1228211863199, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 36291.119983889046, -362.1228211863199, 0, 1], 0, 3, 1148, 450, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [450, 0], 0, [450, 1148], 0, [0, 1148], 0, true, 4, 3, 20, 20, 8.80000000000291, false, "Circle", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 10, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 324.2271826086958, -614.5869582319652, 0, 1], 0, 1, 10, 0, 4, 0, 0, 0, 0, 0, [0, -1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 36300.31998388904, -282.1228211863199, 167.6515268497169, 1], 3, 20, 20, 8.80000000000291, false, "Circle", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 10, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 324.2271826086958, -614.5869582319652, 0, 1], 0, 1, 10, 0, 4, 0, 0, 0, 0, 0, [0, -1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 36300.31998388904, -212.12282118631998, 167.6515268497169, 1], 3, 20, 20, 8.80000000000291, false, "Circle", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 10, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 324.2271826086958, -614.5869582319652, 0, 1], 0, 1, 10, 0, 4, 0, 0, 0, 0, 0, [0, -1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 36300.31998388904, -142.12282118631992, 167.6515268497169, 1], 3, 20, 20, 8.80000000000291, false, "Circle", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 10, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 324.2271826086958, -614.5869582319652, 0, 1], 0, 1, 10, 0, 3, 0, 0, 0, 0, 0, [0, -1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 36300.31998388904, -72.12282118631992, 167.6515268497169, 1], 3, 0, 0, 0, 0, 0, 9, 1, "立板", "主卧", "下柜", "", "", "", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "HardwareCompositeEntity", 1, 8, 2, 9088, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 34201.81915615466, -362.1228211863199, -606.142083904032, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 36309.119983889046, -362.1228211863199, 117.6515268497169, 1], 0, 5, "ExtrudeHole", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 2107.3008277343833, 350, 743.7936107537489, 1], 0, 0, true, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 2102.3008277343833, 450, 743.7936107537489, 1], 0, 5, 350, 0, 0, 2, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1783.8728901982536, -737.2996364928794, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1783.8728901982536, -737.2996364928794, 0, 1], 0, 2, 4, [1783.8728901982536, 737.2996364928794], 0, [1803.8728901982536, 737.2996364928794], 0, [1803.8728901982536, 817.2996364928794], 0, [1783.8728901982536, 817.2996364928794], 0, true, 3, true, "ExtrudeHole", 8, 2, 0, false, 0, 7, 0, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 2107.500827734383, 290, 773.7936107537489, 1], 0, 0, true, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 2107.500827734383, 290, 773.7936107537489, 1], 0, 5, 9, 0, 0, 2, "Circle", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 10, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 324.2271826086958, -614.5869582319652, 0, 1], 0, 1, 10, 3, true, "ExtrudeHole", 8, 2, 0, false, 0, 7, 0, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 2107.500827734383, 220, 773.7936107537489, 1], 0, 0, true, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 2107.500827734383, 220, 773.7936107537489, 1], 0, 5, 9, 0, 0, 2, "Circle", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 10, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 324.2271826086958, -614.5869582319652, 0, 1], 0, 1, 10, 4, true, "ExtrudeHole", 8, 2, 0, false, 0, 7, 0, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 2107.500827734383, 149.99999999999994, 773.7936107537489, 1], 0, 0, true, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 2107.500827734383, 149.99999999999994, 773.7936107537489, 1], 0, 5, 9, 0, 0, 2, "Circle", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 10, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 324.2271826086958, -614.5869582319652, 0, 1], 0, 1, 10, 4, true, "ExtrudeHole", 8, 2, 0, false, 0, 7, 0, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 2107.500827734383, 80, 773.7936107537489, 1], 0, 0, true, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 2107.500827734383, 80, 773.7936107537489, 1], 0, 5, 9, 0, 0, 2, "Circle", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 10, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 324.2271826086958, -614.5869582319652, 0, 1], 0, 1, 10, 4, true, 3, "无类型", false, false, "", "", "铰链", "主卧", "下柜", "L*W*H*100", "W*0.001*15", "X-1", "晨丰", "晨丰", "{W}*{L}", "{W*0.001}", "", "米", 0, true, 1, 0], "basePt": { "x": 36291.119983889046, "y": -362.1228211863199, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; - Check(data, 0); + await Check(data, 0);//理论上4个干涉看起来不大友好,但是因为判断差集是否成功的时候不大准确,导致了这个错误. (设置一样的曲线分段后,这个结果是0) }); - test("斜板件", () => + test("斜板件", async () => { let data = { "file": [2, "Board", 8, 2, 141, false, 1, 2, 0, [0, 1, 0, 0, -0.7071067811865476, 0, -0.7071067811865475, 0, -0.7071067811865475, 0, 0.7071067811865476, 0, 1457.168983625335, 0, 819.3295198795947, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1457.168983625335, 0, 819.3295198795947, 1], 0, 3, 761.1436553548998, 600, 17.999999999999993, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 24, [0, 0], 0, [600, 0], 0, [600, 761.1436553548998], 0, [0, 761.1436553548998], 0, [0, 636.3863794624164], 0, [303, 636.3863794624164], 0, [303, 620.1863794624165], 0, [0, 620.1863794624165], 0, [0, 512.5291035699332], 0, [303, 512.5291035699332], 0, [303, 496.3291035699331], 0, [0, 496.3291035699331], 0, [0, 388.67182767745004], 0, [303, 388.67182767745004], 0, [303, 372.4718276774499], 0, [0, 372.4718276774499], 0, [0, 264.8145517849668], 0, [303, 264.8145517849668], 0, [303, 248.61455178496684], 0, [0, 248.61455178496684], 0, [0, 140.9572758924837], 0, [303, 140.9572758924837], 0, [303, 124.75727589248348], 0, [0, 124.75727589248348], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 0, "右板15", "", "", "", "", "", 0, 0, "不排", 2, 24, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 24, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, -0.7853981633974483, 0, 0, 0, true, "Board", 8, 2, 142, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1439.168983625335, 0, 281.11967972102866, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1439.168983625335, 0, 281.11967972102866, 1], 0, 3, 593.2911126104882, 600, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 593.2911126104882], 0, [0, 593.2911126104882], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "右侧板", "", "", "", "", "", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": 906.231221405411, "y": 0, "z": 281.11967972102866 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] }; - Check(data, 1); + await Check(data, 1); }); - test("鹿角干涉", () => + test("鹿角干涉", async () => { let data = { "file": [2, "Board", 8, 2, 100, false, 1, 1, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 18772.744294221397, 75.30508230915177, 213.02254539250862, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 18772.744294221397, 75.30508230915177, 213.02254539250862, 1], 0, 3, 426.1862999999999, 512.2803050119994, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -11287.040410179, 7.105427357601002e-14, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -11287.040410179, 7.105427357601002e-14, 0, 1], 0, 2, 135, [11575.177889619, 183.9111], -0.254612865, [11519.549149821, 180.0828], -0.254612865, [11486.149016414, 224.733], 0.049131544, [11481.750650228, 236.3367], 0.031145283, [11479.277954769, 240.2842], 0.053715145, [11477.466271849, 226.3247], -0.006397846, [11477.461810351, 214.9593], -0.297918804, [11470.568787514, 201.8175], -0.180078198, [11411.024025155, 243.6921], 0, [11403.562761857, 234.5964], 0, [11393.787959259, 250.9923], 0, [11401.249222556, 260.0879], 0.014430924, [11396.835052412, 292.4591], -0.04253151, [11397.925134219, 355.943], 0.004683701, [11403.360754974, 426.1145], 0.240296591, [11391.815439486, 410.3221], 0.023565487, [11385.352522926, 381.8093], -0.364482816, [11378.084548262, 381.9742], -0.09837455, [11367.021626556, 391.159], 0.071116764, [11362.519097998, 395.0163], 1.02815249, [11361.370679631, 395.0163], 0.052151674, [11368.7771923, 373.0268], -0.04297448, [11381.128178264, 338.3146], -0.158396361, [11380.309935386, 317.5927], -0.132109045, [11377.959294551, 313.3645], -0.275983075, [11357.512291734, 327.2632], -0.067114461, [11343.341893042, 364.7725], 0.029838949, [11328.316966659, 413.214], 0.073072941, [11322.966435497, 421.4163], 0.135789841, [11321.766728399, 421.4163], 0.028827145, [11322.7214116, 408.9037], 0.024405929, [11327.800553142, 383.1967], -0.015601406, [11335.090914834, 349.9768], -0.061798133, [11335.786914938, 334.9212], -0.138782737, [11332.578297984, 326.6398], -0.069487037, [11306.428730945, 328.5789], 0.031600673, [11287.040410179, 331.3179], -0.144553022, [11290.424199241, 326.8061], -0.009458704, [11326.919408534, 315.4381], -0.091477617, [11367.966734075, 293.438], -0.277997279, [11382.956035178, 249.8128], -0.344624021, [11351.907237585, 261.8741], -0.015987502, [11333.313730763, 283.9223], 0.052407896, [11322.953392024, 294.2163], -0.061710025, [11321.775018611, 294.3001], 0.076426257, [11328.466369157, 272.3322], 0.106068382, [11347.011107859, 248.3883], 0.061972259, [11401.60771331, 216.2024], -0.053746633, [11445.339857422, 190.9484], -0.253436665, [11431.529139506, 186.9512], -0.035461175, [11413.310889227, 186.8128], 0.024362283, [11391.366582053, 184.9014], 0.420111382, [11393.247576808, 181.2685], 0.012212189, [11434.512618522, 176.3274], -0.062775564, [11470.7012434, 169.0987], -0.430891816, [11487.195471731, 140.6975], -0.046259578, [11479.04336139, 115.0782], 0.128917906, [11475.733345427, 75.1079], 0.068188271, [11487.362628345, 36.9554], 0, [11487.362628345, 78.8163], 0, [11505.362628345, 78.8163], 0, [11505.362628345, 14.6299], -0.014550612, [11521.804708805, 5.4898], 0.057423089, [11534.066582053, 0.1705], 0, [11534.066582053, 75.8632], 0, [11552.166582053, 75.8632], 0, [11552.166582053, 0], 0.096578936, [11581.576353606, 15.5105], 0, [11581.576353606, 80.0159], 0, [11599.576353606, 80.0159], 0, [11599.576353606, 38.2867], 0.065688118, [11610.599818679, 75.1079], 0.128917906, [11607.289802717, 115.0782], -0.047156952, [11601.02806164, 140.6975], -0.274535317, [11606.260736742, 159.8827], -0.089605693, [11652.588230602, 172.9365], 0.030873658, [11688.991201222, 180.7212], 0.050381766, [11694.916107746, 185.0219], 0.031449162, [11670.4825118, 184.6727], -0.10399231, [11640.966582053, 187.4348], -0.336449094, [11640.966582054, 191.0032], -0.036722822, [11680.533084623, 214.3934], 0.054192788, [11726.213254997, 241.6738], 0.076337606, [11753.770938476, 272.623], 0.049489895, [11762.656825324, 285.98], 0.138087058, [11763.356033891, 294.2058], 0.000047238, [11761.10014684, 291.9499], 0.09861929, [11741.409068782, 271.9504], -0.062439784, [11729.665613854, 258.0381], -0.103116929, [11717.375226864, 249.9555], -0.121468386, [11704.561895684, 248.6304], -0.204317631, [11703.883885051, 265.1182], -0.09587023, [11719.497523575, 291.9725], -0.042673687, [11735.762793765, 309.283], -0.148349705, [11755.152813317, 318.6094], -0.012586025, [11778.962002245, 321.3235], 0.108425739, [11793.825468391, 326.4298], 0.042924224, [11799.320715191, 331.3627], 0.041662745, [11783.783757311, 328.7079], -0.038357208, [11768.815814086, 326.1597], -0.095757819, [11754.317867672, 327.6662], -0.383733711, [11750.208924425, 332.3593], -0.054739054, [11754.267214374, 352.8037], 0.000010299, [11762.660701672, 379.3031], 0.072062048, [11766.60001328, 404.4508], 0.071821088, [11764.350969936, 418.5301], 0.043651943, [11763.319701333, 421.3929], 0.198002445, [11760.015414422, 416.1008], -0.018076552, [11748.95933259, 374.3494], -0.049532619, [11732.343387357, 333.9769], -0.081841348, [11717.821958357, 315.1439], -0.032240782, [11714.246462485, 312.2818], -0.189036719, [11705.507337448, 318.3212], -0.104987178, [11711.766367896, 352.0737], 0.034028207, [11723.837727469, 386.0765], 0.104457129, [11723.731209826, 394.9926], 0.035418053, [11712.759629038, 384.8008], -0.153616808, [11702.165117566, 380.6207], -0.003135161, [11698.291881798, 391.6015], 0.005848381, [11693.803721704, 412.0875], 0.170274322, [11685.922346843, 424.7653], 0.019247846, [11682.966582053, 426.1863], 0.00064047, [11682.966582053, 420.3159], -0.043610118, [11686.317807607, 405.3389], -0.042417751, [11690.375772192, 384.0725], -0.081620938, [11690.955334096, 354.9771], -0.075258115, [11688.304049254, 289.073], -0.039033673, [11680.996648028, 260.0879], 0, [11688.457911326, 250.9923], 0, [11678.683108728, 234.5964], 0, [11671.22184543, 243.6921], -0.209738748, [11629.823294946, 205.3048], -0.221064567, [11608.566582053, 205.4163], 0.003714071, [11608.844070958, 222.4945], 0.077128321, [11604.865848968, 249.0654], -0.258382325, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "背板", "", "", "", "", "", 0, 1, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 135, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 101, false, 1, 5, 0, [0.054881614980321014, 0.9974775965875263, -0.04501613758558334, 0, -0.7712262475747155, 0.07098199987301262, 0.6325912035002161, 0, 0.6341908887621895, -2.0509456545654932e-16, 0.7731765106436074, 0, 19151.417707883873, 0, 461.7794450518195, 1], 0, 0, true, [0.054881614980321014, 0.9974775965875263, -0.04501613758558334, 0, -0.6341908887621895, 2.0509456545654932e-16, -0.7731765106436074, 0, -0.7712262475747155, 0.07098199987301262, 0.6325912035002161, 0, 19151.417707883873, 0, 461.7794450518195, 1], 0, 3, 106.64990000000067, 126.12181744802166, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -12025.442541058, 2.8421709430404007e-13, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -12025.442541058, 2.8421709430404007e-13, 0, 1], 0, 2, 19, [12059.982595379, 13.1415], -0.078990603, [12036.619149227, 30.1953], -0.108446637, [12025.442541058, 49.0499], 0.027641349, [12041.585102303, 37.9538], 0.0535103, [12075.00533063, 21.9583], 0.175280861, [12119.647035707, 19.8245], 0.181980507, [12139.442541058, 38.2499], 0.229616437, [12128.400475628, 60.738], 0, [12109.442541058, 79.0499], 0, [12133.442541058, 64.6499], 0.142440241, [12135.877984698, 71.7828], 0.094561328, [12134.275621159, 83.2365], 0.023401055, [12125.042541058, 106.6499], -0.161182868, [12148.989820487, 65.8239], -0.302830535, [12135.842541058, 15.4499], 0, [12100.854405824, 1.2359], 0, [12100.035375317, 10.2453], 0, [12081.961148198, 10.2453], 0, [12082.892535429, 0], 0.01566032, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "地脚线", "", "", "", "", "", 0, 1, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 19, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": 18772.744294221397, "y": -3.6917021782178875e-15, "z": 213.02254539250862 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] }; - Check(data, 0); + await Check(data, 0); }); - test("干涉检查错误", () => + test("干涉检查错误", async () => { let data = { "file": [2, "Board", 8, 2, 102, false, 1, 11, 0, [-0.06975647374412529, -0.9975640502598242, 0, 0, 0, 0, 1, 0, -0.9975640502598242, 0.06975647374412529, 0, 0, 19556.454728975208, 767.9363869300789, 242.84526779845544, 1], 0, 0, true, [-0.9975640502598242, 0.06975647374412529, 0, 0, -0.06975647374412529, -0.9975640502598242, 0, 0, 0, 0, 1, 0, 19556.454728975208, 767.9363869300789, 242.84526779845544, 1], 0, 3, 1135, 600.0000000000027, 18, false, "Polyline", 8, 2, 0, false, 0, 1, 0, [1.0000000000000004, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1.0000000000000004, 0, 5632.016584763501, 2521.7574867597896, 0, 1], 0, 0, true, [-0.0697564737441253, 0, -0.9975640502598244, 0, -0.9975640502598244, 0, 0.0697564737441253, 0, 0, 1, 0, 0, 5632.016584763501, 2521.7574867597896, -7.275957614183426e-12, 1], 0, 2, 6, [-5382.016584763494, -1386.7574867597896], 0, [-5632.016584763498, -1386.7574867597896], 0, [-5632.016584763496, -2521.7574867597896], 0, [-5032.016584763496, -2521.7574867597896], 0, [-5032.016584763497, -1686.7574867597896], 0, [-5382.016584763495, -1686.7574867597896], 0, true, 6, 3, 409, 5.030673312097093, 5.0418581680963825, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [5.030673312097093, 0], 0, [5.030673312097093, 409], 0, [0, 409], 0, true, 0, 3, 0, 0, 0, 0, 0, [-0.06975647374412529, -0.9975640502598242, 0, 0, 0, 0, 1, 0, -0.9975640502598242, 0.06975647374412529, 0, 0, 19542.489716748765, 753.9899777379917, 255.8452677984559, 1], 3, 293, 5.030673312097093, 5.0418581680963825, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [5.030673312097093, 0], 0, [5.030673312097093, 293], 0, [0, 293], 0, true, 0, 3, 0, 0, 0, 0, 0, [-0.06975647374412529, -0.9975640502598242, 0, 0, 0, 0, 1, 0, -0.9975640502598242, 0.06975647374412529, 0, 0, 19542.489716748765, 753.9899777379917, 1072.8488815631117, 1], 3, 293, 5.038666380177347, 4.945957896650957, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [5.038666380177347, 0], 0, [5.038666380177347, 293], 0, [0, 293], 0, true, 0, 3, 0, 0, 0, 0, 0, [-0.06975647374412529, -0.9975640502598242, 0, 0, 0, 0, 1, 0, -0.9975640502598242, 0.06975647374412529, 0, 0, 19555.412614810877, 753.0334600645194, 1072.8491295150625, 1], 3, 409, 5.038666380177347, 4.945957896650957, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [5.038666380177347, 0], 0, [5.038666380177347, 409], 0, [0, 409], 0, true, 0, 3, 0, 0, 0, 0, 0, [-0.06975647374412529, -0.9975640502598242, 0, 0, 0, 0, 1, 0, -0.9975640502598242, 0.06975647374412529, 0, 0, 19555.412614810877, 753.0334600645194, 255.8452677984559, 1], 3, 394, 5.0386663801773475, 4.945957896650957, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1.0000000000000002, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1.0000000000000002, 0, 0, 0, 0, 1], 0, 0, true, [1.0000000000000002, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1.0000000000000002, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [5.038666380177347, 0], 0, [5.038666380177347, 394], 0, [0, 394], 0, true, 0, 3, 0, 0, 0, 0, 0, [-0.06975647374412529, -0.9975640502598242, 0, 0, 0, 0, 1, 0, -0.9975640502598242, 0.06975647374412529, 0, 0, 19555.412614810877, 753.0334600645194, 670.8452677984554, 1], 3, 394, 5.030673312097093, 5.0418581680963825, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [5.030673312097093, 0], 0, [5.030673312097093, 394], 0, [0, 394], 0, true, 0, 3, 0, 0, 0, 0, 0, [-0.06975647374412529, -0.9975640502598242, 0, 0, 0, 0, 1, 0, -0.9975640502598242, 0.06975647374412529, 0, 0, 19542.489716748765, 753.9899777379917, 670.8406241929855, 1], 3, 0, 0, 0, 0, 0, 10, 1, "侧板", "", "", "", "", "", 0, 0, "三合一", 2, 6, 1, 1, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 6, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 103, false, 1, 2, 0, [1, -1.8369701987210297e-16, 0, 0, 1.8369701987210297e-16, 1, 0, 0, 0, 0, 1, 0, 19522.53385766159, 2.2637008605855804e-13, 658.8452677984554, 1], 0, 0, true, [-1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 0, 0, 0, 1, 0, 17112.285147039474, -4.243356993307089, 658.8452677984554, 1], 0, 3, 767.6683077388061, 1232.301352608582, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 171.87521704525898, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5.684341886080801e-13, -4.14632742068261, 0, 1], 0, 2, 4, [1232.3013526085815, 412.1381720169775], 0.037666321518033015, [41.661911410171, 595.7930906935471], 0, [0, 0], -0.038046266446744866, [1095.4297814411107, -171.87521704525898], 0, true, 2, 3, 188.35578830063844, 1188.6022768256926, 6, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, -1.8369701987210297e-16, 0, 0, 1.8369701987210297e-16, 1, 0, 0, 0, 0, 1, 0, -40.2818226064704, -392.6890905964028, 0, 1], 0, 0, true, [1, -1.8369701987210297e-16, 0, 0, 1.8369701987210297e-16, 1, 0, 0, 0, 0, 1, 0, -40.2818226064704, -392.6890905964028, 0, 1], 0, 2, 4, [40.63061597737366, 581.0448788970413], 0, [40.281822606470314, 576.056901307199], -0.03766601885434294, [1227.7431928443466, 392.68909059640384], 0, [1228.8840994321629, 397.5571922574811], 0.037667551759022824, true, 0, 3, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 19562.81568026806, 564.564307641662, 670.8452677984554, 1], 3, 188.35578830063844, 1188.6022768256926, 6, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, -1.8369701987210297e-16, 0, 0, 1.8369701987210297e-16, 1, 0, 0, 0, 0, 1, 0, -40.2818226064704, -392.6890905964028, 0, 1], 0, 0, true, [1, -1.8369701987210297e-16, 0, 0, 1.8369701987210297e-16, 1, 0, 0, 0, 0, 1, 0, -40.2818226064704, -392.6890905964028, 0, 1], 0, 2, 4, [40.63061597737366, 581.0448788970413], 0, [40.281822606470314, 576.056901307199], -0.03766601885434294, [1227.7431928443466, 392.68909059640384], 0, [1228.8840994321629, 397.5571922574811], 0.037667551759022824, true, 0, 3, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 19562.81568026806, 564.564307641662, 658.8452677984554, 1], 3, 0, 0, 0, 0, 0, 10, 0, "底板", "", "", "", "", "", 1, 1, "三合一", 2, 4, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": 19496.644691824054, "y": 0, "z": 242.84526779845544 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; - Check(data, 0); + await Check(data, 0); }); - test("3干涉背板", () => + test("3干涉背板", async () => { let data = { "file": [3, "Board", 8, 2, 100, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -351.8109794803895, -112.36982647504192, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -346.8109794803895, -594.3698264750419, 5, 1], 0, 3, 949.9999999999998, 942, 6, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [942, 0], 0, [942, 949.9999999999998], 0, [-1.468822192785737e-15, 949.9999999999995], 0, [0, 0], 0, true, 0, 3, 6, 0, 1, 0, 0, 10, 2, "薄背板", "麓府2-202", "2.次卧1衣柜", "", "多层板", "TYH-8076", 1, 1, "三合一", 2, 4, 0, 0, 0, 0, "0", "0", "0", "0", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 101, false, 1, 5, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -346.8109794803895, -106.36982647504192, 944.9999999999991, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -346.8109794803895, -594.3698264750419, 5, 1], 0, 3, 120, 932, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -5, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -5, 0, 0, 1], 0, 2, 4, [937, 2.2737367544323206e-13], 0, [937, 120], 0, [5, 120], 0, [5, 0], 0, true, 0, 3, 6, 0, 1, 0, 0, 10, 2, "背拉条", "麓府2-202", "2.次卧1衣柜", "", "多层板", "TYH-8076", 1, 1, "三合一", 2, 4, 0.6, 0.6, 0.6, 0.6, "0.6", "0.6", "0.6", "0.6", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 102, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -351.8109794803895, -112.36982647504192, 1059.999999999999, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -346.8109794803895, -594.3698264750419, 5, 1], 0, 3, 942.0000000000005, 942, 6, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 140, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 140, 0, 1], 0, 2, 4, [942, -140], 0, [942, 802.0000000000005], 0, [0, 802.0000000000005], 0, [0, -140], 0, true, 0, 3, 6, 0, 1, 0, 0, 10, 2, "薄背板", "麓府2-202", "2.次卧1衣柜", "", "多层板", "TYH-8076", 1, 1, "三合一", 2, 4, 0, 0, 0, 0, "0", "0", "0", "0", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": -351.8109794803895, "y": -124.36982647504192, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; - Check(data, 2); + await Check(data, 2); }); - test("重叠板件", () => + test("重叠板件", async () => { let data = { "file": [2, "Board", 8, 2, 103, false, 1, 2, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 3099.0177832142217, -138.39374678209424, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3099.0177832142217, -138.39374678209424, 0, 1], 0, 3, 1200, 600, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 0, "层板", "", "", "", "", "", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 104, false, 1, 2, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 3099.0177832142217, -138.39374678209424, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3099.0177832142217, -138.39374678209424, 0, 1], 0, 3, 1200, 600, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 0, "层板", "", "", "", "", "", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": 1899.0177832142217, "y": -138.39374678209424, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; - Check(data, 1); + await Check(data, 1); + }); + + test("板件倾斜", async () => + { + let data = { "file": [4, "Board", 8, 2, 100, false, 1, 2, 0, [0, 0.9831300494835278, 0.18290791618329785, 0, -1, 0, 0, 0, 0, -0.18290791618329785, 0.9831300494835278, 0, 1108.4743411927875, 128.72923569518287, 1025.1786752030148, 1], 0, 0, true, [1, 0, 0, 0, 0, 0.9831300494835278, 0.18290791618329785, 0, 0, -0.18290791618329785, 0.9831300494835278, 0, 1108.6443411927876, 126.76297559621582, 1024.8128593706488, 1], 0, 3, 750, 430.6086591386313, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2, -0.17000000000007276, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2, -0.17000000000007276, 0, 1], 0, 2, 4, [2, 0.17000000000007276], 0, [432.6086591386313, 0.17000000000007276], 0, [432.6086591386313, 750.1700000000001], 0, [2, 750.1700000000001], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 0, "顶板", "", "讲桌", "18颗粒蓝色", "颗粒板", "蓝色", 0, 1, "**多种**", 2, 0, "1.5", "1.5", "1.5", "1.5", "", "", "", 4, "三合一", "不排", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 101, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 483.4743411927875, 559.6438564782645, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 483.4743411927875, 559.6438564782645, 0, 1], 0, 3, 1160, 500, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 6, [0, 0], 0, [500, 0], 0, [500, 1130], 0.41421356237309503, [470, 1160], 0, [30, 1160], 0.41421356237309503, [0, 1130], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "封板", "", "讲桌", "18颗粒蓝色", "颗粒板", "蓝色", 0, 1, "不排", 2, 0, "0.6", "0.6", "0.6", "0.6", "", "", "", 6, "不排", "不排", "不排", "不排", "不排", "不排", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 113, false, 1, 2, 0, [0, 0.9831300494835278, 0.18290791618329785, 0, -1, 0, 0, 0, 0, -0.18290791618329785, 0.9831300494835278, 0, 1108.4743411927875, 637.6961828178574, 1044.0516874415487, 1], 0, 0, true, [1, 0, 0, 0, 0, 0.9831300494835278, 0.18290791618329785, 0, 0, -0.18290791618329785, 0.9831300494835278, 0, 1108.6443411927876, 635.7299227188904, 1043.6858716091826, 1], 0, 3, 750, 430.6086591386313, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2, -0.17000000000007276, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2, -0.17000000000007276, 0, 1], 0, 2, 4, [2, 0.17000000000007276], 0, [432.6086591386313, 0.17000000000007276], 0, [432.6086591386313, 750.1700000000001], 0, [2, 750.1700000000001], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 0, "顶板", "", "讲桌", "18颗粒蓝色", "颗粒板", "蓝色", 0, 1, "**多种**", 2, 0, "1.5", "1.5", "1.5", "1.5", "", "", "", 4, "三合一", "不排", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 114, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 483.4743411927875, 1075.7481526935562, 18.873012238533875, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 483.4743411927875, 1075.7481526935562, 18.873012238533875, 1], 0, 3, 1160, 500, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 6, [0, 0], 0, [500, 0], 0, [500, 1130], 0.41421356237309503, [470, 1160], 0, [30, 1160], 0.41421356237309503, [0, 1130], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "封板", "", "讲桌", "18颗粒蓝色", "颗粒板", "蓝色", 0, 1, "不排", 2, 0, "0.6", "0.6", "0.6", "0.6", "", "", "", 6, "不排", "不排", "不排", "不排", "不排", "不排", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": 358.4743411927875, "y": 125.4368932038835, "z": 0 }, "ucs": [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1] }; + await Check(data, 2); }); }); diff --git a/__test__/Polyline/__snapshots__/polyline.test.ts.snap b/__test__/Polyline/__snapshots__/polyline.test.ts.snap index a3fe33c76..4a45de654 100644 --- a/__test__/Polyline/__snapshots__/polyline.test.ts.snap +++ b/__test__/Polyline/__snapshots__/polyline.test.ts.snap @@ -14,7 +14,7 @@ exports[`多段线 存在大圆弧的多段线面积 1`] = `-24.019436375469752` exports[`多段线 最近点精度 1`] = ` Vector3 { - "x": 1.987500976448074, + "x": 1.9875009764480738, "y": 3.9999218841540816, "z": 0, } diff --git a/src/Add-on/Erp/ErpCommands.ts b/src/Add-on/Erp/ErpCommands.ts index 2967418d8..084cfb6c6 100644 --- a/src/Add-on/Erp/ErpCommands.ts +++ b/src/Add-on/Erp/ErpCommands.ts @@ -1,6 +1,6 @@ import { Intent } from "@blueprintjs/core"; import { app } from "../../ApplicationServices/Application"; -import { checkInterfereTool } from "../../Common/InterfereUtil"; +import { CheckInterfereTool } from "../../Common/InterfereUtil"; import { StoreageKeys } from "../../Common/StoreageKeys"; import { Board } from "../../DatabaseServices/Entity/Board"; import { Entity } from "../../DatabaseServices/Entity/Entity"; @@ -149,7 +149,7 @@ async function ExecChaiDan(chaiDanRoute: ErpRoutes) let originEns = new Set(); for (let b of selction.boardList) originEns.add(b.__OriginalEnt__ ?? b); - checkInterfereTool.Check([...originEns, ...selction.metalsList]).then(objMap => + CheckInterfereTool.GetInstance().Check([...originEns, ...selction.metalsList]).then(objMap => { if (objMap.size > 0) { @@ -159,6 +159,8 @@ async function ExecChaiDan(chaiDanRoute: ErpRoutes) intent: Intent.DANGER, }); } + + CheckInterfereTool.GetInstance().Clear(); }); } diff --git a/src/Add-on/interfere.ts b/src/Add-on/interfere.ts index d3506c317..32d6c5514 100644 --- a/src/Add-on/interfere.ts +++ b/src/Add-on/interfere.ts @@ -1,8 +1,9 @@ import { Intent } from '@blueprintjs/core'; import { app } from '../ApplicationServices/Application'; +import { ColorMaterial } from '../Common/ColorPalette'; import { DisposeThreeObj } from '../Common/Dispose'; -import { checkInterfereTool } from '../Common/InterfereUtil'; +import { CheckInterfereTool } from '../Common/InterfereUtil'; import { ExtrudeSolid } from '../DatabaseServices/Entity/Extrude'; import { HardwareCompositeEntity } from '../DatabaseServices/Hardware/HardwareCompositeEntity'; import { PromptStatus } from '../Editor/PromptResult'; @@ -16,8 +17,12 @@ import { AppToaster } from './../UI/Components/Toaster'; export class Interfere implements Command { + checkInterfereTool: CheckInterfereTool; async exec() { + if (!this.checkInterfereTool) + this.checkInterfereTool = new CheckInterfereTool(ColorMaterial.GetConceptualMaterial(1)); + const Filter = { filterTypes: [HardwareCompositeEntity, ExtrudeSolid, SweepSolid] }; @@ -40,7 +45,7 @@ export class Interfere implements Command timeout: 0 }, 'interfere'); - await checkInterfereTool.Check(selectEnts, (i, all) => + await this.checkInterfereTool.Check(selectEnts, (i, all) => { let a = i / all; if (a - down.progress > 0.1) @@ -54,7 +59,7 @@ export class Interfere implements Command down.progress = 1; - let objMap = checkInterfereTool.objMap; + let objMap = this.checkInterfereTool.objMap; if (objMap.size === 0) { @@ -66,14 +71,16 @@ export class Interfere implements Command return; } - for (let [o,] of objMap) - { - app.Viewer.Scene.add(o); - } + for (let [mesh,] of objMap) + app.Viewer.Scene.add(mesh); + let oldType = userConfig.RenderType; userConfig.RenderType = RenderType.Wireframe; - app.Editor.ModalManage.RenderModeless(InterfereModal, { count: checkInterfereTool.entitySet.size, data: objMap }, { canMinimize: false }); + app.Editor.ModalManage.RenderModeless(InterfereModal, { count: this.checkInterfereTool.entitySet.size, data: objMap }, { canMinimize: false }); + + //等待界面呼出的时候 画布并不会刷新,所以强制刷新 + app.Editor.UpdateScreen(); await app.Editor.ModalManage.Wait(); @@ -84,5 +91,7 @@ export class Interfere implements Command } userConfig.RenderType = oldType; + + this.checkInterfereTool.Clear();//回收内存 } } diff --git a/src/Common/InterfereUtil.ts b/src/Common/InterfereUtil.ts index 668db20e5..e5e60e959 100644 --- a/src/Common/InterfereUtil.ts +++ b/src/Common/InterfereUtil.ts @@ -1,6 +1,8 @@ -import { Box3, Face3, Geometry, Mesh, Vector3 } from "three"; +import { Box3, Material, Mesh } from "three"; import { CSG } from "../csg/core/CSG"; -import { Geometry2CSG, Vector3DToVector3 } from "../csg/core/Geometry2CSG"; +import { FuzzyCSGFactory } from "../csg/core/FuzzyFactory3d"; +import { CSG2Geometry, Geometry2CSG } from "../csg/core/Geometry2CSG"; +import { Plane } from "../csg/core/math/Plane"; import { ExtrudeHole } from "../DatabaseServices/3DSolid/ExtrudeHole"; import { SweepSolid } from "../DatabaseServices/3DSolid/SweepSolid"; import { Board } from "../DatabaseServices/Entity/Board"; @@ -11,19 +13,27 @@ import { ObjectId } from "../DatabaseServices/ObjectId"; import { ProcessingGroupRecord } from "../DatabaseServices/ProcessingGroup/ProcessingGroupRecord"; import { TemplateLatticeRecord } from "../DatabaseServices/Template/ProgramTempate/TemplateLatticeRecord"; import { TemplateWineRackRecord } from "../DatabaseServices/Template/ProgramTempate/TemplateWineRackRecord"; -import { CanDrawHoleFuzz } from "../Geometry/DrillParse/BoardGetFace"; -import { equaln, equalv3 } from "../Geometry/GeUtils"; import { OBB } from "../Geometry/OBB/obb"; -import { PlaneExt } from "../Geometry/Plane"; import { ColorMaterial } from "./ColorPalette"; import { Log } from "./Log"; import { Sleep } from "./Sleep"; -import { FixedNotZero } from "./Utils"; export type Solid3D = ExtrudeSolid | SweepSolid | ExtrudeHole; export class CheckInterfereTool { + constructor(public _MeshMaterial: Material = ColorMaterial.GetBasicMaterial(1)) + { + } + + static _SingleInstance: CheckInterfereTool; + static GetInstance(): CheckInterfereTool + { + if (this._SingleInstance) return this._SingleInstance; + this._SingleInstance = new CheckInterfereTool; + return this._SingleInstance; + } + entitySet: Set = new Set(); objMap: Map = new Map(); GetEntitys(selectEnts: (HardwareCompositeEntity | ExtrudeSolid | SweepSolid)[]) @@ -65,7 +75,7 @@ export class CheckInterfereTool let e1 = ens[i]; let IsSkipEntity = this.IsSkipEntity(e1); - if (i % 50 === 0) + if (i !== 0 && i % 50 === 0) { await Sleep(0); if (progressCallBack) @@ -118,11 +128,26 @@ export class CheckInterfereTool if (!obb1.intersectsOBB(this.GetOBB(e2))) continue; + function EntityTypeCode(ext: Entity): 0 | 1 | 2 + { + if (ext instanceof ExtrudeSolid) + return 1; + else if (ext instanceof ExtrudeHole) + return 2; + else + return 0; + } + let t1 = EntityTypeCode(e1); + let t2 = EntityTypeCode(e2); + //#I2DXNO - if (e1 instanceof Board && e2 instanceof Board) + if (t1 > 0 && t2 > 0) { - let [b1, b2] = [e1.Clone(), e2.Clone()]; - if (!b1.Subtract([e2], [b1]) && !b1.IsErase && !b2.Subtract([e1], [b2]) && !b2.IsErase) + let [b1, b2] = [t1 === 1 ? e1.Clone() : (e1).Convert2ExtrudeSolid(), + t2 === 1 ? e2.Clone() : (e2).Convert2ExtrudeSolid()]; + + if (!b1.Subtract([b2]) && !b1.IsErase + && !b2.Subtract([b1]) && !b2.IsErase) continue; } @@ -134,97 +159,18 @@ export class CheckInterfereTool continue; } - let c = csg1.intersect(csg2.transform1(e1.OCSInv.multiply(e2.OCS))); - - if (c.polygons.length > 0) - { + let interCsg = csg1.intersect(csg2.transform1(e1.OCSInv.multiply(e2.OCSNoClone))); - let ptsMap = new Map(); - let geo = new Geometry; + let planeSet = new Set(); + let f = new FuzzyCSGFactory; + for (let polygon of interCsg.polygons) + planeSet.add(f.getPlane(polygon.plane)); - for (let poly of c.polygons) - { - let normal = Vector3DToVector3(poly.plane.normal); - if (equalv3(normal, new Vector3())) continue; - let p0 = Vector3DToVector3(poly.vertices[0].pos); - if (poly.vertices.some((v, i) => - { - if (i === 0) - return false; - let p1 = Vector3DToVector3(v.pos); - return equalv3(p0, p1, 1e-2); - })) - continue; - - let k = `${FixedNotZero(normal.x, 2)},${FixedNotZero(normal.y, 2)},${FixedNotZero(normal.z, 2)}`; - let k2 = `${FixedNotZero(-normal.x, 2)},${FixedNotZero(-normal.y, 2)},${FixedNotZero(-normal.z, 2)}`; - let pts = ptsMap.get(k); - if (!pts) - pts = ptsMap.get(k2); - - if (!pts) - { - pts = []; - ptsMap.set(k, pts); - } - pts.push(...poly.vertices.map(v => Vector3DToVector3(v.pos))); - - for (let v of poly.vertices) - { - v.tag = geo.vertices.length; - geo.vertices.push(Vector3DToVector3(v.pos)); - } - - let firstVertex = poly.vertices[0]; - - for (let i = poly.vertices.length - 3; i >= 0; i--) - { - let [a, b, c] = [ - firstVertex.tag, - poly.vertices[i + 1].tag, - poly.vertices[i + 2].tag - ]; - let f = new Face3(a, b, c, normal); - - geo.faces.push(f); - } - } - let hasSolid = false; - let count = 0; - let plane = new PlaneExt(); - for (let [k, pts] of ptsMap) - { - let nor = new Vector3().fromArray(k.split(",").map(s => parseFloat(s))); - plane.setFromNormalAndCoplanarPoint(nor, pts[0]); - //超过3点不在一个面上,一般可以围城实体 - let outCount = 0; - for (let p of pts) - { - let dist = plane.distanceToPoint(p); - if (!equaln(dist, 0, CanDrawHoleFuzz)) - { - outCount++; - if (outCount >= 3) - { - count++; - hasSolid = true; - ptsMap.delete(k); - break; - } - } - } - } - if (hasSolid) - { - //围不出一个实体的情况 - if (ptsMap.size === 1) continue; - if (ptsMap.size === 0 && count <= 2) continue; - entitySet.add(e1); - entitySet.add(e2); - geo.applyMatrix4(e1.OCS); - let m = new Mesh(geo, ColorMaterial.GetBasicMaterial(1).clone()); - objMap.set(m, [e1, e2]); - } + if (planeSet.size >= 4)//最少4个面围成一个三维实体 + { + let geo = CSG2Geometry(interCsg).applyMatrix4(e1.OCSNoClone); + let mesh = new Mesh(geo, this._MeshMaterial); + objMap.set(mesh, [e1, e2]); } } } @@ -234,6 +180,12 @@ export class CheckInterfereTool return objMap; } + Clear() + { + this.entitySet.clear(); + this.objMap.clear(); + } + csgCache: Map = new Map(); private GetCSG(en: Solid3D) { @@ -273,5 +225,3 @@ export class CheckInterfereTool return box; } } - -export const checkInterfereTool = new CheckInterfereTool(); diff --git a/src/DatabaseServices/3DSolid/ExtrudeHole.ts b/src/DatabaseServices/3DSolid/ExtrudeHole.ts index 9eff16d79..ceaf6120d 100644 --- a/src/DatabaseServices/3DSolid/ExtrudeHole.ts +++ b/src/DatabaseServices/3DSolid/ExtrudeHole.ts @@ -191,7 +191,7 @@ export class ExtrudeHole extends Hole private GeneralMeshGeometry() { let extrudeSettings: ExtrudeGeometryOptions = { - curveSegments: 12, + curveSegments: 6, steps: 1, bevelEnabled: false, depth: this.Height, diff --git a/src/DatabaseServices/Entity/Extrude.ts b/src/DatabaseServices/Entity/Extrude.ts index 8644d2a85..743efe183 100644 --- a/src/DatabaseServices/Entity/Extrude.ts +++ b/src/DatabaseServices/Entity/Extrude.ts @@ -1,7 +1,7 @@ import { BoxGeometry, BufferGeometry, ExtrudeGeometry, ExtrudeGeometryOptions, Geometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, Line as TLine, LineSegments, Matrix3, Matrix4, Mesh, Object3D, Path, UVGenerator, Vector3 } from "three"; import { Line2 } from "three/examples/jsm/lines/Line2"; import { LineGeometry } from "three/examples/jsm/lines/LineGeometry"; -import { arrayClone, arrayLast, arrayRemoveIf, arrayRemoveOnce, arraySortByNumber, arraySum } from "../../Common/ArrayExt"; +import { arrayClone, arrayLast, arrayPushArray, arrayRemoveIf, arrayRemoveOnce, arraySortByNumber, arraySum } from "../../Common/ArrayExt"; import { ColorMaterial } from "../../Common/ColorPalette"; import { equalCurve, PolylineSpliteRect } from "../../Common/CurveUtils"; import { DisposeThreeObj, Object3DRemoveAll } from "../../Common/Dispose"; @@ -514,8 +514,8 @@ export class ExtrudeSolid extends Entity for (let g of this.grooves) { - if (equaln(g.thickness, this.thickness)) - holes.push(Contour.CreateContour(g.ContourCurve.Clone().ApplyMatrix(this.OCSInv.multiply(g.OCS)), false)); + if (equaln(g.thickness, this.thickness, 1e-3)) + holes.push(Contour.CreateContour(g.ContourCurve.Clone().ApplyMatrix(this.OCSInv.multiply(g.OCSNoClone)), false)); } return new Shape(contour, holes); } @@ -666,8 +666,9 @@ export class ExtrudeSolid extends Entity for (let br of extrudes) { let gs = this.ConverToLocalGroove(br); - grooves.push(...gs); + arrayPushArray(grooves, gs); } + if (grooves.length === 0) return false; let area1 = this.ContourCurve.Area; let sum1 = this.Volume; diff --git a/src/Geometry/GeUtils.ts b/src/Geometry/GeUtils.ts index 226d8b63f..5d983930e 100644 --- a/src/Geometry/GeUtils.ts +++ b/src/Geometry/GeUtils.ts @@ -1,5 +1,6 @@ import { Box3, BufferGeometry, Geometry, Line, Matrix4, Mesh, Object3D, Vector, Vector2, Vector3 } from 'three'; import { ToFixed } from '../Common/Utils'; +import { Vec3 } from './IVec3'; export const IdentityMtx4 = new Matrix4(); export const ZeroVec = new Vector3(); @@ -73,7 +74,7 @@ interface P2 x: number; y: number; } -export function equalv3(v1: Vector3, v2: Vector3, fuzz = 1e-8) +export function equalv3(v1: Vec3, v2: Vec3, fuzz = 1e-8) { return equaln(v1.x, v2.x, fuzz) && equaln(v1.y, v2.y, fuzz) && equaln(v1.z, v2.z, fuzz); } diff --git a/src/UI/Components/Modal/InterfereModal.tsx b/src/UI/Components/Modal/InterfereModal.tsx index 3e5292826..158f99b24 100644 --- a/src/UI/Components/Modal/InterfereModal.tsx +++ b/src/UI/Components/Modal/InterfereModal.tsx @@ -2,12 +2,12 @@ import { Button, Card, Classes, Intent } from '@blueprintjs/core'; import { observable } from 'mobx'; import { observer } from 'mobx-react'; import React, { Component } from 'react'; -import { Box3, Mesh, MeshBasicMaterial, Vector3 } from 'three'; +import { Box3, Mesh, Vector3 } from 'three'; import { app } from '../../../ApplicationServices/Application'; +import { Solid3D } from '../../../Common/InterfereUtil'; import { ColorMaterial } from './../../../Common/ColorPalette'; import { FixIndex } from './../../../Common/Utils'; import { CommonModal } from './ModalContainer'; -import { Solid3D } from '../../../Common/InterfereUtil'; interface IInterfereProps { @@ -72,10 +72,7 @@ export class InterfereModal extends Component { private restore = (os: Mesh[]) => { for (let o of os) - { - let mat = o.material as MeshBasicMaterial; - mat.color = ColorMaterial.GetColor(1); - } + o.material = ColorMaterial.GetConceptualMaterial(1); app.Viewer.OutlinePass.selectedObjects = []; }; private next = () => @@ -96,8 +93,7 @@ export class InterfereModal extends Component { }; private update = (o: Mesh) => { - let mat = o.material as MeshBasicMaterial; - mat.color = ColorMaterial.GetColor(5); + o.material = ColorMaterial.GetConceptualMaterial(5); let box = new Box3(); app.Viewer.OutlinePass.selectedObjects = this.props.data.get(o).map(e => { diff --git a/src/csg/core/Geometry2CSG.ts b/src/csg/core/Geometry2CSG.ts index ecc28060b..0fd1e5039 100644 --- a/src/csg/core/Geometry2CSG.ts +++ b/src/csg/core/Geometry2CSG.ts @@ -1,5 +1,5 @@ import { BufferGeometry, Face3, Geometry, Vector2, Vector3 } from "three"; -import { equalv3, ZeroVec } from "../../Geometry/GeUtils"; +import { AsVector2, AsVector3, equalv3, ZeroVec } from "../../Geometry/GeUtils"; import { CSG } from "./CSG"; import { Polygon } from "./math/Polygon3"; import { Vector2D } from "./math/Vector2"; @@ -34,7 +34,7 @@ export function Geometry2CSG(geometry: Geometry | BufferGeometry): CSG } let polygon = new Polygon(vertices); - let normal = Vector3DToVector3(polygon.plane.normal); + let normal = AsVector3(polygon.plane.normal); if (!isNaN(polygon.plane.w) && !equalv3(normal, new Vector3())) polygons.push(polygon); } @@ -49,12 +49,12 @@ export function CSG2Geometry(csg: CSG): Geometry for (let poly of csg.polygons) { - let normal = Vector3DToVector3(poly.plane.normal); + let normal = AsVector3(poly.plane.normal); if (equalv3(normal, ZeroVec)) continue; for (let v of poly.vertices) { v.tag = geo.vertices.length; - geo.vertices.push(Vector3DToVector3(v.pos)); + geo.vertices.push(AsVector3(v.pos)); } let firstVertex = poly.vertices[0]; @@ -70,9 +70,9 @@ export function CSG2Geometry(csg: CSG): Geometry geo.faces.push(f); uvs.push([ - Vector2DToVector2(firstVertex.uv), - Vector2DToVector2(poly.vertices[i + 1].uv), - Vector2DToVector2(poly.vertices[i + 2].uv) + AsVector2(firstVertex.uv), + AsVector2(poly.vertices[i + 1].uv), + AsVector2(poly.vertices[i + 2].uv) ]); } } @@ -83,12 +83,3 @@ function Vector3ToVector3D(v: Vector3): Vector3D { return new Vector3D(v.x, v.y, v.z); } - -export function Vector3DToVector3(v: Vector3D): Vector3 -{ - return new Vector3(v.x, v.y, v.z); -} -function Vector2DToVector2(v: Vector2D): Vector2 -{ - return new Vector2(v.x, v.y); -} diff --git a/src/csg/core/math/Polygon3.ts b/src/csg/core/math/Polygon3.ts index 8df2ba1f3..5290eb175 100644 --- a/src/csg/core/math/Polygon3.ts +++ b/src/csg/core/math/Polygon3.ts @@ -1,10 +1,11 @@ -import { _CSGDEBUG, EPS } from "../constants"; +import { Matrix4 } from "three"; +import { arrayLast, arrayRemoveDuplicateBySort } from "../../../Common/ArrayExt"; +import { equalv3 } from "../../../Geometry/GeUtils"; +import { EPS, _CSGDEBUG } from "../constants"; +import { IsMirror } from "./IsMirrot"; import { Plane } from "./Plane"; import { Vector3D } from "./Vector3"; import { Vertex3D } from "./Vertex3"; -import { arrayRemoveDuplicateBySort } from "../../../Common/ArrayExt"; -import { Matrix4 } from "three"; -import { IsMirror } from "./IsMirrot"; export enum Type { @@ -36,9 +37,9 @@ interface SplitPolygonData * The plane of the polygon is calculated from the vertex coordinates if not provided. * The plane can alternatively be passed as the third argument to avoid calculations. * - *表示凸多边形。 用于初始化多边形的顶点必须共面并形成凸环。 - *多边形是彼此克隆或从同一多边形分割的多边形。 - *这可用于定义每个多边形属性(例如表面颜色)。 + *表示凸多边形。 用于初始化多边形的顶点必须共面并形成凸环。 + *多边形是彼此克隆或从同一多边形分割的多边形。 + *这可用于定义每个多边形属性(例如表面颜色)。 */ export class Polygon { @@ -201,15 +202,12 @@ export class Polygon isBack = nextIsBack; } // for vertexindex // remove duplicate vertices: - let EPS_SQUARED = EPS * EPS; - arrayRemoveDuplicateBySort(backVertices, (v1, v2) => - { - return v1.pos.distanceToSquared(v2.pos) < EPS_SQUARED; - }); - arrayRemoveDuplicateBySort(frontVertices, (v1, v2) => - { - return v1.pos.distanceToSquared(v2.pos) < EPS_SQUARED; - }); + arrayRemoveDuplicateBySort(backVertices, (v1, v2) => equalv3(v1.pos, v2.pos, EPS)); + if (backVertices.length > 2 && equalv3(backVertices[0].pos, arrayLast(backVertices).pos, EPS)) + backVertices.pop(); + arrayRemoveDuplicateBySort(frontVertices, (v1, v2) => equalv3(v1.pos, v2.pos, EPS)); + if (frontVertices.length > 2 && equalv3(frontVertices[0].pos, arrayLast(frontVertices).pos, EPS)) + frontVertices.pop(); if (frontVertices.length >= 3) result.front = new Polygon(frontVertices, this.plane); if (backVertices.length >= 3) @@ -219,7 +217,13 @@ export class Polygon return result; } - static verticesConvex(vertices: Vertex3D[], planenormal: Vector3D) + /** + * 是一个凸多边形 + * @param vertices 顶点列表 + * @param planenormal 平面法线 + * @returns true:是凸多边形 false:不是凸多边形 + */ + static verticesConvex(vertices: Vertex3D[], planenormal: Vector3D): boolean { let count = vertices.length; if (count < 3) return false; diff --git a/src/csg/core/trees.ts b/src/csg/core/trees.ts index 6929263ec..7e822e7cf 100644 --- a/src/csg/core/trees.ts +++ b/src/csg/core/trees.ts @@ -425,8 +425,13 @@ class Node } let args: D = { node: this, polygontreenodes: polygonTreeNodes }; let stack: D[] = []; + + let doCount = 0; do { + if (doCount > 1e3) throw "程序内部错误:尝试对平面进行切割失败!进入死循环!"; + doCount++; + let node = args.node; polygonTreeNodes = args.polygontreenodes;