You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/__test__/Booloperate/BoardCutting.test.ts

66 lines
6.8 KiB

import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util";
import { Board } from "../../src/DatabaseServices/Board";
import "../Utils/jest.util";
function CuttingBoard(orgBoard: Board, cutBoards: Board[])
{
for (let br of cutBoards)
{
let gs = orgBoard.ConverToLocalGroove(br.Clone());
for (let g of gs)
orgBoard.AppendGroove(g);
}
let splitBoard: Board[] = [];
orgBoard.GrooveCheckAll(splitBoard);
return splitBoard;
}
test('板件与板件切割_分裂成多个', () =>
{
let d =
[3, "Board", 3, 2, 101, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -331.4882673815591, 22.964750159997493, 0, 1], 2, 1200, 600, 18, true, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 1, 2, 560.6466, 189.21820000000014, 18, false, "Polyline", 3, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1827.9668979500452, -289.76232632197764, 0, 1], 2, 4, [1827.9668979500452, 755.7998263219777], 0, [1827.9668979500452, 289.76232632197764], 0, [2017.1850979500452, 289.76232632197764], 0, [2017.1850979500452, 755.7998263219777], 0.9999999999999999, true, 0, 3, 0, 0, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -331.4882673815591, 240.21531912679802, 487.0617703059633, 1], 3, 0, 0, 0, 2, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -331.4882673815591, 22.964750159997493, 0, 1], 1, "左侧板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highDrill\":[\"three\",\"three\",\"three\",\"three\",\"three\",\"three\"]}", 0, 0, "Board", 3, 2, 103, false, 1, 2, 0, [0, 0.7071067811865476, 0.7071067811865475, 0, -1, 0, 0, 0, 0, -0.7071067811865475, 0.7071067811865476, 0, 150.8430102636048, -52.19811424968327, 170.47952541755785, 1], 2, 783.3533043634961, 1175.1597867537462, 18, true, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 376.7045899568675, -325.59238647697345, 0, 1], 2, 4, [-376.7045899568675, 325.59238647697345], 0, [798.4551967968786, 325.59238647697345], 0, [798.4551967968786, 1108.9456908404695], 0, [-376.7045899568675, 1108.9456908404695], 0, true, 0, 3, 0, 0, 0, 2, [1, 0, 0, 0, 0, 0.7071067811865476, 0.7071067811865475, 0, 0, -0.7071067811865475, 0.7071067811865476, 0, 476.43539674057826, 214.17225581291558, 436.84989548015665, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highDrill\":[]}", 0, 0, "Board", 3, 2, 105, false, 1, 2, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 150.8430102636048, -84.04268340053818, 746.0908003894185, 1], 2, 1200, 1446.4691198791304, 18, true, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [1446.4691198791304, 0], 0, [1446.4691198791304, 1200], 0, [0, 1200], 0, true, 0, 3, 0, 0, 0, 2, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 150.8430102636048, -84.04268340053818, 746.0908003894185, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highDrill\":[]}", 0, 0];
let brs = LoadBoardsFromFileData(d);
let br = brs.shift()
let splitBrs = CuttingBoard(br, brs);
splitBrs.push(br);
for (let b of splitBrs)
{
expect(b.Width).toMatchNumberSnapshot();
expect(b.Height).toMatchNumberSnapshot();
expect(b.Thickness).toMatchNumberSnapshot();
}
});
test('斜切割', () =>
{
let d =
{ "file": [2, "Board", 3, 2, 101, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -2215.328823760792, 499.71410406375077, -2294.099214285263, 1], 2, 1200, 600, 18, true, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, 3, 0, 0, 0, 2, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -205.28537176904496, 177.69146652013302, 0, 1], 1, "左侧板", { "roomName": "", "cabinetName": "", "boardName": "", "material": "", "color": "", "lines": 0, "bigHoleDir": 0, "composingFace": 2, "highSealed": [], "sealedUp": "1", "sealedDown": "1", "sealedLeft": "1", "sealedRight": "1", "spliteHeight": "", "spliteWidth": "", "spliteThickness": "", "highDrill": ["三合一", "三合一", "三合一", "三合一"], "frontDrill": true, "backDrill": true, "drillType": "三合一" }, 0, 0, "Board", 3, 2, 102, false, 1, 2, 0, [0, 1, 0, 0, -0.9502295409734979, 0, -0.31155066917163815, 0, -0.31155066917163815, 0, 0.9502295409734979, 0, -1370.93197964564, 499.71410406375077, -1535.8828067472384, 1], 2, 1210.53726169844, 600, 18, true, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1210.53726169844], 0, [0, 1210.53726169844], 0, true, 0, 3, 0, 0, 0, 2, [0.9502295409734979, 0, 0.31155066917163815, 0, 0, 1, 0, 0, -0.31155066917163815, 0, 0.9502295409734979, 0, 639.1114723461071, 177.69146652013302, 758.2164075380244, 1], 0, "层板", { "roomName": "", "cabinetName": "", "boardName": "", "material": "", "color": "", "lines": 0, "bigHoleDir": 0, "composingFace": 2, "highSealed": [], "sealedUp": "1", "sealedDown": "1", "sealedLeft": "1", "sealedRight": "1", "spliteHeight": "", "spliteWidth": "", "spliteThickness": "", "highDrill": ["三合一", "三合一", "三合一", "三合一"], "frontDrill": true, "backDrill": true, "drillType": "三合一" }, 0, 0], "basePt": { "x": -1847.3471649178755, "y": -8951.992136339191, "z": 0 } }
{
let [br0, br1] = LoadBoardsFromFileData(d) as Board[];
let splitBrs = CuttingBoard(br0, [br1]);
splitBrs.push(br0);
for (let b of splitBrs)
{
expect(b.Width).toMatchNumberSnapshot();
expect(b.Height).toMatchNumberSnapshot();
expect(b.Thickness).toMatchNumberSnapshot();
}
}
{
let [br1, br0] = LoadBoardsFromFileData(d) as Board[];
let splitBrs = CuttingBoard(br0, [br1]);
splitBrs.push(br0);
for (let b of splitBrs)
{
expect(b.Width).toMatchNumberSnapshot();
expect(b.Height).toMatchNumberSnapshot();
expect(b.Thickness).toMatchNumberSnapshot();
}
}
});