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__/EdgeSealing/OneEdgeSealing.test.ts

91 lines
13 KiB

import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
import { GetSealedBoardContour } from "../../src/GraphicsSystem/CalcEdgeSealing";
import "../Utils/jest.util";
import { LoadBoardsFromFileData, LoadEntityFromFileData } from "../Utils/LoadEntity.util";
test('只有一个封边,并且失败的案例', () =>
{
let d =
{ "file": [4, "Board", 8, 2, 121, false, 1, 1, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 5156.78604262264, 155.71155098138843, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5156.78604262264, 155.71155098138843, -517.2053991103303, 1], 0, 3, 1332.7946008896697, 60, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1332.7946008896697, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 6, [0.9999999999995453, -1332.7946008896697], 0, [0.9999999999995453, -1332], 0, [60, -1332], 0, [60, 0], 0, [0, 0], 0, [0, -1332.7946008896697], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 1, "右收口条", "榻米衣柜及书桌", "柜体4右收口", "固峰希腊白", "多层板", "希腊白", 0, 0, "不排", 2, 0, "1", "1", "1", "1", "", "", "", 6, "不排", "不排", "不排", "不排", "不排", "不排", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 125, false, 1, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5019.321452985634, 377.9382754993276, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 4283.636154264983, 377.9382754993276, 0, 1], 0, 3, 116.0936470770996, 492.7358454018065, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -410.58187625625226, -2.2737367544323206e-13, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -410.58187625625226, -2.2737367544323206e-13, 0, 1], 0, 2, 8, [903.0128456459614, 0.042011759224124035], 0.00006257940248264371, [903.3177216580588, 0.044582197205727425], 0, [903.1637146020545, 18.0439233470006], -0.00006250723639880799, [902.8636905320473, 18.041393772886522], -0.002076508735090201, [892.896577535593, 17.999999999999773], -0.10213911426261756, [417.70988855098807, 116.09364707709983], 0, [410.5818762562526, 99.56514318901282], 0.10213916213559157, [892.8965775355929, 4.547473508864641e-13], 0.0020764365686957082, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "背板", "", "", "", "", "", 1, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 8, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 126, false, 1, 3, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4947.116633075755, 488.82041104941163, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 4211.431334355104, 488.82041104941163, 0, 1], 0, 3, 116.09364707712712, 492.73584540181275, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4.547473508864641e-13, 99.56514318901509, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -69.12869845001791, -1926.3342224071403, 0, 1], 0, 2, 6, [492.73584540181236, -99.52056099181004], 0, [492.5818383458083, -81.52121984201517], -0.00006250723639903003, [492.2818142757997, -81.52374941612948], -0.10423773106609027, [7.128012294613768, 16.528503888112027], 0, [0, 0], 0.10423770600938752, [492.4309693897147, -99.52313142979142], 0.00006257940248264371, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "背板", "", "", "", "", "", 1, 0, "三合一", 2, 4, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 6, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 127, false, 1, 4, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 5078.087564233807, 657.0134638837771, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5078.087564233807, 657.0134638837771, 0, 1], 0, 3, 2111.999999999998, 350, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 2031, 0, 1], 0, 0, true, [0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, -1207.750629722921, -11265.46679826914, 0, 1], 0, 2, 8, [350, -2031], 0, [350, 80.99999999999818], 0, [147, 80.99999999999818], 0, [147, 80], -0.41421356237309503, [107, 40], 0, [40, 40], 0.41421356237309503, [0, 0], 0, [0, -2031], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 1, "右侧板", "大厅", "鞋柜", "格绿", "生态板", "和风细雨", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 8, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": 4947.116633075755, "y": 155.71155098138843, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let brs = LoadBoardsFromFileData(d);
for (let br of brs)
{
let con = GetSealedBoardContour(br).sealedContour;
expect(con.IsClose).toBeTruthy();
expect(con.Area2).toMatchNumberSnapshot();
expect(con.Length).toMatchNumberSnapshot();
}
});
test('只有一个封边,并且失败的案例(展示这个改进的缺陷的地方)', () =>
{
let d =
{ "file": [1, "Board", 8, 2, 16179, false, 1, 2, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 31910.70739109177, 919.8136702083284, 1313, 1], 16190, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 30796.70739109177, 901.8136702083284, 1300, 1], 0, 3, 677, 552, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 677, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 6, [1.9681978798586215, -677], 0, [1.9681978798586215, -672], 0, [552, -672], 0, [552, 0], 0, [0, 0], 0, [0, -677], 0, true, 0, 3, 0, 0, 0, 0, 1, 16188, 10, 1, "右侧板", "橱柜", "地柜6号柜", "18-16181", "颗粒板", "16181", 0, 1, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 6, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 3, 16172, 2, 3, 36616, 36617, 36618, 3, 36619, 36620, 36621, 16180, 4, 3, 36624, 36625, 36626, 3, 36627, 36628, 36629, 1, 36630, 1, 36631, 16183, 2, 3, 36636, 36637, 36638, 3, 36639, 36640, 36641, 6, 16173, 16174, 16175, 16176, 16177, 16178, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": 31910.70739109177, "y": 919.8136702083284, "z": 1313 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] };
let brs = LoadBoardsFromFileData(d);
for (let br of brs)
{
let con = GetSealedBoardContour(br).sealedContour;
expect(con.IsClose).toBeTruthy();
expect(con.Area2).toMatchNumberSnapshot();
expect(con.Length).toMatchNumberSnapshot();
}
});
test('矩形板解析封边错误', () =>
{
let d =
{ "file": [1, "Board", 8, 2, 100, false, 1, 2, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -152.34375, 18, -167.96874999976717, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -152.34375, 18, -167.96874999976717, 1], 0, 3, 1515.0003295573406, 406, 18, true, "Polyline", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -899.9973051166162, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -899.9973051166162, 0, 1], 0, 2, 4, [406, 2414.9973051175475], 0, [0, 2414.997634673957], 0, [0, 899.9976346730255], 0, [406, 899.9973051166162], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "假门", "4-5装饰柜2", "1号柜", "南亚柚木", "夹板", "南亚柚木", 0, 1, "不排", 2, 4, 0, 1.5, 1.5, 1.5, "0", "0", "1.5", "1.5", "", "", "", 4, "不排", "不排", "不排", "不排", false, false, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": -152.34375, "y": 0, "z": -167.96874999976717 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let brs = LoadBoardsFromFileData(d);
for (let br of brs)
{
let con = GetSealedBoardContour(br).sealedContour;
expect(con.IsClose).toBeTruthy();
expect(con.Area2).toMatchNumberSnapshot();
expect(con.Length).toMatchNumberSnapshot();
}
});
test('偏移后曲线不闭合的问题', () =>
{
let d =
{ "file": [1, "Board", 8, 2, 137, false, 1, 4, 0, [-1.8369701987210297e-16, -1, 0, 0, 0, 0, 1, 0, -1, 1.8369701987210297e-16, 0, 0, 1294.2320411714973, 300.3864645821159, -77.81148543980584, 1], 0, 0, true, [-1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 0, 0, 0, 1, 0, 1294.2320411714973, 300.3864645821159, -77.81148543980584, 1], 0, 3, 391.2271, 64.5794295120013, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -15312.627584699, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -15312.627584699, 0, 0, 1], 0, 2, 20, [15368.177451746, 207.7892], -0.001715932, [15369.259901937, 258.6605], 0.014190138, [15374.529207322, 332.1809], 0.13371958, [15352.837584699, 390.6834], 0, [15352.837584699, 187.2], 0, [15334.817584699, 187.2], 0, [15334.817044013, 391.2271], 0.215796468, [15315.698324922, 309.4969], -0.01395558, [15320.518932854, 190.4847], -0.002175123, [15319.827584699, 79.2], -0.000333642, [15322.227584698, 49.2], 0.084045656, [15312.627584699, 9], 0, [15322.227584699, 9], 0, [15322.227584699, 0], 0, [15365.427584699, 0], 0, [15365.427584699, 9], 0, [15377.207014211, 9], 0.092440732, [15365.427584699, 55.2], -0.00015712, [15369.027584698, 78], -0.000156089, [15367.97674234, 104.4], -0.000039603, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "收口条", "", "_收口条", "", "", "", 0, 0, "不排", 2, 0, "1", "1", "1", "1", "", "", "", 20, "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", "不排", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": 1276.2320411714973, "y": 235.80703507011458, "z": -77.81148543980584 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let brs = LoadBoardsFromFileData(d);
for (let br of brs)
{
let cus = br.ContourCurve.GetOffsetCurves(-1);
for (let c of cus)
{
expect(c.Length).toMatchNumberSnapshot();
expect(c.IsClose).toBeTruthy();
}
let con = GetSealedBoardContour(br).sealedContour;
expect(con.IsClose).toBeTruthy();
expect(con.Area2).toMatchNumberSnapshot();
expect(con.Length).toMatchNumberSnapshot();
}
});
test('偏移后曲线不闭合的问题2', () =>
{
let d =
{ "file": [1, "Polyline", 10, 2, 209, 0, 1, 7, 71, [2.220446049250313e-16, 1, -1.8369701987210297e-16, 0, -1, 2.220446049250313e-16, -1.232595164407831e-32, 0, 1.232595164407831e-32, 1.8369701987210297e-16, 1, 0, 2800.6273980057904, -327.6194030341822, 154.3982712660218, 1], 0, 0, 1, [0, 1, -1.8369701987210297e-16, 0, -1, 0, 0, 0, 0, 1.8369701987210297e-16, 1, 0, 2800.6273980057904, -327.6194030341822, 154.3982712660218, 1], 0, 0, 1, 2, 37, [203.75274236917448, 0.6657821176631771], -0.12647817046362458, [216.58249214357465, 3.9639078952714044], 0, [216.70369214357606, 3.9639078952714044], 0, [216.70349214357384, 3.9670232852913614], 0, [216.7026921436518, 3.970172431976607], 0.005962190972429685, [216.04074477292943, 6.451513648837135], -0.002176672718212006, [215.35998088513043, 8.927953781329961], -0.00044376333274056043, [213.84759951148862, 14.544604951137444], -0.0003667819041204022, [212.34429214357397, 20.16382417328441], -0.001544194315380855, [206.4925267933031, 42.376867817670245], -0.0015310584877568476, [200.7774921435739, 64.62548417628375], -0.009890393483378371, [165.09260900743266, 218.00339530303336], -0.006193200118673486, [134.3552921435803, 372.4679898662846], -0.003954883402352878, [109.80113359540337, 510.43208818801577], -0.0012080368562184874, [86.67219214350916, 648.6462885313813], -0.00011581093482110962, [53.09282355173491, 852.6265914568794], 0.00002500101529673068, [19.906391149862884, 1054.4486651826255], 0, [21.720227807596984, 1087.039396742547], -0.00521091907627027, [26.7729988737874, 1161.6355313137447], -0.006073474799553129, [35.294008103393935, 1255.8468454906397], -0.0050452671458160485, [45.90799214357321, 1349.8476338032733], -0.009637488483441259, [73.09402035463063, 1540.2785908202159], -0.0021345969443920146, [83.22271449620018, 1600.9769090419366], 0, [62.8446583269706, 1600.9769090419366], 0.0036001887197470227, [48.08769214356744, 1510.076619646293], 0.009976279550128881, [20.351018578063304, 1303.993887760866], 0.01322079246633355, [2.2040921435805103, 1096.8779752522942], -0.0042031964376284, [0.3365602451176528, 1069.9961093543807], 0.06027708278844141, [1.4769921435768083, 1043.2679710122866], 0, [61.287392140351585, 679.720449795841], 0.00009084267787460379, [68.4354857399303, 636.314626773783], 0.0003367141025187746, [75.62069214250369, 592.9149412077645], 0.0017524780389864619, [96.762927535794, 468.4425780357958], 0.003912932302896014, [119.31359214358599, 344.2207988532739], 0.007554149456815115, [154.3982712660013, 173.3497428441044], 0.011551705859636422, [195.9783921435751, 3.9698256912733987], 0.3388891824181241, [201.16284145136657, -5.506706202140776e-13], 0.12647815605716622, true], "basePt": { "x": 1199.6504889638538, "y": -327.6194030341818, "z": 154.39827126602174 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3117.2750559817937, 228.82635435795817, 154.39827126600176, 1] };
let pl = LoadEntityFromFileData(d)[0] as Polyline;
let cus = pl.GetOffsetCurves(-1);
for (let c of cus)
{
expect(c.EndParam).toMatchNumberSnapshot(0);
expect(c.Length).toMatchNumberSnapshot();
expect(c.IsClose).toBeTruthy();
}
});