diff --git a/__test__/Booloperate/BoardCutting.test.ts b/__test__/Booloperate/BoardCutting.test.ts index da780f64c..fa1cbe418 100644 --- a/__test__/Booloperate/BoardCutting.test.ts +++ b/__test__/Booloperate/BoardCutting.test.ts @@ -16,9 +16,7 @@ test('板件与板件切割_分裂成多个', () => for (let b of splitBrs) { - expect(b.Width).toMatchNumberSnapshot(); - expect(b.Height).toMatchNumberSnapshot(); - expect(b.Thickness).toMatchNumberSnapshot(); + expect(b.Volume).toMatchNumberSnapshot(); } }); @@ -34,9 +32,7 @@ test('斜切割', () => splitBrs.push(br0); for (let b of splitBrs) { - expect(b.Width).toMatchNumberSnapshot(); - expect(b.Height).toMatchNumberSnapshot(); - expect(b.Thickness).toMatchNumberSnapshot(); + expect(b.Volume).toMatchNumberSnapshot(); } } { @@ -45,9 +41,7 @@ test('斜切割', () => splitBrs.push(br0); for (let b of splitBrs) { - expect(b.Width).toMatchNumberSnapshot(); - expect(b.Height).toMatchNumberSnapshot(); - expect(b.Thickness).toMatchNumberSnapshot(); + expect(b.Volume).toMatchNumberSnapshot(); } } }); @@ -63,7 +57,7 @@ test("板件切割测试2", () => splitBrs.push(br0); for (let b of splitBrs) { - expect(b.ContourCurve.Area).toMatchNumberSnapshot(); + expect(b.Volume).toMatchNumberSnapshot(); } } { @@ -72,7 +66,7 @@ test("板件切割测试2", () => splitBrs.push(br0); for (let b of splitBrs) { - expect(b.ContourCurve.Area).toMatchNumberSnapshot(); + expect(b.Volume).toMatchNumberSnapshot(); } } }); @@ -87,9 +81,7 @@ test("板件切割测试3", () => splitBrs.push(br0); for (let b of splitBrs) { - expect(b.Width).toMatchNumberSnapshot(); - expect(b.Height).toMatchNumberSnapshot(); - expect(b.Thickness).toMatchNumberSnapshot(); + expect(b.Volume).toMatchNumberSnapshot(); } } { @@ -98,9 +90,7 @@ test("板件切割测试3", () => splitBrs.push(br0); for (let b of splitBrs) { - expect(b.Width).toMatchNumberSnapshot(); - expect(b.Height).toMatchNumberSnapshot(); - expect(b.Thickness).toMatchNumberSnapshot(); + expect(b.Volume).toMatchNumberSnapshot(); } } }); @@ -116,9 +106,7 @@ test("切圆环", () => splitBrs.push(br0); for (let b of splitBrs) { - expect(b.Width).toMatchNumberSnapshot(); - expect(b.Height).toMatchNumberSnapshot(); - expect(b.Thickness).toMatchNumberSnapshot(); + expect(b.Volume).toMatchNumberSnapshot(); } } }); @@ -133,9 +121,7 @@ test("切割", () => splitBrs.push(br0); for (let b of splitBrs) { - expect(b.Width).toMatchNumberSnapshot(); - expect(b.Height).toMatchNumberSnapshot(); - expect(b.Thickness).toMatchNumberSnapshot(); + expect(b.Volume).toMatchNumberSnapshot(); } } { @@ -144,9 +130,20 @@ test("切割", () => splitBrs.push(br0); for (let b of splitBrs) { - expect(b.Width).toMatchNumberSnapshot(); - expect(b.Height).toMatchNumberSnapshot(); - expect(b.Thickness).toMatchNumberSnapshot(); + expect(b.Volume).toMatchNumberSnapshot(); } } }); + +test("板件分裂后槽需要在正确的位置", () => +{ + let d = + { "file": [2, "Board", 8, 2, 101, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -151.11600608984008, 205.95532868849114, 0, 1], 100, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -151.11600608984008, 205.95532868849114, 0, 1], 0, 2, 2000, 600, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 2000], 0, [0, 2000], 0, true, 2, 2, 244.77611940298527, 116.41791044776096, 18, true, "Polyline", 8, 2, 0, false, 1, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1823.3682640118734, -735.3233830845768, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1823.3682640118734, -735.3233830845768, 0, 1], 0, 2, 4, [1823.3682640118734, 735.3233830845768], 0, [1939.7861744596344, 735.3233830845768], 0, [1939.7861744596344, 980.0995024875621], 0, [1823.3682640118734, 980.0995024875621], 0, true, 0, 3, 0, 0, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -151.11600608984008, 627.845875952172, 705.47263681592, 1], 2, 271.64179104477626, 116.41791044776141, 18, true, "Polyline", 8, 2, 0, false, 1, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1480.0846819223211, -1186.069651741293, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1480.0846819223211, -1186.069651741293, 0, 1], 0, 2, 4, [1480.0846819223211, 1186.0696517412932], 0, [1596.5025923700825, 1186.0696517412932], 0, [1596.5025923700825, 1457.7114427860695], 0, [1480.0846819223211, 1457.7114427860695], 0, true, 0, 3, 0, 0, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -151.11600608984008, 284.56229386261975, 1156.2189054726364, 1], 3, 0, 0, 0, 9, 1, "左侧板", "主卧", "下柜", "", "", "", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 104, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -397.8891404181982, 618.1463734646105, -6, 1], 103, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -397.8891404181982, 618.1463734646105, -6, 1], 0, 2, 2012, 1174, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [1174, 0], 0, [1174, 2012], 0, [0, 2012], 0, true, 0, 3, 0, 0, 0, 9, 2, "背板", "主卧", "下柜", "", "", "", 0, 1, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": -397.8891404181982, "y": 205.95532868849114, "z": -6 } }; + let [br0, br1] = LoadBoardsFromFileData(d) as Board[]; + let splitBrs = CuttingBoard(br0, [br1]); + + for (let b of splitBrs) + { + expect(b.Volume).toMatchNumberSnapshot(); + } +}); diff --git a/__test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap b/__test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap index 646dbd25e..23238a1f5 100644 --- a/__test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap +++ b/__test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap @@ -1,117 +1,47 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`切割 1`] = `"600.00000"`; +exports[`切割 1`] = `"21519645.98149"`; -exports[`切割 2`] = `"2000.00000"`; +exports[`切割 2`] = `"103836.66905"`; -exports[`切割 3`] = `"18.00000"`; +exports[`切割 3`] = `"12396235.11855"`; -exports[`切割 4`] = `"179.98192"`; +exports[`切圆环 1`] = `"6547348.76281"`; -exports[`切割 5`] = `"64.10315"`; +exports[`切圆环 2`] = `"5634286.80144"`; -exports[`切割 6`] = `"18.00000"`; +exports[`切圆环 3`] = `"15351393.37905"`; -exports[`切割 7`] = `"600.00000"`; +exports[`斜切割 1`] = `"5198741.81897"`; -exports[`切割 8`] = `"1164.00000"`; +exports[`斜切割 2`] = `"7492938.32873"`; -exports[`切割 9`] = `"18.00000"`; +exports[`斜切割 3`] = `"3476662.44783"`; -exports[`切圆环 1`] = `"1324.87954"`; +exports[`斜切割 4`] = `"9328820.12621"`; -exports[`切圆环 2`] = `"481.37079"`; +exports[`板件与板件切割_分裂成多个 1`] = `"3707934.65330"`; -exports[`切圆环 3`] = `"18.00000"`; +exports[`板件与板件切割_分裂成多个 2`] = `"1432683.00820"`; -exports[`切圆环 4`] = `"507.77759"`; +exports[`板件与板件切割_分裂成多个 3`] = `"59855.95566"`; -exports[`切圆环 5`] = `"1099.97958"`; +exports[`板件与板件切割_分裂成多个 4`] = `"5558571.43374"`; -exports[`切圆环 6`] = `"18.00000"`; +exports[`板件分裂后槽需要在正确的位置 1`] = `"6248188.54979"`; -exports[`切圆环 7`] = `"1902.56149"`; +exports[`板件切割测试2 1`] = `"1707974.98308"`; -exports[`切圆环 8`] = `"1689.88004"`; +exports[`板件切割测试2 2`] = `"1081121.00089"`; -exports[`切圆环 9`] = `"18.00000"`; +exports[`板件切割测试2 3`] = `"7101610.37256"`; -exports[`斜切割 1`] = `"600.00000"`; +exports[`板件切割测试2 4`] = `"12524853.26877"`; -exports[`斜切割 2`] = `"481.36498"`; +exports[`板件切割测试3 1`] = `"1104841.62590"`; -exports[`斜切割 3`] = `"18.00000"`; +exports[`板件切割测试3 2`] = `"1081121.00089"`; -exports[`斜切割 4`] = `"600.00000"`; +exports[`板件切割测试3 3`] = `"7051142.41179"`; -exports[`斜切割 5`] = `"693.79059"`; - -exports[`斜切割 6`] = `"18.00000"`; - -exports[`斜切割 7`] = `"600.00000"`; - -exports[`斜切割 8`] = `"321.91319"`; - -exports[`斜切割 9`] = `"18.00000"`; - -exports[`斜切割 10`] = `"600.00000"`; - -exports[`斜切割 11`] = `"863.77964"`; - -exports[`斜切割 12`] = `"18.00000"`; - -exports[`板件与板件切割_分裂成多个 1`] = `"600.00000"`; - -exports[`板件与板件切割_分裂成多个 2`] = `"435.90920"`; - -exports[`板件与板件切割_分裂成多个 3`] = `"18.00000"`; - -exports[`板件与板件切割_分裂成多个 4`] = `"217.25057"`; - -exports[`板件与板件切割_分裂成多个 5`] = `"474.99257"`; - -exports[`板件与板件切割_分裂成多个 6`] = `"18.00000"`; - -exports[`板件与板件切割_分裂成多个 7`] = `"81.55159"`; - -exports[`板件与板件切割_分裂成多个 8`] = `"81.55159"`; - -exports[`板件与板件切割_分裂成多个 9`] = `"18.00000"`; - -exports[`板件与板件切割_分裂成多个 10`] = `"600.00000"`; - -exports[`板件与板件切割_分裂成多个 11`] = `"746.09080"`; - -exports[`板件与板件切割_分裂成多个 12`] = `"18.00000"`; - -exports[`板件切割测试2 1`] = `"119495.88378"`; - -exports[`板件切割测试2 2`] = `"76784.50363"`; - -exports[`板件切割测试2 3`] = `"404548.00931"`; - -exports[`板件切割测试2 4`] = `"695825.18160"`; - -exports[`板件切割测试3 1`] = `"120.58111"`; - -exports[`板件切割测试3 2`] = `"991.00000"`; - -exports[`板件切割测试3 3`] = `"18.00000"`; - -exports[`板件切割测试3 4`] = `"77.48184"`; - -exports[`板件切割测试3 5`] = `"991.00000"`; - -exports[`板件切割测试3 6`] = `"18.00000"`; - -exports[`板件切割测试3 7`] = `"600.00000"`; - -exports[`板件切割测试3 8`] = `"991.00000"`; - -exports[`板件切割测试3 9`] = `"18.00000"`; - -exports[`板件切割测试3 10`] = `"600.00000"`; - -exports[`板件切割测试3 11`] = `"1164.00000"`; - -exports[`板件切割测试3 12`] = `"18.00000"`; +exports[`板件切割测试3 4`] = `"12538723.29298"`;