mirror of https://gitee.com/cf-fz/WebCAD.git
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.
63 lines
2.5 KiB
63 lines
2.5 KiB
6 years ago
|
import { Factory } from "../../src/DatabaseServices/CADFactory";
|
||
|
import { CADFile } from "../../src/DatabaseServices/CADFile";
|
||
|
import { Curve } from "../../src/DatabaseServices/Curve";
|
||
|
import { Polyline } from "../../src/DatabaseServices/Polyline";
|
||
|
Factory(Polyline);
|
||
|
function loadFile(data)
|
||
|
{
|
||
|
let file = new CADFile();
|
||
|
file.Data = data;
|
||
|
let cus: Curve[] = [];
|
||
|
let count = file.Read();
|
||
|
for (let i = 0; i < count; i++)
|
||
|
{
|
||
|
cus.push(file.ReadObject(undefined) as Curve);
|
||
|
}
|
||
|
return cus;
|
||
|
}
|
||
|
test('补充bug测试#IKWGF', () =>
|
||
|
{
|
||
|
//https://gitee.com/BearCAD/WebThreeJs/issues/IKWGF
|
||
|
let data =
|
||
|
[1, ["Polyline", 1, 1, 28, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1.073087818696886, -6.460623229461753, 0, 1], 2, 13, [2.913294797687863, 5.657009425680781], -0.10216571300036134, [3.0668619767188887, 5.578034682080925], 0, [4.6094463694365295, 5.578034682080925], -2.632498680881094, [4.609446369436524, 3.627167630057804], 0, [2.4566473988439355, 3.627167630057804], 0, [2.4566473988439355, 3.627167630057804], 0, [2.4566473988439355, 4.990312071734102], -0.11795690250598688, [2.37813156168231, 5.1728323699421965], 0, [1.8884393063583844, 5.1728323699421965], 0, [1.8884393063583844, 5.1728323699421965], 0, [1.8884393063583844, 6.15606936416185], 0, [2.913294797687864, 6.15606936416185], 0, [2.913294797687864, 5.657009425680784], 0, false]];
|
||
|
|
||
|
let pl = loadFile(data)[0];
|
||
|
|
||
|
//situation 1
|
||
|
let cus = pl.GetOffsetCurves(0.3743);
|
||
|
expect(cus.length).toBe(3);
|
||
|
expect(cus[0].Length).toMatchSnapshot();
|
||
|
expect(cus[1].Length).toMatchSnapshot();
|
||
|
expect(cus[2].Length).toMatchSnapshot();
|
||
|
|
||
|
//situation 2
|
||
|
cus = pl.GetOffsetCurves(0.3602);
|
||
|
expect(cus.length).toBe(1);
|
||
|
expect(cus[0].Length).toMatchSnapshot();
|
||
|
|
||
|
//situation 3
|
||
|
cus = pl.GetOffsetCurves(0.4269);
|
||
|
expect(cus.length).toBe(2);
|
||
|
expect(cus[0].Length).toMatchSnapshot();
|
||
|
expect(cus[1].Length).toMatchSnapshot();
|
||
|
|
||
|
//situation 4
|
||
|
cus = pl.GetOffsetCurves(0.2286);
|
||
|
expect(cus.length).toBe(1);
|
||
|
expect(cus[0].Length).toMatchSnapshot();
|
||
|
|
||
|
//situation 5
|
||
|
cus = pl.GetOffsetCurves(0.2309);
|
||
|
expect(cus.length).toBe(2);
|
||
|
expect(cus[0].Length).toMatchSnapshot();
|
||
|
expect(cus[1].Length).toMatchSnapshot();
|
||
|
|
||
|
//situation 6
|
||
|
cus = pl.GetOffsetCurves(0.3792);
|
||
|
expect(cus.length).toBe(3);
|
||
|
expect(cus[0].Length).toMatchSnapshot();
|
||
|
expect(cus[1].Length).toMatchSnapshot();
|
||
|
expect(cus[2].Length).toMatchSnapshot();
|
||
|
|
||
|
})
|