mirror of https://gitee.com/cf-fz/WebCAD.git
parent
fca8afd868
commit
22f4a54bd3
@ -0,0 +1,103 @@
|
||||
import { Board } from "../../src/DatabaseServices/Board";
|
||||
import { Factory } from "../../src/DatabaseServices/CADFactory";
|
||||
import { CADFile } from "../../src/DatabaseServices/CADFile";
|
||||
import { FeedingToolPath } from "../../src/GraphicsSystem/FeedingToolPath";
|
||||
|
||||
Factory(Board);
|
||||
function loadFile(data)
|
||||
{
|
||||
let file = new CADFile();
|
||||
file.Data = data;
|
||||
let brs: Board[] = [];
|
||||
let count = file.Read();
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
brs.push(file.ReadObject(undefined) as Board);
|
||||
}
|
||||
return brs;
|
||||
}
|
||||
function testPathCount(br: Board, count?: number)
|
||||
{
|
||||
let holeCount = 0;
|
||||
for (let model of br.BoardModeling)
|
||||
{
|
||||
holeCount += model.shape.Holes.length;
|
||||
}
|
||||
let cus = feedUtil.CalcPath(br);
|
||||
if (count !== undefined)
|
||||
expect(cus.length).toBe(count);
|
||||
expect(cus.length).toBeGreaterThan(2);
|
||||
expect(cus.length - 2 - holeCount).toMatchSnapshot("走刀数量");
|
||||
for (let cu of cus)
|
||||
{
|
||||
expect(cu.Length).toMatchSnapshot("曲线长度");
|
||||
}
|
||||
}
|
||||
let feedUtil = new FeedingToolPath();
|
||||
|
||||
test("通孔造型测试", () =>
|
||||
{
|
||||
let data = [1, ["Board", 1, 1, 44, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 126.93136983439945, -7851.102620205904, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 126.93136983439945, -7851.102620205904, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 7822.630590069403, 2129.4641561015833, 0, 1], 2, 4, [-7679.5111852499285, -1949.1412985704153], 0, [-7405.040814734067, -1949.141298570415], 0, [-7405.040814734067, -1275.3032520065758], 0, [-7679.5111852499285, -1275.303252006576], 0, true], 0, 18, 0, 3, 0]]
|
||||
let brs = loadFile(data);
|
||||
testPathCount(brs[0]);
|
||||
})
|
||||
|
||||
test("带孔造型板件", () =>
|
||||
{
|
||||
let data = [1, ["Board", 1, 1, 9, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2793.4596524207154, -1846.8398587682314], 0, [-2477.4137499665617, -1846.8398587682314], 0, [-2477.4137499665617, -1064.898703558386], 0, [-2793.4596524207154, -1064.898703558386], 0, true], 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2714.448176807177, -1707.8886430340776], 0, [-2570.047893789331, -1707.8886430340776], 0, [-2570.047893789331, -1247.442457562078], 0, [-2714.448176807177, -1247.442457562078], 0, true], 10, 0, 3, 0]]
|
||||
let brs = loadFile(data);
|
||||
testPathCount(brs[0]);
|
||||
|
||||
data = [2, ["Board", 1, 1, 9, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 315.04650013028345, -2923.9345412691255, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2793.4596524207154, -1846.8398587682314], 0, [-2477.4137499665617, -1846.8398587682314], 0, [-2477.4137499665617, -1064.898703558386], 0, [-2793.4596524207154, -1064.898703558386], 0, true], 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2916.366392263997, 1987.6074302636166, 0, 1], 2, 4, [-2714.448176807177, -1707.8886430340776], 0, [-2570.047893789331, -1707.8886430340776], 0, [-2570.047893789331, -1247.442457562078], 0, [-2714.448176807177, -1247.442457562078], 0, true], 10, 0, 3, 0], ["Board", 1, 1, 35, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 142.7476665886519, -6652.181401176747, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 142.7476665886519, -6652.181401176747, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6646.274106889091, 2021.2672500633112, 0, 1], 2, 6, [-6459.603607399157, -1131.628730342293], 0, [-6168.964728446474, -1131.628730342293], 0, [-6303.651038205035, -1393.9125967142265], 0, [-6186.686611309442, -1702.2733585298784], 0, [-6466.692360544344, -1702.2733585298784], 0, [-6388.716075947283, -1393.9125967142265], 0, true], 2, ["Circle", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 305.61977726617806, 415.9680345595966, 0, 1], 1, 49.62380364928433], ["Circle", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 309.447703964579, 788.5528998706459, 0, 1], 1, 43.30804682119281], 15, 0, 0, 0]]
|
||||
brs = loadFile(data);
|
||||
testPathCount(brs[0]);
|
||||
})
|
||||
|
||||
test("极限刀半径", () =>
|
||||
{
|
||||
let data = [1, ["Board", 1, 1, 23, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -657.7056127057733, -888.0170782475586, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -657.7056127057733, -888.0170782475586, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 669.7767195227455, 373.85642669358367, 0, 1], 2, 8, [-269.2307692307692, -223.9316239316239], 0, [-209.23076923076923, -223.9316239316239], 0, [-209.2307692307692, -473.9316239316239], 0, [40.7692307692308, -473.9316239316239], 0, [40.76923076923081, -533.9316239316239], 0, [-519.2307692307692, -533.9316239316238], 0, [-519.2307692307692, -473.9316239316238], 0, [-269.23076923076917, -473.9316239316238], 0, true], 0, 15, 0, 30, 0]]
|
||||
let brs = loadFile(data);
|
||||
testPathCount(brs[0], 3);
|
||||
data = [1, ["Board", 1, 1, 25, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -663.8732094729834, -1836.8490686954794, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -663.8732094729834, -1836.8490686954794, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1784.6350413145396, 919.9380237783905, 0, 1], 2, 4, [-1450.7590848806103, 26.7131494779253], 0, [-1450.7590848806103, -719.3699285130117], 0, [-1480.7590848806103, -719.3699285130117], 0, [-1480.7590848806103, 26.88247329704346], 0, true], 0, 18, 0, 15, 0]]
|
||||
brs = loadFile(data);
|
||||
testPathCount(brs[0], 3);
|
||||
data = [1, ["Board", 1, 1, 47, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -1045.5289925195948, 676.3547294712749, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1045.5289925195948, 676.3547294712749, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -89.78543368837677, 733.8187514408725, 0, 1], 2, 8, [-269.2307692307692, 119.65811965811966], 0, [-269.23076923076945, 631.2089459697221], 0, [526.6267506621481, 631.2089459697221], 0, [526.6267506621481, 119.65811965811963], 0, [466.6267506621481, 119.65811965811962], 0, [466.62675066214797, 571.2089459697221], 0, [-209.2307692307695, 571.2089459697221], 0, [-209.23076923076923, 119.65811965811966], 0, true], 0, 20, 0, 30, 0]]
|
||||
brs = loadFile(data);
|
||||
testPathCount(brs[0], 3);
|
||||
|
||||
data = [1, ["Board", 1, 1, 40, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -703.1898726073867, -3031.7293464532195, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -703.1898726073867, -3031.7293464532195, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, 60, false, 4, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 2958.0041022950545, -2782.375300102465, 0, 1], 2, 6, [-445.8689458689459, -202.27920227920225], 0, [-445.8689458689459, -142.27920227920225], 0, [-245.8689458689459, -142.27920227920225], 0, [-245.8689458689459, -82.27920227920225], 0, [-45.8689458689459, -82.27920227920225], 0, [-45.86894586894589, -202.27920227920225], 0, true], 0, 18, 0, 30, 0]]
|
||||
brs = loadFile(data);
|
||||
testPathCount(brs[0], 3);
|
||||
|
||||
data = [1, ["Board", 1, 1, 42, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -723.8046937091931, -4479.271007572378, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -723.8046937091931, -4479.271007572378, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4420.876631461465, 1125.350549803055, 0, 1], 2, 6, [-4011.700851750289, -387.1968681241217], 0, [-4011.700851750289, -687.1968681241217], 0, [-4161.700851750289, -687.1968681241217], 0, [-4161.700851750289, -657.1968681241217], 0, [-4041.700851750289, -657.1968681241217], 0, [-4041.700851750289, -387.1968681241217], 0, true], 0, 18, 0, 15, 0]]
|
||||
brs = loadFile(data);
|
||||
testPathCount(brs[0]);
|
||||
|
||||
})
|
||||
|
||||
test("复杂极限刀半径", () =>
|
||||
{
|
||||
let data = [1, ["Board", 1, 1, 3, false, 7, -1, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -604.0236327121571, -287.85437391994753, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -929.3989071038254, 27.540983606557347, 0, 1], 2, 12, [1090.0546448087434, 872.1311475409834], 0, [1057.9234972677596, 599.0163934426229], 0, [929.3989071038254, 599.016393442623], 0, [929.3989071038254, 354.03292181069946], 0, [1167.7049180327872, 368.74316939890696], 0, [1114.1530054644809, 122.40437158469933], 0, [929.3989071038254, 143.05335904853735], 0, [929.3989071038254, -27.540983606557347], 0, [1529.3989071038254, -27.540983606557404], 0, [1529.3989071038254, 1172.4590163934427], 0, [929.3989071038254, 1172.4590163934427], 0, [929.3989071038254, 872.1311475409834], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -604.0236327121571, -287.85437391994753, 0, 1], 1, "左侧板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 2, 1, ["Polyline", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1045.0710382513657, 11.47540983606541, 0, 1], 2, 12, [1111.5123746027145, 991.5327839891172], 0, [1234.7237593481482, 991.5327839891172], 0, [1234.7237593481482, 985.5327839891172], 0, [1118.2025855391182, 985.5327839891172], 0, [1118.2025855391182, 961.9843523533344], 0, [1238.6263823943837, 961.9843523533344], 0, [1238.6263823943837, 953.9843523533344], 0, [1102.0345757761427, 953.9843523533344], 0, [1102.0345757761427, 938.011096497888], 0, [1243.0865230186528, 938.011096497888], 0, [1243.0865230186528, 929.011096497888], 0, [1068.026003516091, 929.011096497888], 0, true], 0, 7.5, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1045.0710382513657, 11.47540983606541, 0, 1], 2, 21, [1045.0710382513657, 988.2305644705416], 0, [1071.838538645684, 1047.9617459060103], 0, [1045.0710382513657, 1056.0304182736754], 0, [1045.0710382513662, 1091.938334606794], 0, [1237.9650273224047, 1083.1256830601092], 0, [1543.8535519125685, 1083.1256830601092], 0, [1543.8535519125685, 1077.1256830601092], 0, [1249.5168174863388, 1077.1256830601092], 0, [1249.5168174863388, 1064.203778797814], 0, [1543.9255256830606, 1064.203778797814], 0, [1543.9255256830606, 1057.203778797814], 0, [1251.5572738797819, 1057.203778797814], 0, [1251.5572738797819, 1046.7141525683055], 0, [1544.800006994536, 1046.7141525683055], 0, [1301.694202404372, 980.8365604371581], 0, [1546.954728946011, 745.6150793512566], 0, [1300.598185827323, 682.4262257591249], 0, [1180.816692501768, 676.4610119480917], 0, [1205.7267759562842, 888.1967213114754], 0, [1205.7267759562842, 888.1967213114754], 0, [1045.0710382513657, 888.1967213114754], 0, true], 0, 6, 0, 3, 0]]
|
||||
let brs = loadFile(data);
|
||||
testPathCount(brs[0]);
|
||||
})
|
||||
|
||||
test("刀切到外轮廓情况", () =>
|
||||
{
|
||||
let data = [1, ["Board", 1, 1, 16, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 5026.542613652899, -82.94991876210884, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5026.542613652899, -82.94991876210884, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 93.09030137237562, 6897.948239526741, 0, 1], 2, 4, [46.493939839332825, -6527.979974776644], 0, [340.601203930893, -6527.979974776644], 0, [340.601203930893, -6082.617546295138], 0, [46.493939839332825, -6082.617546295138], 0, true], 1, ["Circle", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 257.65748249413025, 589.5547926179952, 0, 1], 1, 116.11448843944343], 15, 0, 3, 0]];
|
||||
let brs = loadFile(data);
|
||||
testPathCount(brs[0]);
|
||||
data = [1, ["Board", 1, 1, 22, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 5057.50249574722, -1024.0000779051127, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5057.50249574722, -1024.0000779051127, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 1, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1042.216784740986, 6887.269493483857, 0, 1], 2, 4, [-442.216784740986, -6287.269493483857], 0, [-742.216784740986, -5687.269493483857], 0, [-1042.216784740986, -6287.269493483857], 0, [-742.216784740986, -6887.269493483857], 0, true], 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1042.216784740986, 6887.269493483857, 0, 1], 2, 4, [-892.216784740986, -6587.269493483857], 0, [-592.216784740986, -6587.269493483857], 0, [-592.216784740986, -5987.269493483857], 0, [-892.216784740986, -5987.269493483857], 0, true], 15, 0, 3, 0]]
|
||||
brs = loadFile(data);
|
||||
testPathCount(brs[0]);
|
||||
})
|
||||
|
||||
test("复杂造型测试", () =>
|
||||
{
|
||||
let data = [1, ["Board", 1, 1, 54, false, 7, -1, [0, 0, 1, 0, 0, -1, 0, 0, 1, 0, 0, 0, -919.5114893425489, -2703.8098770005176, -134.6026210568009, 1], 1, 1, ["Circle", 1, 1, -1, false, 7, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 382.3715309714528, 382.3715309714528, 0, 1], 1, 382.3715309714528], 0, 764.7430619429056, 764.7430619429056, 18, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -919.5114893425489, -2703.8098770005176, -134.6026210568009, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 12, 1, ["Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 134.6026210568009, -1224.6532653675133, 0, 1], 2, 4, [-1985.6277286542445, 194.21699734632784], 0, [-1228.4218640236884, 194.21699734632784], 0.06505182506170779, [-1227.3723277647396, 293.288035597694], 0, [-1986.6772649131926, 293.288035597694], 0.06505182506170767, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 658.4697692228576, 691.9524021857917, 0, 1], 2, 2, [108.09377347199688, 48.88012586045511], -0.6501592260197776, [-36.242715090388515, -112.9601530205507], -0.14475251191859181, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 90.4398943583576, 629.3207306904399, 0, 1], 2, 2, [-49.8138945074669, 50.80997934732096], -0.9109068504784374, [58.36556874536063, -40.70059547852842], -0.09345012042788828, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 1, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 106.62611044415758, 117.47069904431623, 0, 1], 2, 2, [-53.9075765860091, -43.14301434924033], -0.9134441585739421, [45.27005907439718, 52.13413710723313], -0.09065675641591214, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 2, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 786.5650872556355, 426.693071038251, 0, 1], 2, 2, [106.7018657003265, -26.944722394258406], -0.694630372644427, [-98.32737655143399, -49.427049571531825], -0.13740047935395364, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 2, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 134.6026210568009, -1224.6532653675133, 0, 1], 2, 8, [-1742.842992143469, 270.75339078895075], 0, [-1465.8082380451083, 270.75339078895075], 0, [-1465.8082380451083, 264.75339078895075], 0, [-1734.1675823074033, 264.75339078895075], 0, [-1734.1675823074033, 241.83535800206553], 0, [-1465.8082380451083, 241.83535800206553], 0, [-1465.8082380451083, 234.83535800206553], 0, [-1747.4698773893706, 234.83535800206553], 0, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 757.0918282392297, 199.97569398907103, 0, 1], 2, 2, [62.728362159705455, -81.25460132972853], -0.6202999489718836, [-102.6478640873703, -0.7574000218211268], -0.12204522179623141, true], 0, 10, 0, 3, 0, 1, ["Polyline", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 615.3934675834237, 37.87276939890694, 0, 1], 2, 2, [3.062518172307499, -73.61947577910792], -0.5578203020437067, [-67.19070005156576, 30.242619895222106], -0.08254084283422802, true], 0, 10, 0, 3, 0, 1, ["Circle", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 296.1754006981712, 336.45955497267846, 0, 1], 1, 15.87021639344266], 0, 10, 0, 3, 0, 1, ["Circle", 1, 1, -1, false, 3, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 299.3494439768467, 458.660221202186, 0, 1], 1, 5.610968815350429], 0, 10, 0, 3, 0, 1, ["Circle", 1, 1, -1, false, 4, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 537.4026898785589, 512.6189569398905, 0, 1], 1, 26.9326503136821], 0, 10, 0, 3, 0, 1, ["Circle", 1, 1, -1, false, 6, -1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 534.2286465998834, 261.869537923498, 0, 1], 1, 25.810456550614163], 0, 10, 0, 3, 0]]
|
||||
let brs = loadFile(data);
|
||||
testPathCount(brs[0]);
|
||||
data = [1, ["Board", 1, 1, 55, false, 7, -1, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1369.5548078237812, 1023.4201319657191, -0.00000703445402905345, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1369.5548078237812, 1023.4201319657191, -0.00000703445402905345, 1], 1, "右侧板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0, 2, 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1112.552131147541, -16.083529411764744, 0, 1], 2, 4, [1231.0912524651885, 1062.969244235294], 0, [1585.4666497357766, 1062.969244235294], 0, [1585.4666497357766, 128.1994955294116], 0, [1228.3008950063647, 128.1994955294116], 0, true], 1, ["Polyline", 1, 1, -1, false, 1, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1112.552131147541, -16.083529411764744, 0, 1], 2, 4, [1404.0934149122481, 647.2059828705881], 0, [1473.852351382836, 647.2059828705881], 0, [1473.852351382836, 809.046715482353], 0, [1404.0934149122481, 809.046715482353], 0, true], 3, 0, 3, 0, 1, ["Circle", 1, 1, -1, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 291.54128376470703, 469.28172084705875, 0, 1], 1, 113.61929894258292], 0, 6, 0, 7, 0]]
|
||||
brs = loadFile(data);
|
||||
testPathCount(brs[0]);
|
||||
})
|
@ -0,0 +1,197 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 1`] = `3600`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 2`] = `22596.75011038597`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 3`] = `6355.243980782`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 4`] = `1478.9393851461323`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 5`] = `729.5688477133849`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 6`] = `3600`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 7`] = `939.4039853849399`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 8`] = `13736.355649626385`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 9`] = `1216.9875775199403`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 10`] = `13428.231939084159`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 11`] = `939.4039853849375`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 12`] = `13736.35564962633`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 13`] = `13428.231939084155`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 14`] = `1216.9875775199403`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 15`] = `2683.281572999748`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 曲线长度 16`] = `1800`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 走刀数量 1`] = `2`;
|
||||
|
||||
exports[`刀切到外轮廓情况: 走刀数量 2`] = `8`;
|
||||
|
||||
exports[`复杂极限刀半径: 曲线长度 1`] = `4356.840832388074`;
|
||||
|
||||
exports[`复杂极限刀半径: 曲线长度 2`] = `1068.3190582501115`;
|
||||
|
||||
exports[`复杂极限刀半径: 曲线长度 3`] = `951.5402172137751`;
|
||||
|
||||
exports[`复杂极限刀半径: 曲线长度 4`] = `35730.26757931215`;
|
||||
|
||||
exports[`复杂极限刀半径: 曲线长度 5`] = `2927.3167299028473`;
|
||||
|
||||
exports[`复杂极限刀半径: 曲线长度 6`] = `3278.917934988776`;
|
||||
|
||||
exports[`复杂极限刀半径: 走刀数量 1`] = `4`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 1`] = `2402.511185283596`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 2`] = `24373.250750763476`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 3`] = `1715.2225461089636`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 4`] = `4285.071854430759`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 5`] = `493.42887087968927`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 6`] = `2418.143451783812`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 7`] = `352.7973262382525`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 8`] = `2293.0762218537748`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 9`] = `342.70973636046426`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 10`] = `4096.105045378745`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 11`] = `476.0989607667294`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 12`] = `910.1341511193465`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 13`] = `1167.5479341842504`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 14`] = `2841.13372275202`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 15`] = `413.7195254587743`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 16`] = `1079.273647743498`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 17`] = `275.9275697576068`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 18`] = `227.8342135021163`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 19`] = `99.71551046503953`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 20`] = `16.405200898113836`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 21`] = `35.25475681965266`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 22`] = `696.1986486992679`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 23`] = `169.22283273433305`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 24`] = `639.7910377879329`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 25`] = `162.171881370416`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 26`] = `3600`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 27`] = `103756.10963582453`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 28`] = `487.19933816470575`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 29`] = `2152.7628031484855`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 30`] = `2581.084814115112`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 31`] = `463.19933816470575`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 32`] = `5545.665343214347`;
|
||||
|
||||
exports[`复杂造型测试: 曲线长度 33`] = `713.891109728082`;
|
||||
|
||||
exports[`复杂造型测试: 走刀数量 1`] = `23`;
|
||||
|
||||
exports[`复杂造型测试: 走刀数量 2`] = `5`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 1`] = `3600`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 2`] = `53389.1518227565`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 3`] = `1233.6929369796912`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 4`] = `4667.086663355046`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 5`] = `2195.9741153279983`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 6`] = `1209.6929369796912`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 7`] = `3600`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 8`] = `53389.1518227565`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 9`] = `1233.6929369796912`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 10`] = `4667.086663355046`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 11`] = `2195.9741153279983`;
|
||||
|
||||
exports[`带孔造型板件: 曲线长度 12`] = `1209.6929369796912`;
|
||||
|
||||
exports[`带孔造型板件: 走刀数量 1`] = `3`;
|
||||
|
||||
exports[`带孔造型板件: 走刀数量 2`] = `3`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 1`] = `3600`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 2`] = `999.9999999999999`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 3`] = `1740`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 4`] = `3600`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 5`] = `1552.3359576397822`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 6`] = `716.1675009811012`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 7`] = `3600`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 8`] = `3517.9183450322453`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 9`] = `1638.9591725161226`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 10`] = `3600`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 11`] = `1040`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 12`] = `600`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 13`] = `3600`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 14`] = `900`;
|
||||
|
||||
exports[`极限刀半径: 曲线长度 15`] = `390`;
|
||||
|
||||
exports[`极限刀半径: 走刀数量 1`] = `1`;
|
||||
|
||||
exports[`极限刀半径: 走刀数量 2`] = `1`;
|
||||
|
||||
exports[`极限刀半径: 走刀数量 3`] = `1`;
|
||||
|
||||
exports[`极限刀半径: 走刀数量 4`] = `1`;
|
||||
|
||||
exports[`极限刀半径: 走刀数量 5`] = `1`;
|
||||
|
||||
exports[`通孔造型测试: 曲线长度 1`] = `3600`;
|
||||
|
||||
exports[`通孔造型测试: 曲线长度 2`] = `1896.616834159402`;
|
||||
|
||||
exports[`通孔造型测试: 曲线长度 3`] = `1872.616834159402`;
|
||||
|
||||
exports[`通孔造型测试: 走刀数量 1`] = `1`;
|
@ -0,0 +1,55 @@
|
||||
import { Vector3 } from "three";
|
||||
import { app } from "../ApplicationServices/Application";
|
||||
import { Singleton } from "../Common/Singleton";
|
||||
import { Board } from "../DatabaseServices/Board";
|
||||
import { Point } from "../DatabaseServices/Point";
|
||||
import { Command } from "../Editor/CommandMachine";
|
||||
import { PromptStatus } from "../Editor/PromptResult";
|
||||
import { MoveMatrix } from "../Geometry/GeUtils";
|
||||
import { FeedingToolPath } from "../GraphicsSystem/ToolPath/FeedingToolPath";
|
||||
|
||||
export class FeedingCommand implements Command
|
||||
{
|
||||
async exec()
|
||||
{
|
||||
let brRes = await app.m_Editor.GetSelection({
|
||||
Msg: "选择板件",
|
||||
UseSelect: true,
|
||||
Filter: { filterTypes: [Board] }
|
||||
})
|
||||
|
||||
if (brRes.Status === PromptStatus.Cancel)
|
||||
return;
|
||||
|
||||
let brs = brRes.SelectSet.SelectEntityList
|
||||
.filter((br: Board) => br.BoardModeling.length > 0) as Board[];
|
||||
if (brs.length > 0)
|
||||
{
|
||||
let feedingTool = Singleton.GetInstance(FeedingToolPath);
|
||||
|
||||
let retCus = brs.map(br => feedingTool.CalcPath(br));
|
||||
|
||||
let ptRes = await app.m_Editor.GetPoint({ Msg: "点取位置" });
|
||||
|
||||
if (ptRes.Status === PromptStatus.OK)
|
||||
{
|
||||
for (let i = 0; i < retCus.length; i++)
|
||||
{
|
||||
let cus = retCus[i];
|
||||
let pos = ptRes.Value.sub(cus[0].StartPoint);
|
||||
if (i > 0)
|
||||
{
|
||||
let x = cus[0].BoundingBox.getSize(new Vector3).x;
|
||||
pos.add(new Vector3(x * 1.5));
|
||||
}
|
||||
for (let cu of cus)
|
||||
{
|
||||
cu.ApplyMatrix(MoveMatrix(pos));
|
||||
app.m_Database.ModelSpace.Append(cu);
|
||||
app.m_Database.ModelSpace.Append(new Point(cu.StartPoint));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
import { Board } from "../../DatabaseServices/Board";
|
||||
import { Circle } from "../../DatabaseServices/Circle";
|
||||
import { Contour } from "../../DatabaseServices/Contour";
|
||||
import { Curve } from "../../DatabaseServices/Curve";
|
||||
import { Polyline } from "../../DatabaseServices/Polyline";
|
||||
import { Shape } from "../../DatabaseServices/Shape";
|
||||
import { ShapeManager } from "../../DatabaseServices/ShapeManager";
|
||||
import { BoolOpeartionType } from "../BoolOperateUtils";
|
||||
import { OptimizeToolPath } from "./OptimizeToolPath";
|
||||
|
||||
/**
|
||||
*计算走刀工具类
|
||||
*/
|
||||
export class FeedingToolPath
|
||||
{
|
||||
/**
|
||||
*处理形状,内偏移
|
||||
* @param {Shape} shape
|
||||
* @param {number} rad 刀半径/偏移距离
|
||||
* @param {boolean} isOut 是否是最外轮廓,如果是,洞需要外偏移一个刀半径,多段线偏移保留不闭合轮廓
|
||||
*/
|
||||
private HandleShape(shape: Shape, rad: number, isOut = true): Curve[]
|
||||
{
|
||||
let outline = shape.Outline.Curve.Clone();
|
||||
|
||||
let dir = this.GetCurveToInDir(outline);
|
||||
|
||||
let offsetCus: Curve[] = [outline];
|
||||
|
||||
//获得形状外孔轮廓
|
||||
let holes = shape.Holes.map(h =>
|
||||
{
|
||||
if (!isOut)
|
||||
return h.Clone();
|
||||
|
||||
let dir = -this.GetCurveToInDir(h.Curve);
|
||||
let tmpCus = h.Curve.GetOffsetCurves(rad * dir);
|
||||
return Contour.CreateContour(tmpCus);
|
||||
});
|
||||
|
||||
|
||||
let offsetDist = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
offsetDist += rad;
|
||||
|
||||
let retCus: Curve[] = [];
|
||||
if (outline instanceof Polyline && isOut && offsetDist === rad)
|
||||
retCus.push(...outline.GetFeedingToolPath(offsetDist * dir));
|
||||
else
|
||||
retCus.push(...outline.GetOffsetCurves(offsetDist * dir));
|
||||
|
||||
if (retCus.length === 0) break;
|
||||
|
||||
//是否和孤岛相交
|
||||
let isInt = false;
|
||||
for (let c of retCus)
|
||||
{
|
||||
if (holes.length > 0)
|
||||
{
|
||||
isInt = holes.some(h => h.Curve.IntersectWith(c, 0).length > 0 || h.CuInOutline(c));
|
||||
if (isInt) break;
|
||||
}
|
||||
|
||||
c.ColorIndex = outline.ColorIndex;
|
||||
offsetCus.push(c);
|
||||
}
|
||||
if (isInt)
|
||||
{
|
||||
//洞形状管理器
|
||||
let holesMg = new ShapeManager();
|
||||
holesMg.AppendShapeList(holes.map(h => new Shape(h)));
|
||||
let shapeMg = new ShapeManager();
|
||||
shapeMg.AppendShapeList(retCus.map(c => new Shape(Contour.CreateContour([c]))));
|
||||
shapeMg.BoolOper(holesMg, BoolOpeartionType.Subtract);
|
||||
for (let s of shapeMg.ShapeList)
|
||||
{
|
||||
s.Outline.Curve.ColorIndex = outline.ColorIndex;
|
||||
offsetCus.push(...this.HandleShape(s, rad, false));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//如果加工洞外圈和最外轮廓相交,则去掉
|
||||
for (let h of holes)
|
||||
{
|
||||
if (h.Curve.IntersectWith(outline, 0).length === 0)
|
||||
offsetCus.push(h.Curve);
|
||||
}
|
||||
|
||||
return offsetCus;
|
||||
}
|
||||
/**
|
||||
* 获得曲线内偏移方向
|
||||
* @param cu
|
||||
*/
|
||||
private GetCurveToInDir(cu: Curve): number
|
||||
{
|
||||
let dir = -Math.sign(cu.Area2);
|
||||
if (cu instanceof Circle)
|
||||
dir = -1;
|
||||
return dir;
|
||||
}
|
||||
/**
|
||||
* 开始计算走刀路径
|
||||
* TODO:圆孔半径===刀半径时推送ys 显示点
|
||||
* @param br
|
||||
* @returns Curve[]
|
||||
*/
|
||||
CalcPath(br: Board): Curve[]
|
||||
{
|
||||
let cus: Curve[] = [br.Shape.Outline.Curve.Clone()];
|
||||
let modelings = br.BoardModeling;
|
||||
for (let { shape, thickness, rad } of modelings)
|
||||
{
|
||||
if (thickness >= br.Thickness)
|
||||
{
|
||||
//通孔只切一刀
|
||||
let outline = shape.Outline.Curve;
|
||||
let dir = this.GetCurveToInDir(outline);
|
||||
let paths: Curve[];
|
||||
if (outline instanceof Circle)
|
||||
paths = outline.GetOffsetCurves(dir * rad);
|
||||
else
|
||||
paths = outline.GetFeedingToolPath(dir * rad);
|
||||
paths.forEach(p => p.ColorIndex = outline.ColorIndex);
|
||||
outline.ColorIndex++;
|
||||
cus.push(outline, ...paths);
|
||||
}
|
||||
else
|
||||
{
|
||||
let offsetCus = this.HandleShape(shape, rad);
|
||||
if (offsetCus.length > 1)
|
||||
cus.push(
|
||||
...OptimizeToolPath(offsetCus, shape, rad)
|
||||
);
|
||||
}
|
||||
}
|
||||
return cus;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue