import { RoomWallBase } from "../../src/DatabaseServices/Room/Entity/Wall/RoomWallBase"; import { RoomWallRemoveDuplicate } from "../../src/DatabaseServices/Room/ParseService/RoomWallRemoveDuplicate"; import "../Utils/jest.util"; import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; test('简单的墙体删除重复', () => { let d1 = { "file": [4, "RoomWallLine", 1, 3, 8, 2, 116, false, 1, 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, 120, 0, 2700, 0, 2000, 0, 0, 0, 0, "RoomWallLine", 1, 3, 8, 2, 117, false, 1, 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, 120, 0, 2700, 0, 0, 0, 2000, 0, 0, "RoomWallLine", 1, 3, 8, 2, 118, false, 1, 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, 120, 0, 2700, 2000, 0, 0, 2000, 2000, 0, "RoomWallLine", 1, 3, 8, 2, 119, false, 1, 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, 120, 0, 2700, 2000, 2000, 0, 0, 2000, 0], "basePt": { "x": -60, "y": -60, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; let d2 = { "file": [4, "RoomWallLine", 1, 3, 8, 2, 126, false, 1, 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, 120, 0, 2700, 1300, 0, 0, 1300, 1000, 0, "RoomWallLine", 1, 3, 8, 2, 127, false, 1, 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, 120, 0, 2700, 1300, 1000, 0, 300, 1000, 0, "RoomWallLine", 1, 3, 8, 2, 124, false, 1, 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, 120, 0, 2700, 300, 1000, 0, 300, 0, 0, "RoomWallLine", 1, 3, 8, 2, 125, false, 1, 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, 120, 0, 2700, 300, 0, 0, 1300, 0, 0], "basePt": { "x": 240, "y": -60, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; let walls1 = LoadEntityFromFileData(d1); let walls2 = LoadEntityFromFileData(d2); let rrd = new RoomWallRemoveDuplicate(walls1, walls2); expect(rrd.SplitWalls.length).toMatchSnapshot(); for (let w of rrd.SplitWalls) expect(w.Length).toMatchNumberSnapshot(); walls1 = LoadEntityFromFileData(d1); walls2 = LoadEntityFromFileData(d2); let rrd2 = new RoomWallRemoveDuplicate(walls2, walls1); expect(rrd2.SplitWalls.length).toMatchSnapshot(); for (let w of rrd2.SplitWalls) expect(w.Length).toMatchNumberSnapshot(); });