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/bool2.test.ts

36 lines
3.0 KiB

import { Region } from "../../src/DatabaseServices/Region";
import { LoadRegionsFromFileData } from "../Utils/LoadEntity.util";
import { BoolOpeartionType } from "../../src/GraphicsSystem/BoolOperateUtils";
test("#IRFL2面域消失", () =>
{
let data =
[2, "Region", 2, 1, 102, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -284.847850497852, -347.14497813089565, 0, 1], 1, 1, 1, 1, 1, "Polyline", 2, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -284.847850497852, -347.14497813089565, 0, 1], 0, 2, 4, [258.7734554093699, 1.1368683772161603e-13], 0, [674.3301771838924, 5.684341886080802e-14], 0, [674.3301771838924, 1091.0460568668868], 0, [258.7734554093699, 1091.0460568668868], 0, true, 0, "Region", 2, 1, 103, false, 7, 0, [-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 389.4823496974607, -74.09892126400852, 0, 1], 1, 1, 1, 1, 1, "Polyline", 2, 1, 0, false, 7, 0, [-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 389.4823496974607, -74.09892126400852, 0, 1], 0, 2, 4, [0, 0], 0, [415.5567321777343, 0], 0, [415.5567321777343, 18], 0, [0, 18], 0, true, 0]
let regs: Region[] = LoadRegionsFromFileData(data);
expect(regs.length).toBe(2);
let reg = regs[0].Clone();
reg.BooleanOper(regs[1], BoolOpeartionType.Subtract);
expect(reg.ShapeManager.ShapeList.length).toBe(2);
reg = regs[0].Clone();
reg.BooleanOper(regs[1], BoolOpeartionType.Intersection);
expect(reg.ShapeManager.ShapeList.length).toBe(1);
});
test('#IR8AN交集错误', () =>
{
let data =
[2, "Region", 2, 1, 104, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 111.34512004857766, 13.95089482226993, 0, 1], 0, 1, 1, 1, 1, "Polyline", 2, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 111.34512004857766, 13.95089482226993, 0, 1], 0, 2, 4, [-97.39422719143477, -0.0000019651270122267306], 0, [674.3281411676799, -0.0000019651270122267306], 0, [674.3281421679894, 1199.9999984537135], 0, [-97.3942261911252, 1199.9999984537135], 0, true, 0, "Region", 2, 1, 105, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 13.95089285714289, 113.95089285714292, 0, 1], 0, 1, 1, 1, 1, "Polyline", 2, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 13.95089285714289, 113.95089285714292, 0, 1], 0, 2, 13, [314.3387826639938, -99.99999883531063], 0, [318, -100], 0, [318, 0], 0, [579.5436603415255, 67.84500522108829], 0, [530.3246820683962, 361.2662670472655], 0, [446.27460696874186, 251.38290037066872], 0, [495.4935852418712, 1057.9616385444915], 0, [151.43841386299755, 1055.5264270248226], 0, [151.43841386299755, 155.52640117119142], 0, [0, 200], 0, [0, 0], 0, [140.39432277924786, -16.215571265653125], 0, [140.3943227792479, -100], 0, true, 0]
let regs: Region[] = LoadRegionsFromFileData(data);
expect(regs.length).toBe(2);
let reg = regs[0].Clone();
reg.BooleanOper(regs[1], BoolOpeartionType.Subtract);
expect(reg.ShapeManager.ShapeList.length).toBe(2);
reg = regs[0].Clone();
reg.BooleanOper(regs[1], BoolOpeartionType.Intersection);
expect(reg.ShapeManager.ShapeList.length).toBe(1);
});