import { BoolOpeartionType } from "../../src/api"; import { Board } from "../../src/DatabaseServices/Entity/Board"; import { Region } from "../../src/DatabaseServices/Entity/Region"; import "../Utils/jest.util"; import { LoadEntityFromFileData, LoadRegionsFromFileData } from "../Utils/LoadEntity.util"; test('造型里面有重复的圆造型', () => { let d = require("./br.json").file; let br = LoadEntityFromFileData(d)[0] as Board; let split = []; br.GrooveCheckAll(split); expect(br.Grooves.length).toMatchSnapshot(); expect(split.length).toMatchSnapshot(); }); test('同心圆', () => { let f = { "file": [2, "Region", 8, 2, 506, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 1, 1, 1, 1, "Circle", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, 320.4444931257359, 0, "Region", 8, 2, 507, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 1, 1, 1, 1, "Circle", 8, 2, 0, false, 0, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, 179.954009116518, 0], "basePt": { "x": 1623.8278194823188, "y": 1169.183093664109, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; let regs = LoadRegionsFromFileData(f) as Region[]; let regs2 = regs.map(r => r.Clone()); let regs3 = regs.map(r => r.Clone()); regs[0].BooleanOper(regs[1], BoolOpeartionType.Intersection); expect(regs[0].Area).toMatchNumberSnapshot(); regs2[0].BooleanOper(regs2[1], BoolOpeartionType.Union); expect(regs2[0].Area).toMatchNumberSnapshot(); regs3[0].BooleanOper(regs3[1], BoolOpeartionType.Subtract); expect(regs3[0].Area).toMatchNumberSnapshot(); });