!187 计算造型的走刀结果

Merge pull request !187 from ZoeLeeFZ/toolPath
pull/187/MERGE
ChenX 6 years ago
parent fca8afd868
commit 22f4a54bd3

@ -2,7 +2,7 @@ import { Factory } from "../../src/DatabaseServices/CADFactory";
import { Board } from "../../src/DatabaseServices/Board";
import { CADFile } from "../../src/DatabaseServices/CADFile";
import { Curve } from "../../src/DatabaseServices/Curve";
import { calcEdgeSealing } from "../../src/GraphicsSystem/CalcEdgeSealing";
import { calcEdgeSealing, paragraphCulist } from "../../src/GraphicsSystem/CalcEdgeSealing";
import { Polyline } from "../../src/DatabaseServices/Polyline";
Factory(Board);
@ -24,6 +24,7 @@ function testBrSealing(br: Board, sealingSize: number[])
let originCurve = br.Shape.Outline.Curve;
let dir = Math.sign(originCurve.Area2) * -1;
let calcCus = originCurve.Explode() as Curve[];
paragraphCulist(calcCus);
let offsetCus: Curve[] = [];
for (let i = 0; i < calcCus.length; i++)
@ -61,20 +62,18 @@ test("异型板件,常规坐标系", () =>
let data = [1, ["Board", 1, 1, 9, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 3681.8686077049847, -1396.263281011676, 0, 1], 1, 1, ["Polyline", 1, 1, -1, true, 7, -1, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 1396.2632810116759, 3681.8686077049847, 0, 1], 2, 5, [2345.694899782759, -1396.263281011676], 0, [3681.8686077049847, -1396.263281011676], 0, [3681.8686077049847, 443.1597468696174], 0.41421356237309503, [3481.8686077049847, 643.1597468696174], 0, [2345.694899782759, 643.1597468696174], 0, true], 0, 1336.1737079222257, 2039.4230278812934, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3681.8686077049847, -1396.263281011676, 0, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0]];
//第三段为圆弧
let br = loadFile(data)[0];
let sealingSize = [1, 1, 1, 1, 1];
let sealingSize = [1, 1, 1];
testBrSealing(br, sealingSize);
sealingSize = [3, 3, 10, 3, 3];
sealingSize = [3, 3, 10];
testBrSealing(br, sealingSize);
sealingSize = [10, 10, 5, 5, 10];
sealingSize = [10, 10, 5];
testBrSealing(br, sealingSize);
// 2,4,6,8段为圆弧
data = [1, ["Board", 1, 1, 11, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 6239.212423224621, -1330.0896939146003, 0, 1], 1, 1, ["Polyline", 1, 1, -1, true, 7, -1, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 1330.0896939146, 6239.212423224621, 0, 1], 2, 8, [5263.6654731094095, -1330.0896939146003], 0, [5939.212423224621, -1330.0896939146003], 0.41421356237309503, [6239.212423224621, -1030.0896939146003], 0, [6239.212423224621, 495.8218896107525], 0.41421356237309503, [5939.212423224621, 795.8218896107526], 0, [5263.6654731094095, 795.8218896107526], 0.4142135623730949, [4963.6654731094095, 495.8218896107527], 0, [4963.6654731094095, -1030.0896939146003], 0.4142135623730949, true], 0, 1275.546950115211, 2125.911583525353, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6239.212423224621, -1330.0896939146003, 0, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highSealed\":[]}", 0]]
br = loadFile(data)[0];
sealingSize = [1, 1, 1, 1, 1, 1, 1, 1];
sealingSize = [1];
testBrSealing(br, sealingSize);
sealingSize = [1, 3, 1, 3, 1, 2, 1, 3];
testBrSealing(br, sealingSize);
sealingSize = [5, 3, 5, 3, 5, 2, 5, 3];
sealingSize = [5];
testBrSealing(br, sealingSize);
})

@ -8,18 +8,16 @@ exports[`常规板件,常规坐标系 3`] = `712816`;
exports[`异型板件,常规坐标系 1`] = `2709777.7883832143`;
exports[`异型板件,常规坐标系 2`] = `2696477.36609459`;
exports[`异型板件,常规坐标系 2`] = `2682243.404899422`;
exports[`异型板件,常规坐标系 3`] = `2657160.4995995373`;
exports[`异型板件,常规坐标系 3`] = `2660261.483308105`;
exports[`异型板件,常规坐标系 4`] = `2628158.6443366623`;
exports[`异型板件,常规坐标系 5`] = `2628158.6443366623`;
exports[`异型板件,常规坐标系 6`] = `2607100.626176849`;
exports[`异型板件,常规坐标系 5`] = `2603082.551922608`;
exports[`异型板件,非常规坐标系 1`] = `75939516.39226122`;
exports[`异型板件,非常规坐标系 2`] = `75870817.54933015`;
exports[`异型板件,非常规坐标系 2`] = `75852693.84266448`;
exports[`异型板件,非常规坐标系 3`] = `75754806.13472572`;
exports[`异型板件,非常规坐标系 3`] = `75675829.72975095`;

