diff --git a/__test__/EdgeSealing/SmoothEdge.test.ts b/__test__/EdgeSealing/SmoothEdge.test.ts new file mode 100644 index 000000000..d07fed29e --- /dev/null +++ b/__test__/EdgeSealing/SmoothEdge.test.ts @@ -0,0 +1,49 @@ +import { SetSmoothEdges } from "../../src/Add-on/SetSmoothEdge/SetSmoothEdgeFace"; +import { Board } from "../../src/DatabaseServices/Entity/Board"; +import { ISmoothEdgeOption } from "../../src/UI/Store/BoardInterface"; +import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util"; + +describe("见光面封边测试", () => +{ + const smoothOption: ISmoothEdgeOption = { + smoothEdge: 1, + edge: 0, + scale: 10, + filterArr: [], + }; + test("异型板和层板", () => + { + let data = { "file": [2, "Board", 8, 2, 245, false, 1, 2, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 2386.6534132798843, -350.616335546365, 991, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2386.6534132798843, -350.616335546365, 991, 1], 0, 3, 1164, 582, 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, [582, 0], 0, [582, 1164], 0, [0, 1164], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 0, "层板", "", "", "", "", "", 0, 1, "test", 2, 4, 3, 3, 3, 6, "3", "3", "6", "3", "", "", "", 4, "test", "test", "test", "test", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 246, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 1222.6534132798843, 249.383664453635, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2145.2890228780084, 249.383664453635, 0, 1], 0, 3, 2000, 1165.1248637220942, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -3335.482188966598, -7.2639225183823015, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -3335.482188966598, -7.2639225183823015, 0, 1], 0, 2, 12, [4064.7800097898426, 2007.2639225183823], 0, [4064.7800097898426, 810.169491525735], 0, [4111.269113906065, 810.169491525735], 0, [4111.269113906065, 2007.2639225183823], 0, [4500.607052688692, 2007.2639225183823], 0, [4500.607052688692, 7.2639225183823015], 0, [3335.482188966598, 7.2639225183823015], 0, [3335.482188966598, 2007.2639225183823], 0, [3737.419234971441, 2007.2639225183823], 0, [3737.419234971441, 786.9249394675348], 0, [3761.632310031973, 786.9249394675348], 0, [3761.632310031973, 2007.2639225183823], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 3, 6, 6, "6", "6", "6", "3", "", "", "", 12, "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": 1222.6534132798843, "y": -350.616335546365, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let brs = LoadBoardsFromFileData(data) as Board[]; + SetSmoothEdges(brs, smoothOption); + expect(brs[0].BoardProcessOption.highSealed.some(h => h.size === 0)).toBeTruthy(); + }); + test("圆弧边", () => + { + let data = { "file": [3, "Board", 8, 2, 258, false, 1, 7, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 3664.8207843769305, -861.5798655676876, 485, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3666.516880569243, -861.5798655676876, 485, 1], 0, 3, 836.4018093134093, 479.391355847491, 15, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -1.6960961923121545, 0, 1], 0, 0, true, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -685.528, 8600.725947753688, 0, 1], 0, 2, 3, [239.61368075950736, 838.0979055057214], 0, [0, 413.90249020100055], 0, [259.69656147153364, 1.696096192312325], 0.549002568812166, true, 0, 3, 0, 0, 0, 0, 0, 9, 0, "层板", "", "", "", "", "", 0, 0, "三合一", 2, 3, 1, 1, 0, "1", "1", "1", "1", "", "", "", 3, "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 257, false, 1, 11, 0, [0.8460935354814001, 0.5330344540614469, 0, 0, 0, 0, 1, 0, 0.5330344540614469, -0.8460935354814001, 0, 0, 3252.6143903682423, -861.5798655676876, 0, 1], 0, 0, true, [0.5330344540614469, -0.8460935354814001, 0, 0, 0.8460935354814001, 0.5330344540614469, 0, 0, 0, 0, 1, 0, 3252.6143903682423, -861.5798655676876, 0, 1], 0, 3, 1000, 489, 15, 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, [489, 0], 0, [489, 1000], 0, [0, 1000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "立板", "", "", "", "", "", 0, 0, "三合一", 2, 4, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 256, false, 1, 11, 0, [-0.8707099555169678, 0.4917968822223659, 0, 0, 0, 0, 0.9999999999999998, 0, 0.4917968822223659, 0.8707099555169678, 0, 0, 3245.237437134907, -874.6405149004422, 2.2737367544323206e-13, 1], 0, 0, true, [0.4917968822223659, 0.8707099555169678, 0, 0, -0.8707099555169678, 0.4917968822223659, 0, 0, 0, 0, 0.9999999999999998, 0, 3245.237437134907, -874.6405149004422, 2.2737367544323206e-13, 1], 0, 3, 1000, 489, 15, 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, [489, 0], 0, [489, 1000], 0, [0, 1000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "立板", "", "", "", "", "", 0, 0, "三合一", 2, 4, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": 2819.4602688871096, "y": -874.6405149004422, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let brs = LoadBoardsFromFileData(data) as Board[]; + SetSmoothEdges(brs, smoothOption); + expect(brs[0].BoardProcessOption.highSealed.some(h => h.size === 1)).toBeTruthy(); + }); + test("多碰撞板", () => + { + let data = { "file": [6, "Board", 8, 2, 181, false, 1, 2, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 444.0235511587234, -202.08196334145032, 991, 1], 180, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 444.0235511587234, -202.08196334145032, 991, 1], 0, 3, 1164, 582, 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, [582, 0], 0, [582, 1164], 0, [0, 1164], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 0, "层板", "", "", "", "", "", 0, 1, "test", 2, 4, 3, 3, 3, 6, "3", "3", "6", "3", "", "", "", 4, "test", "test", "test", "test", true, true, 0, 2, 101, 4, 3, 182, 183, 184, 3, 185, 186, 187, 1, 188, 1, 189, 102, 4, 3, 194, 195, 196, 3, 197, 198, 199, 1, 200, 1, 201, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 167, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -40.536965151142795, 397.9180366585497, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -40.536965151142795, 397.9180366585497, 0, 1], 0, 3, 2000, 242.4892541239698, 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, [242.4892541239698, 0], 0, [242.4892541239698, 2000], 0, [0, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 6, 6, 3, "6", "6", "3", "6", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 206, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 202.65916075684757, 397.9180366585497, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 202.65916075684757, 397.9180366585497, 0, 1], 0, 3, 2000, 242.4892541239698, 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, [242.4892541239698, 0], 0, [242.4892541239698, 2000], 0, [0, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 3, 6, 6, "6", "6", "6", "3", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 130, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -261.5048716471938, 397.9180366585497, 0, 1], 129, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -719.9764488412766, 397.9180366585497, 0, 1], 0, 3, 2000, 220.967906496051, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -458.4715771940828, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -458.4715771940828, 0, 0, 1], 0, 2, 4, [458.4715771940828, 0], 0, [679.4394836901338, 0], 0, [679.4394836901338, 2000], 0, [458.4715771940828, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 3, 6, 6, "6", "6", "6", "3", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 207, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -504.2657787104647, 397.9180366585497, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -504.2657787104647, 397.9180366585497, 0, 1], 0, 3, 2000, 242.4892541239698, 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, [242.4892541239698, 0], 0, [242.4892541239698, 2000], 0, [0, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 6, 6, 6, "6", "6", "6", "6", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 212, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -706.2398046844908, 397.9180366585497, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -706.2398046844908, 397.9180366585497, 0, 1], 0, 3, 2000, 242.4892541239698, 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, [242.4892541239698, 0], 0, [242.4892541239698, 2000], 0, [0, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 6, 6, 6, "6", "6", "6", "6", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": -719.9764488412766, "y": -202.08196334145032, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let brs = LoadBoardsFromFileData(data) as Board[]; + SetSmoothEdges(brs, smoothOption); + expect(brs[0].BoardProcessOption.highSealed.some(h => h.size === 1)).toBeTruthy(); + }); + test("重叠板", () => + { + let data = { "file": [3, "Board", 8, 2, 259, false, 1, 2, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 5919.2197075555305, 525.3948776598554, 991, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5919.2197075555305, 525.3948776598554, 991, 1], 0, 3, 1164, 582, 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, [582, 0], 0, [582, 1164], 0, [0, 1164], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 0, "层板", "", "", "", "", "", 0, 1, "test", 2, 4, 3, 3, 3, 6, "3", "3", "6", "3", "", "", "", 4, "test", "test", "test", "test", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 260, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 5357.5608843600785, 1125.3948776598554, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5677.855317153655, 1125.3948776598554, 0, 1], 0, 3, 2000, 562.7836869175463, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 320.29443279357656, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 320.29443279357656, 0, 0, 1], 0, 2, 4, [-320.29443279357656, 0], 0, [242.4892541239698, 0], 0, [242.4892541239698, 2000], 0, [-320.29443279357656, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 3, 6, 6, "6", "6", "6", "3", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 261, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 5195.328684163361, 1125.3948776598554, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5515.623116956937, 1125.3948776598554, 0, 1], 0, 3, 2000, 562.7836869175463, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 320.29443279357656, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 320.29443279357656, 0, 0, 1], 0, 2, 4, [-320.29443279357656, 0], 0, [242.4892541239698, 0], 0, [242.4892541239698, 2000], 0, [-320.29443279357656, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 3, 6, 6, "6", "6", "6", "3", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": 4755.2197075555305, "y": 525.3948776598554, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let brs = LoadBoardsFromFileData(data) as Board[]; + SetSmoothEdges(brs, smoothOption); + expect(brs[0].BoardProcessOption.highSealed.some(h => h.size === 0)).toBeFalsy(); + }); + test("多片切割板", () => + { + let data = { "file": [10, "Board", 8, 2, 181, false, 1, 2, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 444.0235511587234, -202.08196334145032, 991, 1], 180, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 444.0235511587234, -202.08196334145032, 991, 1], 0, 3, 1164, 582, 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, [582, 0], 0, [582, 1164], 0, [0, 1164], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 0, "层板", "", "", "", "", "", 0, 1, "test", 2, 4, 3, 3, 3, 6, "3", "3", "6", "3", "", "", "", 4, "test", "test", "test", "test", true, true, 0, 4, 262, 5, 3, 263, 264, 265, 3, 266, 267, 268, 3, 269, 270, 271, 1, 272, 1, 273, 102, 5, 3, 279, 280, 281, 3, 282, 283, 284, 3, 285, 286, 287, 1, 288, 1, 289, 295, 5, 3, 296, 297, 298, 3, 299, 300, 301, 3, 302, 303, 304, 1, 305, 1, 306, 101, 5, 3, 312, 313, 314, 3, 315, 316, 317, 3, 318, 319, 320, 1, 321, 1, 322, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 101, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -737.9764488412766, -202.08196334145032, 0, 1], 100, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -737.9764488412766, -202.08196334145032, 0, 1], 0, 3, 2000, 187.47435439499293, 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, [187.47435439499287, 0], 0, [187.47435439499293, 2000], 0, [0, 2000], 0, [0, 0], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "左侧板", "", "", "", "", "", 0, 0, "test", 2, 4, 3, 6, 6, 6, "6", "6", "6", "3", "", "", "", 4, "test", "test", "test", "test", true, true, 0, 1, 181, 5, 3, 312, 313, 314, 3, 315, 316, 317, 3, 318, 319, 320, 1, 321, 1, 322, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 102, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 444.0235511587234, -202.08196334145032, 0, 1], 100, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 444.0235511587234, -202.08196334145032, 0, 1], 0, 3, 2000, 300, 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, [300, 0], 0, [300, 2000], 0, [0, 2000], 0, [0, 0], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "右侧板", "", "", "", "", "", 0, 0, "test", 2, 4, 3, 6, 6, 6, "6", "6", "6", "3", "", "", "", 4, "test", "test", "test", "test", true, true, 0, 1, 181, 5, 3, 279, 280, 281, 3, 282, 283, 284, 3, 285, 286, 287, 1, 288, 1, 289, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 130, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -261.5048716471938, 397.9180366585497, 0, 1], 129, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -719.9764488412766, 397.9180366585497, 0, 1], 0, 3, 2000, 220.967906496051, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -458.4715771940828, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -458.4715771940828, 0, 0, 1], 0, 2, 4, [458.4715771940828, 0], 0, [679.4394836901338, 0], 0, [679.4394836901338, 2000], 0, [458.4715771940828, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 3, 6, 6, "6", "6", "6", "3", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 167, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -40.536965151142795, 397.9180366585497, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -40.536965151142795, 397.9180366585497, 0, 1], 0, 3, 2000, 242.4892541239698, 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, [242.4892541239698, 0], 0, [242.4892541239698, 2000], 0, [0, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 6, 6, 3, "6", "6", "3", "6", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 206, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 202.65916075684757, 397.9180366585497, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 202.65916075684757, 397.9180366585497, 0, 1], 0, 3, 2000, 242.4892541239698, 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, [242.4892541239698, 0], 0, [242.4892541239698, 2000], 0, [0, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 3, 6, 6, "6", "6", "6", "3", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 207, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -504.2657787104647, 397.9180366585497, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -504.2657787104647, 397.9180366585497, 0, 1], 0, 3, 2000, 242.4892541239698, 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, [242.4892541239698, 0], 0, [242.4892541239698, 2000], 0, [0, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 6, 6, 3, "6", "6", "3", "6", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 212, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -706.2398046844908, 397.9180366585497, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -706.2398046844908, 397.9180366585497, 0, 1], 0, 3, 2000, 201.9740259740261, 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, [201.9740259740261, 0], 0, [201.9740259740261, 2000], 0, [0, 2000], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "", "", "", 0, 1, "test", 2, 4, 6, 3, 6, 6, "6", "6", "6", "3", "", "", "", 4, "test", "test", "test", "test", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 262, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 444.0235511587234, 97.91803665854968, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 444.0235511587234, -202.08196334145032, 0, 1], 0, 3, 2000, 300, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -300, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -300, 0, 0, 1], 0, 2, 4, [600, 0], 0, [600, 2000], 0, [300, 2000], 0, [300, 0], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "右侧板", "", "", "", "", "", 0, 0, "test", 2, 4, 6, 6, 3, 6, "6", "6", "3", "6", "", "", "", 4, "test", "test", "test", "test", true, true, 0, 1, 181, 5, 3, 263, 264, 265, 3, 266, 267, 268, 3, 269, 270, 271, 1, 272, 1, 273, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 295, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -737.9764488412766, -14.607608946457447, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -737.9764488412766, -202.08196334145032, 0, 1], 0, 3, 2000, 412.5256456050071, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -187.47435439499287, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -187.47435439499287, 0, 0, 1], 0, 2, 4, [600, 0], 0, [600, 2000], 0, [187.47435439499287, 2000], 0, [187.47435439499287, 0], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "左侧板", "", "", "", "", "", 0, 0, "test", 2, 4, 6, 6, 3, 6, "6", "6", "3", "6", "", "", "", 4, "test", "test", "test", "test", true, true, 0, 1, 181, 5, 3, 296, 297, 298, 3, 299, 300, 301, 3, 302, 303, 304, 1, 305, 1, 306, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": -737.9764488412766, "y": -202.08196334145032, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let brs = LoadBoardsFromFileData(data) as Board[]; + SetSmoothEdges(brs, smoothOption); + expect(brs[0].BoardProcessOption.highSealed.filter(s => s.size === 0).length).toBe(3); + }); +}); diff --git a/src/Add-on/SetSmoothEdge/SetSmoothEdgeFace.ts b/src/Add-on/SetSmoothEdge/SetSmoothEdgeFace.ts index 6dce7a73c..767ca9339 100644 --- a/src/Add-on/SetSmoothEdge/SetSmoothEdgeFace.ts +++ b/src/Add-on/SetSmoothEdge/SetSmoothEdgeFace.ts @@ -4,7 +4,7 @@ import { equaln, equalv3 } from "../../Geometry/GeUtils"; import { Arc } from "../../DatabaseServices/Entity/Arc"; import { GetBoardSealingCurves, GetBoardHighSeal, HandleRectBoardSealingData } from "../../GraphicsSystem/CalcEdgeSealing"; import { Face } from "../../Geometry/DrillParse/Face"; -import { Matrix4, Vector3 } from "three"; +import { Box3, Matrix4, Vector3 } from "three"; import { Polyline } from "../../DatabaseServices/Entity/Polyline"; import { Board } from "../../DatabaseServices/Entity/Board"; import { Box3Ext } from "../../Geometry/Box"; @@ -18,6 +18,7 @@ class SetSmoothEdgeFaces extends BoardGetFace highSealingData: IHighSealedItem[]; private sealCus: Curve[]; private _ArcFaceIndexs: Set; + private _CoveredWidthFaceMap = new Map(); constructor(public Board: Board) { super(Board); @@ -101,26 +102,56 @@ class SetSmoothEdgeFaces extends BoardGetFace else continue; } - + let f1CoverBoxes = this._CoveredWidthFaceMap.get(f1) ?? []; + let f2CoverBoxes = bg._CoveredWidthFaceMap.get(f2) ?? []; if (f1.type === f2.type) { - if (f1.IsIntersect(f2, scale)) + let intRes = f1.IsIntersect(f2, scale, f1CoverBoxes); + if (intRes.isInt) + { this.SmoothFace.add(f1); - if (f2.IsIntersect(f1, scale)) + this._CoveredWidthFaceMap.delete(f1); + } + else + this._CoveredWidthFaceMap.set(f1, intRes.coverBoxesList); + + intRes = f2.IsIntersect(f1, scale, f2CoverBoxes); + if (intRes.isInt) + { bg.SmoothFace.add(f2); + bg._CoveredWidthFaceMap.delete(f2); + } + else + bg._CoveredWidthFaceMap.set(f2, intRes.coverBoxesList); } else - if (f1.IsIntersect(f2, scale)) + { + let intRes = f1.IsIntersect(f2, scale, f1.type === BoardFaceType.Side ? f1CoverBoxes : f2CoverBoxes); + if (intRes.isInt) { if (f1.type === BoardFaceType.Side) { this.SmoothFace.add(f1); + this._CoveredWidthFaceMap.delete(f1); } if (f2.type === BoardFaceType.Side) { bg.SmoothFace.add(f2); + bg._CoveredWidthFaceMap.delete(f2); } } + else + { + if (f1.type === BoardFaceType.Side) + { + this._CoveredWidthFaceMap.set(f1, intRes.coverBoxesList); + } + if (f2.type === BoardFaceType.Side) + { + bg._CoveredWidthFaceMap.set(f2, intRes.coverBoxesList); + } + } + } } } } diff --git a/src/Geometry/DrillParse/Face.ts b/src/Geometry/DrillParse/Face.ts index 67e4a2a3c..2d86fa772 100644 --- a/src/Geometry/DrillParse/Face.ts +++ b/src/Geometry/DrillParse/Face.ts @@ -1,4 +1,4 @@ -import { Matrix4, Vector3 } from "three"; +import { Box3, Matrix4, Vector3 } from "three"; import { MatrixPlanarizere } from "../../Common/Matrix4Utils"; import { Board } from "../../DatabaseServices/Entity/Board"; import { Region } from "../../DatabaseServices/Entity/Region"; @@ -145,7 +145,7 @@ export class Face } return newFaces; } - IsIntersect(f: Face, fuzz = 1e-6): boolean + IsIntersect(f: Face, fuzz = 1e-6, currentCoverBoxes: Box3[] = []): { isInt: boolean, coverBoxesList?: Box3[]; } { //获得侧面和非侧面 let [sideFace, noSideFace] = this.type === BoardFaceType.Side ? [this, f] : [f, this]; @@ -169,19 +169,55 @@ export class Face let size = box.getSize(new Vector3); if (equaln(size.x * size.y, 0)) - return false; + return { isInt: false, coverBoxesList: currentCoverBoxes }; let con1 = Contour.CreateContour(c1); let con2 = Contour.CreateContour(c2); let cs = con1.IntersectionBoolOperation(con2); - + let width = 0; + let boxList: Box3[] = []; + //当前碰撞区域如果遮光直接退出 for (let c of cs) { - c.BoundingBox.getSize(size); - if (size.x / sideFace.Length > fuzz) - return true; + let b = c.BoundingBox; + b.getSize(size); + width += size.x; + if (width / sideFace.Length > fuzz) + return { isInt: true }; + boxList.push(b); + } + if (currentCoverBoxes.length === 0) + { + return { isInt: false, coverBoxesList: boxList }; + } + //与旧盒子合并后测试是否遮光 + width = 0; + while (currentCoverBoxes.length > 0) + { + let b = currentCoverBoxes.pop(); + let isInt = false; + for (let box of boxList) + { + if (box.intersectsBox(b)) + { + isInt = true; + box.union(b); + break; + } + } + if (!isInt) + boxList.push(b); + } + + for (let b of boxList) + { + b.getSize(size); + width += size.x; + if (width / sideFace.Length > fuzz) + return { isInt: true }; } - return false; + + return { isInt: false, coverBoxesList: boxList }; } else { @@ -195,10 +231,38 @@ export class Face { retBox.intersect(box3); let size = retBox.getSize(new Vector3()); - return !equaln(size.x * size.y, 0) && size.x / sideFace.Length > fuzz && size.y / sideFace.Width > fuzz; + if (equaln(size.x * size.y, 0) || size.y / sideFace.Width <= fuzz) + return { isInt: false, coverBoxesList: currentCoverBoxes }; + + if (size.x / sideFace.Length > fuzz) + return { isInt: true }; + if (currentCoverBoxes.length === 0) + { + return { isInt: false, coverBoxesList: [retBox] }; + } + for (let b of currentCoverBoxes) + { + if (b.intersectsBox(retBox)) + { + b.union(retBox); + retBox = null; + break; + } + } + if (retBox) + currentCoverBoxes.push(retBox); + let width = 0; + for (let b of currentCoverBoxes) + { + b.getSize(size); + width += size.x; + if (width / sideFace.Length > fuzz) + return { isInt: true }; + } + + return { isInt: false, coverBoxesList: currentCoverBoxes }; } + return { isInt: false, coverBoxesList: currentCoverBoxes }; } - - return false; } }