|
|
@ -1,8 +1,21 @@
|
|
|
|
import { Factory } from "../../src/DatabaseServices/CADFactory";
|
|
|
|
import { Factory } from "../../src/DatabaseServices/CADFactory";
|
|
|
|
import { CADFile } from "../../src/DatabaseServices/CADFile";
|
|
|
|
import { CADFile } from "../../src/DatabaseServices/CADFile";
|
|
|
|
import { Polyline } from "../../src/DatabaseServices/Polyline";
|
|
|
|
import { Polyline } from "../../src/DatabaseServices/Polyline";
|
|
|
|
|
|
|
|
import { Curve } from "../../src/DatabaseServices/Curve";
|
|
|
|
Factory(Polyline);
|
|
|
|
Factory(Polyline);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadFile(data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let file = new CADFile();
|
|
|
|
|
|
|
|
file.Data = data;
|
|
|
|
|
|
|
|
let cus: Curve[] = [];
|
|
|
|
|
|
|
|
for (let i = 0; i < file.Data.length; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cus.push(file.ReadObject(undefined) as Curve);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return cus;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
test('IKKGK圆与直线补圆弧', () =>
|
|
|
|
test('IKKGK圆与直线补圆弧', () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let f = new CADFile();
|
|
|
|
let f = new CADFile();
|
|
|
@ -37,3 +50,57 @@ test('IKKGK圆与直线补圆弧', () =>
|
|
|
|
cus = pl.GetOffsetCurves(-1.926388985025112);
|
|
|
|
cus = pl.GetOffsetCurves(-1.926388985025112);
|
|
|
|
expect(cus.length).toBe(1);
|
|
|
|
expect(cus.length).toBe(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('多段线偏移测试1', () =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let data = [["Polyline", 1, 1, 3, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [6.059716713881022, 3.983456090651555], 1.1217395195062214, [6.383002832861191, 4.064022662889515], 0, [4.929178470254959, 8.399433427762037], 1.2642365052895204, [5.750708215297452, 4.050991501416427], 0.7171789779484218, true]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cus = loadFile(data);
|
|
|
|
|
|
|
|
for (let i = 0; i < 10; i += 0.01)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = -1.5; i < 0; i += 0.01)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 2; i < 10; i += 0.01)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
expect(cus[0].GetOffsetCurves(-i).length).toBe(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
test('多段线偏移测试2', () =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let data = [["Polyline", 1, 1, 734, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [8.176442643449754, 4.003694129881114], 0.6482011490054378, [8.554554536583165, 4.090460859042256], 0, [7.7292787370841225, 8.733182129315965], 0, [7.8227800907745895, 4.037582052934876], 1.223388515290821, true]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cus = loadFile(data);
|
|
|
|
|
|
|
|
expect(cus[0].GetOffsetCurves(-0.1799).length).toBe(2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 10; i += 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = -0.17; i < 0; i += 0.01)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = -0.18; i < -0.34; i -= 0.01)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 0.35; i < 3; i += 0.01)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
expect(cus[0].GetOffsetCurves(-i).length).toBe(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
test('多段线偏移测试3', () =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let data = [["Polyline", 1, 1, 1172, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [12.52535684411379, 4.512623511896158], 0.39558516940595195, [13.121416971132648, 4.487590129452889], 0, [12.414545456418505, 8.796498405316765], 0, [12.015990240675425, 8.743859037199755], 0, [12.015990240675425, 4.4951100391838885], 0.8508932598252141, true]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cus = loadFile(data);
|
|
|
|
|
|
|
|
for (let i = 0; i < 10; i += 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|