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__/Interfere/intf.test.ts

24 lines
1.4 KiB

import { Polyline } from "../../src/api";
import { Contour } from "../../src/DatabaseServices/Contour";
import "../Utils/jest.util";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
test('求交集错误', () =>
{
let d = [2, "Polyline", 8, 2, 0, false, 0, 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, 2, 4, [9.094947017729282e-12, -1411.0000000000002], 0, [9.094947017729282e-12, 2423], 0, [-17.999999999990905, 2423], 0, [-17.999999999990905, -1411.0000000000002], 0, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5140442132778844, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5140442132778844, 0, 0, 1], 0, 2, 8, [540, 0], 0, [540, 102], 0, [552, 102], 0, [561, 2329], 0, [-0.5140442132778844, 2329], 0, [-0.5140442132778844, 2329], 0, [-0.5140442132778844, 2329], 0, [0, 0], 0, true];
let pls = LoadEntityFromFileData(d) as Polyline[];
let cons = pls.map(pl => Contour.CreateContour(pl));
let res = cons[0].GetIntersetAndUnionList(cons[1]);
expect(res.unionList.length).toMatchSnapshot();
expect(res.intersectionList.length).toMatchSnapshot();
for (let c of res.unionList)
expect(c.Length).toMatchNumberSnapshot();
for (let c of res.intersectionList)
expect(c.Length).toMatchNumberSnapshot();
});