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/seal.test.ts

105 lines
13 KiB

import { Board } from "../../src/DatabaseServices/Entity/Board";
import { ObjectId } from "../../src/DatabaseServices/ObjectId";
import { GetSealedBoardContour } from "../../src/GraphicsSystem/CalcEdgeSealing";
import { Production } from "../../src/Production/Product";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
import "../Utils/jest.util";
test('无法计算封边', () =>
{
let d =
[1, "Board", 8, 2, 45360, false, 1, 5, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 162355.7743531527, 18, -582496.0854969013, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 162337.7743531527, 18, -582514.0854969013, 1], 0, 3, 1704, 401, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1704, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -78, 0, 1], 0, 2, 6, [401, -1704], 0, [401, -1704], 0, [383, -1704], 0, [382.99999999999994, 0], 0, [0, 0], 0, [0, -1704], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "背板", "一楼次卧", "衣柜3", "福人颗粒板-山水之恋-晶钻面", "颗粒板", "山水之恋", 0, 1, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 6, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0];
let br = LoadEntityFromFileData(d)[0] as Board;
let seald = GetSealedBoardContour(br);
expect(seald.sealedContour.Length).toMatchNumberSnapshot();
});
test('封边', () =>
{
let d =
{ "file": [1, "Board", 10, 2, 100, 0, 1, 2, 71, [0, 1, -1.8369701987210297e-16, 0, -1, 0, 0, 0, 0, 1.8369701987210297e-16, 1, 0, 2808.550429183707, 1026.6977927045664, 2.842170943040401e-14, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, -1.8369701987210297e-16, 0, 0, 1.8369701987210297e-16, 1, 0, 2808.550429183707, 1026.6977927045664, 2.842170943040401e-14, 1], 0, 0, 1, 3, 1600.976909041937, 216.70369214357592, 18, false, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 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, 0, 3, 0, 0, 0, 0, 0, 11, 0, "异型板", "", "", "", "", "", 0, 0, "三合一", 2, 8, 1, 1, 1, 1, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 37, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null], "basePt": { "x": 1207.57352014177, "y": 1026.6977927045664, "z": -1.1386113011652544e-14 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let br = LoadEntityFromFileData(d)[0] as Board;
let seald = GetSealedBoardContour(br);
expect(seald.sealedContour.Length).toMatchNumberSnapshot();
expect(seald.brContour.Length).toMatchNumberSnapshot();
expect(seald.sealedContour.EndParam).toMatchNumberSnapshot();
expect(seald.brContour.EndParam).toMatchNumberSnapshot();
expect(seald.highSeals.length).toMatchNumberSnapshot();
});
test('小圆弧封边', () =>
{
let d =
{ "file": [1, "Board", 10, 2, 101, 0, 1, 2, 71, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1557.566765578644, 603.2640949554933, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1557.566765578644, 603.2640949554933, 0, 1], 0, 0, 1, 3, 527.0029673590507, 543.0267062314539, 18, true, "Polyline", 10, 2, 0, 0, 1, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -603.2640949554933, 1557.566765578644, 0, 1], 0, 0, 1, 2, 5, [0, 527.0029673590507], 0, [0, 0], 0, [542.5267062314539, 0], 0.41421356237309503, [543.0267062314539, 0.5], 0, [543.0267062314539, 527.0029673590507], 0, true, 0, 3, 0, 0, 0, 0, 0, 11, 0, "层板", "", "", "", "", "", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 5, "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null], "basePt": { "x": 1030.5637982195933, "y": 603.2640949554933, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let br = LoadEntityFromFileData(d)[0] as Board;
let seald = GetSealedBoardContour(br);
expect(seald.sealedContour.Area2).toMatchNumberSnapshot();
expect(seald.brContour.Area2).toMatchNumberSnapshot();
expect(seald.sealedContour.EndParam).toMatchNumberSnapshot(0);
expect(seald.brContour.EndParam).toMatchNumberSnapshot(0);
expect(seald.highSeals.length).toMatchNumberSnapshot(0);
});
test('特殊链接 圆弧间', () =>
{
let d =
{ "file": [1, "Board", 10, 2, 100, 0, 1, 2, 71, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1259.5443313570531, 375.21311475409846, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1259.5443313570531, 375.21311475409846, 0, 1], 0, 0, 1, 3, 404.0689215209877, 600.0000000000003, 18, false, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -610.8739531813568, 7260.612476120086, 0, 1], 0, 0, 1, 2, 6, [2.2737367544323206e-13, 57.83551241479472], 0, [121.15231478518581, 178.98782719999963], -0.44349303569486936, [376.8492107851855, 0], 0, [600.0000000000003, 0], 0, [600.0000000000003, 404.0689215209877], 0, [0, 404.0689215209877], 0, true, 0, 3, 0, 0, 0, 0, 0, 11, 0, "层板", "", "", "", "", "", 0, 0, "三合一", 2, 6, 1, 2, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 6, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null], "basePt": { "x": 855.4754098360654, "y": 375.21311475409846, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let br = LoadEntityFromFileData(d)[0] as Board;
let seald = GetSealedBoardContour(br);
expect(seald.sealedContour.Area2).toMatchNumberSnapshot();
expect(seald.brContour.Area2).toMatchNumberSnapshot();
expect(seald.sealedContour.EndParam).toMatchNumberSnapshot(0);
expect(seald.brContour.EndParam).toMatchNumberSnapshot(0);
expect(seald.highSeals.length).toMatchNumberSnapshot(0);
});
test('圆弧连接,连接失败了强行连接', () =>
{
let d =
{ "file": [2, "Board", 10, 2, 250, 0, 1, 2, 71, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 5420.396189184161, -2536.8980307174484, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5420.396189184161, -2536.8980307174484, 0, 1], 0, 0, 1, 3, 827.7272727272722, 600.0000000000002, 18, false, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -172.0808080808082, 47706.26352358669, 4737.41794856498, 1], 0, 0, 1, 2, 5, [363.08080808080774, 0], 0, [600.0000000000001, 0], 0, [600.0000000000002, 827.7272727272721], 0, [1.4210854715202004e-13, 827.7272727272721], 0, [0, 326.3131313131307], -0.20262143281721134, true, 0, 3, 0, 0, 0, 0, 0, 11, 0, "层板", "", "", "", "", "", 0, 0, "三合一", 2, 5, 0, 0, 0, 0, 1, "0", "0", "0", "0", "", "", "", 5, "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 1, "1", "1", 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null, "Board", 10, 2, 445, 0, 1, 2, 71, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1480.3203606069178, 844.0742138083208, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1480.3203606069178, 844.0742138083208, 0, 1], 0, 0, 1, 3, 705.3016287401363, 763.5607321131454, 18, false, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -1363.0853726921553, -1423.7469138504698, 0, 1], 0, 0, 1, 2, 5, [763.5607321131454, -2.2737367544323206e-13], 0, [600.0000000000007, 705.301628740136], 0, [600.0000000000007, 301.23270721914173], 0.3784142003682244, [440.4202016404272, 480.2205344191484], 0, [0, 359.0682196339435], 0, true, 0, 3, 0, 0, 0, 0, 0, 11, 0, "层板", "", "", "", "", "", 0, 0, "三合一", 2, 5, 0, 0, 2, 0, 2, "0", "2", "2", "0", "", "", "", 5, "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null], "basePt": { "x": 775.0187318667815, "y": -2536.8980307174484, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let brs = LoadEntityFromFileData(d) as Board[];
for (let br of brs)
{
let seald = GetSealedBoardContour(br);
expect(seald.sealedContour.Area2).toMatchNumberSnapshot();
expect(seald.brContour.Area2).toMatchNumberSnapshot();
expect(seald.sealedContour.EndParam).toMatchNumberSnapshot(0);
expect(seald.brContour.EndParam).toMatchNumberSnapshot(0);
expect(seald.highSeals.length).toMatchNumberSnapshot(0);
}
});
test('每段封边对应', () =>
{
let d =
{ "file": [2, "Board", 10, 2, 128, 0, 1, 2, 71, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 3199.279879469078, -184.30835593784656, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3199.279879469078, -184.30835593784656, 0, 1], 0, 0, 1, 3, 1200, 600.0000000000001, 18, false, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, 2, 7, [600, 0], 0, [600.0000000000001, 1068.1313131313123], 0, [277.2828282828283, 1068.1313131313123], 0, [277.28282828282823, 1200], 0, [2.6645352591003757e-13, 1200], 0, [5.3677170396015264e-14, 241.74048459379696], 0.41421356237309503, [241.74048459379696, 0], 0, true, 0, 3, 0, 0, 0, 0, 0, 11, 0, "层板", "", "", "", "", "", 0, 0, "三合一", 2, 5, 1, 0, 0, 0, 2, "0", "2", "2", "1", "", "", "", 7, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 1, "1", "1", 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null, "Board", 10, 2, 129, 0, 1, 2, 71, [0.9999999999999999, 0, 0, 0, 0, 0.9999999999999999, 0, 0, 0, 0, 1, 0, 3325.715287455372, -16.86877780939915, 0, 1], 0, 0, 1, [0.9999999999999999, 0, 0, 0, 0, 0.9999999999999999, 0, 0, 0, 0, 1, 0, 3325.715287455372, -16.86877780939915, 0, 1], 0, 0, 1, 3, 350, 300, 18, false, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, 2, 4, [0, 0], 0, [0, 350], 0, [200, 350], -0.5714285714285715, [200, 0], 0, true, 0, 3, 0, 0, 1, 0, 0, 11, 0, "圆弧板-G", "", "", "默认板材18厘", "生态板", "经典檀木", 1, 1, "三合一", 2, 4, 1, 1, 2, 1, "1", "1", "1", "2", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null], "basePt": { "x": 1999.279879469078, "y": -184.30835593784656, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let brs = LoadEntityFromFileData(d) as Board[];
for (let br of brs)
{
br.objectId = new ObjectId(101);//创造101
let data = Production.GetBoardSplitOrderData(br);
expect(data.sealing.map(s => s.size)).toMatchSnapshot();
expect(data.outline).toMatchSnapshot();
}
});