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__/Polyline/offset.test.ts

1093 lines
96 KiB

import { Factory } from "../../src/DatabaseServices/CADFactory";
import { Curve } from "../../src/DatabaseServices/Entity/Curve";
import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
import { OffsetPolyline } from "../../src/GraphicsSystem/OffsetPolyline";
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('IKKGK圆与直线补圆弧', () =>
{
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -47.808747539346534, 10.92028558763661, 0, 1], 2, 3, [-0.906131771640112, 6.969061295372345], 3.7897716494829594, [4.660056657223795, 6.487252124645892], 0, [18.466397865202012, 17.128892766521286], 0, false]
)[0] as Polyline;
//负1 左边. 禁止补圆弧
let cus = pl.GetOffsetCurves(-1);
EntityToMatchSnapshot(cus);
pl.GetOffsetCurves(-5.654208780429431);
//
//翻转曲线后测试
pl.Reverse();
cus = pl.GetOffsetCurves(1);
EntityToMatchSnapshot(cus);
//圆丢失的问题
cus = pl.GetOffsetCurves(-1.926388985025112);
EntityToMatchSnapshot(cus);
});
describe("闭合多段线", () =>
{
test('闭合多段线偏移测试1', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [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 = 1; i < 10; i += 1)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = -0.5; i < -0.15; i += 0.05)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 2; i < 10; i += 2)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(0);
}
});
test('闭合多段线偏移测试2', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [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.2; i < 10; i += 2)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = -0.17; i < 0; i += 0.03)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = -0.2; i > -0.34; i -= 0.02)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 0.35; i < 0.5; i += 0.05)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(0);
}
});
test('闭合多段线偏移测试3', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [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.5; i < 10; i += 1)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 0.1; i <= 0.5; i += 0.1)//i+=0.01
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
for (let i = 0.51; i <= 1; i += 0.1)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(0);
}
});
test('闭合多段线偏移测试4', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [17.138593827490823, 4.9429359111242475], 0.6262511063576436, [18.12066066115083, 4.8347623552068075], 0, [18.12066066115083, 10.450468898178228], 0, [16.250318720818097, 10.450468898178228], 0, [16.250318720818097, 4.952028938447833], 0.8739221457690426, true];
let cus = loadFile(data);
for (let i = 1; i < 10; i += 2)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 0.4; i <= 0.6; i += 0.5)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
for (let i = 1; i <= 2; i += 0.5)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(0);
}
//变换曲线顺序
data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [22.178278439318607, -1.9155229050126357], 0, [22.83746943877066, -1.800164480108526], 0, [23.79329638797614, -6.11786552651948], -0.871731137783436, [23.348342463346004, -6.282663276382493], -0.7430788314178012, [22.903388538715866, -6.267501883395095], 0, true];
cus = loadFile(data);
for (let i = 0.01; i <= 0.33; i += 0.08)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 0.5; i <= 1; i += 0.2)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(0);
}
});
test('闭合多段线偏移测试5', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [0, 0], 0, [5, 0], 0.9999999999999999, [5, 5], -0.9999999999999999, [5, 10], 0, [0, 10], 0, [0, 0], 0, false];
let cus = loadFile(data);
for (let i = 0.5; i < 10; i += 1.5)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
expect(cus[0].GetOffsetCurves(-1.3).length).toBe(2);
expect(cus[0].GetOffsetCurves(-1.2).length).toBe(1);
expect(cus[0].GetOffsetCurves(-2).length).toBe(1);
for (let i = 2; i <= 2.8; i += 0.1)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
for (let i = 2.9; i <= 6; i += 0.5)
{
let len = cus[0].GetOffsetCurves(-i).length;
expect(len).toBe(0);
}
//反转曲线
cus[0].Reverse();
for (let i = 0.5; i < 10; i += 1.5)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
expect(cus[0].GetOffsetCurves(1.3).length).toBe(2);
expect(cus[0].GetOffsetCurves(1.2).length).toBe(1);
expect(cus[0].GetOffsetCurves(2).length).toBe(1);
for (let i = 2; i <= 2.8; i += 0.2)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 2.9; i <= 6; i += 1)
{
let len = cus[0].GetOffsetCurves(i).length;
expect(len).toBe(0);
}
});
test('闭合多段线偏移测试6', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2.007355593658339, -15.226898894860806, 0, 1], 2, 6, [0.06393073988345588, -13.474722415885717], 0, [0.06393073988345643, -4.4950563800695225], 0, [6.069811270331949, -4.495056380069524], -0.9999999999999999, [6.0698112703319484, -9.101508437403805], 0.8261854469247998, [6.069811270331948, -13.53303193559881], 0, [0.06393073988345588, -13.474722415885717], 0, false];
let cus = loadFile(data);
for (let i = 0.5; i < 10; i += 1)//i+=0.5
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
for (let i = 0.1; i <= 2.9; i += 0.4)//i+=0.1
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 3; i <= 6; i += 0.5)//i+=0.1
{
let len = cus[0].GetOffsetCurves(i).length;
expect(len).toBe(0);
}
});
test('闭合多段线偏移测试7', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [7.068575921553821, 19.385189367549113], 0, [17.866251977281493, 27.179961431447197], -0.7242773730087224, [27.449988121418478, 20.215779833374317], -0.5496546648274403, [21.06083069199382, 18.554598901723907], 0.7351204491094537, [17.802360402987244, 16.70174324719076], -1.609719383557213, [7.068575921553821, 19.385189367549113], 0, true];
let cus = loadFile(data);
//外偏移
for (let i = 0.5; i < 5.5; i += 1)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
//内偏移
for (let i = 3.6; i > 0; i -= 0.6)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 3.7; i <= 4.7; i += 0.2)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(2);
}
expect(cus[0].GetOffsetCurves(5).length).toBe(1);
for (let i = 6.1; i < 10; i += 1)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(0);
}
});
test('闭合多段线偏移测试8', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 9, [-35.77751476623335, 275.4953263952156], 0, [220.87993293360785, 358.6317790975911], 0, [317.8724610863793, 154.43698298649332], 0, [128.26300755464567, 91.72000989522755], 0, [202.6482547094027, 193.81740795077644], 0, [96.90452100901277, 149.33211308371583], 0, [167.64343251892882, 238.30270281783706], 0, [-5.9221441755043855, 147.87357882577945], 0, [115.1361992332179, 265.2855865896607], 0, true];
let cus = loadFile(data);
//外偏移 -
for (let i = 20; i < 200; i += 100)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
//内偏移+
expect(cus[0].GetOffsetCurves(15).length).toBe(1);
expect(cus[0].GetOffsetCurves(17.8).length).toBe(2);
expect(cus[0].GetOffsetCurves(19).length).toBe(3);
for (let i = 20; i <= 40; i += 10)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(3);
}
for (let i = 41.3; i <= 44.3; i += 1)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(2);
}
expect(cus[0].GetOffsetCurves(45).length).toBe(1);
for (let i = 50; i <= 250; i += 100)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(0);
}
});
test('闭合多段线偏移测试9', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2494.1602062139054, -154.37421492307953, 0, 1], 2, 4, [-835.9056689963722, -81.71614968554674], -1.404257507243489, [-2.5205246091134654, -224.3682931983378], -0.7704346688180675, [-677.9527382520764, -55.635630094036955], 0, [-835.9056689963722, -81.71614968554674], 0, false];
let cus = loadFile(data);
//外偏移 -
//内偏移+
for (let i = -350; i <= 350; i += 100)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 370; i <= 460; i += 50)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(0);
}
cus[0].Reverse();
for (let i = -350; i <= 350; i += 100)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
for (let i = 370; i <= 460; i += 50)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(0);
}
});
test('闭合多段线偏移测试10', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -38.7066882611841, -36.73336766355714, 0, 1], 2, 10, [57.916496677407835, -1.0361149153581897], 0, [57.916496677407835, 9.149866136686853], 0, [63.00948720343037, 6.40233177396418], 0, [67.96845166297861, 11.696361399698116], 0, [67.96845166297861, 5.866227508067071], 0, [76.41209385085804, 8.144670638129776], -0.6438035714487224, [82.13500688930966, 1.215523001409662], -0.16133386709235895, [73.7315725213725, -7.388950466238915], -0.24328993833238707, [62.473382937533245, -7.388950466238914], 0.16864648307761998, [53.5472469103464, -6.102300228085856], -1.9523252757782097, true];
let cus = loadFile(data);
//外偏移 -
for (let i = 5; i < 20; i += 5)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
//内偏移+
expect(cus[0].GetOffsetCurves(2.3).length).toBe(1);
for (let i = 2.5; i < 4; i += 1)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(2);
}
for (let i = 4.2; i <= 7.2; i += 0.8)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 7.5; i <= 17.5; i += 5)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(0);
}
});
test('闭合多段线偏移测试11', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 9, [8.533519553072624, 3.044692737430166], 0, [8.198324022346368, 5.782122905027932], 0, [9.483240223463685, 4.594972067039105], 0, [10.293296089385473, 4.958100558659217], 0, [11.298882681564244, 3.50558659217877], 0, [11.648044692737429, 3.1424581005586587], 0, [9.525139664804467, 2.3324022346368705], 0, [9.748603351955305, 3.589385474860334], 0, [8.519553072625698, 1.3268156424580995], 0, true];
let cus = loadFile(data);
//外偏移 -
for (let i = 0.1; i <= 0.3; i += 0.1)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
//内偏移+
expect(cus[0].GetOffsetCurves(0.15).length).toBe(1);
for (let i = 0.2; i <= 0.7; i += 0.1)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(2);
}
for (let i = 0.8; i <= 3.8; i++)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(0);
}
});
test('闭合多段线偏移测试12', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 12, [13.549363225511495, 3.33570646745377], 0, [14.34284463241268, 4.996139781895137], 0, [14.523074259257426, 3.9557232996550056], 0, [15.838887129162556, 4.9814356943054605], 0, [15.943612070431213, 3.9627476292376005], 0, [17.33950450111622, 4.461280640196535], 0, [18.123624596131165, 2.7156799524846913], 0, [17.99903152781382, 1.6177035379380693], 0, [16.03466125512531, 2.900960499995888], 0, [15.014220997727234, 1.7794865537465168], 0, [14.332835411729478, 2.6268506799232134], 0, [13.549363225511495, 3.33570646745377], 0, false];
let cus = loadFile(data);
//外偏移 -
for (let i = 0.5; i <= 2; i += 0.5)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
//内偏移+
expect(cus[0].GetOffsetCurves(0.3).length).toBe(1);
expect(cus[0].GetOffsetCurves(0.4).length).toBe(2);
expect(cus[0].GetOffsetCurves(0.46).length).toBe(3);
expect(cus[0].GetOffsetCurves(0.5).length).toBe(2);
expect(cus[0].GetOffsetCurves(0.9).length).toBe(1);
for (let i = 0.55; i <= 0.85; i++)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(2);
}
for (let i = 1; i <= 2; i += 0.2)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(0);
}
});
test('闭合多段线偏移测试13', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 13.053732578466253, -1.845982384833612, 0, 1], 2, 12, [10.73237450059647, 5.925995426719515], 0, [14.934000173256667, 9.279899014962986], 0, [15.443475259425389, 6.338838290261696], 0, [16.902963217271246, 7.476549375511614], 0, [17.07910144494388, 5.7632047972414195], 0, [18.04054823840169, 6.106578652047782], 0, [19.469515702452366, 2.925424892792106], 0, [19.064111106000592, -0.6472031134391991], 0, [17.253277279358528, 2.956832838161076], 0, [14.95258895308757, 3.1324290048358128], 0, [13.37431523183268, 1.7225442000746034], 0, [10.73237450059647, 5.925995426719515], 0, false];
let cus = loadFile(data);
//外偏移 -
for (let i = 0.5; i <= 2; i += 0.5)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
//内偏移+
expect(cus[0].GetOffsetCurves(1).length).toBe(1);
expect(cus[0].GetOffsetCurves(1.2).length).toBe(3);
});
test('闭合多段线偏移测试14', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 14, [340.820007357324, -3.870032999900914], 0, [431.6163856609081, 116.2815653567217], 0, [485.54806901416487, 54.84040710617603], 0, [533.3356365423672, 67.81131829240235], 0, [624.1320148459513, 40.504136847715344], 0, [656.9006325795757, 23.43714844478601], -0.783383849320176, [633.0068488154745, -74.86870475608706], 0.4462700081240285, [605.0169878346704, -106.27196341747704], -0.8416099256631104, [529.9222388617812, -128.11770857322662], 0, [510.1245323143834, -22.98506001118185], 0, [430.251026588674, -129.48306764546098], 0, [430.251026588674, -65.99387078656383], 0, [351.74287993519897, -145.86737651227318], 0, [303.2726328708796, -87.83961594231337], 0, true];
let cus = loadFile(data);
//外偏移 -
for (let i = 10; i <= 90; i += 10)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
//内偏移+
for (let i = 5; i <= 25; i += 10)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
expect(cus[0].GetOffsetCurves(26.5).length).toBe(2);
expect(cus[0].GetOffsetCurves(36).length).toBe(2);
expect(cus[0].GetOffsetCurves(36.1).length).toBe(3);
expect(cus[0].GetOffsetCurves(45).length).toBe(2);
expect(cus[0].GetOffsetCurves(60).length).toBe(1);
for (let i = 71; i <= 101; i += 10)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(0);
}
});
test('闭合多段线偏移测试15', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 8, [-3.096429035694039, 1.977370035127478], 0, [2.646251476487261, 5.186031066288948], -0.5113280232193118, [8.158566581303122, 2.619102241359773], 0.23700604598013766, [11.103952861189804, -1.2148363240793185], -1.4842976346055852, [7.994019861756378, -4.028585228328609], 0.5402454464135219, [3.1398916351274853, -2.8932128634560885], -1.0879771453350477, [1.4615150957507161, -0.803469525212464], -0.082022192610066, [-3.096429035694039, 1.977370035127478], 0, true];
let cus = loadFile(data);
//外偏移 -
for (let i = 0.5; i <= 5.5; i += 1)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
//内偏移+
for (let i = 0.1; i <= 1.8; i += 0.3)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 1.9; i <= 2.2; i += 0.05)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(2);
}
for (let i = 2.3; i <= 3.7; i += 0.2)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 3.9; i <= 6.9; i += 0.5)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(0);
}
});
test('闭合多段线偏移测试16', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-6.203966005665723, -0.056657223796033884], 0, [-1.8834846458923415, -0.923353563739375], -1.4125691360015384, [-1.9069913201133035, -1.5932937790368253], 0, [-6.189801699716714, -2.2096317280453257], -2.3881275241710798, [-6.203966005665723, -0.056657223796033884], 0, true];
let cus = loadFile(data);
//外偏移 -
//内偏移+
for (let i = -1.5; i <= 1.5; i += 0.2)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
expect(cus[0].GetOffsetCurves(1.6).length).toBe(0);
for (let i = 1.6; i <= 4.6; i++)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(0);
}
});
});
describe("补圆弧测试", () =>
{
test("补圆弧测试1", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-99.60068327971061, 80.69599512140186], 0, [-48.362234971168355, 80.69599512140186], -0.9874208089640422, [-14.972250883848176, 88.46675505445091], -1.1745224194600496, [18.29631507951812, 78.51046889023182], 0, [89.44733571649859, 78.5104688902318], 0, false];
let cus = loadFile(data);
// 向上-
// 向下+
expect(cus[0].GetOffsetCurves(17.45).length).toBe(2);
for (let i = -55; i <= 55; i += 5)
{
if (i === 0) continue;
EntityToMatchSnapshot(cus[0].GetOffsetCurves(i));
}
});
test("补圆弧测试2", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-869.4193524531552, -50.92359793870933], 0, [-609.861025770732, -50.92359793870939], -0.8167984427288847, [-480.7149315189898, -23.068558002059024], -1.4042575072434897, [-317.9835774160859, -50.92359793870939], 0, [-92.77019349218811, -50.92359793870939], 0, false];
let cus = loadFile(data);
// 向上-
// 向下+
expect(cus[0].GetOffsetCurves(83.24).length).toBe(2);
expect(cus[0].GetOffsetCurves(86.46).length).toBe(2);
for (let i = 364; i <= 395; i++)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
});
test("补圆弧测试3", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [-894.3165541673695, -331.80629190023], 0, [-671.3300245231958, -331.80629190023], -1.0058680701224356, [-535.7124860261546, -329.1982623137485], 0, [-214.92484688892245, -329.1982623137485], 0, false];
let cus = loadFile(data);
// 向上-
// 向下+
expect(cus[0].GetOffsetCurves(-1200).length).toBe(1);
for (let i = 63; i <= 94; i++)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
});
test("补圆弧测试4", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 23, [-25.572010711696727, -62.383195892823124], 0, [-10.312959798454724, -40.55427583637971], 0, [0.28360333574111785, -55.81332674962171], 0, [9.820510156517361, -48.18380129300071], 0, [18.721623189241864, -65.13830230771404], 0, [29.530117586121616, -60.47581452866788], 0, [39.06702440689787, -79.97349069558823], 0, [51.78290016793288, -70.64851513749588], -0.6227891115113805, [70.85671380948538, -80.60928448363998], 0.3759603135798005, [86.75155851077912, -99.68309812519247], -1.1383492019405204, [81.45327694368122, -117.6972554533254], 0.6271394112393051, [57.2931129977147, -138.2545879336653], -1.2933960333754264, [21.68866086681669, -138.2545879336653], -0.8106183277649434, [-17.73055399239181, -132.9563063665674], 0, [-43.37423677714574, -105.82910474302606], 0, [-51.003762233766736, -83.5763221612148], 0, [-48.67251834424364, -64.07864599429448], 0, [-62.65998168138215, -50.09118265715597], 0, [-86.39628310198083, -65.35023357039795], 0, [-86.39628310198083, -33.13668164244262], 0, [-73.68040734094582, -13.639005475522275], 0, [-43.16230551446182, -13.639005475522275], 0, [-33.62539869368556, -11.307761585999202], 0, false];
let cus = loadFile(data);
// 向外-
// 向内+
expect(cus[0].GetOffsetCurves(18).length).toBe(3);
for (let i = 50; i <= 80; i += 5)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
//需要删除一个无效的线段 ref #IKO6L
expect(cus[0].GetOffsetCurves(27.3).length).toBe(1);
});
test("补圆弧测试5", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 10, [-5.637393767705383, -1.586402266288952], 0, [-0.84985835694051, 1.954674220963173], -0.5207626681247078, [1.728045325779038, 1.0906515580736542], -1.2136457904456304, [4.060938624362605, 1.3838754084985838], -1.0694858869096764, [6.891142200566573, -0.047681051558073895], -1.4716493502287318, [9.178341602266286, -2.976612659490083], -1.5003222663355726, [8.09233325325779, -7.040916632294616], -0.9628743606456998, [4.53257790368272, -7.478753541076488], -1.076087427994497, [2.3229461756373926, -7.478753541076488], 0, [-5.39660056657224, -7.478753541076487], 0, false];
let cus = loadFile(data);
// 向外-
// 向内+
expect(cus[0].GetOffsetCurves(1.88).length).toBe(2);
expect(cus[0].GetOffsetCurves(2.12).length).toBe(2);
expect(cus[0].GetOffsetCurves(3.2).length).toBe(1);
for (let i = 0.5; i <= 4.5; i += 0.5)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
for (let i = 5.0; i <= 7.0; i += 0.5)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(0);
}
for (let i = 2.33; i <= 3.2; i += 0.5)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
});
});
describe("不规则不闭合多段线测试", () =>
{
test("test1", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [16.034190840579708, -16.545186318840567], 0, [36.985943188405784, -16.545186318840567], 0, [31.311510260869554, -12.507609043478254], 0, [48.334809043478245, -12.507609043478254], 0, [43.969860637681144, -16.6543100289855], 0, [56.84645843478259, -16.654310028985503], 0, false];
let cus = loadFile(data);
for (let i = 1.27; i <= 2.96; i += 0.2)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(2);
}
expect(cus[0].GetOffsetCurves(9.16).length).toBe(2);
for (let i = 0.5; i <= 7.5; i++)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
});
test("test2-共线线段", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 7, [15.642409533480423, -31.01626057276902], 0, [38.129771973149346, -31.016260572769028], 0, [32.85929640135194, -26.50707591689791], 0, [47.440945483324754, -26.50707591689791], 0, [45.33685543194063, -31.016260572769028], 0, [61.52187596164093, -31.016260572769035], 0, [70.31099992504923, -35.88209931313313], 0, false];
let cus = loadFile(data);
for (let i = 1.82; i <= 3.37; i += 0.3)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(2);
}
expect(cus[0].GetOffsetCurves(18).length).toBe(2);
for (let i = 1; i <= 27; i += 5)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
cus[0].Reverse();
expect(cus[0].GetOffsetCurves(-18).length).toBe(2);
data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 7, [21.944751443449043, -31.01626057276902], 0, [38.129771973149346, -31.016260572769028], 0, [32.85929640135194, -26.50707591689791], 0, [47.440945483324754, -26.50707591689791], 0, [45.33685543194063, -31.016260572769028], 0, [61.52187596164093, -31.016260572769035], 0, [70.31099992504923, -35.88209931313313], 0, false];
cus = loadFile(data);
expect(cus[0].GetOffsetCurves(11.4).length).toBe(1);
data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -56.21146708819905, -48.62279820279199, 0, 1], 2, 7, [26.333787338902418, -31.01626057276902], 0, [35.05226039203026, -31.016260572769013], 0, [32.85929640135194, -26.50707591689791], 0, [47.440945483324754, -26.50707591689791], 0, [41.54871106124796, -31.016260572769013], 0, [61.52187596164093, -31.016260572769035], 0, [70.31099992504923, -35.88209931313313], 0, false];
cus = loadFile(data);
expect(cus[0].GetOffsetCurves(5.2).length).toBe(1);
data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 6, [-3.158640226628895, -0.9915014164305944], 0, [-1.0906515580736538, -0.991501416430595], 0, [-1.983002832861189, 0.18413597733711037], 0, [1.0906515580736549, 0.3966005665722377], 0, [0.2974504249291776, -0.9915014164305944], 0, [3.966005665722378, -0.9915014164305953], 0, false];
cus = loadFile(data);
expect(cus[0].GetOffsetCurves(2.01133).length).toBe(1);
});
test("test3", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [-41.52354973772388, -163.989590203395], 0, [-41.5235497377239, -231.3399374277236], 0, [21.016058399152634, -231.3399374277236], 0, [21.016058399152623, -294.68133541250876], 1.378670046466899, [261.5530127717545, -216.10593031745873], 0, false];
let cus = loadFile(data);
for (let i = -100; i <= 181; i += 30)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
expect(cus[0].GetOffsetCurves(-122.6).length).toBe(2);
});
test("test4", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -131.50093441946296, -806.1569163328921, 0, 1], 2, 24, [256.5228611988947, -38.705370748164505], 0, [372.1955588024039, 31.844231195771492], 0, [372.1955588024039, -31.54297461172431], 0, [450.9819163032461, 37.57414810492366], 0, [423.0485713711294, -54.10452244151095], 0, [589.216161736542, 52.97329979827009], 0, [611.0614699526845, -2.177150452319474], 0, [672.6580767260702, 61.21005535517633], 0, [678.0298738284004, 13.938240854670997], 0, [735.329042919922, 21.100636991111184], 0, [684.1179105443746, -21.515620020708024], 0, [730.6734854312358, -32.61733403219032], 0, [815.1897598412304, 38.29038771856768], 0, [835.6025888300849, -8.981426781937659], 0, [862.1034545349137, 74.4604882075907], 0, [943.4539498526012, 74.46048820759069], 0, [986.972668777612, -29.064785548515978], 0, [924.5022496755805, -66.26627108118637], 0, [1001.0109652050348, -106.27541589934134], 0, [965.9152241364777, -128.73669018321777], 0, [1006.6262837760039, -176.46689803645526], 0, [904.1467198558175, -189.8032796425069], 0, [981.3573502066429, -242.44689124534239], 0, [1004.5205393118904, -256.48518767276516], 0, false];
let cus = loadFile(data);
expect(cus[0].GetOffsetCurves(-100).length).toBe(1);
expect(cus[0].GetOffsetCurves(46.8).length).toBe(2);
expect(cus[0].GetOffsetCurves(49.6).length).toBe(3);
expect(cus[0].GetOffsetCurves(86.6).length).toBe(2);
expect(cus[0].GetOffsetCurves(102.3).length).toBe(2);
expect(cus[0].GetOffsetCurves(110).length).toBe(1);
});
test("test5", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 18, [-3.895184135977337, 0.7648725212464592], 0, [0.8215297450424939, 0.7648725212464592], 0, [-2.1246458923512743, -2.1388101983002827], 0, [5.311614730878187, -2.1388101983002827], 0, [1.89801699716714, 3.4844192634560907], 0, [6.671388101983003, 3.4844192634560907], 0, [6.671388101983002, -3.4985835694051], 0, [10.6657223796034, -0.11331444759206824], 0, [8.810198300283286, 1.161473087818697], 0, [14.674220963172807, 3.30028328611898], 0, [16.713881019830033, -2.521246458923512], 0, [11.55807365439094, -5.773371104815864], 0, [3.8441926345609083, -5.773371104815863], 0, [2.3569405099150167, -8.787535410764873], 0, [-1.5297450424929169, -6.090651558073655], 0, [-6.586402266288951, -12.674220963172807], 0, [-8.113314447592067, -8.767705382436262], 0, [-10.929178470254957, -12.436260623229463], 0, false];
let cus = loadFile(data);
expect(cus[0].GetOffsetCurves(0.755).length).toBe(3);
expect(cus[0].GetOffsetCurves(1.915).length).toBe(4);
expect(cus[0].GetOffsetCurves(2.36).length).toBe(4);
expect(cus[0].GetOffsetCurves(2.892).length).toBe(2);
expect(cus[0].GetOffsetCurves(3.6850).length).toBe(1);
expect(cus[0].GetOffsetCurves(-1).length).toBe(3);
for (let i = 2; i <= 4; i++)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
});
test("test6", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -38.54242746474825, 6.4891615215880964, 0, 1], 2, 3, [18.466397865202012, 17.128892766521286], 0, [4.660056657223795, 6.487252124645892], -3.7897716494829594, [-0.906131771640112, 6.969061295372345], 0, false];
let cus = loadFile(data);
for (let i = -2.766; i <= 4.57; i++)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
for (let i = 2.9; i <= 5.3; i += 0.5)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(2);
}
for (let i = 6.14; i <= 8; i += 0.5)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
cus[0].Reverse();
for (let i = -2.766; i <= 4.57; i++)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 2.9; i <= 5.3; i += 0.5)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(2);
}
for (let i = 6.14; i <= 8; i += 0.5)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
});
test("test7", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -86.54515219838936, -34.782221464287886, 0, 1], 2, 5, [-51.274354719855246, 28.573003242461496], 0, [-13.931531095689206, 15.255196629685734], 3.7897716494829594, [-8.365342666825299, 14.77338745895928], 0, [5.4409985411529185, 25.415028100834675], 0.37399715496699776, [29.033295173881022, 23.38858533792915], 0, false];
let cus = loadFile(data);
expect(cus[0].GetOffsetCurves(-3.133).length).toBe(2);
for (let i = 10; i <= 60; i += 10)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
for (let i = 5.9; i <= 43.3; i += 10)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
cus[0].Reverse();
expect(cus[0].GetOffsetCurves(3.133).length).toBe(2);
for (let i = 10; i <= 60; i += 10)
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
for (let i = 5.9; i <= 43.3; i += 10)
{
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
});
test("test8", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 8, [14.442408344729744, 12.584578126613017], 0, [14.442408344729742, 4.502438174603963], 0, [20.086360825183, 4.502438174603963], 0, [20.086360825183, -0.9157562066311582], 0, [26.226981123916133, -0.9157562066311598], 0.4633692494967541, [33.496391918739924, 7.663051563657783], -0.673355221273594, [51.96340443478295, 18.996108144407916], 0.32851266965536, [64.10919017271836, 18.996108144407913], -1.9784627492130062, false];
let cus = loadFile(data);
for (let i = -15; i <= 15; i += 5)
{
if (i === 0) continue;
expect(cus[0].GetOffsetCurves(i).length).toBe(1);
}
});
test("test9-2圆弧没交点", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 3, [-245.7800398731897, -124.83507012637789], 0.47532901948537815, [-247.69480466441718, -117.62074637472406], 0.12615539092932912, [-193.96898890583213, -126.5297489543612], 0, false];
let cus = loadFile(data);
expect(cus[0].GetOffsetCurves(11.22).length).toBe(1);
expect(cus[0].GetOffsetCurves(-11.22).length).toBe(1);
});
test("test10-共线部分错误裁剪", () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 13, [37846.488077851434, 5711.914029035103], 0, [28152.473806690192, 5711.914029035104], 0, [31338.416239942802, 10002.31650581529], 0, [39750.51284565329, 10002.316505815288], 0, [39750.51284565329, 17632.65706309083], 0, [45109.026777541825, 17632.65706309083], 0, [45109.02677754183, 10002.31650581529], 0, [54643.39210261924, 10002.31650581529], -0.8704734266845496, [55266.30970531861, 5526.15551510335], 0, [45201.90603450778, 5526.155515103216], 0, [45201.90603450778, 249.9945243911434], 0, [37846.488077851434, 435.75303832303064], 0, [37846.488077851434, 5711.914029035103], 0, false];
let cus = loadFile(data);
expect(cus[0].GetOffsetCurves(2700).length).toBe(1);
});
});
test('提前丢失所有的线段', () =>
{
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -17.386067452264705, 17.11283965241085, 0, 1], 2, 3, [108.37693694676932, 28.257776463252547], 0.4472440944881872, [108.37693694676932, 17.68555707305448], 3.5940684866260213, [111.70676982557188, 14.089337563947739], 0.5086040192926764, false]
)[0] as Polyline;
let cus = pl.GetOffsetCurves(-7.155086190577401);
expect(cus.length).toBe(1);//是1也可以接受
});
test('中间区域需要圆裁剪', () =>
{
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1325.2800870006804, -703.3564533406019, 0, 1], 2, 5, [-51.274354719855246, 28.573003242461496], 0, [-13.931531095689206, 15.255196629685734], 3.7897716494829594, [-8.365342666825299, 14.77338745895928], 0, [5.4409985411529185, 25.415028100834675], 0.37399715496699776, [29.033295173881022, 23.38858533792915], 0, false]
)[0] as Polyline;
let cus = pl.GetOffsetCurves(-35.6);
EntityToMatchSnapshot(cus);
});
test('拱门偏移', () =>
{
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [0, 2], -1, [1, 2], 0, [1, 0], 0, false]
)[0] as Polyline;
let cus = pl.GetOffsetCurves(0.4);
EntityToMatchSnapshot(cus);
cus = pl.GetOffsetCurves(-0.4);
EntityToMatchSnapshot(cus);
});
test('土偏移因为点在圆弧切线上错误导致的丢失', () =>
{
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -9159.663865546216, 8361.344537815126, 0, 1], 2, 17, [28900.928792569663, -4648.336577340973], -0.9999999999999999, [28900.928792569663, 580.3540867812549], 0, [37687.5122530782, 580.3540867812552], 0, [37687.5122530782, 5568.3816889128875], 0, [27851.140930176796, 5568.381688912888], 0, [31251.043800494088, 10146.917554273516], 0, [39591.53702088006, 10146.917554273514], 0, [39591.53702088006, 17633.191417258837], -0.9999999999999999, [45238.18434134903, 17633.191417258837], 0, [45238.184341349035, 10146.917554273516], 0, [54628.482972136226, 10146.917554273516], -0.8741669928857767, [55271.13672581777, 5382.623174980927], 0, [45331.063598314984, 5382.623174981001], 0, [45331.063598314984, 1648.4655418896164], 0, [53885.44891640867, 1648.4655418896143], -0.6803347640614656, [56371.20555398866, -4648.336577340822], 0, [28900.928792569663, -4648.336577340976], 0, false]
)[0] as Polyline;
let cus = pl.GetOffsetCurves(-801);
expect(cus.length).toBe(1);
cus = pl.GetOffsetCurves(801);
expect(cus.length).toBe(1);
});
//ISSUE #IKSMH
test('闭合多段线判断精度和重复交点参数导致偏移丢失', () =>
{
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.042016806722689815, 0.028011204481792618, 0, 1], 2, 11, [15758.920914649752, -1642.832074394305], 1.1432358165627696, [15758.920914649756, -3551.5797508523133], 0.010240353549940432, [20850.68748853413, -2761.478041111637], 0.39873042440013945, [23564.17781148077, 901.7338948663096], 0.029927117999965277, [22452.27083112051, 6973.8467189556395], 0, [31778.947378692996, 6973.846718955635], 0, [31327.636369627562, 7575.594679533537], 0, [31646.066893308867, 7787.881806674935], 0, [20955.832135358123, 7787.881806674936], 0, [21703.795934364476, 5637.485884531684], -0.559029831351755, [15758.920914649752, -1642.832074394304], 0, false]
)[0] as Polyline;
for (let d of [40, 50, 100, 200, 300])
{
let cus = pl.GetOffsetCurves(d);
expect(cus.length).toBe(1);
expect(cus[0].Length).toMatchSnapshot();
}
});
//ISSUE #IKSMH
test('简单图形因为点在线内算法错误导致的丢失', () =>
{
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.01400560224089542, 0.37815126050420145, 0, 1], 2, 7, [2.075848303393214, 0.09193367302761479], -3.109533447960064, [2.8332320619106284, 1.1077844311377247], 0, [3.542914171656688, 1.1077844311377247], 0, [3.542914171656688, -0.4890219560878247], 0, [2.0758483033932134, -0.4890219560878247], 0, [2.0758483033932134, -0.4890219560878247], 0, [2.0758483033932134, 0.09193367302761501], 0, false]
)[0] as Polyline;
for (let d of [0.2, 0.3, 0.4, 0.5])
{
let cus = pl.GetOffsetCurves(d);
expect(cus.length).toBe(1);
expect(cus[0].Length).toMatchSnapshot();
}
});
test('圆求交错误导致的线丢失', () =>
{
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 8, [245.62964413684085, 1116.1391538309313], -0.6953179171905909, [357.14209871457234, 1741.1251588427203], -0.6821635222887411, [892.2042303620135, 1596.040230558597], 0.37526047823909664, [1317.3934365017694, 1221.2756098839004], 0.14384173346393453, [1715.0964405621776, 1096.7424042631346], 0.026448384140957723, [1793.2064027435729, 1099.4889679050386], -0.1912121824403452, [733.4339688924879, 1000.3133228797258], -0.3304377553967397, [245.62964413684108, 1116.139153830931], 0, false]
)[0] as Polyline;
for (let d of [10, 20, 30, 40, 269, 280, 320])//270 280 320因为圆弧选点导致的错误
{
let cus = pl.GetOffsetCurves(d);
expect(cus.length).toBe(1);
expect(cus[0].Length).toMatchSnapshot();
cus = pl.GetOffsetCurves(-d);
expect(cus.length).toBe(1);
expect(cus[0].Length).toMatchSnapshot();
}
});
test('海豚圆选点导致的错误', () =>
{
let cus = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5.653674874772044, 7.68794016265532, 0, 1], 2, 8, [933.8513988456853, 1095.3110732229222], -0.8740345959811056, [920.2952842385836, 1109.7702508499967], 0, [1041.059365726312, 1258.0770175893115], -0.47531159669542833, [1335.8552450029906, 1258.0770175893115], 0.4755782365532149, [1656.4630038262355, 1258.2164686086066], 0.011876098909362552, [1662.4715751586689, 1265.9781137467012], -0.44350119503715907, [1205.357990246699, 1110.5168645352571], 0.28917769175330255, [933.8513988456853, 1095.3110732229222], 0, false]
);
let pl = cus[0] as Polyline;
testOffset(pl, 10);
testOffset(pl, -10);
});
test('复杂圆盘选点', () =>
{
let cus = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 21, [-4.193877551020408, 0.5102040816326532], 0, [-2.051020408163265, 2.418367346938776], 0, [-1.0612244897959189, 0.7244897959183673], 0, [1.591836734693877, 1.153061224489796], 0, [1.5918367346938769, -0.13265306122449028], 0.20147559294404743, [2.6632653061224483, -2.6836734693877555], -1.1981710602936018, [-0.959183673469388, -5.244897959183675], 0.25804389257576854, [-2.8061224489795915, -3.897959183673469], 0.18939417098307887, [-5.571428571428572, -4.6020408163265305], -1.079995071965533, [-7.982857142857145, -0.6404081632653051], 1.1849950705219705, [-11.56285714285714, 4.179591836734694], -6.781917601823303, [-9.102857142857141, 9.019591836734694], 0.9585222487987152, [-7.222857142857144, 8.599591836734694], -0.7670525420358739, [14.397142857142853, 8.599591836734689], -0.13182825774707282, [14.397142857142851, 1.1795918367346951], 0.7921649344252789, [18.149142857142856, -0.836408163265304], -2.2405773687929207, [18.653142857142853, -5.176408163265303], 0.3179128740881875, [12.381142857142857, -5.176408163265302], -1.0648321015993136, [9.13314285714286, 0.08759183673469462], 1.761831734888522, [3.0011428571428587, 3.7835918367346952], -1.1347525744875853, [-1.702857142857143, 4.399591836734693], -0.019957132806512356, true]
);
let pl = cus[0] as Polyline;
for (let d of [0.8, -0.8, 0.2, 0.3, 0.4])
{
testOffset(pl, d);
}
});
test('补充bug测试', () =>
{
let data =
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3014.1813078325877, -118.48659432946494, 0, 1], 2, 25, [7212.90932057689, -239.9823077249786], -0.9999999999999921, [7212.9093205768895, 122.19897643916269], 0, [7779.276759343887, 122.19897643916269], 0, [7779.276759344071, 428.1814280252842], 0.1947099739542557, [7740.981455628771, 522.7925370761521], 0, [7304.310456694637, 522.7925370760897], 0, [7489.002384561892, 796.1365903196343], 0, [7742.516525859682, 796.1365903196343], 0, [7742.516525859682, 961.2048135488966], -1.3463056702167695, [8021.98728468389, 876.8699986200176], 0, [8021.987284683929, 789.3738464533299], -0.05161685745547489, [8028.1320183974, 790.0098847386233], 0, [8444.377142303902, 790.0098847389027], -1.1043175340350022, [8413.555740131487, 479.90559801040376], 0, [8049.204632346665, 479.9055980109795], 1.512505548953077, [8054.570478774117, 467.3001115689552], 0.06283615294599319, [8055.684165377956, 468.79464872233984], 0, [8055.684165377962, 182.7089738110588], -0.056342427094734256, [8062.381207162069, 183.46603224647305], 0, [8468.88396462686, 183.4660322464784], -0.20525770195463292, [8655.475816304977, 103.49809581299945], -0.8336853670274493, [8492.531297747215, -120.51154890075377], 0, [8104.435007347477, -120.51154890071338], -0.6646338605614993, [7740.532382653638, -239.9823077249987], 0, [7212.90932057689, -239.9823077249786], 0, false];
let pl = loadFile(data)[0];
let cus = pl.GetOffsetCurves(10);
expect(cus.length).toBe(1);
expect(cus[0].Length).toMatchSnapshot();
cus = pl.GetOffsetCurves(-10);
expect(cus.length).toBe(1);
expect(cus[0].Length).toMatchSnapshot();
});
test('多段线存在0长度线段导致偏移错误', () =>
{
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 9, [18464.40681262459, -261.95809608907166], 0, [23818.6302458671, 7299.349805818285], 0, [34567.94904695702, 3988.7231028210094], 0, [34567.94904695702, 3988.7231028210094], 0, [42946.69564096247, 8484.635909360519], -0.7515576999403787, [50221.90000063549, 1045.9438112678758], -0.43729267560971036, [41557.04986439571, -997.652918977356], -0.5825417553875781, [27905.82370635756, -6760.5956982689095], 0, [19404.461308537397, -2591.658368568635], 0, true]
)[0];
testOffset(pl, 400);
testOffset(pl, -400);
});
test('纯圆生成的多段线偏移', () =>
{
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1904.6173097681894, -4.547473508864641e-13, 0, 1], 2, 2, [18361.211643461193, 495.8146231175723], 0.7691548555148293, [18910.40925296759, 2564.4589522583397], 1.3001283068422635, true]
)[0];
testOffset(pl, 100);
testOffset(pl, -100);
});
test('多段线因为合并问题造成的错误', () =>
{
let pl = loadFile(
[1, "Polyline", 1, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 10, [560.4622946261899, 280.3468208092485], 0, [273.1213872832369, 280.3468208092485], 0, [273.1213872832369, 70.80924855491334], 0, [273.1213872832369, 70.80924855491334], 0, [520.5860801571987, 70.80924855491334], 0.45552774411272906, [773.2934581245079, 9.947706891888771], 1.0105662598284268, [843.111615774608, 120.72879526430421], 0.42745194242823337, [695.3090834219281, 321.1478937918483], 3.4733857741050023, [602.1148370593586, 307.0986147536708], 0.07222028753966563, [560.4622946261899, 280.3468208092485], 0, false]
)[0];
testOffset(pl, 37.8831);
});
//TODO: 这么小的测试用例似乎是没有意义的
test("正确的裁剪多段线", () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 177, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2507.5760599251325, -1024.118430461783, 0, 1], 0, 0, 2, 9, [0.1144508670519997, 0.411344685796422], 0, [0.1144508670519997, 0.9104046242774757], 0, [-0.9104046242774757, 0.9104046242774757], 0, [-0.9104046242774757, 0.2714179492914752], 0, [1.2674125167280863, -1.6184971098265635], 0, [1.8106024388006858, -1.6184971098265635], 0, [1.8106024388006858, 0.33236994219655003], 0, [0.268018046083057, 0.33236994219655003], 0.10216571300036134, [0.11445086705202812, 0.411344685796422], 0, false], "basePt": { "x": 2506.665655300855, "y": -1025.7369275716096, "z": 0 } }
)[0];
testOffset(pl, -0.3792);
});
test("极限刀半径偏移", () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 101, false, 1, 2, 0, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 340.1517196254039, 192.68310636731692, 0, 1], 0, 0, 2, 8, [-269.23076923076917, -473.9316239316238], 0, [-519.2307692307692, -473.9316239316238], 0, [-519.2307692307692, -533.9316239316238], 0, [40.76923076923081, -533.9316239316239], 0, [40.7692307692308, -473.9316239316239], 0, [-209.2307692307692, -473.9316239316239], 0, [-209.23076923076923, -223.9316239316239], 0, [-269.2307692307692, -223.9316239316239], 0, true], "basePt": { "x": -193.77990430621998, "y": 151.91387559808612, "z": 0 } }
)[0];
testOffset(pl, -30);
});
test('双圆偏移导致求延伸点错误', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 101, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 218.6045526504426, -252.49648981851198, 0, 1], 0, 0, 2, 3, [76.66953810162238, -86.81133085285757], -2.219258954152199, [71.33090803386779, 64.97443486580221], -3.5679817627813364, [76.66953810162238, -86.81133085285757], 0, false], "basePt": { "x": 124.11616995057648, "y": -405.14474387199533, "z": 0 } }
)[0];
testOffset(pl, 69.3565);
testOffset(pl, 120);
});
test('圆弧选点实例', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 101, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 16.19344795796399, 135.0766710390067, 0, 1], 0, 0, 2, 5, [-6.203966005665723, -0.056657223796033884], 0, [-1.8834846458923415, -0.923353563739375], -1.4125691360015384, [-1.9069913201133035, -1.5932937790368253], 0, [-6.189801699716714, -2.2096317280453257], -2.3881275241710798, [-6.203966005665723, -0.056657223796033884], 0, true], "basePt": { "x": 7.425742574257429, "y": 132.42574257425747, "z": 0 } }
)[0];
testOffset(pl, 1.3);
});
test("圆弧连接后逆向", () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 101, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 597.8005954347436, 479.37954280316484, 0, 1], 0, 0, 2, 5, [167.98627715254565, -111.94253427447359], -2.235590494415529, [92.52712628683605, 179.4136315681265], 0.6826133878306185, [385.1692190172362, 136.47681103047847], -1.5346483158911062, [287.433293813986, -109.45380861449172], -0.17172709011725532, [167.98627715254565, -111.94253427447353], 0, false], "basePt": { "x": 395.9330143540669, "y": 277.5119617224881, "z": 0 } }
)[0];
testOffset(pl, -360);
});
test("圆弧如果连接就自交,需要补圆弧才能解决", () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 125, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -207.54414497633752, -1556.5810873225296, 0, 1], 0, 0, 2, 5, [4603.757758938077, 593.6664091318919], -2.219258954152197, [4598.419128870322, 745.4521748505518], 0, [4760.538514402408, 884.9500449898966], 0, [4923.050442679999, 533.4110843473188], 0, [4603.757758938077, 593.6664091318919], 0, false], "basePt": { "x": 4225.055693160251, "y": -1023.1700029752108, "z": 0 } }
)[0];
testOffset(pl, 57);
});
test("被补圆弧的裁剪圆所裁剪导致的曲线丢失(和CAD一样)", () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 103, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1398.251881176373, 1411.2423837601018, 0, 1], 0, 0, 2, 5, [263.25649229242754, -496.3780796281579], -1.6515296725917887, [257.53512452479345, 499.3704419621269], -0.02322114634871773, [286.4951078605276, 482.68977986242965], -0.06010857523756142, [371.6713326415636, 496.2236762890787], -1.1581445685688583, [263.25649229242765, -496.3780796281578], 0, false], "basePt": { "x": 836.3843000956963, "y": 849.3748026794251, "z": 0 } }
)[0];
testOffset(pl, 380);
});
test("圆弧错误的直连(需要验证是否可以连接,避免反向连接)", () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 134, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6112.5678224459125, -1065.4659496101615, 0, 1], 0, 0, 2, 5, [263.25649229242754, -496.3780796281579], -1.7903397005665043, [296.5845834873048, 443.7572521059671], -0.010180473605896625, [267.31623288370463, 509.71120429495124], -0.10304286423691834, [371.6713326415636, 496.2236762890787], -1.1581445685688583, [263.25649229242765, -496.3780796281578], 0, false], "basePt": { "x": 5550.560765550236, "y": -1633.9291866028718, "z": 0 } }
)[0];
testOffset(pl, 50);
pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 147, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1026.772157834298, 2130.88375223014, 0, 1], 0, 0, 2, 5, [286.302290657027, 503.78496132581995], 0.021527095370394104, [276.9071934869128, 525.7583449951944], -0.1030428642369184, [381.2622932447721, 512.2708169893212], -1.1581445685688583, [272.84745289563557, -480.33093892791567], -1.6900591615435467, [286.302290657027, 503.78496132581995], 0, false], "basePt": { "x": 474.6875180335993, "y": 1584.8751730829545, "z": 0 } }
)[0];
testOffset(pl, 80);
});
test('圆弧错误连接', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 102, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2259.1441880926873, 773.1891257570742, 0, 1], 0, 0, 2, 5, [328.0439324263227, 451.7232922284297], -0.10340615467215077, [276.9071934869128, 525.7583449951944], 0.32399567200291585, [381.2622932447721, 512.2708169893212], 0.07052734499851136, [272.84745289563557, -480.33093892791567], -1.827918042325391, [328.0439324263227, 451.7232922284297], 0, false], "basePt": { "x": 1706.7609521238574, "y": 222.18579043452291, "z": 0 } }
)[0];
testOffset(pl, -30);
});
test('点在多段线内', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 143, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4555.272636134648, 288.86379442442706, 0, 1], 0, 0, 2, 7, [89.09718873801867, 12.715775988192085], 0.4432102328398421, [-21.370271340732355, 87.4260344681347], -2.031453439397569, [106.2882126486112, 376.2403174588135], -1.9534916059560468, [246.17792837185547, 84.84004156037321], 0.41942707445850347, [141.47128192655254, 10.514196006194956], 0.09632223217375552, [107.13355592506404, 11.671944350249753], 0.050311885391361756, [89.09718873801866, 12.7157759881921], 0, false], "basePt": { "x": 4287.368421052632, "y": 299.37799043062205, "z": 0 } }
)[0];
testOffset(pl, 74);
});
test('假圆弧交点选点直连', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 106, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4338.779773072596, 1478.769255552619, 0, 1], 0, 0, 2, 7, [-99.76976288377993, -489.9448891601117], 0.14694571746848875, [186.7216973960727, -463.82648449773677], 0.07092929978041122, [336.91679787003386, -592.2410724670758], -0.27040679117512567, [378.6368180205662, -672.9968518192081], -0.9540136739352206, [148.3191914428038, -786.0629656864282], 0.05251695815112128, [-211.9687804728832, -786.4458908902668], 0.04640002721980451, [-99.76976288378003, -489.9448891601119], 0, false], "basePt": { "x": 4126.810992599712, "y": 626.2335877788942, "z": 0 } }
)[0];
testOffset(pl, 100);
});
test('圆弧连接成圆', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 101, false, 1, 7, 0, [0.5000000000000001, -0.8660254037844386, 0, 0, 0.8660254037844386, 0.5000000000000001, 0, 0, 0, 0, 1, 0, 389.42494481406175, 210.82148232183062, 0, 1], 0, 0, 2, 27, [-83.07073993499657, 0.8269354921289374], 0.10184605973644185, [-76.64483473264329, -32.04685576560943], 0.6522765349049682, [54.0010291988235, 45.75305414616944], 0.23596051205532206, [73.41540415096487, 57.21107588341927], -0.5914519010332271, [8.952266758064908, -92.64332512534449], 0.2140380409986856, [76.95983331150204, -92.19158268498886], 0.21403804099868534, [142.04794821690678, -72.47431923862268], -0.10329070701704057, [103.99885971414966, -72.42116385978626], 0.516142220984897, [74.90606688149397, 59.851009334915865], 0.2359605120553218, [74.69031645599186, 82.39336211069161], -0.4600557076424082, [180.59244300270308, -11.240294254991033], 0.10184605973644298, [205.8490287494348, 10.761598521427063], 0.6522765349049668, [73.14939838796012, 85.00428062955271], 0.2359605120553207, [53.51927301031667, 96.08861166807836], -0.591451901033227, [215.5285598492564, 115.1890975825626], 1.0068882499140974, [50.48769221175576, 96.05959673544288], 0.23596051205532112, [31.073317259614363, 84.60157499819303], -0.5914519010332269, [95.53645465251428, 234.45597600695686], 1.0068882499140976, [29.58265452908519, 81.96164154669648], 0.23596051205532054, [29.798404954587458, 59.419288770920865], -0.5914519010332271, [-67.74774449145258, 190.1732038652006], 0.2140380409986849, [-101.36030733885552, 131.0510523601852], 0.21403804099868418, [-116.82871375389443, 64.82445964448134], -0.1032907070170408, [-97.75813559409578, 97.74935918929305], 0.5161422209848976, [31.339323022619247, 56.80837025205961], 0.235960512055321, [50.96944840026263, 45.72403921353395], -0.4600557076424087, [-83.07073993499662, 0.8269354921289764], 0, false], "basePt": { "x": 313.6696051434847, "y": 37.93179334118034, "z": 0 } }
)[0];
testOffset(pl, -3);
});
test('连续丢圆弧后无法连接', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 106, false, 1, 3, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -567.4063340972411, 1456.4847944096769, 0, 1], 0, 0, 2, 39, [838.6942638940667, -206.2489487883961], 0, [864.8377861332657, -206.2489487883961], 0, [864.8377861332657, -158.95474961566856], 0, [818.9312808604154, -158.95474961566856], 0, [818.9312808604153, -169.03321364032257], 0.37053452142155574, [783.6164871832165, -184.70060270846358], 0, [774.5059826252042, -184.70060270846358], 0, [774.5059826252037, -186.47136549762922], -0.037316682914943736, [771.2243918351782, -178.8695991954375], -0.11426681014922678, [756.1998142491512, -182.02097661656495], 0.7138529441383806, [746.9265548351201, -207.29436915460144], -0.01478368893153686, [748.4493542266122, -208.60883489652468], 0, [712.4399703545349, -208.60883489652474], 0, [712.4399703545349, -259.197556251971], 0.7966805802386544, [701.9499401116049, -324.42266262477676], 0, [701.9499401116046, -343.04631759286684], 0.18977471500526005, [687.327969050377, -358.82138332977365], 0, [668.3845930549477, -358.82138332977365], 0, [668.3845930549477, -415.7518591960502], 0, [696.7831905997194, -415.7518591960502], 0, [696.7831905997194, -392.77830740129156], 0.4762396892690236, [741.127921345345, -382.22429882660674], 0, [783.3405548225938, -382.22429882660674], 0, [783.3405548225938, -367.50784216202834], 0.5198330309007874, [811.7657015613546, -314.22928813809364], -0.09411712475346413, [809.818481883436, -307.48283334573034], 0, [846.0534057939268, -307.4828333457304], 0.5026102634669043, [855.0371645891342, -295.39979201396176], -0.5977564466489893, [857.8002629949973, -292.63669360809854], 0.5026102634669082, [869.883304326766, -283.6529348128912], 0, [869.883304326766, -282.5719852262679], 0.9999999999999999, [869.883304326766, -253.63108028534668], 0, [869.883304326766, -252.55013069872342], 0.49929486045458626, [857.8956516709469, -243.53823491123893], -0.5905845302049125, [854.6227110175462, -240.26529425783775], 0.4992948604545915, [845.6108152300616, -228.27764160201855], 0, [823.1152528270367, -228.2776416020185], 0, [823.1152528270367, -224.1993683522838], 0.2092099078281357, [838.6942638940667, -206.2489487883961], 0, false], "basePt": { "x": 100.97825895770654, "y": 1040.7329352136267, "z": 0 } }
)[0];
testOffset(pl, 60);
pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 104, false, 1, 2, 0, [0.5000000000000001, -0.8660254037844386, 0, 0, 0.8660254037844386, 0.5000000000000001, 0, 0, 0, 0, 1, 0, -1590.0719079709852, 9426.592260199775, 0, 1], 0, 0, 2, 103, [8515.314746566539, -556.3658219788067], 0, [8035.022676761735, -462.557424921436], -0.6635872795072744, [7894.752635321667, -322.28738348139086], 0.19560765654894927, [7894.752635321669, -190.71947164322228], -0.29882437827791913, [7923.759733994661, -43.40484909687257], 0.9898281059505385, [7845.440567577609, 34.91431732016645], -1.442946642283402, [7802.551500253992, 131.88090431270757], -0.8093239052680682, [8015.132094814551, 64.75019024095491], 0.832461880093909, [7977.8372536635725, 290.3839792043509], -0.3475847145489082, [8210.930010857164, 226.98274924769248], 0.7541136729398036, [8162.446717360899, 452.6165382110903], -0.820623571745973, [8413.608825238658, 252.6022904989277], -0.18075640268239695, [8442.84524728326, 186.35620817566087], -0.7264755735432326, [8553.91213051174, 23.99656238982425], -0.370975277556559, [8519.224956353799, -106.36973770577242], -0.3063671600538868, [8483.182351259278, -216.48611302460085], -0.1913456876589615, [8641.722006251419, -306.58984251603397], -0.09504975276320408, [8776.379586079263, -218.61724183962542], 0, [8617.474006116845, 244.23209037622564], -0.6635872795072751, [8668.816404673787, 435.844530373246], 0.19560765654894927, [8782.75755864851, 501.6284862923294], -0.2988243782779201, [8924.83931345906, 550.1649132246093], 0.9898281059505389, [8953.506117970912, 657.1508841535187], -1.4429466422834343, [9016.03711196292, 742.7771994966624], -0.8093239052680679, [9064.190505482868, 525.1116472197427], 0.8324618800939108, [9240.947678101818, 670.2268215682916], -0.3475847145489083, [9302.58698092497, 436.66195742215405], 0.7541136729398015, [9473.749927371273, 591.4666157307556], -0.8206235717459719, [9426.11356167259, 273.9467259844887], -0.18075640268239504, [9383.360982501748, 215.50420061646764], -0.7264755735432271, [9298.28684631601, 38.137635328523174], -0.3709752775565557, [9168.042731556867, 2.99445928699879], -0.3063671600538841, [9054.65785061084, -20.849916741992274], -0.1913456876589577, [9055.895559391609, -203.20115021811762], -0.09504975276320021, [9199.41085632828, -275.8317348229548], 0, [9520.797346170662, 93.2092003355292], -0.6635872795072741, [9712.409786167671, 144.5515988925008], 0.19560765654894882, [9826.350940142398, 78.76764297341651], -0.29882437827791875, [9939.425596279956, -20.01055264065235], 0.9898281059505387, [10046.41156720886, 8.656251871216227], -1.442946642283423, [10151.831628524482, -2.684019778182119], -0.8093239052680679, [9987.404427483874, -153.21885798334915], 0.8324618800939075, [10201.456441253802, -233.73747259819174], -0.3475847145489082, [10030.00298688336, -403.9011067876736], 0.7541136729398019, [10249.649226825934, -474.7302374424671], -0.8206235717459756, [9950.850753249484, -592.2358794765751], -0.1807564026823984, [9878.86175203404, -584.432322521332], -0.7264755735432308, [9682.720732619824, -599.4392420234362], -0.37097527755655973, [9587.163792018622, -504.21611796936577], -0.30636716005388875, [9509.821516167114, -417.94411867952476], -0.1913456876589582, [9352.519569955744, -510.1916226642252], -0.09504975276320335, [9361.377287064573, -670.7948079454719], 0, [9841.669356869374, -764.6032050028434], -0.6635872795072755, [9981.939398309443, -904.8732464428875], 0.19560765654894904, [9981.939398309441, -1036.4411582810562], -0.29882437827791863, [9952.932299636452, -1183.7557808274069], 0.9898281059505445, [10031.251466053503, -1262.074947244445], -1.4429466422834027, [10074.140533377118, -1359.0415342369859], -0.8093239052680687, [9861.559938816561, -1291.9108201652343], 0.8324618800939101, [9898.85477996754, -1517.5446091286303], -0.34758471454890855, [9665.762022773946, -1454.1433791719737], 0.7541136729397993, [9714.245316270215, -1679.777168135367], -0.8206235717459733, [9463.08320839245, -1479.7629204232062], -0.180756402682396, [9433.846786347849, -1413.5168380999412], -0.7264755735432326, [9322.77990311937, -1251.157192314104], -0.3709752775565557, [9357.467077277313, -1120.790892218508], -0.306367160053888, [9393.509682371832, -1010.674516899675], -0.19134568765895976, [9234.97002737969, -920.5707874082475], -0.09504975276319776, [9100.312447551856, -1008.5433880846549], 0, [9259.218027514278, -1471.3927203005096], -0.6635872795072755, [9207.875628957336, -1663.0051602975254], 0.19560765654894927, [9093.934474982607, -1728.7891162166106], -0.2988243782779215, [8951.85272017206, -1777.3255431488906], 0.9898281059505389, [8923.185915660208, -1884.3115140778018], -1.4429466422834172, [8860.654921668203, -1969.9378294209428], -0.8093239052680679, [8812.501528148252, -1752.2722771440249], 0.8324618800939076, [8635.744355529303, -1897.3874514925728], -0.34758471454890855, [8574.105052706149, -1663.8225873464353], 0.7541136729398008, [8402.942106259847, -1818.6272456550387], -0.8206235717459722, [8450.578471958532, -1501.10735590877], -0.18075640268239798, [8493.331051129375, -1442.6648305407462], -0.7264755735432308, [8578.405187315111, -1265.2982652528062], -0.37097527755656073, [8708.649302074255, -1230.1550892112791], -0.30636716005388875, [8822.034183020285, -1206.310713182289], -0.19134568765895688, [8820.796474239512, -1023.9594797061645], -0.09504975276320358, [8677.281177302835, -951.3288951013228], 0, [8355.894687460453, -1320.3698302598068], -0.6635872795072745, [8164.282247463445, -1371.7122288167784], 0.19560765654894882, [8050.341093488718, -1305.9282728976941], -0.29882437827791863, [7937.266437351161, -1207.1500772836253], 0.9898281059505387, [7830.280466422258, -1235.8168817954938], -1.4429466422834234, [7724.860405106635, -1224.4766101460964], -0.8093239052680679, [7889.287606147243, -1073.9417719409294], 0.8324618800939076, [7675.235592377316, -993.4231573260831], -0.3475847145489082, [7846.689046747755, -823.259523136604], 0.7541136729398019, [7627.042806805183, -752.4303924818114], -0.8206235717459756, [7925.841280381632, -634.9247504477025], -0.18075640268239826, [7997.8302815970765, -642.7283074029456], -0.7264755735432308, [8193.971301011292, -627.7213879008414], -0.3709752775565595, [8289.528241612494, -722.9445119549118], -0.306367160053889, [8366.870517464004, -809.2165112447528], -0.19134568765895826, [8524.172463675372, -716.9690072600524], -0.09504975276320324, [8515.314746566539, -556.3658219788058], 0, false], "basePt": { "x": 1033.8277511961717, "y": -2.918660287080783, "z": 0 } }
)[0];
testOffset(pl, 250);
});
test('圆弧全部丢失', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 101, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 632.4260201651778, 306.1636234424211, 0, 1], 0, 0, 2, 29, [36.37069437158061, 19.439752751377], -0.7123995667293839, [-16.602777874049934, -37.750220700952696], -0.38902776698602376, [-67.29233229320016, -60.930589109776975], -0.39575307788764214, [-120.13720350865697, -80.76110079474938], -0.2510519239370229, [-155.81796518401097, -96.40117872622181], -0.4401592563880412, [-213.05269426281666, -116.98744415455144], -0.5725845968148544, [-283.11590130257537, -104.70063313648416], -0.37443535464444794, [-318.38517803070135, -63.58302116645518], -0.270072747699035, [-342.68534646202534, -29.913752794033144], -0.30204918439048223, [-378.59967258530014, -1.7177518465878165], -0.4916711967603866, [-440.19726209747387, 20.006877568470372], -0.7200163954969004, [-440.5823529333029, 98.2276374813755], -0.9206339273151827, [-363.91719410161386, 127.87677205484283], -0.4244951536070515, [-304.917297798067, 134.15520223171188], -0.1914266417129986, [-280.2097502798788, 151.97195994686012], -0.16415950284336714, [-285.094390630813, 177.88469146695115], -0.45083830308595857, [-323.3160481272025, 226.4569828790743], -0.38920226900367944, [-334.0176218595334, 281.1770985710739], -0.5628842050977027, [-338.56134219477826, 351.5427658946892], -0.8667997782041291, [-261.6544519066483, 378.9492862585389], -0.48177976270290346, [-208.69938247126265, 342.1209188342277], -0.34120655338524586, [-167.1839625076027, 313.5162829666949], -0.3628510032688694, [-133.35254383027495, 272.8592107208947], -0.3623671695182369, [-94.22856638310259, 237.34650697847155], -0.5332799952050609, [-47.27862948352413, 187.47870916997203], -0.33367677879321517, [-30.595276514824945, 140.8444233640655], -0.09453880585667056, [-20.169534645436215, 129.43297905255963], -0.5685380908499404, [43.85863433804843, 99.03848179090187], -0.7781000001051073, [36.37069437158061, 19.43975275137609], 0, false], "basePt": { "x": 163.87559808612437, "y": 174.64114832535893, "z": 0 } }
)[0];
testOffset(pl, 42);
});
test('判断点在线上错误导致的偏移错误', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 101, false, 1, 3, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -100734.86243186146, 44383.331635333445, 0, 1], 0, 0, 2, 39, [127277.81151293858, -36620.707373191544], 0, [130815.96109517067, -36620.707373191544], 0, [130815.96109517064, -35554.466705877174], 0.6887172212245157, [130291.21448189336, -31533.945897231803], -0.36193373148997876, [128773.59498831566, -29570.704146790635], 1.1796860042294097, [126333.40360075582, -30180.7519936806], -1.287135792508298, [124682.68589740657, -30180.751993680595], 0.779185042024048, [122637.23135195201, -29391.278309470064], 0.010799107353114023, [121201.82465338742, -31508.50318985285], -0.4776149778954755, [119335.79594525344, -31508.503189852843], 0.700515994329636, [116967.37489262187, -32549.173046312168], -0.9278840414420589, [114850.15001223912, -32549.173046312157], 1.4480326048631014, [112930.29355291484, -33751.32615636614], -1.029709203909742, [111764.02561032523, -34917.59409894375], 0.20000000000000107, [108749.67154333959, -33661.61323769973], -0.02277643035683432, [108838.49552612088, -31770.760827730846], 0.0001885101725321654, [106201.82465338672, -32333.86204152787], 2.006103958007126, [103941.05910314823, -32333.862041527485], 1.3816050810686566, [103941.05910314822, -33625.728070235615], -0.9878106970714999, [105096.05769331472, -36695.970088982445], 0, [105096.05769331472, -35189.64237915029], 0, [102417.0482599521, -35189.64237915029], 0, [102417.0482599521, -35889.67138518257], 1.0912246439015139, [102417.0482599521, -38825.899587824555], 0, [102417.0482599521, -41968.68279764475], 0, [105096.05769331472, -41968.68279764475], 0, [105096.05769331472, -40160.607321239266], 0.4212054214672999, [107282.06546869678, -39671.70329158335], 0, [107282.06546869678, -43462.81111910043], 0, [112473.92446810291, -43462.81111910043], 0, [112473.92446810291, -41805.547281515814], 0.1318356548905449, [113770.25347482559, -40928.81616704816], 0, [113770.25347482559, -44343.85795112292], 0, [119637.25821281743, -44343.85795112292], 0, [119637.25821281743, -41945.442740045866], 0, [124876.50952109811, -41945.442740045866], 0, [124876.50952109811, -38869.61336018733], 0, [127277.81151293858, -38869.61336018733], 0, [127277.81151293858, -36620.707373191544], 0, false], "basePt": { "x": 80.14354066985356, "y": 39.4736842105267, "z": 0 } }
)[0];
testOffset(pl, 200);
});
test('精度过高导致无法连接', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 3986, false, 1, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6579.761024280382, -284.69386708033016, 0, 1], 0, 0, 2, 151, [26186.559895161856, 2340.8637086870967], 0, [26148.65538728819, 2360.408630292287], -1.3088618180444112, [26104.282532746754, 2363.9206686770012], -0.9123557287923755, [26123.961538895655, 2405.432722292411], -1.199317806271941, [26152.143230784444, 2369.8613078440985], 0, [26182.558878903546, 2354.177910501486], 0.2536687013302224, [26181.43883467805, 2390.150848623748], -3.0648492881772293, [26211.68095564566, 2390.150848623748], 0.33753088116466423, [26217.297836094946, 2344.7396718304008], 0, [26243.323590091964, 2370.7654258274824], -0.725559559863707, [26258.596943624292, 2402.3201933541477], -0.9663623936288359, [26290.610605573293, 2384.0609588973457], -1.2305179800917057, [26259.40903826917, 2365.91015672961], -0.09254370864724822, [26252.6417207249, 2365.9414208366916], 0, [26216.559895161856, 2329.8595952735586], 0, [26216.559895161856, 2278.967684202135], -0.020862027430925353, [26225.965463599274, 2276.905385992105], 0, [26235.503078112375, 2300.623249652883], -0.2495726219465555, [26228.37897043196, 2314.748894863499], -0.7668590421252343, [26238.59738628403, 2322.267186432391], -0.8431806725804747, [26255.879634904904, 2314.652667155984], -0.6994782626735623, [26259.160739936935, 2304.9561953985917], -0.24703433544859793, [26245.34549656838, 2297.5437996320193], 0, [26235.811644062163, 2273.835291221057], -0.15459540270989447, [26291.15753053891, 2231.43698383026], 0, [26343.625036429334, 2261.729112479804], 0, [26341.599181117566, 2304.327840018944], -1.3088618180444112, [26322.45426830708, 2344.5118784826163], -0.9123557287923755, [26368.244264375735, 2348.2253860441388], -1.199317806271941, [26351.529361759352, 2306.0336177226673], 0, [26353.154965302554, 2271.85119510765], 0.2536687013302224, [26383.74842145245, 2290.807650921421], -3.0648492881772293, [26398.869481936254, 2264.6172058991515], 0.33753088116466423, [26362.35068944211, 2237.047256343374], 0, [26397.902530554737, 2227.5211692278544], -0.725559559863707, [26432.866437609508, 2230.07144083121], -0.9663623936288359, [26433.06030769076, 2193.217179086808], -1.2305179800917057, [26401.74046826237, 2211.163127926199], -0.09254370864724822, [26398.383885001193, 2217.039428888558], 0, [26349.09519466708, 2230.246293659503], 0, [26305.021506832094, 2204.8003381237895], -0.02086202743092287, [26307.938288410736, 2195.623727814943], 0, [26333.24736812102, 2199.222843185479], -0.2495726219465555, [26341.918481878045, 2212.455324021329], -0.7668590421252343, [26353.538721295798, 2207.3650620914477], -0.8431806725804747, [26355.585478475263, 2188.5909361130443], -0.6994782626735623, [26348.828640122298, 2180.9011799241252], -0.24703433544859793, [26335.50169540127, 2189.1593337574686], 0, [26310.202598578424, 2185.5616380183064], -0.15459540270989144, [26301.15753053891, 2116.431540639078], 0, [26353.625036429334, 2086.1394119895313], 0, [26389.503688991234, 2109.193217923482], -1.3088618180444112, [26414.73163072218, 2145.865218002439], -0.9123557287923755, [26440.842620641935, 2108.0666719485525], -1.199317806271941, [26395.94602613676, 2101.4463180753937], 0, [26367.15598156086, 2082.947292802991], 0.2536687013302224, [26398.869481936254, 2065.9308104944976], -3.0648492881772293, [26383.74842145245, 2039.7403654722284], 0.33753088116466423, [26341.612748509022, 2057.5815927097983], 0, [26351.138835624628, 2022.0297515972006], -0.725559559863707, [26370.82938914707, 1993.025255673887], -0.9663623936288359, [26339.009597279324, 1974.4302283862867], -1.2305179800917057, [26338.89132515506, 2010.5269793934133], -0.09254370864724822, [26342.302059438156, 2016.372016248691], 0, [26329.09519466708, 2065.6607065827693], 0, [26285.021506832094, 2091.106662118481], -0.02086202743091419, [26278.532719973326, 2083.9923500196655], 0, [26294.304185170502, 2063.8736017294214], -0.24957262194655538, [26310.099406607947, 2062.9804373546544], -0.7668590421252341, [26311.50123017363, 2050.371883855883], -0.8431806725804747, [26296.26573873222, 2039.2122771538843], -0.6994782626735623, [26286.22779534722, 2041.2189927223576], -0.24703433544859793, [26286.71609399474, 2056.889542322273], 0, [26270.950849678124, 2077.0003549940766], -0.15459540270990305, [26206.559895161856, 2050.2685650056414], 0, [26206.559895161856, 1989.6843077065525], 0, [26244.464403035523, 1970.1393861013623], -1.3088618180444112, [26288.837257576957, 1966.6273477166478], -0.9123557287923755, [26269.158251428056, 1925.1152941012383], -1.199317806271941, [26240.976559539264, 1960.6867085495508], 0, [26210.56091142016, 1976.370105892163], 0.2536687013302224, [26211.68095564566, 1940.3971677699012], -3.0648492881772293, [26181.43883467805, 1940.3971677699012], 0.33753088116466423, [26175.821954228766, 1985.8083445632487], 0, [26149.796200231747, 1959.7825905661668], -0.725559559863707, [26134.52284669942, 1928.2278230395013], -0.9663623936288359, [26102.50918475042, 1946.4870574963034], -1.2305179800917057, [26133.710752054543, 1964.637859664039], -0.09254370864724822, [26140.478069598816, 1964.6065955569577], 0, [26176.559895161856, 2000.6884211200909], 0, [26176.559895161856, 2051.5803321915146], -0.02086202743092108, [26167.15432672444, 2053.6426304015445], 0, [26157.61671221134, 2029.9247667407633], -0.2495726219465555, [26164.74081989176, 2015.7991215301495], -0.7668590421252343, [26154.522404039686, 2008.2808299612575], -0.8431806725804747, [26137.240155418807, 2015.8953492376643], -0.6994782626735623, [26133.959050386777, 2025.5918209950569], -0.24703433544859793, [26147.77429375533, 2033.0042167616293], 0, [26157.30814626155, 2056.7127251725924], -0.15459540270989622, [26101.962259784803, 2099.11103256339], 0, [26049.494753894378, 2068.818903913848], 0, [26051.520609206145, 2026.2201763747062], -1.3088618180444112, [26070.665522016632, 1986.0361379110332], -0.9123557287923755, [26024.875525947973, 1982.3226303495103], -1.199317806271941, [26041.590428564363, 2024.5143986709818], 0, [26039.964825021158, 2058.696821286], 0.2536687013302224, [26009.371368871263, 2039.7403654722282], -3.0648492881772293, [25994.250308387458, 2065.9308104944976], 0.33753088116466423, [26030.7691008816, 2093.500760050275], 0, [25995.217259768975, 2103.0268471657937], -0.725559559863707, [25960.253352714204, 2100.476575562439], -0.9663623936288359, [25960.05948263295, 2137.330837306841], -1.2305179800917057, [25991.379322061337, 2119.3848884674503], -0.09254370864724822, [25994.735905322515, 2113.5085875050913], 0, [26044.02459565663, 2100.301722734147], 0, [26088.098283491618, 2125.7476782698604], -0.020862027430917966, [26085.18150191298, 2134.924288578707], 0, [26059.872422202694, 2131.3251732081694], -0.2495726219465555, [26051.201308445667, 2118.0926923723205], -0.7668590421252343, [26039.581069027914, 2123.1829543022013], -0.8431806725804747, [26037.53431184845, 2141.9570802806047], -0.6994782626735623, [26044.291150201414, 2149.646836469524], -0.24703433544859793, [26057.618094922444, 2141.388682636181], 0, [26082.917191745288, 2144.986378375343], -0.15459540270989405, [26091.962259784803, 2214.116475754572], 0, [26039.494753894378, 2244.4086044041187], 0, [26003.616101332478, 2221.35479847017], -1.3088618180444112, [25978.38815960153, 2184.68279839121], -0.9123557287923755, [25952.277169681776, 2222.4813444450965], -1.199317806271941, [25997.17376418695, 2229.1016983182553], 0, [26025.963808762852, 2247.6007235906627], 0.2536687013302224, [25994.250308387458, 2264.6172058991515], -3.0648492881772293, [26009.371368871263, 2290.8076509214206], 0.33753088116466423, [26051.50704181469, 2272.9664236838507], 0, [26041.980954699084, 2308.518264796453], -0.725559559863707, [26022.29040117664, 2337.5227607197626], -0.9663623936288359, [26054.110193044387, 2356.117788007363], -1.2305179800917057, [26054.228465168653, 2320.021037000236], -0.09254370864724822, [26050.817730885556, 2314.1760001449584], 0, [26064.02459565663, 2264.8873098108807], 0, [26108.098283491618, 2239.441354275171], -0.02086202743092352, [26114.587070350393, 2246.555666373988], 0, [26098.815605153213, 2266.6744146642295], -0.2495726219465555, [26083.020383715764, 2267.567579038996], -0.7668590421252343, [26081.61856015008, 2280.176132537769], -0.8431806725804747, [26096.85405159149, 2291.3357392397647], -0.6994782626735623, [26106.891994976486, 2289.3290236712915], -0.24703433544859793, [26106.403696328973, 2273.6584740713774], 0, [26122.16894064559, 2253.547661399576], -0.1545954027098919, [26186.559895161856, 2280.279451388008], 0, [26186.559895161856, 2340.8637086870967], 0, false], "basePt": { "x": 32522.109900548017, "y": 1609.359529229296, "z": 0 } }
)[0] as Polyline;
let u = new OffsetPolyline(pl, 2, true);
u.Do();
expect(u._RetCurves[0].Length).toMatchNumberSnapshot();
});
test('精度过高导致的曲线丢失', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 251, false, 1, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 2, 13, [41568.41939449503, -16055.957031544558], 0, [41568.41939449503, -19085.900092302996], 0, [30759.326124901945, -19085.900092302996], -0.5620803766633276, [32250.53989507628, -17057.09381683477], 0, [32250.53989507628, -16357.06481080249], 0, [34929.549328438894, -16357.06481080249], 0, [34929.549328438894, -17863.39252063465], 0.987810697071495, [33774.55073827239, -14793.15050188782], -1.3816050810686162, [33774.55073827241, -13501.28447317968], -2.006103958007124, [36035.31628850903, -13501.284473179749], -0.0001885101725322209, [38671.98716124392, -12938.183259384707], 0.02277643035683432, [38583.16317846376, -14829.035669351935], -0.19748258058151022, [41568.41939449503, -16055.95703154455], 0, false], "basePt": { "x": 30648.49760765549, "y": -19085.900092302996, "z": 0 } }
)[0];
testOffset(pl, -6353.8678);
testOffset(pl, -7108.8942);
});
test('双圆可能只有一个交点的问题', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 636, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 8816.790579978495, 1650.6512717161677, 0, 1], 0, 0, 2, 100, [-37.63997927032032, -122.31163856112178], -0.5850546209475238, [-84.92238785528671, 95.73449225818709], 0.00048018346906500295, [-85.27707472776136, 95.88824662159877], -0.10038125296941941, [-100.93665631505141, 106.79052252639573], -0.09978689253876652, [-131.76667746262092, 104.80702667339267], -0.12073301752491941, [-151.67431650500077, 73.37209505357924], -0.5147180077889115, [-232.0223308644795, 5.840987907604884], -0.4421725056265134, [-343.00499218797165, 38.35573246512353], -0.14690306216640125, [-364.26735878587374, 68.74797211310536], -0.0789057495185578, [-388.5254434655121, 72.31955396748418], -0.21282420582827116, [-433.18722338719715, 44.69096592404263], -0.06917535096525852, [-449.2439796725272, 30.35284996317626], -0.013050188065150235, [-448.05241473562984, 26.45089280427763], -0.34287563284334255, [-405.3000739317947, -40.144263097799424], -0.20891260124539257, [-381.7347890041258, -86.08606068332617], -0.2246373308823597, [-335.6246400076669, -134.5096752147314], -0.21813830679087096, [-266.9707266593898, -171.66583367022992], -0.20814567305857132, [-196.83037314615297, -206.35838746065957], -0.0488609763647568, [-183.43081949963988, -213.6216104956162], -0.5893114558987727, [-103.70193128809301, -265.8769545830993], 0.1365773165792166, [-79.95072251724413, -384.84437230537276], -0.5885213600554807, [-302.4576921365059, -361.220067129458], -0.06557799694475708, [-317.30556800997874, -369.17085995623484], -0.11621539070929156, [-325.0401583401413, -404.18065455827946], -0.12073301752494925, [-301.29556056580026, -432.8278724811278], -0.5147180077888068, [-261.89856296335944, -530.1116348661351], -0.44217250851076284, [-327.11745182745744, -625.6148095821012], -0.1469030525145038, [-362.59262098629074, -636.4448023523848], -0.07890575249105626, [-373.4855578748615, -658.4119332516439], -0.21282420513501799, [-361.01045814439436, -709.4255131431923], -0.06917535209620826, [-352.33590991267806, -729.1271175046942], -0.013050187963299782, [-348.25671434700826, -729.1996429900106], -0.34287562971868696, [-271.70975785893273, -709.1187856953593], -0.20891260202956674, [-220.73443821197503, -700.9036640077483], -0.31675246275620333, [-134.11031143157686, -676.4439632892754], -0.16230999968995205, [-85.91240781566471, -665.3936829062455], -0.12553096852905601, [-65.93014936543435, -632.3191768509196], -0.29664259727671044, [-38.161618560529064, -551.7160280205677], -0.5893113859543132, [36.17374838803935, -492.0371475290025], 0.13657730967860005, [156.6580059392573, -506.2113564430807], -0.573366330822081, [71.19636084103496, -709.8930956755739], -0.03690801267675709, [67.08632481074491, -716.7947085866487], -0.0403664415590649, [68.40492915087238, -727.1058474058361], -0.11621539027255794, [99.31110245603931, -745.2805014019764], -0.12073301752492402, [133.89370997215167, -731.5505241416072], -0.5147180082028758, [238.5904079584172, -724.1440887681127], -0.4421725039650299, [309.26557962310653, -815.6830412453354], -0.14690306099053752, [308.60308521759185, -852.768585009891], -0.07890574997172202, [326.1289649479008, -869.916599931916], -0.21282420582831063, [378.5007804971855, -873.8161382532904], -0.06917535096523136, [399.9187023140022, -871.6542833178032], -0.01305018806511863, [401.24821890322517, -867.7971493678833], -0.34287563390009135, [405.80449931746523, -788.7913408909262], -0.20891259829029268, [413.7436943971827, -737.7723193445075], -0.31675246318302686, [417.24946371877616, -647.82941579443], -0.16231000026306786, [421.6339936759038, -598.5757610995396], -0.12553097358493912, [396.35312614415346, -569.3509183300448], -0.29664257811819367, [328.27592627148056, -518.0337346310055], -0.5893113946164944, [294.48882837820696, -428.8948110258959], 0.1365773096786672, [345.200985267305, -318.6875442070351], -0.5760384593638737, [512.3147161695078, -463.91803280390724], -0.027762450863063955, [517.4394566611734, -468.911824478552], -0.041768197273778056, [528.0124297776388, -470.88135964102474], -0.11621539027254314, [554.8480856744687, -447.10411907709465], -0.12073301752493472, [552.4767147646883, -409.971308542578], -0.5147180082028519, [577.7858350729049, -308.1101172900079], -0.4421725037232871, [686.6843813901379, -269.18112667103946], -0.14690306179977608, [721.7501075357419, -281.27125954479726], -0.07890574972248751, [743.4746334847587, -269.9021855004115], -0.21282420621694662, [763.3670959161645, -221.29865259730752], -0.06917535033121872, [767.9295515459406, -200.26094870913468], -0.013050189132785087, [764.6720421240976, -197.8045831504546], -0.34287562914615266, [690.9410217478106, -169.0571658545639], -0.20891260217326688, [644.872394450502, -145.7407977893127], -0.3167524628946992, [560.4149523821089, -114.61272710126653], -0.16230999832660697, [514.9268376990387, -95.22257497271181], -0.12553097444531064, [479.3201426312775, -110.2351358549983], -0.2966425778523087, [409.4775890118797, -159.1225185178718], -0.5893113063750319, [314.26065493198496, -163.7105280567915], 0.13657731819301375, [225.11822645442106, -81.42446978963335], -0.5521520302060734, [406.60433937507884, 36.81315291034779], -0.047088274465754566, [418.17451838908585, 40.41883860776523], -0.04932881457566483, [423.2591444006404, 49.86141664669075], -0.09866801760096591, [412.0341636398682, 78.27886668585671], -0.12073301752494194, [375.9859683015703, 87.4982284336266], -0.5147180077888471, [286.9311668964115, 143.04547130452087], -0.4421725057028689, [283.55899816798757, 258.6438632019194], -0.14690306191037403, [305.8933031040614, 288.2572940179554], -0.07890574959740947, [301.7939188753185, 312.43178303838596], -0.21282420582828568, [261.71632118573507, 346.3699566262424], -0.06917535096525027, [243.1181520030554, 357.21011782274053], -0.013050188065110081, [239.77538403619326, 354.87110115149983], -0.34287563284336736, [189.65082691952335, 293.63217392634607], -0.20891260124541192, [153.23965447542747, 257.02345993147196], -0.3167524626595722, [97.5363151713131, 186.31876216651972], -0.0022449989277561824, [97.26309990631562, 185.67215126773345], -0.28667947844744857, [96.24805730936309, 48.61340648360716], -0.06367853269332903, [93.22543368129013, 29.01451546984611], -0.5893113794230874, [68.16522360588714, -62.95994473241845], 0.13657730967861118, [-37.639979270320296, -122.3116385611219], 0, false], "basePt": { "x": 8367.546600305966, "y": 776.8351334628773, "z": 0 } }
)[0];
testOffset(pl, -12);
});
test('精度过高导致连接失败', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 101, false, 1, 5, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 14518.613504172958, 18703.388772543934, 0, 1], 0, 0, 2, 33, [-2728.035021537973, -693.4012148813017], -0.3132583645586733, [-1601.8632919752708, 2314.522481497792], -0.03271654995069073, [-2273.419222591714, 2989.362495244932], -0.5625634539464556, [-3890.2801394762355, 3812.997524299488], 0.578639696480197, [-8788.605498322046, 960.1267108962238], -1.029709203909757, [-9954.873440911644, -206.14123168138758], 0.06337366142629626, [-10799.636417792484, 453.559442471018], 0.03792997284958775, [-9953.629162487545, -1660.1039329838386], -0.03406559295613797, [-10578.714309501978, -3162.773362526852], -0.026933451515028697, [-10332.24074169185, -3483.7939054907183], 0.00006795169607499043, [-11282.624637088404, -3687.0024757001956], 2.006103958007124, [-13543.3901873231, -3687.0024757005376], 1.3816050810686014, [-13543.390187323123, -4978.868504408674], -0.3636717333201528, [-12751.044634472513, -11523.955695998557], 0, [-9096.970935262972, -13685.493692909986], 0, [-9096.970935262972, -14046.280681946693], 0, [-8505.59719095358, -13657.009824881847], -0.3132583645586735, [-9631.768920516282, -16664.933521260944], -0.03271654995069073, [-8960.212989899832, -17339.773535008077], -0.5625634539464553, [-7343.352073015318, -18163.408564062644], 0.578639696480197, [-2445.0267141695076, -15310.537750659381], -1.0297092039097568, [-1278.758771579909, -14144.269808081766], 0.06337366142629626, [-433.9957946990762, -14803.970482234176], 0.03792997284958775, [-1280.0030500040084, -12690.307106779323], -0.03406559295613797, [-654.9179029895749, -11187.637677236302], -0.026933451515028697, [-901.3914707997028, -10866.617134272436], 0.00006795169607499043, [48.9924245969014, -10663.408564062645], 2.006103958007124, [2309.75797483154, -10663.408564062616], 1.3816050810686011, [2309.7579748315547, -9371.54253535448], -0.3636717333201528, [1517.41242198094, -2826.4553437645973], 0, [-2136.661277228579, -664.917346853168], 0, [-2136.661277228579, -304.1303578164607], 0, [-2728.0350215379567, -693.4012148813072], 0, false], "basePt": { "x": 82.79898218830704, "y": 105.03816793893884, "z": 0 } }
)[0];
testOffset(pl, -700);
testOffset(pl, 3097.5341);
});
test('精度过高导致直连失败', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 102, false, 1, 7, 0, [-0.9259244671528073, 0.37770872524710086, 0, 0, -0.37770872524710086, -0.9259244671528073, 0, 0, 0, 0, 1, 0, 6897.759879664679, 15205.352986914135, 0, 1], 0, 0, 2, 54, [-4354.152742830657, 13827.177939596737], 0, [-4262.7811479846705, 13409.171935420743], 0.4142135623731054, [-3949.382308443396, 13722.570774962005], -2.4142135623730643, [-3742.972460584606, 13516.160927103203], 0.41421356237309165, [-4056.371300125894, 13202.762087561938], 0, [-3.959206250088073, 14807.966978465562], 0, [374.86545725511814, 14627.059181391069], 0, [-308.3555283984747, 13943.838195737577], 0, [679.7597941901334, 13785.920221807895], -1.4592811343207486, [1009.1868138637083, 13733.272067978744], 0, [1505.5914256528936, 13653.937997601468], -1.1454616257969195, [1431.8308803096738, 13410.207502425372], 0.17647228147005975, [954.3937019885567, 13448.442761469398], 0.04501244263911578, [910.3672178888974, 12872.838967064557], 0.31352869106557485, [1254.453721297551, 12392.154572095944], 0.11606667962528619, [-769.1723201668815, 12475.541357089327], -0.4715020269053065, [-914.7290948999207, 12299.027686249425], 0.36270572632482756, [-1223.1098162314288, 12041.415740385853], -0.21031969189409624, [-1312.846126325028, 11908.417649155192], 0.18813889756470098, [-963.4449465315768, 11768.757856769267], 0.4991924773796846, [-1214.7276490074717, 11335.387842142274], -0.4715020269052786, [-1320.506481009447, 11132.521656284785], 0.362705726324842, [-1568.7468099597754, 10816.548045008172], -0.36230920816255674, [-1726.2154811248029, 10615.824015261507], 0.4243185463169048, [-1964.8264682160366, 10233.392254718088], 0, [-2265.5315916327377, 10110.726796713447], 0.41421356237309614, [-2437.3417689642583, 9702.169667027829], -2.41421356237314, [-2706.4244978711795, 9815.326794908384], 0.41421356237310153, [-2534.614320539642, 10223.883924594023], 0, [-2754.00600324702, 10761.706096363048], 0, [-3341.7022762014294, 10795.952557540084], 0.40448613781936477, [-3672.0207589378324, 10511.730420211165], -0.3283082854240908, [-3828.745250127082, 10335.177993847788], 0.42431854631690913, [-4067.356237218308, 9952.746233304364], 0, [-4368.061360635038, 9830.080775299726], 0.4142135623730961, [-4539.8715379665655, 9421.523645614097], -2.414213562373104, [-4808.954266873471, 9534.680773494647], 0.4142135623730893, [-4637.144089542, 9943.237903180267], 0, [-4856.535772249306, 10481.06007494932], 0, [-5275.629250369966, 10505.481649814608], 0, [-4901.076750834305, 11396.151204456679], 0, [-5875.6439010142485, 11169.151541429335], -1.4592811343207353, [-6200.554105740638, 11093.47229554728], 0, [-6690.152451994631, 10979.433299262762], -1.1454616257969006, [-6713.914892987609, 11232.969329692667], 0.17647228147005561, [-6257.402337098669, 11377.898555845191], 0.045012442639116336, [-6434.047713700185, 11927.493379656988], 0.3480949900000013, [-6998.304586811107, 12235.672947006504], 0.4991924773796818, [-6827.906275759371, 12706.753600113925], -0.4715020269052993, [-6759.802450275848, 12925.169990567034], 0.3627057263248343, [-6571.567474877286, 13280.177283417874], -0.36230920816254886, [-6452.2139365386165, 13505.657329990141], 0.2494829232648448, [-6264.109974726044, 13732.159080724145], -0.0032219232791951347, [-4354.152742830706, 13827.177939596728], 0, false], "basePt": { "x": 284.68899521531, "y": 124.40191387562407, "z": 0 } }
)[0];
testOffset(pl, -488.7623);
testOffset(pl, -463.9361);
});
test('圆弧全丢时需要扇形切割', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 663, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6853.1135131705805, 836.8675810089517, 0, 1], 0, 0, 2, 27, [-16.65652680662606, -139.45855145395706], -0.07144822635709537, [-55.23422677371218, -129.1329069277308], -0.561450112948161, [-231.7482903492928, -291.4845802732408], -0.6533600789999746, [-488.9850632026728, -293.4891020338172], -0.09057099782999173, [-537.1231686572528, -278.3295686052045], -0.7618610483782836, [-785.3594189458317, -170.06019773383105], -0.5437626258582055, [-831.7965011168826, 61.09406785259716], -0.20989748425823024, [-821.5658136697248, 173.5739612523115], -0.44178467697699414, [-962.6165195283729, 325.9842596711035], -0.4640169462600465, [-930.7589203066564, 538.105200854457], -0.14150555348001248, [-884.1985938177158, 600.6057847806414], -0.3918412064449112, [-892.1911162706765, 791.273561468744], -1.2401869081054664, [-656.9329637971105, 932.7370024409249], -0.3780572143676024, [-511.23200314928545, 817.3911809150459], -0.15855910573440352, [-450.7514918718289, 755.0002355441181], -0.13423106558088388, [-390.0232449991963, 797.4190811206659], -0.37585301846721253, [-389.91032633598115, 982.4363154046794], -0.7527397478179146, [-220.4149163916445, 1192.5254581753811], -0.4657146279670491, [-14.69865666698206, 1130.0102224751936], -0.5121975123633337, [165.04952102208426, 989.8251327583196], -0.6686805682229583, [239.92044665198318, 741.2647937618274], -0.1190799996199453, [257.1716909424922, 677.5969246887876], -1.0785062605296105, [333.64851468926736, 408.14039255881926], -0.10448637020767436, [304.455989416344, 357.9457422079879], -0.8222462346235836, [242.6073012666575, 89.37100447247508], -0.13660899257896938, [192.97621867324324, 32.687778966786595], -1.304546181288702, [-16.65652680662606, -139.45855145395706], 0, false], "basePt": { "x": 5855.654258829502, "y": 460.34235664660923, "z": 0 } }
)[0];
testOffset(pl, 141);
});
test('精度问题导致的连接错误', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 5, 2, 152, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 2, 7, [20, 10], 0, [20, 0], 0, [10.000000000000004, 2.5000000000000018], 0, [0, 0], 0, [0, 10], 0, [10, 7.5], 0, [20, 10], 0, false], "basePt": { "x": 0, "y": 0, "z": 0 } }
)[0];
testOffset(pl, 2.4254);
});