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

30 lines
2.9 KiB

import { LoadRegionsFromFileData } from "../Utils/LoadEntity.util";
import { BoolOpeartionType } from "../../src/GraphicsSystem/BoolOperateUtils";
test('布尔_误差共线_误差交点', () =>
{
let d = [2, "Region", 3, 2, 128, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 1, 1, 1, 1, "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, [600, 0], 0, [600, 1241.380049628613], 0, [0, 1241.380049628613], 0, [0, 0], 0, true, 0, "Region", 3, 2, 129, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1232.380049628613, 0, 1], 1, 1, 1, 1, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1232.380049628613, 0, 1], 2, 4, [0, 0], 0, [582, 0], 0, [582, 8.999955254199449], 0, [0, 8.999955254199449], 0, true, 0];
let regs = LoadRegionsFromFileData(d);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Subtract);
expect(regs[0].Area).toMatchSnapshot();
//弧形情况
d =
[2, "Region", 3, 2, 156, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3051.4141274641142, 141.87083942583706, 0, 1], 1, 1, 1, 1, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3051.4141274641142, 141.87083942583706, 0, 1], 2, 4, [600, 0], 0, [600, 1241.380049628613], 0, [0, 1241.380049628613], 0, [0, 0], 0, true, 0, "Region", 3, 2, 155, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3051.4141274641142, 1374.2508890544507, 0, 1], 1, 1, 1, 1, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3051.4141274641142, 1374.2508890544507, 0, 1], 2, 4, [0, 0], 0, [582, 0], 0.26581272283978424, [582, 8.999955254199449], 0, [0, 8.999955254199449], 0, true, 0];
regs = LoadRegionsFromFileData(d);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Subtract);
expect(regs[0].Area).toMatchSnapshot();
});
test('误差打断', () =>
{
let d = [2, "Region", 3, 2, 780, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1270.0801901174855, 251.0534593864627, 0, 1], 1, 1, 1, 1, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1270.0801901174855, 251.0534593864627, 0, 1], 2, 7, [337.0932869688667, -418.03134104109404], 0, [482, -246.84009191289078], 0, [482, -146.84009191289078], 0, [582, -146.84009191289078], 0, [582, 573.0000000000002], 0, [0, 573.0000000000002], 0, [0, -418.03134104109404], 0, true, 0, "Region", 3, 2, 779, false, 1, 7, 0, [-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, -872.726286511064, -95.7866325264281, 0, 1], 1, 1, 1, 1, "Polyline", 3, 2, 0, false, 0, 7, 0, [-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, -872.726286511064, -95.7866325264281, 0, 1], 2, 4, [0, 0], 0, [397.3539036064214, 0], 0, [397.3539036064214, 18], 0, [0, 18], 0, true, 0];
let regs = LoadRegionsFromFileData(d);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Subtract);
expect(regs[0].ShapeManager.ShapeList.length).toBe(2);
});