@ -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));
}
}
}
}
}
}

@ -5,6 +5,7 @@ import { GetPointPrompt } from '../Common/InputState';
import { Polyline } from '../DatabaseServices/Polyline';
import { PromptStatus } from '../Editor/PromptResult';
import { JigUtils } from '../Editor/JigUtils';
import { equalv3 } from '../Geometry/GeUtils';
enum PolylineModel
{
@ -52,12 +53,16 @@ export class DrawPolyline
let p = await app.m_Editor.GetPoint(ops);
if (p.Status === PromptStatus.OK)
{
//避免直接画出0长度的多段线段
if (!equalv3(p.Value, pl.EndPoint))
{
this.UpdatePoint(plJig, p.Value);
pl.AddVertexAt(pl.NumberOfVertices, new Vector2());
this.UpdatePoint(pl, p.Value);
}
}
else if (p.Status === PromptStatus.Keyword)
{
this.RemoveLastVertex(plJig);

@ -8,6 +8,7 @@ import { Polyline } from '../DatabaseServices/Polyline';
import { Command } from '../Editor/CommandMachine';
import { polar } from '../Geometry/GeUtils';
import { IntersectOption } from '../GraphicsSystem/IntersectWith';
import { Point } from '../DatabaseServices/Point';
export class Command_PLTest implements Command
@ -15,7 +16,8 @@ export class Command_PLTest implements Command
async exec()
{
this.splitPolyline();
this.testResetPoint();
// this.splitPolyline();
// this.splitPolyline();
// this.splitPolyline();
@ -25,7 +27,43 @@ export class Command_PLTest implements Command
// this.testGetPointAtParam();
}
testResetPoint()
{
let pl = new Polyline([
{
pt: new Vector2(0, 0),
bul: 0
},
{
pt: new Vector2(5, 0),
bul: 1
},
{
pt: new Vector2(5, 5),
bul: -1
},
{
pt: new Vector2(5, 10),
bul: 0
},
{
pt: new Vector2(0, 10),
bul: 0
},
{
pt: new Vector2(0, 0),
bul: 0
}
]);
// pl.CloseMark = true;
app.m_Database.ModelSpace.Append(pl);
// app.m_Database.ModelSpace.Append(new Point(pl.StartPoint));
pl.ResetStartPoint(5);
app.m_Database.ModelSpace.Append(new Point(pl.StartPoint));
}
createPolyline()
{

@ -137,3 +137,13 @@ function checkEqual(e1, e2): boolean
{
return e1 === e2;
}
/**
*
* @param arr
* @param index //将index位置以后的值放到起始位置
*/
export function changeArrayStartIndex(arr: any[], index: number)
{
arr.unshift(...arr.splice(index))
}

@ -210,13 +210,7 @@ export class Circle extends Curve
get BoundingBox(): Box3
{
let pts = [
this.Center.add(new Vector3(this.m_Radius, 0)),
this.Center.add(new Vector3(0, this.m_Radius)),
this.Center.add(new Vector3(-this.m_Radius, 0)),
this.Center.add(new Vector3(0, -this.m_Radius)),
];
return new Box3().setFromPoints(pts);
return new Box3().setFromPoints(this.GetGripPoints());
}
InitDrawObject(renderType: RenderType = RenderType.Wireframe): THREE.Line

@ -62,7 +62,9 @@ export abstract class Curve extends Entity
set EndPoint(v: Vector3) { return; }
get EndParam(): number { return; }
get Area(): number { return 0; }
//获得曲线的面积,逆时针为正,顺时针为负.
/**
*线,,.
*/
get Area2(): number { return 0; }
get Length(): number { return 0; }
get IsClose(): boolean { return false; }

@ -1,13 +1,13 @@
import * as THREE from 'three';
import { Box3, Geometry, Matrix4, Object3D, Vector2, Vector3 } from 'three';
import { CreateBoardUtil } from '../ApplicationServices/mesh/createBoard';
import { arrayLast, arrayRemoveDuplicateBySort } from '../Common/ArrayExt';
import { arrayLast, arrayRemoveDuplicateBySort, changeArrayStartIndex } from '../Common/ArrayExt';
import { ColorMaterial } from '../Common/ColorPalette';
import { getDeterminantFor2V, Vec2DTo3D, Vec3DTo2D } from '../Common/CurveUtils';
import { matrixAlignCoordSys } from '../Common/Matrix4Utils';
import { Status } from '../Common/Status';
import { FixIndex } from '../Common/Utils';
import { equaln, equalv3, updateGeometry } from '../Geometry/GeUtils';
import { equaln, equalv3, updateGeometry, equalv2 } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/Enum';
import { IntersectOption, IntersectPolylineAndCurve } from '../GraphicsSystem/IntersectWith';
import { PolyOffsetUtil } from '../GraphicsSystem/OffsetPolyline';
@ -141,12 +141,30 @@ export class Polyline extends Curve
}
return this;
}
/**
* 线
* @param index index,index,
*/
ResetStartPoint(index: number)
{
if (!this.IsClose || index >= this.EndParam) return false;
if (equalv2(this.m_LineData[0].pt, arrayLast(this.m_LineData).pt))
this.m_LineData.pop();
changeArrayStartIndex(this.m_LineData, Math.floor(index + 0.5));
this.m_LineData.push({
pt: this.m_LineData[0].pt.clone(),
bul: 0
});
return true;
}
GetPoint2dAt(index: number): Vector2 | undefined
{
if (index >= 0 && this.m_LineData.length > index)
return this.m_LineData[index].pt.clone();
}
/**
*
*
@ -810,6 +828,11 @@ export class Polyline extends Curve
let polyOffestUtil = new PolyOffsetUtil(this, offsetDist);
return polyOffestUtil.GetOffsetCurves();
}
GetFeedingToolPath(offsetDist: number): Array<Curve>
{
let polyOffestUtil = new PolyOffsetUtil(this, offsetDist);
return polyOffestUtil.GetOffsetCurves(true);
}
/**
*
*

@ -4,8 +4,10 @@ import { DisposeThreeObj } from '../Common/Dispose';
import { MoveMatrix } from '../Geometry/GeUtils';
import { BoolOpeartionType } from '../GraphicsSystem/BoolOperateUtils';
import { RenderType } from '../GraphicsSystem/Enum';
import { Arc } from './Arc';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { Circle } from './Circle';
import { Contour } from './Contour';
import { Curve } from './Curve';
import { Entity } from './Entity';
@ -55,7 +57,11 @@ export class Region extends Entity
if (shapeList.length <= 1)
{
let cus = shapeList[0].Explode();
cus.forEach(c => c.ApplyMatrix(this.OCS));
cus.forEach(c =>
{
if (!(c instanceof Circle) && !(c instanceof Arc))
c.ApplyMatrix(c.OCSInv).ApplyMatrix(this.OCS)
});
return cus;
}
else
@ -63,7 +69,7 @@ export class Region extends Entity
let regs: Region[] = [];
shapeList.forEach(s =>
{
let reg = new Region();
let reg = new Region().ApplyMatrix(this.OCS);
reg.ShapeManager.AppendShapeList(s);
regs.push(reg);
})

@ -61,7 +61,8 @@ export class Shape
let contours: Contour[] = [this.m_Outline, ...this.m_Holes];
contours.forEach(h =>
{
h.Curve instanceof Polyline ? cus.push(...h.Curve.Explode()) : cus.push(h.Curve)
h.Curve instanceof Polyline
? cus.push(...h.Curve.Explode()) : cus.push(h.Curve.Clone())
});
return cus;
}
@ -72,6 +73,11 @@ export class Shape
shape.Holes = this.Holes.map(h => h.Clone());
return shape;
}
SetColor(color: number)
{
this.m_Outline.Curve.ColorIndex = color;
this.m_Holes.forEach(h => h.Curve.ColorIndex = color);
}
//交集 如果成功返回一个面域 失败返回0个
IntersectionBoolOperation(targetShape: Shape): Shape[]
{

@ -92,6 +92,7 @@ import { CommandServer } from '../DatabaseServices/CommandServer';
import { ICommand } from '../UI/Components/CommandPanel/CommandList';
import { ChangeColor } from '../Add-on/ChangeColor';
import { Command_Draw2LineAngularDim } from '../Add-on/DrawDim/Draw2LineAngularDim';
import { FeedingCommand } from '../Add-on/CommandFeeding';
export function registerCommand()
{
commandMachine.RegisterCommand("b", new DrawBox())
@ -222,6 +223,8 @@ export function registerCommand()
for (let i = 0; i < 24; i++)
commandMachine.RegisterCommand((i + 1).toString(), new ChangeColor(i + 1));
//提取走刀
commandMachine.RegisterCommand("testm", new FeedingCommand());
/*******test ↓↓↓*********/
commandMachine.RegisterCommand("pltest", new Command_PLTest());

@ -1,5 +1,4 @@
import * as THREE from "three";
import { Geometry, Vector2, Vector3 } from "three";
import { Face3, Face4, Geometry, Material, Matrix4, Mesh, Vector2, Vector3 } from "three";
const EPSILON = 1e-5,
COPLANAR = 0, //共面
@ -10,13 +9,13 @@ const EPSILON = 1e-5,
export default class ThreeBSP
{
tree: Node;
matrix: THREE.Matrix4;
matrix: Matrix4;
Node: Node;
Vertex: Vertex[];
Polygon: Polygon[];
constructor(obj: Geometry | THREE.Mesh | Node)
constructor(obj: Geometry | Mesh | Node)
{
// Convert THREE.Geometry to ThreeBSP
// Convert Geometry to ThreeBSP
let i, _length_i,
face, vertex, faceVertexUvs, uvs,
polygon,
@ -25,12 +24,12 @@ export default class ThreeBSP
this.Polygon = polygons;
this.Vertex = vertex;
let geometry: Geometry;
if (obj instanceof THREE.Geometry)
if (obj instanceof Geometry)
{
geometry = obj;
this.matrix = new THREE.Matrix4();
this.matrix = new Matrix4();
}
else if (obj instanceof THREE.Mesh)
else if (obj instanceof Mesh)
{
// #todo: add hierarchy support
this.matrix = obj.matrix.clone();
@ -39,7 +38,7 @@ export default class ThreeBSP
else if (obj instanceof Node)
{
this.tree = obj;
this.matrix = new THREE.Matrix4();
this.matrix = new Matrix4();
return this;
}
else
@ -53,48 +52,48 @@ export default class ThreeBSP
faceVertexUvs = geometry.faceVertexUvs[0][i];
polygon = new Polygon();
if (face instanceof THREE.Face3)
if (face instanceof Face3)
{
vertex = geometry.vertices[face.a];
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[0].x, faceVertexUvs[0].y) : null;
uvs = faceVertexUvs ? new Vector2(faceVertexUvs[0].x, faceVertexUvs[0].y) : null;
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[0], uvs);
vertex.applyMatrix4(this.matrix);
polygon.vertices.push(vertex);
vertex = geometry.vertices[face.b];
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[1].x, faceVertexUvs[1].y) : null;
uvs = faceVertexUvs ? new Vector2(faceVertexUvs[1].x, faceVertexUvs[1].y) : null;
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[1], uvs);
vertex.applyMatrix4(this.matrix);
polygon.vertices.push(vertex);
vertex = geometry.vertices[face.c];
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[2].x, faceVertexUvs[2].y) : null;
uvs = faceVertexUvs ? new Vector2(faceVertexUvs[2].x, faceVertexUvs[2].y) : null;
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2], uvs);
vertex.applyMatrix4(this.matrix);
polygon.vertices.push(vertex);
}
else if (typeof THREE.Face4)
else if (typeof Face4)
{
vertex = geometry.vertices[face.a];
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[0].x, faceVertexUvs[0].y) : null;
uvs = faceVertexUvs ? new Vector2(faceVertexUvs[0].x, faceVertexUvs[0].y) : null;
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[0], uvs);
vertex.applyMatrix4(this.matrix);
polygon.vertices.push(vertex);
vertex = geometry.vertices[face.b];
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[1].x, faceVertexUvs[1].y) : null;
uvs = faceVertexUvs ? new Vector2(faceVertexUvs[1].x, faceVertexUvs[1].y) : null;
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[1], uvs);
vertex.applyMatrix4(this.matrix);
polygon.vertices.push(vertex);
vertex = geometry.vertices[face.c];
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[2].x, faceVertexUvs[2].y) : null;
uvs = faceVertexUvs ? new Vector2(faceVertexUvs[2].x, faceVertexUvs[2].y) : null;
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2], uvs);
vertex.applyMatrix4(this.matrix);
polygon.vertices.push(vertex);
vertex = geometry.vertices[face.d];
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[3].x, faceVertexUvs[3].y) : null;
uvs = faceVertexUvs ? new Vector2(faceVertexUvs[3].x, faceVertexUvs[3].y) : null;
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[3], uvs);
vertex.applyMatrix4(this.matrix);
polygon.vertices.push(vertex);
@ -168,8 +167,8 @@ export default class ThreeBSP
toGeometry()
{
let i, j,
matrix = new THREE.Matrix4().getInverse(this.matrix),
geometry = new THREE.Geometry(),
matrix = new Matrix4().getInverse(this.matrix),
geometry = new Geometry(),
polygons = this.tree.allPolygons(),
polygon_count = polygons.length,
polygon, polygon_vertice_count,
@ -188,8 +187,8 @@ export default class ThreeBSP
verticeUvs = [];
vertex = polygon.vertices[0];
verticeUvs.push(new THREE.Vector2(vertex.uv.x, vertex.uv.y));
vertex = new THREE.Vector3(vertex.x, vertex.y, vertex.z);
verticeUvs.push(new Vector2(vertex.uv.x, vertex.uv.y));
vertex = new Vector3(vertex.x, vertex.y, vertex.z);
vertex.applyMatrix4(matrix);
if (typeof vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] !== 'undefined')
@ -202,8 +201,8 @@ export default class ThreeBSP
}
vertex = polygon.vertices[j - 1];
verticeUvs.push(new THREE.Vector2(vertex.uv.x, vertex.uv.y));
vertex = new THREE.Vector3(vertex.x, vertex.y, vertex.z);
verticeUvs.push(new Vector2(vertex.uv.x, vertex.uv.y));
vertex = new Vector3(vertex.x, vertex.y, vertex.z);
vertex.applyMatrix4(matrix);
if (typeof vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] !== 'undefined')
{
@ -215,8 +214,8 @@ export default class ThreeBSP
}
vertex = polygon.vertices[j];
verticeUvs.push(new THREE.Vector2(vertex.uv.x, vertex.uv.y));
vertex = new THREE.Vector3(vertex.x, vertex.y, vertex.z);
verticeUvs.push(new Vector2(vertex.uv.x, vertex.uv.y));
vertex = new Vector3(vertex.x, vertex.y, vertex.z);
vertex.applyMatrix4(matrix);
if (typeof vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] !== 'undefined')
{
@ -228,11 +227,11 @@ export default class ThreeBSP
vertex_idx_c = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] = geometry.vertices.length - 1;
}
face = new THREE.Face3(
face = new Face3(
vertex_idx_a,
vertex_idx_b,
vertex_idx_c,
new THREE.Vector3(polygon.normal.x, polygon.normal.y, polygon.normal.z)
new Vector3(polygon.normal.x, polygon.normal.y, polygon.normal.z)
);
geometry.faces.push(face);
@ -243,10 +242,10 @@ export default class ThreeBSP
return geometry;
}
toMesh(material?: THREE.Material | THREE.Material[])
toMesh(material?: Material | Material[])
{
let geometry = this.toGeometry(),
mesh = new THREE.Mesh(geometry, material);
mesh = new Mesh(geometry, material);
mesh.applyMatrix(this.matrix)
return mesh;
@ -439,13 +438,13 @@ class Vertex
z: number;
y: number;
x: number;
constructor(x: number, y: number, z: number, normal: THREE.Vector3, uv: THREE.Vector2)
constructor(x: number, y: number, z: number, normal: Vector3, uv: Vector2)
{
this.x = x;
this.y = y;
this.z = z;
this.normal = normal || new THREE.Vector3();
this.uv = uv || new THREE.Vector2();
this.normal = normal || new Vector3();
this.uv = uv || new Vector2();
}
clone()
@ -535,7 +534,7 @@ class Vertex
applyMatrix4(m)
{
// input: THREE.Matrix4 affine matrix
// input: Matrix4 affine matrix
let x = this.x, y = this.y, z = this.z;

@ -3,7 +3,75 @@ import { Curve } from "../DatabaseServices/Curve";
import { Polyline } from "../DatabaseServices/Polyline";
import { IntersectOption } from "./IntersectWith";
import { PolyOffsetUtil } from "./OffsetPolyline";
import { Line } from "../DatabaseServices/Line";
/**
*线
* @l-arc-l,l-arc-arc-l,l-arc-l-arc-l....
*/
export function paragraphCulist(cus: Curve[])
{
let newCulist: Curve[][] = [];
let usedCu: WeakSet<Curve> = new WeakSet();
//归类曲线,返回归类是否成功
const paragraph = (cu: Curve, originCu: Curve, cus: Curve[]) =>
{
if (usedCu.has(cu) || (cu instanceof Line && originCu instanceof Line))
return false;
cus.push(cu);
usedCu.add(cu);
return true;
}
while (cus.length > 0)
{
let originCu = cus.shift();
if (usedCu.has(originCu))
continue;
let originCus = [originCu];
usedCu.add(originCu);
//往后搜索
for (let i = 0; i < cus.length; i++)
{
if (!paragraph(cus[i], originCu, originCus))
break;
originCu = cus[i];
}
originCu = originCus[0];
//往前搜索
for (let i = cus.length - 1; i >= 0; i--)
{
if (!paragraph(cus[i], originCu, originCus))
break;
originCu = cus[i];
}
newCulist.push(originCus);
}
//同组多条曲线连接为多段线
for (let g of newCulist)
{
if (g.length === 1)
cus.push(g[0]);
else
{
let pl = new Polyline();
for (let c of g)
{
pl.Join(c)
}
cus.push(pl);
}
}
}
/**
*
*/
export function calcEdgeSealing(cus: Curve[])
{
if (cus.length <= 1)
@ -19,7 +87,6 @@ export function calcEdgeSealing(cus: Curve[])
);
let iPt = PolyOffsetUtil.selectFitInterPt(tPts.length > 0 ? tPts : iPts, frontLine.EndPoint);
let iPt1 = iPt.clone();
if (frontLine instanceof Polyline)
iPt1.applyMatrix4(frontLine.OCSInv);

@ -42,7 +42,7 @@ export class PolyOffsetUtil
this.m_AbsDist = Math.abs(this.m_OffsetDist);
this.m_PtCount = pl.EndParam;
}
GetOffsetCurves(): Curve[]
GetOffsetCurves(isCalcPath = false): Curve[]
{
const originOCS = this.m_Polyline.OCS;
this.m_Polyline.ApplyMatrix(this.m_Polyline.OCSInv);
@ -66,10 +66,10 @@ export class PolyOffsetUtil
this.linkCurves();
//如果源线段闭合只保留闭合的部分(理论上可以删除这个判断)
if (this.m_Polyline.IsClose)
if (!isCalcPath && this.m_Polyline.IsClose)
this.m_RetCurves = this.m_RetCurves.filter(c => c.IsClose);
if (this.m_Polyline.CloseMark)
if (!isCalcPath && this.m_Polyline.CloseMark)
this.m_RetCurves.forEach(pl => (<Polyline>pl).CloseMark = true);
return this.m_RetCurves.map(pl => pl.ApplyMatrix(originOCS));
@ -93,7 +93,7 @@ export class PolyOffsetUtil
this.m_RetCurves = this.m_RetCurves.filter(c =>
{
//与源线段自交
if (c.IntersectWith(this.m_Polyline, IntersectOption.OnBothOperands).length !== 0)
if (equaln(c.Length, 0, 1e-6) || c.IntersectWith(this.m_Polyline, IntersectOption.OnBothOperands).length !== 0)
return false;
//删除在反方向的无效线段
return this.CheckPointDir(c.StartPoint) || this.CheckPointDir(c.EndPoint);

@ -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;
}
}

@ -0,0 +1,216 @@
import { Curve } from "../../DatabaseServices/Curve";
import { Shape } from "../../DatabaseServices/Shape";
import { matrixAlignCoordSys } from "../../Common/Matrix4Utils";
import { Vec2DTo3D, Vec3DTo2D, curveLinkGroup, ConverCircleToPolyline } from "../../Common/CurveUtils";
import { Line } from "../../DatabaseServices/Line";
import { Circle } from "../../DatabaseServices/Circle";
import { Polyline } from "../../DatabaseServices/Polyline";
import { comparePoint } from "../../Geometry/GeUtils";
import { arrayLast } from "../../Common/ArrayExt";
/**
* ,线
* @param offsetCus 线
* @param originShape
* @param rad
* @returns tool path
*/
export function OptimizeToolPath(offsetCus: Curve[], originShape: Shape, rad: number): Curve[]
{
// 去掉最外轮廓
let outline = offsetCus.shift();
outline.ColorIndex += 1;
//洞轮廓
let holesCurve = originShape.Holes.map(h =>
{
let c = h.Curve.Clone();
c.ColorIndex += 1;
return c;
});
let plList: Polyline[] = [];
let noCloseCus: Curve[] = [];
for (let cu of offsetCus)
{
if (!cu.IsClose)
{
noCloseCus.push(cu)
continue;
}
if (cu instanceof Polyline)
{
plList.push(cu);
}
else if (cu instanceof Circle)
{
let c = ConverCircleToPolyline(cu);
c.ColorIndex = cu.ColorIndex;
plList.push(c)
}
else
console.warn("错误形状");
}
if (noCloseCus.length > 0)
{
let culist: Curve[] = [];
noCloseCus.forEach(c => culist.push(...c.Explode() as Curve[]))
let groups = curveLinkGroup(culist);
for (let g of groups)
{
let pl = new Polyline();
pl.ColorIndex = noCloseCus[0].ColorIndex;
for (let c of g)
{
pl.Join(c);
}
plList.push(pl);
}
}
let cantIntCur: Curve[] = [outline];
if (originShape.Holes.length > 0)
{
for (let h of originShape.Holes)
{
let dir = Math.sign(h.Curve.Area2);
if (h.Curve instanceof Circle)
dir = 1;
cantIntCur.push(...h.Curve.GetOffsetCurves(rad * dir));
}
}
//曲线统一起点
ChangePlListStartPt(plList);
//对多段线进行排序,按最起始点远近排序
SortPlByStartPt(plList);
let result: Curve[] = [];
let firstPl = plList[0];
firstPl.CloseMark = false;
for (let i = 1; i < plList.length; i++)
{
let ePt = firstPl.EndPoint;
let refLine = new Line(ePt, plList[i].StartPoint);
let isDisVail = false;
isDisVail = cantIntCur.some(c => c.IntersectWith(refLine, 0).length > 0);
if (isDisVail)
{
result.push(firstPl);
firstPl = plList[i];
firstPl.CloseMark = false;
}
else
{
let alMat = matrixAlignCoordSys(plList[i].OCS, firstPl.OCS);
let cuPtsBul = plList[i].PtsBuls;
for (let i = 0; i < cuPtsBul.pts.length; i++)
{
//坐标系对齐
let p = cuPtsBul.pts[i];
p.copy(Vec3DTo2D(Vec2DTo3D(p).applyMatrix4(alMat)));
firstPl.LineData.push({ pt: p, bul: cuPtsBul.buls[i] });
}
}
}
result.push(firstPl, outline, ...holesCurve);
return result;
}
/**
*
* ,
* @param plList
*/
function ChangePlListStartPt(plList: Polyline[])
{
let firstPl = plList[0];
if (firstPl.IsClose)
{
let minP = undefined;
let compare = comparePoint("xy");
for (let p of firstPl.GetStretchPoints())
{
if (!minP)
minP = p;
else
if (compare(minP, p) === 1)
minP = p;
}
let par = firstPl.GetParamAtPoint(minP);
firstPl.ResetStartPoint(par);
}
let firstSpt = firstPl.StartPoint;
for (let i = 1; i < plList.length; i++)
{
let pl = plList[i];
if (pl.IsClose)
{
let pts = pl.GetStretchPoints().sort((p1, p2) =>
{
let dist1 = p1.distanceToSquared(firstSpt);
let dist2 = p2.distanceToSquared(firstSpt);
return dist1 - dist2;
});
let par = pl.GetParamAtPoint(pts[0]);
pl.ResetStartPoint(par);
}
else
{
let sPt = pl.StartPoint;
let ePt = pl.EndPoint;
let dist1 = sPt.distanceToSquared(firstSpt);
let dist2 = ePt.distanceToSquared(firstSpt);
if (dist1 > dist2)
pl.Reverse();
}
}
}
/**
* 线,
* @param plList
*/
function SortPlByStartPt(plList: Polyline[])
{
if (plList.length <= 1) return plList;
let result = [plList[0]];
let usedPl = new WeakSet([plList[0]]);
while (true)
{
if (plList.length === result.length)
break;
let refPt = arrayLast(result).StartPoint;
let vaildPl: Polyline;
let refDist: number;
for (let pl of plList)
{
if (usedPl.has(pl))
continue;
let sPt = pl.StartPoint;
if (!refDist || sPt.distanceToSquared(refPt) < refDist)
{
refDist = sPt.distanceToSquared(refPt);
vaildPl = pl;
}
}
result.push(vaildPl);
usedPl.add(vaildPl);
}
plList.length = 0;
plList.push(...result);
}

@ -17,7 +17,7 @@ import { Shape } from "../../../DatabaseServices/Shape";
import { commandMachine } from "../../../Editor/CommandMachine";
import { JigUtils } from "../../../Editor/JigUtils";
import { SelectBox, SelectType } from "../../../Editor/SelectBox";
import { MoveMatrix } from "../../../Geometry/GeUtils";
import { MoveMatrix, equalv3 } from "../../../Geometry/GeUtils";
import { BoardConfigOption, BoardProcessOption } from '../../Store/BoardInterface';
import { RightPanelStore } from "../../Store/RightPanelStore";
import { BoardTypeComponent, ItemName, SetBoardDataBlock } from "./BoardCommon";
@ -105,7 +105,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
let cuMap: Map<number, Contour[]> = new Map();
for (let cu of cus)
{
if (originEns.length > 0 && cu === originEns[0])
if (originEns.length > 0 && (cu === originEns[0] || !equalv3(cu.Normal, originEns[0].Normal)))
continue;
let colorIndex = cu.ColorIndex;
@ -141,14 +141,19 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
{
if (modelData.height >= br.Thickness)
s.Holes.length = 0;
//还原构建形状到原来的坐标系,
//还原构建形状到原来的坐标系,在转换到外轮廓所在位置
s.ApplyMatrix(oldOcs);
//转换形状到外轮廓所在位置,保持造型轮廓和外轮廓的相对位置
changeShapeUCS(s, br, oldOcsInv);
s.ApplyMatrix(MoveMatrix(box.min.clone().negate()));
let ss = s.IntersectionBoolOperation(br.Shape);
for (let s1 of ss)
{
s1.SetColor(i);
modelings.push({
shape: s,
shape: s1,
thickness: modelData.height,
dir: modelData.dir,
rad: modelData.rad,
@ -156,6 +161,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
});
}
}
}
br.BoardModeling = modelings;
}

@ -6,11 +6,9 @@ import { Matrix4 } from 'three';
import { app } from '../../../ApplicationServices/Application';
import { Board } from '../../../DatabaseServices/Board';
import { Curve } from '../../../DatabaseServices/Curve';
import { Line } from '../../../DatabaseServices/Line';
import { Polyline } from '../../../DatabaseServices/Polyline';
import { Text } from '../../../DatabaseServices/Text/Text';
import { JigUtils } from '../../../Editor/JigUtils';
import { calcEdgeSealing } from '../../../GraphicsSystem/CalcEdgeSealing';
import { calcEdgeSealing, paragraphCulist } from '../../../GraphicsSystem/CalcEdgeSealing';
@observer
export class EdgeSealingComponent extends React.Component<{ br: Board }, {}>
@ -26,7 +24,10 @@ export class EdgeSealingComponent extends React.Component<{ br: Board }, {}>
let br = this.props.br;
let cus = br.Shape.Outline.Curve.Explode() as Curve[];
this.ParagraphCulist(cus);
//曲线分段
paragraphCulist(cus);
//替换曲线列表
observable(this.cuList).replace(cus);
app.m_Viewer.m_CameraCtrl.LookAt(br.Normal.negate());
app.m_Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS);
@ -44,73 +45,11 @@ export class EdgeSealingComponent extends React.Component<{ br: Board }, {}>
JigUtils.Draw(refCu.ApplyMatrix(br.OCS));
}
}
//曲线列表分段
private ParagraphCulist = (cus: Curve[]) =>
{
let newCulist: Curve[][] = [];
let usedCu: WeakSet<Curve> = new WeakSet();
//归类曲线,返回归类是否成功
const paragraph = (cu: Curve, originCu: Curve, cus: Curve[]) =>
{
if (usedCu.has(cu) || (cu instanceof Line && originCu instanceof Line))
return false;
cus.push(cu);
usedCu.add(cu);
return true;
}
while (cus.length > 0)
{
let originCu = cus.shift();
if (usedCu.has(originCu))
continue;
let originCus = [originCu];
usedCu.add(originCu);
//往后搜索
for (let i = 0; i < cus.length; i++)
{
if (!paragraph(cus[i], originCu, originCus))
break;
originCu = cus[i];
}
originCu = originCus[0];
//往前搜索
for (let i = cus.length - 1; i >= 0; i--)
{
if (!paragraph(cus[i], originCu, originCus))
break;
originCu = cus[i];
}
newCulist.push(originCus);
}
//同组多条曲线连接为多段线
for (let g of newCulist)
{
if (g.length === 1)
cus.push(g[0]);
else
{
let pl = new Polyline();
for (let c of g)
{
pl.Join(c)
}
cus.push(pl);
}
}
//替换曲线列表
observable(this.cuList).replace(cus);
}
private CalcEdgeSealing = () =>
{
let originCurve = this.props.br.Shape.Outline.Curve;
let dir = Math.sign(originCurve.Area2) * -1;
let infoEls = this.ulList.querySelectorAll('li input');
let edgeSealingNum: number[] = [];
let highSeal = this.props.br.BoardProcessOption.highSealed;

@ -11,7 +11,7 @@ import { BehindBoardOption, BehindHeightPositon, BoardConfigOption, BoardOption,
export class BoardStore
{
m_Option: BoardOption;
protected m_UiOption = {};
protected m_UiOption;
title: string;
@observable UseBoardProcessOption = true;
@observable m_BoardProcessOption: BoardProcessOption = {
@ -82,7 +82,8 @@ export class BoardStore
UpdateOption(cof: IConfigOption)
{
Object.assign(this.m_Option, cof.boardData);
Object.assign(this.UIOption, DataAdapter.ConvertUIData(cof.boardData));
if (this.m_UiOption)
Object.assign(this.m_UiOption, DataAdapter.ConvertUIData(cof.boardData));
Object.assign(this.m_BoardProcessOption, cof.processData);
}
HasInvailValue()

@ -22,14 +22,14 @@ export class RightPanelStore
color: (i + 1).toString(),
height: "0",
dir: PXLFaceType.Positive,
rad: "0",
rad: "3",
length: "0"
})
this.modelingItems.push({
color: i + 1,
height: 0,
dir: PXLFaceType.Positive,
rad: 0,
rad: 3,
length: 0
})
}

Loading…
Cancel
Save