import { Factory } from "../../src/DatabaseServices/CADFactory"; import { Curve } from "../../src/DatabaseServices/Entity/Curve"; import { Polyline } from "../../src/DatabaseServices/Entity/Polyline"; import "../Utils/jest.util"; import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; Factory(Polyline); function loadFile(data) { return LoadEntityFromFileData(data) as Curve[]; } function EntityToMatchSnapshot(ens: Curve[]) { expect(ens.length).toMatchSnapshot(); for (let c of ens) { expect(c.Length).toMatchNumberSnapshot(); } } function testOffset(pl: Curve, dis: number) { let cus = pl.GetOffsetCurves(dis); EntityToMatchSnapshot(cus); } test('圆弧被压扁时', () => { let pl = loadFile( { "file": [1, "Polyline", 8, 2, 154, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 377.4539113436276, 1247.0593462341237, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 6, [0, 0], 0, [19.763395114298646, 0], 0, [19.763395114298646, -77.16333081989751], 0, [620.8495708336222, 2], 0, [12.422828246409608, 2], 0.07998201834820468, [0, 0], 0, false], "basePt": { "x": 377.4539113436276, "y": 1169.8960154142262, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] } )[0] as Polyline; testOffset(pl, -1); });