diff --git a/__test__/Polyline/__snapshots__/offset4.test.ts.snap b/__test__/Polyline/__snapshots__/offset4.test.ts.snap new file mode 100644 index 000000000..f2949b6b5 --- /dev/null +++ b/__test__/Polyline/__snapshots__/offset4.test.ts.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`圆裁剪精度 1`] = `1`; + +exports[`圆裁剪精度 2`] = `"8360.62214"`; + +exports[`圆裁剪精度 3`] = `1`; + +exports[`圆裁剪精度 4`] = `"8385.98689"`; diff --git a/__test__/Polyline/offset4.test.ts b/__test__/Polyline/offset4.test.ts new file mode 100644 index 000000000..d35b83f49 --- /dev/null +++ b/__test__/Polyline/offset4.test.ts @@ -0,0 +1,20 @@ +import { Polyline } from "../../src/api"; +import "../Utils/jest.util"; +import { LoadCurvesFromFileData } from "../Utils/LoadEntity.util"; + +test('圆裁剪精度', () => +{ + /** + * 因为中间圆裁剪后,线连接不起来了,提高连接的容差精度后就可以了 + */ + let d = { "file": [1, "Polyline", 8, 2, 144, false, 1, 1, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 2498.5166835831396, 36.13526573480675, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -19109.681164799094, -6847.127428943546, -650.2465814234456, 1], 0, 2, 86, [902.4995200499297, 796.94830297053], -0.1951364646053483, [876.6722294192559, 788.4182847681989], 0.09008012997174562, [807.2798879906641, 784.269732982488], 0.011304462581459947, [626.7414453220681, 746.8591896016189], -0.08145268876046645, [497.95958813109246, 743.9587448130044], 0.05469866637397533, [461.598775141887, 742.4068100594197], -0.14158509451267687, [167.5399769558053, 735.0187133723596], 0.14883741766395087, [124.73356210168276, 738.4523598792077], -0.1762833507999994, [90.72364714116429, 743.2982127913349], -0.00017925105772946114, [60.42076201722557, 759.4813678043868], -0.011735559502437955, [31.888417693167867, 770.3410730034195], -0.11405611771458905, [9.000000000008185, 790.8032363070199], 0, [9.000000000006366, 767.1161755375181], 0, [7.275957614183426e-12, 767.1161755375181], 0, [0, 688.0597703872302], 0, [9.000000000006366, 688.0597703872302], 0, [9.000000000008185, 682.6369128258086], 0.06415407275910487, [57.34231533059028, 683.1966012153791], -0.19807449241100195, [110.18789286439278, 662.8365248285884], 0.3026677012686125, [188.26097728819968, 668.8638548677084], -0.14366777746287163, [266.06035213251835, 679.1611182426607], 0.00030001193746414704, [369.8477918860217, 673.4971650811788], -0.05316803152838944, [432.3620989954443, 656.7422450734741], 0.19256796512901278, [460.69814993965065, 659.3267828027967], -0.3095521122195693, [487.06682830495356, 660.4716627915916], 0.20524760558389235, [508.52706718012723, 661.0442550997398], -0.13484995306011927, [567.7914273904162, 661.4096984228711], -0.00271119918346341, [876.1506475768674, 631.490156287033], -0.44849973476657085, [904.5934184669359, 586.1363099981138], 0.0018854733989563197, [872.5906775537633, 453.62011868038485], 0.18398956435194652, [889.5514272168102, 354.0257905309302], -0.11281691135918825, [902.605289452521, 311.24015893414276], -0.40133683662301495, [886.0735147666228, 283.68831239792075], -0.056242785012797496, [646.6143945889153, 160.32938655479325], -0.0808333028390403, [207.32188038244567, 105.39347844947793], -0.13897024205252478, [160.05731903955711, 118.53905822455295], 0.15905576487307935, [111.8974586853983, 125.94473750648126], -0.14538860983722812, [77.24618464509422, 130.6220599550909], 0.10095689870794057, [35.394366977898244, 140.02628632000074], -0.19410070448829217, [21.668183581078665, 156.04485518096067], 0.11746359471898192, [8.999999999993634, 169.5113861193788], 0, [9.000000000009095, 142.37756939545966], 0, [7.275957614183426e-12, 142.37756939545966], 0, [7.275957614183426e-12, 80.84611264924047], 0, [9.000000000008185, 80.84611264924047], 0, [9.000000000008185, 61.50478582528763], 0.06744774385388243, [27.471260145146516, 67.25695886344715], -0.1886820042909182, [75.00398637547733, 60.172345281586104], 0.23000044917334742, [146.81900186699386, 58.547699537710514], -0.10533426099931531, [211.10887840761188, 57.95549544539995], 0.026671718008239195, [318.25214132559995, 59.124904717817344], -0.0637946216602559, [513.2252524891555, 6.285719837433362], 0.31032893218565827, [573.4123378315908, 13.064178429918911], -0.14822686950420233, [754.8909168793052, 55.41649961748794], -0.012869066270174635, [861.8930603851568, 39.10102077981014], 0.05740033333712818, [1008.6061728950863, 13.713647862409061], 0, [1008.6061728950835, 80.84611264960063], 0, [555.9521628553302, 80.84611264960063], 0, [555.9521628553302, 98.84611264960063], 0, [1008.6061728950826, 98.84611264960063], 0, [1008.6061728950826, 221.69403883663858], 0, [948.1750629556973, 221.69403883663858], 0, [948.1750629556973, 239.69403883663858], 0, [1008.6061728950826, 239.69403883663858], 0, [1008.6061728950826, 380.4047908802788], 0, [934.0384032830189, 380.4047908802788], 0, [934.0384032830198, 398.4047908802788], 0, [1008.6061728950826, 398.4047908802788], 0, [1008.6061728950826, 531.685038542448], 0, [942.865965661329, 531.685038542448], 0, [942.865965661329, 549.685038542448], 0, [1008.6061728950826, 549.685038542448], 0, [1008.6061728950835, 688.0597703872302], 0, [696.0073137969339, 688.0597703872302], 0, [696.0073137969339, 706.0597703872302], 0, [1386.0030192337754, 706.0597703872302], 0.3478557890603773, [1343.8971152812383, 827.5515079423096], 0, [1168.7328939696072, 827.5515079422987], 0, [1168.7328939696072, 845.5515079422878], 0, [1332.6674704959778, 845.5515079422878], 0.3192848665270317, [1312.219454025052, 864.588864080026], 0.037616847238474985, [1286.7202327687683, 866.6949135917678], -0.01715185217142492, [1267.4281082691705, 870.5466396738996], -0.009710461384245753, [1196.3844465449565, 882.1230229504656], -0.08767664517897532, [1156.6944492858338, 897.6016474314895], 0.28429013535939607, [1092.1003220072607, 900.8170406706015], -0.0019459978183986042, true], "basePt": { "x": 1590.0495863597362, "y": 36.13526573480675, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let pl = LoadCurvesFromFileData(d)[0] as Polyline; + + for (let dist of [-1, 1]) + { + let cus = pl.GetOffsetCurves(dist); + expect(cus.length).toMatchSnapshot(); + for (let c of cus) + expect(c.Length).toMatchNumberSnapshot(); + } +}); diff --git a/src/DatabaseServices/HistoricManage.ts b/src/DatabaseServices/HistoricManage.ts index 444aa9bd6..bcb2bcad5 100644 --- a/src/DatabaseServices/HistoricManage.ts +++ b/src/DatabaseServices/HistoricManage.ts @@ -88,8 +88,8 @@ export class HistoricManage extends CADObject key: "no_command_his" }); } - else - console.error("命令未执行中,但是却产生了错误了记录!"); + // else jest会警告这个 + // console.error("命令未执行中,但是却产生了错误了记录!"); } if (this._SignalCommandHistory && CommandState.CommandIng) diff --git a/src/GraphicsSystem/OffsetPolyline.ts b/src/GraphicsSystem/OffsetPolyline.ts index adece3556..09ac4acf2 100644 --- a/src/GraphicsSystem/OffsetPolyline.ts +++ b/src/GraphicsSystem/OffsetPolyline.ts @@ -649,7 +649,7 @@ export class OffsetPolyline { used.add(minR.curve); preP = minR.e; - let status = pl.Join(minR.curve, false, 5e-2); + let status = pl.Join(minR.curve, false, 8e-2); if (status !== Status.True) console.warn("连接失败"); return minR.to;