Merge pull request !172 from ZoeLeeFZ/edgesealing2
pull/172/MERGE
ChenX 6 years ago
parent 31c15b75f4
commit 07d6fb7e25

@ -0,0 +1,92 @@
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 { Polyline } from "../../src/DatabaseServices/Polyline";
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 testBrSealing(br: Board, sealingSize: number[])
{
let originCurve = br.Shape.Outline.Curve;
let dir = Math.sign(originCurve.Area2) * -1;
let calcCus = originCurve.Explode() as Curve[];
let offsetCus: Curve[] = [];
for (let i = 0; i < calcCus.length; i++)
{
let cu = calcCus[i];
offsetCus.push(...cu.GetOffsetCurves(sealingSize[i] * dir))
}
calcEdgeSealing(offsetCus);
let pl = new Polyline();
for (let cu of offsetCus)
{
let res = pl.Join(cu);
expect(res).toBeTruthy();
}
pl.ApplyMatrix(br.OCS);
expect(pl.IsClose).toBeTruthy();
expect(pl.Area).toMatchSnapshot();
}
test("常规板件,常规坐标系", () =>
{
let data = [1, ["Board", 1, 1, 3, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 145.29914529914527, -290.5982905982906, 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, 145.29914529914527, -290.5982905982906, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"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 layerBr = loadFile(data)[0];
let sealingSize = [1, 1, 1, 1];
testBrSealing(layerBr, sealingSize);
sealingSize = [3, 2, 3, 2];
testBrSealing(layerBr, sealingSize);
data = [1, ["Board", 1, 1, 3, false, 7, -1, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -292.022792022792, -213.67521367521368, 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, -292.022792022792, -213.67521367521368, 0, 1], 1, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"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 vBr = loadFile(data)[0];
sealingSize = [2, 2, 2, 2];
testBrSealing(vBr, sealingSize);
})
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];
testBrSealing(br, sealingSize);
sealingSize = [3, 3, 10, 3, 3];
testBrSealing(br, sealingSize);
sealingSize = [10, 10, 5, 5, 10];
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];
testBrSealing(br, sealingSize);
sealingSize = [1, 3, 1, 3, 1, 2, 1, 3];
testBrSealing(br, sealingSize);
sealingSize = [5, 3, 5, 3, 5, 2, 5, 3];
testBrSealing(br, sealingSize);
})
test("异型板件,非常规坐标系", () =>
{
let data = [1, ["Board", 1, 1, 15, false, 7, -1, [0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0, 15844.064994449893, 0, -2833.834144511985, 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, 2833.8341445119845, 15844.064994449893, 0, 1], 2, 6, [5008.758238702114, -2833.834144511985], 0, [5008.758238702114, 2775.380162574158], -0.414213562373095, [7222.921780972962, 4989.543704845006], 0, [13759.976048629745, 4989.543704845006], -0.8565683416116343, [14392.594203564273, 919.700241432878], 0, [14076.28512609701, -2833.834144511985], 0, true], 0, 10835.306755747779, 7823.377849356992, 18, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 15844.064994449893, 0, -2833.834144511985, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0]]
//第2,4段为圆弧
let br = loadFile(data)[0];
let sealingSize = [1, 1, 1, 1, 1, 1];
testBrSealing(br, sealingSize);
sealingSize = [3, 5, 3, 3, 3, 3];
testBrSealing(br, sealingSize);
sealingSize = [10, 5, 5, 5, 10, 5];
testBrSealing(br, sealingSize);
})

@ -0,0 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`常规板件,常规坐标系 1`] = `716404`;
exports[`常规板件,常规坐标系 2`] = `711624`;
exports[`常规板件,常规坐标系 3`] = `712816`;
exports[`异型板件,常规坐标系 1`] = `2709777.7883832143`;
exports[`异型板件,常规坐标系 2`] = `2696477.36609459`;
exports[`异型板件,常规坐标系 3`] = `2657160.4995995373`;
exports[`异型板件,常规坐标系 4`] = `2628158.6443366623`;
exports[`异型板件,常规坐标系 5`] = `2628158.6443366623`;
exports[`异型板件,常规坐标系 6`] = `2607100.626176849`;
exports[`异型板件,非常规坐标系 1`] = `75939516.39226122`;
exports[`异型板件,非常规坐标系 2`] = `75870817.54933015`;
exports[`异型板件,非常规坐标系 3`] = `75754806.13472572`;

@ -1,18 +0,0 @@
import { fixAngle } from '../../src/Geometry/GeUtils';
test("GeUtils.angle", () =>
{
let pi2 = Math.PI * 0.5;
let pi4 = pi2 * 0.5;
console.log(fixAngle(0.05, pi2, 0.1)/*?*/ == 0);
console.log(fixAngle(0.08, pi2, 0.1)/*?*/ == 0);
console.log(fixAngle(0.09, pi2, 0.1)/*?*/ == 0);
console.log(fixAngle(-0.05, pi2, 0.1)/*?*/ == Math.PI * 2);
console.log(fixAngle(Math.PI / 2 + 0.01, pi2, 0.1)/*?*/ == Math.PI / 2);
console.log(fixAngle(0.3, pi2));
})

@ -66,7 +66,7 @@ Vector3 {
exports[`直线偏移 3`] = ` exports[`直线偏移 3`] = `
Vector3 { Vector3 {
"x": -7.0710678118654755, "x": -7.071067811865475,
"y": 7.071067811865475, "y": 7.071067811865475,
"z": 0, "z": 0,
} }
@ -74,7 +74,7 @@ Vector3 {
exports[`直线偏移 4`] = ` exports[`直线偏移 4`] = `
Vector3 { Vector3 {
"x": -2.0710678118654755, "x": -2.0710678118654746,
"y": 12.071067811865476, "y": 12.071067811865476,
"z": 0, "z": 0,
} }
@ -82,7 +82,7 @@ Vector3 {
exports[`直线偏移 5`] = ` exports[`直线偏移 5`] = `
Vector3 { Vector3 {
"x": 7.0710678118654755, "x": 7.071067811865475,
"y": -7.071067811865475, "y": -7.071067811865475,
"z": 0, "z": 0,
} }
@ -98,7 +98,7 @@ Vector3 {
exports[`直线偏移 7`] = ` exports[`直线偏移 7`] = `
Vector3 { Vector3 {
"x": -7.071067811865477, "x": -7.071067811865475,
"y": 7.071067811865475, "y": 7.071067811865475,
"z": 0, "z": 0,
} }
@ -106,7 +106,7 @@ Vector3 {
exports[`直线偏移 8`] = ` exports[`直线偏移 8`] = `
Vector3 { Vector3 {
"x": -12.071067811865477, "x": -12.071067811865476,
"y": 2.0710678118654746, "y": 2.0710678118654746,
"z": 0, "z": 0,
} }
@ -114,7 +114,7 @@ Vector3 {
exports[`直线偏移 9`] = ` exports[`直线偏移 9`] = `
Vector3 { Vector3 {
"x": 7.071067811865477, "x": 7.071067811865475,
"y": -7.071067811865475, "y": -7.071067811865475,
"z": 0, "z": 0,
} }
@ -122,7 +122,7 @@ Vector3 {
exports[`直线偏移 10`] = ` exports[`直线偏移 10`] = `
Vector3 { Vector3 {
"x": 2.0710678118654773, "x": 2.0710678118654746,
"y": -12.071067811865476, "y": -12.071067811865476,
"z": 0, "z": 0,
} }

@ -2,19 +2,19 @@
exports[`IKKGK圆与直线补圆弧 1`] = `1`; exports[`IKKGK圆与直线补圆弧 1`] = `1`;
exports[`IKKGK圆与直线补圆弧 2`] = `44.99893545255324`; exports[`IKKGK圆与直线补圆弧 2`] = `44.99893545255323`;
exports[`IKKGK圆与直线补圆弧 3`] = `1`; exports[`IKKGK圆与直线补圆弧 3`] = `1`;
exports[`IKKGK圆与直线补圆弧 4`] = `44.99893545255324`; exports[`IKKGK圆与直线补圆弧 4`] = `44.998935452553226`;
exports[`IKKGK圆与直线补圆弧 5`] = `1`; exports[`IKKGK圆与直线补圆弧 5`] = `1`;
exports[`IKKGK圆与直线补圆弧 6`] = `52.52699197436397`; exports[`IKKGK圆与直线补圆弧 6`] = `52.526991974363945`;
exports[`中间区域需要圆裁剪 1`] = `1`; exports[`中间区域需要圆裁剪 1`] = `1`;
exports[`中间区域需要圆裁剪 2`] = `24.711300177432424`; exports[`中间区域需要圆裁剪 2`] = `24.711300177432427`;
exports[`圆求交错误导致的线丢失 1`] = `4148.6552839918695`; exports[`圆求交错误导致的线丢失 1`] = `4148.6552839918695`;
@ -70,7 +70,7 @@ exports[`多段线因为合并问题造成的错误 2`] = `2210.3833040297095`;
exports[`多段线存在0长度线段导致偏移错误 1`] = `1`; exports[`多段线存在0长度线段导致偏移错误 1`] = `1`;
exports[`多段线存在0长度线段导致偏移错误 2`] = `81933.70549460054`; exports[`多段线存在0长度线段导致偏移错误 2`] = `81933.70549460052`;
exports[`多段线存在0长度线段导致偏移错误 3`] = `1`; exports[`多段线存在0长度线段导致偏移错误 3`] = `1`;
@ -86,13 +86,13 @@ exports[`拱门偏移 4`] = `6.827433388230814`;
exports[`海豚圆选点导致的错误 1`] = `1`; exports[`海豚圆选点导致的错误 1`] = `1`;
exports[`海豚圆选点导致的错误 2`] = `1591.1982232513824`; exports[`海豚圆选点导致的错误 2`] = `1591.1982232513815`;
exports[`海豚圆选点导致的错误 3`] = `1`; exports[`海豚圆选点导致的错误 3`] = `1`;
exports[`海豚圆选点导致的错误 4`] = `1827.6352392619829`; exports[`海豚圆选点导致的错误 4`] = `1827.6352392619826`;
exports[`简单图形因为点在线内算法错误导致的丢失 1`] = `8.675189454805246`; exports[`简单图形因为点在线内算法错误导致的丢失 1`] = `8.675189454805244`;
exports[`简单图形因为点在线内算法错误导致的丢失 2`] = `8.252841733482935`; exports[`简单图形因为点在线内算法错误导致的丢失 2`] = `8.252841733482935`;
@ -108,9 +108,9 @@ exports[`纯圆生成的多段线偏移 3`] = `1`;
exports[`纯圆生成的多段线偏移 4`] = `6328.578192723271`; exports[`纯圆生成的多段线偏移 4`] = `6328.578192723271`;
exports[`补充bug测试 1`] = `7385.123391644452`; exports[`补充bug测试 1`] = `7385.123391644449`;
exports[`补充bug测试 2`] = `7455.861403941385`; exports[`补充bug测试 2`] = `7455.861403941378`;
exports[`补圆弧测试 补圆弧测试1 1`] = `1`; exports[`补圆弧测试 补圆弧测试1 1`] = `1`;
@ -122,7 +122,7 @@ exports[`补圆弧测试 补圆弧测试1 4`] = `202.97120101469034`;
exports[`补圆弧测试 补圆弧测试1 5`] = `1`; exports[`补圆弧测试 补圆弧测试1 5`] = `1`;
exports[`补圆弧测试 补圆弧测试1 6`] = `203.63368101398322`; exports[`补圆弧测试 补圆弧测试1 6`] = `203.6336810139832`;
exports[`补圆弧测试 补圆弧测试1 7`] = `1`; exports[`补圆弧测试 补圆弧测试1 7`] = `1`;
@ -130,7 +130,7 @@ exports[`补圆弧测试 补圆弧测试1 8`] = `204.40243508941455`;
exports[`补圆弧测试 补圆弧测试1 9`] = `1`; exports[`补圆弧测试 补圆弧测试1 9`] = `1`;
exports[`补圆弧测试 补圆弧测试1 10`] = `205.30936570465025`; exports[`补圆弧测试 补圆弧测试1 10`] = `205.30936570465022`;
exports[`补圆弧测试 补圆弧测试1 11`] = `1`; exports[`补圆弧测试 补圆弧测试1 11`] = `1`;
@ -194,18 +194,18 @@ exports[`补圆弧测试 补圆弧测试1 40`] = `193.2116587563558`;
exports[`补圆弧测试 补圆弧测试1 41`] = `1`; exports[`补圆弧测试 补圆弧测试1 41`] = `1`;
exports[`补圆弧测试 补圆弧测试1 42`] = `192.84673020284995`; exports[`补圆弧测试 补圆弧测试1 42`] = `192.84673020284998`;
exports[`补圆弧测试 补圆弧测试1 43`] = `1`; exports[`补圆弧测试 补圆弧测试1 43`] = `1`;
exports[`补圆弧测试 补圆弧测试1 44`] = `192.58327191623619`; exports[`补圆弧测试 补圆弧测试1 44`] = `192.58327191623619`;
exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 1`] = `54789.24964851233`; exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 1`] = `54789.24964851234`;
exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 2`] = `54907.28173780601`; exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 2`] = `54907.281737806145`;
exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 3`] = `55497.502122668855`; exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 3`] = `55497.50212266897`;
exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 4`] = `56678.24106604482`; exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 4`] = `56678.24106604482`;
exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 5`] = `57859.37443960541`; exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 5`] = `57859.374439605526`;

@ -1,25 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`补充bug测试#IKWGF 1`] = `1.1376403544773546`; exports[`补充bug测试#IKWGF 1`] = `1.1376403544773552`;
exports[`补充bug测试#IKWGF 2`] = `0.4457395323615243`; exports[`补充bug测试#IKWGF 2`] = `0.44573953236152586`;
exports[`补充bug测试#IKWGF 3`] = `10.732981364094249`; exports[`补充bug测试#IKWGF 3`] = `10.732981364094256`;
exports[`补充bug测试#IKWGF 4`] = `12.786911814880924`; exports[`补充bug测试#IKWGF 4`] = `12.78691181488093`;
exports[`补充bug测试#IKWGF 5`] = `0.6246933440840133`; exports[`补充bug测试#IKWGF 5`] = `0.6246933440840137`;
exports[`补充bug测试#IKWGF 6`] = `10.586693752451833`; exports[`补充bug测试#IKWGF 6`] = `10.586693752451833`;
exports[`补充bug测试#IKWGF 7`] = `14.067113755971715`; exports[`补充bug测试#IKWGF 7`] = `14.067113755971711`;
exports[`补充bug测试#IKWGF 8`] = `2.168984971098264`; exports[`补充bug测试#IKWGF 8`] = `2.168984971098264`;
exports[`补充bug测试#IKWGF 9`] = `11.891017922899268`; exports[`补充bug测试#IKWGF 9`] = `11.891017922899273`;
exports[`补充bug测试#IKWGF 10`] = `1.0803374679586222`; exports[`补充bug测试#IKWGF 10`] = `1.0803374679586235`;
exports[`补充bug测试#IKWGF 11`] = `0.394745939838908`; exports[`补充bug测试#IKWGF 11`] = `0.39474593983890816`;
exports[`补充bug测试#IKWGF 12`] = `10.69886845125427`; exports[`补充bug测试#IKWGF 12`] = `10.69886845125427`;

@ -65,7 +65,7 @@ export class DrawBehindBoard extends DrawBoardTool
{ {
let b = board.Clone(); let b = board.Clone();
b.Name = opt.name; b.Name = opt.name;
b.m_BoardProcessOption = Object.assign({}, data.boardProcess); b.BoardProcessOption = data.boardProcess;
if (relPos === BrRelativePos.Front) if (relPos === BrRelativePos.Front)
b.ApplyMatrix(MoveMatrix(newBox.min.clone().add(new Vector3(0, spaceSize * i + (i - 1) * thickness, 0)))); b.ApplyMatrix(MoveMatrix(newBox.min.clone().add(new Vector3(0, spaceSize * i + (i - 1) * thickness, 0))));

@ -118,7 +118,7 @@ export class DrawClosingStrip implements Command
opt.width = br.Width; opt.width = br.Width;
br.Name = opt.name; br.Name = opt.name;
br.m_BoardProcessOption = Object.assign({}, this.store.m_BoardProcessOption); br.BoardProcessOption = this.store.m_BoardProcessOption;
//收口条颜色 //收口条颜色
br.ColorIndex = 4; br.ColorIndex = 4;

@ -48,7 +48,7 @@ export class DrawLayerBoard extends DrawBoardTool
{ {
let b = board.Clone() as Board; let b = board.Clone() as Board;
b.Name = opt.name; b.Name = opt.name;
b.m_BoardProcessOption = Object.assign({}, data.boardProcess); b.BoardProcessOption = data.boardProcess;
if (type === BrRelativePos.Top) if (type === BrRelativePos.Top)
b.ApplyMatrix(MoveMatrix(box.min.clone().add( b.ApplyMatrix(MoveMatrix(box.min.clone().add(

@ -50,10 +50,10 @@ export class DrawLeftRight implements Command
rightBoard.ApplyMatrix(MoveMatrix(vec)); rightBoard.ApplyMatrix(MoveMatrix(vec));
leftBoard.Name = "左侧板" leftBoard.Name = "左侧板"
leftBoard.m_BoardProcessOption = Object.assign({}, store.m_BoardProcessOption); leftBoard.BoardProcessOption = store.m_BoardProcessOption;
rightBoard.Name = "右侧板" rightBoard.Name = "右侧板"
rightBoard.m_BoardProcessOption = Object.assign({}, store.m_BoardProcessOption); rightBoard.BoardProcessOption = store.m_BoardProcessOption;
app.m_Database.ModelSpace.Append(leftBoard); app.m_Database.ModelSpace.Append(leftBoard);
app.m_Database.ModelSpace.Append(rightBoard); app.m_Database.ModelSpace.Append(rightBoard);

@ -21,7 +21,7 @@ export class DrawSingleBoard implements Command
{ {
const opt = store.m_Option; const opt = store.m_Option;
let board = Jig.Draw(Board.CreateBoard(opt.height, opt.width, opt.thickness, opt.type)); let board = Jig.Draw(Board.CreateBoard(opt.height, opt.width, opt.thickness, opt.type));
board.m_BoardProcessOption = store.m_BoardProcessOption; board.BoardProcessOption = store.m_BoardProcessOption;
let rx = Math.degToRad(opt.rotateX); let rx = Math.degToRad(opt.rotateX);
let ry = Math.degToRad(opt.rotateY); let ry = Math.degToRad(opt.rotateY);
let rz = Math.degToRad(opt.rotateZ); let rz = Math.degToRad(opt.rotateZ);

@ -1,6 +1,6 @@
import { Vector3 } from "three"; import { Vector2 } from "three";
import { app } from "../../ApplicationServices/Application"; import { app } from "../../ApplicationServices/Application";
import { curveLinkGroup, Vec3DTo2D } from "../../Common/CurveUtils"; import { curveLinkGroup } from "../../Common/CurveUtils";
import { Board } from "../../DatabaseServices/Board"; import { Board } from "../../DatabaseServices/Board";
import { Circle } from "../../DatabaseServices/Circle"; import { Circle } from "../../DatabaseServices/Circle";
import { Contour } from "../../DatabaseServices/Contour"; import { Contour } from "../../DatabaseServices/Contour";
@ -32,13 +32,11 @@ export async function getEntShape()
export function getViewEntiy(filter?: Filter) export function getViewEntiy(filter?: Filter)
{ {
//屏幕左上角点 //屏幕左上角点
let leftTopPt = new Vector3(); let leftTopPt = new Vector2();
app.m_Viewer.ScreenToWorld(leftTopPt);
//屏幕右下角点 //屏幕右下角点
let rightBottomPt = new Vector3(app.m_Viewer.Width, app.m_Viewer.Height); let rightBottomPt = new Vector2(app.m_Viewer.Width, app.m_Viewer.Height);
app.m_Viewer.ScreenToWorld(rightBottomPt);
let selectBox = new SelectBox(app.m_Viewer, Vec3DTo2D(leftTopPt), Vec3DTo2D(rightBottomPt)); let selectBox = new SelectBox(app.m_Viewer, leftTopPt, rightBottomPt);
selectBox.Select(app.m_Viewer.Scene.children, filter) selectBox.Select(app.m_Viewer.Scene.children, filter)
return selectBox.SelectEntityList; return selectBox.SelectEntityList;
} }
@ -70,9 +68,10 @@ export function getCulistShape(cus: Entity[], isErase = false)
{ {
if ((c instanceof Polyline && c.IsClose) || c instanceof Circle) if ((c instanceof Polyline && c.IsClose) || c instanceof Circle)
{ {
let shape = new Shape(Contour.CreateContour([c.Clone()]));
if (isErase) if (isErase)
c.Erase(); c.Erase();
return new Shape(Contour.CreateContour([c.Clone()])); return shape;
} }
//获得屏幕内的曲线 //获得屏幕内的曲线
let totalCulist = getViewEntiy({ filterTypes: [Curve] }) as Curve[]; let totalCulist = getViewEntiy({ filterTypes: [Curve] }) as Curve[];
@ -89,6 +88,7 @@ export function getCulistShape(cus: Entity[], isErase = false)
let con = Contour.CreateContour(g); let con = Contour.CreateContour(g);
if (con) if (con)
{ {
//TODO:应该在确定绘制后在删除构建曲线
if (isErase) if (isErase)
g.forEach(c => c.Erase()) g.forEach(c => c.Erase())
return new Shape(con); return new Shape(con);

@ -78,7 +78,7 @@ export class DrawSpecialShapedBoard implements Command
//创建板件 //创建板件
let br = Board.CreateBoard(length, width, thickness, store.m_Option.type); let br = Board.CreateBoard(length, width, thickness, store.m_Option.type);
br.Name = store.m_Option.name; br.Name = store.m_Option.name;
br.m_BoardProcessOption = store.m_BoardProcessOption; br.BoardProcessOption = store.m_BoardProcessOption;
br.ApplyMatrix(br.OCSInv); br.ApplyMatrix(br.OCSInv);
br.ApplyMatrix(MoveMatrix(br.MinPoint.negate())); br.ApplyMatrix(MoveMatrix(br.MinPoint.negate()));

@ -138,7 +138,7 @@ export class DrawTopBottomBoard implements Command
let board = Board.CreateBoard(length, width, thickness, BoardType.Layer); let board = Board.CreateBoard(length, width, thickness, BoardType.Layer);
board.m_BoardProcessOption = Object.assign({}, this.store.m_BoardProcessOption); board.BoardProcessOption = this.store.m_BoardProcessOption;
//移动右缩和前距的距离 //移动右缩和前距的距离
basePt.add(new Vector3(rightExt, -frontDist)); basePt.add(new Vector3(rightExt, -frontDist));
@ -153,9 +153,9 @@ export class DrawTopBottomBoard implements Command
if (offset > 0) if (offset > 0)
{ {
let footBoard = Board.CreateBoard(offset, spaceParse.Size.x, opt.footThickness, BoardType.Behind); let footBoard = Board.CreateBoard(offset, spaceParse.Size.x, opt.footThickness, BoardType.Behind);
footBoard.m_BoardProcessOption = Object.assign({}, this.store.m_BoardProcessOption); footBoard.BoardProcessOption = this.store.m_BoardProcessOption;
footBoard.m_BoardProcessOption.composingFace = ComposingType.Reverse; footBoard.BoardProcessOption.composingFace = ComposingType.Reverse;
footBoard.m_BoardProcessOption.bigHoleDir = PXLFaceType.Reverse; footBoard.BoardProcessOption.bigHoleDir = PXLFaceType.Reverse;
footBoard.ApplyMatrix(MoveMatrix(spaceParse.m_SpaceBox.min.add(new Vector3(0, opt.footBehindShrink)))); footBoard.ApplyMatrix(MoveMatrix(spaceParse.m_SpaceBox.min.add(new Vector3(0, opt.footBehindShrink))));
footBoard.ApplyMatrix(spaceParse.m_SpaceOCS); footBoard.ApplyMatrix(spaceParse.m_SpaceOCS);
app.m_Database.ModelSpace.Append(footBoard); app.m_Database.ModelSpace.Append(footBoard);

@ -53,7 +53,7 @@ export class DrawVerticalBoard extends DrawBoardTool
{ {
let b = board.Clone() as Board; let b = board.Clone() as Board;
b.Name = opt.name; b.Name = opt.name;
b.m_BoardProcessOption = Object.assign({}, data.boardProcess); b.BoardProcessOption = data.boardProcess;
if (type === BrRelativePos.Left) if (type === BrRelativePos.Left)
b.ApplyMatrix(MoveMatrix(box.min.clone().add( b.ApplyMatrix(MoveMatrix(box.min.clone().add(

@ -70,7 +70,7 @@ export class DrawDrillingTool
{ {
//偏心轮下偏距离 //偏心轮下偏距离
let pxlOffestDist = this.m_Option.pxlOffset; let pxlOffestDist = this.m_Option.pxlOffset;
let isPostive = this.m_Face.m_InterBoard.m_BoardProcessOption.bigHoleDir === PXLFaceType.Positive; let isPostive = this.m_Face.m_InterBoard.BoardProcessOption.bigHoleDir === PXLFaceType.Positive;
pxlEnt.ApplyMatrix(MoveMatrix( pxlEnt.ApplyMatrix(MoveMatrix(
new Vector3(0, isPostive ? this.m_Face.m_Width - pxlOffestDist : pxlDepth - pxlOffestDist) new Vector3(0, isPostive ? this.m_Face.m_Width - pxlOffestDist : pxlDepth - pxlOffestDist)
)); ));

@ -47,6 +47,9 @@ export namespace CheckoutValid
case "material": case "material":
case "color": case "color":
case "striptype": case "striptype":
case "spliteHeight":
case "spliteWidth":
case "spliteThickness":
return ""; return "";
case "height": case "height":
case "width": case "width":

@ -3,7 +3,7 @@ import { ExtrudeGeometry, Matrix4, Mesh, MeshNormalMaterial, Object3D, Vector2,
import { Box3Ext } from '../Geometry/Box'; import { Box3Ext } from '../Geometry/Box';
import { equaln, rotatePoint } from '../Geometry/GeUtils'; import { equaln, rotatePoint } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/Enum'; import { RenderType } from '../GraphicsSystem/Enum';
import { BoardProcessOption } from '../UI/Store/BoardInterface'; import { BoardProcessOption, LinesType, PXLFaceType, DrillType, ComposingType } from '../UI/Store/BoardInterface';
import { Factory } from './CADFactory'; import { Factory } from './CADFactory';
import { CADFile } from './CADFile'; import { CADFile } from './CADFile';
import { Circle } from './Circle'; import { Circle } from './Circle';
@ -58,7 +58,7 @@ export class Board extends Entity
private m_BoardType: BoardType; private m_BoardType: BoardType;
private m_Name = ""; private m_Name = "";
private m_SpecOCS: Matrix4 = new Matrix4(); //板件的标系 private m_SpecOCS: Matrix4 = new Matrix4(); //板件的标系
m_BoardProcessOption: BoardProcessOption = {}; private m_BoardProcessOption: BoardProcessOption = {};
//板件排钻表,与之碰撞板件为key //板件排钻表,与之碰撞板件为key
private m_DrillList: Map<ObjectId, ObjectId[][]> = new Map(); private m_DrillList: Map<ObjectId, ObjectId[][]> = new Map();
constructor(shape?: Shape, thickness?: number) constructor(shape?: Shape, thickness?: number)
@ -89,6 +89,29 @@ export class Board extends Entity
{ {
let board = new Board(); let board = new Board();
board.InitBoard(length, width, thickness, boardType); board.InitBoard(length, width, thickness, boardType);
board.m_BoardProcessOption = {
roomName: "",
cabinetName: "",
boardName: "",
material: "",
color: "",
lines: LinesType.Positive,
bigHoleDir: PXLFaceType.Positive,
drillType: DrillType.Three,
composingFace: ComposingType.Arbitrary,
highSealed: [],
sealedUp: "1",
sealedDown: "1",
sealedLeft: "1",
sealedRight: "1",
knifeRad: "0",
grooveAddLength: "0",
grooveAddWidth: "0",
grooveAddDepth: "0",
spliteHeight: "",
spliteWidth: "",
spliteThickness: ""
}
let roMat = board.RotateMat let roMat = board.RotateMat
board.ApplyMatrix(roMat); board.ApplyMatrix(roMat);
board.m_SpecOCS.identity(); board.m_SpecOCS.identity();
@ -99,6 +122,16 @@ export class Board extends Entity
{ {
return this.m_DrillList; return this.m_DrillList;
} }
get BoardProcessOption()
{
return this.m_BoardProcessOption;
}
set BoardProcessOption(obj: BoardProcessOption)
{
this.WriteAllObjectRecord();
obj.highSealed = obj.highSealed.slice();
Object.assign(this.m_BoardProcessOption, obj);
}
AppendDrillList(k: ObjectId, drs: ObjectId[][]) AppendDrillList(k: ObjectId, drs: ObjectId[][])
{ {
this.WriteAllObjectRecord(); this.WriteAllObjectRecord();
@ -308,6 +341,12 @@ export class Board extends Entity
this.m_Width = size.x ? size.x : size.z; this.m_Width = size.x ? size.x : size.z;
this.Update(); this.Update();
} }
get IsSpecialShape()
{
let refArea = this.m_Length * this.m_Width;
let cuArea = this.m_Shape.Outline.Area;
return !equaln(refArea, cuArea);
}
get Name() get Name()
{ {
return this.m_Name; return this.m_Name;

@ -1,5 +1,5 @@
import * as THREE from 'three'; import * as THREE from 'three';
import { Box3, Geometry, Matrix4, Object3D, Vector2, Vector3, Matrix3 } from 'three'; import { Box3, Geometry, Matrix4, Object3D, Vector2, Vector3 } from 'three';
import { CreateBoardUtil } from '../ApplicationServices/mesh/createBoard'; import { CreateBoardUtil } from '../ApplicationServices/mesh/createBoard';
import { arrayLast, arrayRemoveDuplicateBySort } from '../Common/ArrayExt'; import { arrayLast, arrayRemoveDuplicateBySort } from '../Common/ArrayExt';
import { ColorMaterial } from '../Common/ColorPalette'; import { ColorMaterial } from '../Common/ColorPalette';
@ -873,6 +873,7 @@ export class Polyline extends Curve
let d1 = this.m_LineData[i]; let d1 = this.m_LineData[i];
let d2 = this.m_LineData[FixIndex(i + 1, this.m_LineData)]; let d2 = this.m_LineData[FixIndex(i + 1, this.m_LineData)];
if (equaln(d1.bul, 0, 1e-8)) if (equaln(d1.bul, 0, 1e-8))
{ {
return new Line(Vec2DTo3D(d1.pt), Vec2DTo3D(d2.pt)).ApplyMatrix(this.OCS); return new Line(Vec2DTo3D(d1.pt), Vec2DTo3D(d2.pt)).ApplyMatrix(this.OCS);

@ -30,7 +30,7 @@ export class Text extends Entity
pos && this.m_Matrix.setPosition(pos); pos && this.m_Matrix.setPosition(pos);
ro && setRotationOnAxis(this.m_Matrix, this.Normal, Math.degToRad(ro)); ro && setRotationOnAxis(this.m_Matrix, this.Normal, Math.degToRad(ro));
this.m_TextString = str || ""; this.m_TextString = str || "";
this.m_Height = h || 0; this.m_Height = h || 60;
this.m_TextRotation = ro || 0; this.m_TextRotation = ro || 0;
} }

@ -238,16 +238,19 @@ export class DBClickPolyline
let groups = curveLinkGroup(cus); let groups = curveLinkGroup(cus);
for (let g of groups) for (let g of groups)
{ {
if (!g.includes(pl)) let i = g.indexOf(pl);
if (i === -1)
continue; continue;
if (i !== 0)
g.unshift(...g.splice(i));
g.shift();
for (let cu of g) for (let cu of g)
{ {
if (cu !== pl) pl.Join(cu);
{ cu.Erase();
pl.Join(cu);
cu.Erase();
}
} }
} }
return PromptStatus.OK; return PromptStatus.OK;

@ -48,6 +48,7 @@ export class DbClickManager
} }
else if (obj3d.userData instanceof Board) else if (obj3d.userData instanceof Board)
{ {
app.m_Editor.m_ModalManage.Clear();
app.m_Editor.m_ModalManage.RenderModeless( app.m_Editor.m_ModalManage.RenderModeless(
BoardOptionModal, BoardOptionModal,
ModalPosition.Right, ModalPosition.Right,

@ -98,5 +98,6 @@ export class Jig
e.GoodBye(); e.GoodBye();
}); });
this.m_JigEnts.length = 0; this.m_JigEnts.length = 0;
app.m_Editor.UpdateScreen();
} }
} }

@ -0,0 +1,32 @@
import { FixIndex } from "../Common/Utils";
import { Curve } from "../DatabaseServices/Curve";
import { Polyline } from "../DatabaseServices/Polyline";
import { IntersectOption } from "./IntersectWith";
import { PolyOffsetUtil } from "./OffsetPolyline";
export function calcEdgeSealing(cus: Curve[])
{
if (cus.length <= 1)
return;
for (let i = 0; i < cus.length; i++)
{
let frontLine = cus[i];
let laterLine = cus[FixIndex(i + 1, cus)];
let iPts = frontLine.IntersectWith(laterLine, IntersectOption.ExtendBoth);
let tPts = iPts.filter(p =>
frontLine.PtOnCurve(p)
&& laterLine.PtOnCurve(p)
);
let iPt = PolyOffsetUtil.selectFitInterPt(tPts.length > 0 ? tPts : iPts, frontLine.EndPoint);
let iPt1 = iPt.clone();
if (frontLine instanceof Polyline)
iPt1.applyMatrix4(frontLine.OCSInv);
frontLine.EndPoint = iPt1;
if (laterLine instanceof Polyline)
iPt.applyMatrix4(laterLine.OCSInv)
laterLine.StartPoint = iPt;
}
}

@ -318,7 +318,7 @@ export class PolyOffsetUtil
if (tPts.length > 0)//存在真交点情况下直接修剪 if (tPts.length > 0)//存在真交点情况下直接修剪
{ {
let iPt = this.selectFitInterPt(tPts, frontLine.EndPoint); let iPt = PolyOffsetUtil.selectFitInterPt(tPts, frontLine.EndPoint);
if (isFillArc) if (isFillArc)
{ {
//用丢失圆弧和交点构建扇形轮廓 //用丢失圆弧和交点构建扇形轮廓
@ -339,7 +339,7 @@ export class PolyOffsetUtil
} }
else //iPts.length > 0 有交点,但是都是假交点. else //iPts.length > 0 有交点,但是都是假交点.
{ {
let iPt = this.selectFitInterPt(iPts, frontLine.EndPoint); let iPt = PolyOffsetUtil.selectFitInterPt(iPts, frontLine.EndPoint);
//通过真假交点连接 //通过真假交点连接
this.checkCuAndAppendList(frontLine, laterLine, iPt, nextStartPt, startIndex, endIndex); this.checkCuAndAppendList(frontLine, laterLine, iPt, nextStartPt, startIndex, endIndex);
} }
@ -450,7 +450,7 @@ export class PolyOffsetUtil
* @param {Curve} frontLine * @param {Curve} frontLine
* @param {Curve} laterLine * @param {Curve} laterLine
* @returns * @returns
* @memberof PolyOffestUtil3 * @memberof PolyOffestUtil
*/ */
fillArc(startIndex: number, endIndex: number, fillArc(startIndex: number, endIndex: number,
nextPt: Vector3, nextPt: Vector3,
@ -490,7 +490,7 @@ export class PolyOffsetUtil
else else
iPts = [frontLine.EndPoint]; iPts = [frontLine.EndPoint];
let iPt = this.selectFitInterPt(iPts, frontLine.EndPoint); let iPt = PolyOffsetUtil.selectFitInterPt(iPts, frontLine.EndPoint);
this.appendNewCuAndContour(frontLine, nextPt, iPt, startIndex); this.appendNewCuAndContour(frontLine, nextPt, iPt, startIndex);
//连接剩下的圆. //连接剩下的圆.
@ -514,7 +514,7 @@ export class PolyOffsetUtil
if (iPtsLater.length > 0)//直接和最后一条连接 if (iPtsLater.length > 0)//直接和最后一条连接
{ {
let iPt = this.selectFitInterPt(iPtsLater, nextPt); let iPt = PolyOffsetUtil.selectFitInterPt(iPtsLater, nextPt);
this.buildArcJoinList(c1, nextPt, iPt, FixIndex(startIndex + 1, this.m_PtCount) === endIndex); this.buildArcJoinList(c1, nextPt, iPt, FixIndex(startIndex + 1, this.m_PtCount) === endIndex);
return; return;
} }
@ -522,7 +522,7 @@ export class PolyOffsetUtil
let c2 = cirs[index + 1]; let c2 = cirs[index + 1];
let iPts = c1.IntersectWith(c2, 0); let iPts = c1.IntersectWith(c2, 0);
let iPt = this.selectFitInterPt(iPts, nextPt); let iPt = PolyOffsetUtil.selectFitInterPt(iPts, nextPt);
this.buildArcJoinList(c1, nextPt, iPt, FixIndex(startIndex + 1, this.m_PtCount) === endIndex); this.buildArcJoinList(c1, nextPt, iPt, FixIndex(startIndex + 1, this.m_PtCount) === endIndex);
} }
@ -679,7 +679,7 @@ export class PolyOffsetUtil
* @returns * @returns
* @memberof PolyOffestUtil * @memberof PolyOffestUtil
*/ */
private selectFitInterPt(pts: Vector3[], refPt: Vector3) static selectFitInterPt(pts: Vector3[], refPt: Vector3)
{ {
if (pts.length > 1) if (pts.length > 1)
{ {

@ -1,8 +1,11 @@
import { Button, Checkbox } from "@blueprintjs/core"; import { Button, Checkbox } from "@blueprintjs/core";
import { IObservableValue, observable } from "mobx";
import * as React from 'react'; import * as React from 'react';
import { Matrix4 } from "three"; import { Matrix4 } from "three";
import { aplicateContour, getEntShape } from "../../../Add-on/DrawBoard/DrawSpecialShapeBoardTool"; import { aplicateContour, getEntShape } from "../../../Add-on/DrawBoard/DrawSpecialShapeBoardTool";
import { app } from "../../../ApplicationServices/Application"; import { app } from "../../../ApplicationServices/Application";
import { CheckObjectType } from "../../../Common/CheckoutVaildValue";
import { DataAdapter } from "../../../Common/DataAdapter";
import { Board } from "../../../DatabaseServices/Board"; import { Board } from "../../../DatabaseServices/Board";
import { commandMachine } from "../../../Editor/CommandMachine"; import { commandMachine } from "../../../Editor/CommandMachine";
import { Jig } from "../../../Editor/Jig"; import { Jig } from "../../../Editor/Jig";
@ -10,15 +13,13 @@ import { PromptStatus } from "../../../Editor/PromptResult";
import { MoveMatrix } from "../../../Geometry/GeUtils"; import { MoveMatrix } from "../../../Geometry/GeUtils";
import { BoardConfigOption, BoardProcessOption } from '../../Store/BoardInterface'; import { BoardConfigOption, BoardProcessOption } from '../../Store/BoardInterface';
import { BoardTypeComponent, ItemName, SetBoardDataBlock } from "./BoardCommon"; import { BoardTypeComponent, ItemName, SetBoardDataBlock } from "./BoardCommon";
import { DataAdapter } from "../../../Common/DataAdapter";
import { observable } from "mobx";
import { CheckObjectType } from "../../../Common/CheckoutVaildValue";
interface BoardConfigProps interface BoardConfigProps
{ {
boardConfig: BoardConfigOption; boardConfig: BoardConfigOption;
boardProcess: BoardProcessOption; boardProcess: BoardProcessOption;
br: Board; br: Board;
isSpecial: IObservableValue<boolean>;
} }
export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
private pars = [["height", "显示高"], ["width", "显示宽"], ["thickness", "显示厚"], private pars = [["height", "显示高"], ["width", "显示宽"], ["thickness", "显示厚"],
@ -46,8 +47,6 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
app.m_Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS); app.m_Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS);
let cu = Jig.Draw(br.Shape.Outline.Curve.Clone().ApplyMatrix(br.OCS)); let cu = Jig.Draw(br.Shape.Outline.Curve.Clone().ApplyMatrix(br.OCS));
let ptRes = await app.m_Editor.GetPoint({ let ptRes = await app.m_Editor.GetPoint({
Msg: "点取位置", Msg: "点取位置",
Callback: v => Callback: v =>
@ -72,7 +71,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
aplicateContour(shape, [br], false); aplicateContour(shape, [br], false);
app.m_Editor.m_ModalManage.ToggleShow(); app.m_Editor.m_ModalManage.ToggleShow();
this.props.isSpecial.set(br.IsSpecialShape);
commandMachine.CommandEnd("selectlk"); commandMachine.CommandEnd("selectlk");
} }
render() render()

@ -19,24 +19,26 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
@observable private m_ConfigOption: SingleBoardOption; @observable private m_ConfigOption: SingleBoardOption;
@observable private m_ProcessOption: BoardProcessOption; @observable private m_ProcessOption: BoardProcessOption;
private m_BoardMap: Map<string, Board> = new Map(); private m_BoardMap: Map<string, Board> = new Map();
private currentBoard: Board; private m_CurrentBoard: Board;
private m_IsSpecialBoard = observable.box(false);
constructor(props) constructor(props)
{ {
super(props); super(props);
this.currentBoard = this.props.board; this.m_CurrentBoard = this.props.board;
this.m_IsSpecialBoard.set(this.props.board.IsSpecialShape);
this.SetBrConfig(); this.SetBrConfig();
this.m_ProcessOption = Object.assign({}, this.currentBoard.m_BoardProcessOption); this.m_ProcessOption = Object.assign({}, this.m_CurrentBoard.BoardProcessOption);
} }
SetBrConfig = () => SetBrConfig = () =>
{ {
let ro = this.currentBoard.Rotation; let ro = this.m_CurrentBoard.Rotation;
let newConfig = { let newConfig = {
name: this.currentBoard.Name, name: this.m_CurrentBoard.Name,
type: this.currentBoard.BoardType, type: this.m_CurrentBoard.BoardType,
height: parseFloat(FixedNotZero(this.currentBoard.Length, 2)), height: parseFloat(FixedNotZero(this.m_CurrentBoard.Length, 2)),
width: parseFloat(FixedNotZero(this.currentBoard.Width, 2)), width: parseFloat(FixedNotZero(this.m_CurrentBoard.Width, 2)),
thickness: parseFloat(FixedNotZero(this.currentBoard.Thickness, 2)), thickness: parseFloat(FixedNotZero(this.m_CurrentBoard.Thickness, 2)),
rotateX: parseFloat(FixedNotZero(Math.radToDeg(ro.x), 2)), rotateX: parseFloat(FixedNotZero(Math.radToDeg(ro.x), 2)),
rotateY: parseFloat(FixedNotZero(Math.radToDeg(ro.y), 2)), rotateY: parseFloat(FixedNotZero(Math.radToDeg(ro.y), 2)),
rotateZ: parseFloat(FixedNotZero(Math.radToDeg(ro.z), 2)), rotateZ: parseFloat(FixedNotZero(Math.radToDeg(ro.z), 2)),
@ -61,8 +63,8 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
commandMachine.m_CommandIng = true; commandMachine.m_CommandIng = true;
app.m_Database.hm.StartCmd("changeSize"); app.m_Database.hm.StartCmd("changeSize");
let board = this.currentBoard; let board = this.m_CurrentBoard;
Object.assign(board.m_BoardProcessOption, this.m_ProcessOption); board.BoardProcessOption = this.m_ProcessOption;
board.Name = this.m_ConfigOption.name; board.Name = this.m_ConfigOption.name;
board.Length = this.m_ConfigOption.height; board.Length = this.m_ConfigOption.height;
@ -82,7 +84,6 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
{ {
board.RotateBoard(newRoX, newRoY, newRoZ); board.RotateBoard(newRoX, newRoY, newRoZ);
} }
app.m_Editor.UpdateScreen();
app.m_Editor.m_ModalManage.Clear(); app.m_Editor.m_ModalManage.Clear();
commandMachine.CommandEnd("changeSize"); commandMachine.CommandEnd("changeSize");
@ -95,7 +96,7 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
let br = en.userData; let br = en.userData;
if (en.visible && br if (en.visible && br
&& br instanceof Board && br.Id && br instanceof Board && br.Id
&& br.m_BoardProcessOption.roomName === this.props.board.m_BoardProcessOption.roomName) && br.BoardProcessOption.roomName === this.props.board.BoardProcessOption.roomName)
{ {
this.m_BoardMap.set(br.Id.Index.toString(), br); this.m_BoardMap.set(br.Id.Index.toString(), br);
} }
@ -128,13 +129,13 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
> >
<div className={Classes.CARD}> <div className={Classes.CARD}>
<HTMLSelect <HTMLSelect
style={{ width: "15rem" }} className="option-header"
defaultValue={this.props.board.Id.Index.toString()} defaultValue={this.props.board.Id.Index.toString()}
options={ options={
Array.from(this.m_BoardMap.values()).map(b => Array.from(this.m_BoardMap.values()).map(b =>
{ {
return { return {
label: "板件名" + b.Name + "柜名" + b.m_BoardProcessOption.boardName, label: "板件名" + b.Name + "柜名" + b.BoardProcessOption.boardName,
value: b.Id.Index.toString() value: b.Id.Index.toString()
} }
}) })
@ -143,16 +144,25 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
{ {
let br = this.m_BoardMap.get(e.target.value); let br = this.m_BoardMap.get(e.target.value);
this.SetBrConfig(); this.SetBrConfig();
Object.assign(this.m_ProcessOption, br.m_BoardProcessOption); Object.assign(this.m_ProcessOption, br.BoardProcessOption);
}} }}
/> />
</div> </div>
<div className="flex"> <div className="flex">
<div className={Classes.CARD}> <div className={Classes.CARD}>
<BoardConfigModal boardConfig={this.m_ConfigOption} boardProcess={this.m_ProcessOption} br={this.props.board} /> <BoardConfigModal
boardConfig={this.m_ConfigOption}
boardProcess={this.m_ProcessOption}
br={this.props.board}
isSpecial={this.m_IsSpecialBoard}
/>
</div> </div>
<div className={Classes.CARD}> <div className={Classes.CARD}>
<BoardProcessModal opt={this.m_ProcessOption} /> <BoardProcessModal
opt={this.m_ProcessOption}
br={this.props.board}
isSpecial={this.m_IsSpecialBoard}
/>
</div> </div>
<div className={Classes.CARD}> <div className={Classes.CARD}>
<Notes /> <Notes />

@ -2,169 +2,194 @@ import { Classes, HTMLSelect } from '@blueprintjs/core';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import { CheckObjectType } from '../../../Common/CheckoutVaildValue'; import { CheckObjectType } from '../../../Common/CheckoutVaildValue';
import { Board } from '../../../DatabaseServices/Board';
import { BoardProcessOption, ComposingType, DrillType, LinesType, PXLFaceType } from '../../Store/BoardInterface'; import { BoardProcessOption, ComposingType, DrillType, LinesType, PXLFaceType } from '../../Store/BoardInterface';
import { ToasterInput } from '../Toaster'; import { ToasterInput } from '../Toaster';
import { BoardModel, SetBoardDataBlock, SetBoardDataItem } from './BoardCommon'; import { BoardModel, SetBoardDataBlock, SetBoardDataItem } from './BoardCommon';
import { EdgeSealingComponent } from './EdgeSealingComponent';
import { Circle } from '../../../DatabaseServices/Circle';
import { IObservableValue } from 'mobx';
export const BoardProcessModal = observer(({ opt }: { opt: BoardProcessOption }) => interface BoardProcessProps
{ {
let matPars = [ opt: BoardProcessOption;
isSpecial?: IObservableValue<boolean>;
br?: Board;
}
@observer
export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
private matPars = [
["boardName", "板材名"], ["material", "材料"], ["color", "颜色"] ["boardName", "板材名"], ["material", "材料"], ["color", "颜色"]
]; ];
return ( render()
<div className="board-info"> {
<SetBoardDataItem let isShowHighEditor = this.props.br
type={CheckObjectType.BR} && !(this.props.br.Shape.Outline.Curve instanceof Circle)
optKey="roomName" && this.props.isSpecial.get();
option={opt}
title="房间名" return (
placeHolder="输入房间名" <div className="board-info">
/> <SetBoardDataItem
<SetBoardDataItem
type={CheckObjectType.BR}
optKey="cabinetName"
option={opt}
title="柜名"
placeHolder="输入柜名"
/>
<div className="flex br-mat">
<SetBoardDataBlock
type={CheckObjectType.BR} type={CheckObjectType.BR}
pars={matPars} optKey="roomName"
option={opt} option={this.props.opt}
isInline={true} title="房间名"
placeHolder="输入房间名"
/> />
<button className="bp3-button bp3-intent-success"></button> <SetBoardDataItem
</div>
<div>
<label className="bp3-label bp3-inline .modifier">
<span></span>
<HTMLSelect
value={opt.lines.toString()}
options={
[
{
label: "正纹",
value: LinesType.Positive.toString()
},
{
label: "反纹",
value: LinesType.Reverse.toString()
},
{
label: "可翻转",
value: LinesType.CanReversal.toString()
},
]
}
onChange={e =>
{
opt.lines = parseFloat(e.target.value);
}}
/>
</label>
<label className="bp3-label bp3-inline .modifier">
<span></span>
<HTMLSelect
value={opt.bigHoleDir.toString()}
options={
[
{
label: "正",
value: PXLFaceType.Positive.toString()
},
{
label: "反",
value: PXLFaceType.Reverse.toString()
}
]
}
onChange={e =>
{
opt.bigHoleDir = parseFloat(e.target.value);
}}
/>
</label>
<label className="bp3-label bp3-inline .modifier">
<span></span>
<HTMLSelect
value={opt.drillType}
options={
[
{
label: "三合一",
value: DrillType.Three
},
{
label: "二合一",
value: DrillType.Two
},
{
label: "不排",
value: DrillType.None
}
]
}
onChange={e =>
{
opt.drillType = e.target.value as DrillType;
}}
/>
</label>
<label className="bp3-label bp3-inline .modifier">
<span></span>
<HTMLSelect
value={opt.composingFace.toString()}
options={
[
{
label: "正面",
value: ComposingType.Positive.toString()
},
{
label: "反面",
value: ComposingType.Reverse.toString()
},
{
label: "随意面",
value: ComposingType.Arbitrary.toString()
}
]
}
onChange={e =>
{
opt.composingFace = parseFloat(e.target.value);
}}
/>
</label>
</div>
<h6 className={Classes.HEADING}></h6>
<div className="boardSize center">
<ToasterInput
type={CheckObjectType.BR} type={CheckObjectType.BR}
optKey="sealedUp" optKey="cabinetName"
option={opt} option={this.props.opt}
title="柜名"
placeHolder="输入柜名"
/> />
<div className="flex br-mat">
<SetBoardDataBlock
type={CheckObjectType.BR}
pars={this.matPars}
option={this.props.opt}
isInline={true}
/>
<button className="bp3-button bp3-intent-success"></button>
</div>
<div> <div>
<label className="bp3-label bp3-inline .modifier">
<span></span>
<HTMLSelect
value={this.props.opt.lines.toString()}
options={
[
{
label: "正纹",
value: LinesType.Positive.toString()
},
{
label: "反纹",
value: LinesType.Reverse.toString()
},
{
label: "可翻转",
value: LinesType.CanReversal.toString()
},
]
}
onChange={e =>
{
this.props.opt.lines = parseFloat(e.target.value);
}}
/>
</label>
<label className="bp3-label bp3-inline .modifier">
<span></span>
<HTMLSelect
value={this.props.opt.bigHoleDir.toString()}
options={
[
{
label: "正",
value: PXLFaceType.Positive.toString()
},
{
label: "反",
value: PXLFaceType.Reverse.toString()
}
]
}
onChange={e =>
{
this.props.opt.bigHoleDir = parseFloat(e.target.value);
}}
/>
</label>
<label className="bp3-label bp3-inline .modifier">
<span></span>
<HTMLSelect
value={this.props.opt.drillType}
options={
[
{
label: "三合一",
value: DrillType.Three
},
{
label: "二合一",
value: DrillType.Two
},
{
label: "不排",
value: DrillType.None
}
]
}
onChange={e =>
{
this.props.opt.drillType = e.target.value as DrillType;
}}
/>
</label>
<label className="bp3-label bp3-inline .modifier">
<span></span>
<HTMLSelect
value={this.props.opt.composingFace.toString()}
options={
[
{
label: "正面",
value: ComposingType.Positive.toString()
},
{
label: "反面",
value: ComposingType.Reverse.toString()
},
{
label: "随意面",
value: ComposingType.Arbitrary.toString()
}
]
}
onChange={e =>
{
this.props.opt.composingFace = parseFloat(e.target.value);
}}
/>
</label>
</div>
<h6 className={"edge-sealing " + Classes.HEADING}>
{
isShowHighEditor ? (
<EdgeSealingComponent br={this.props.br} />
)
: null
}
</h6>
<div className="boardSize center" style={{ display: isShowHighEditor ? "none" : "block" }}>
<ToasterInput <ToasterInput
type={CheckObjectType.BR} type={CheckObjectType.BR}
optKey="sealedLeft" optKey="sealedUp"
option={opt} option={this.props.opt}
/> />
<BoardModel /> <div>
<ToasterInput
type={CheckObjectType.BR}
optKey="sealedLeft"
option={this.props.opt}
/>
<BoardModel />
<ToasterInput
type={CheckObjectType.BR}
optKey="sealedRight"
option={this.props.opt}
/>
</div>
<ToasterInput <ToasterInput
type={CheckObjectType.BR} type={CheckObjectType.BR}
optKey="sealedRight" optKey="sealedDown"
option={opt} option={this.props.opt}
/> />
</div> </div>
<ToasterInput
type={CheckObjectType.BR}
optKey="sealedDown"
option={opt}
/>
</div> </div>
</div> )
) }
}) }

@ -0,0 +1,218 @@
import { Button, Classes, Intent, Popover } from '@blueprintjs/core';
import { observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
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 { Jig } from '../../../Editor/Jig';
import { calcEdgeSealing } from '../../../GraphicsSystem/CalcEdgeSealing';
@observer
export class EdgeSealingComponent extends React.Component<{ br: Board }, {}>
{
private ulList: HTMLUListElement;
@observable private cuList: Curve[] = [];
constructor(props)
{
super(props);
}
private EditorEdgeSealing = () =>
{
let br = this.props.br;
let cus = br.Shape.Outline.Curve.Explode() as Curve[];
this.ParagraphCulist(cus);
app.m_Viewer.m_CameraCtrl.LookAt(br.Normal.negate());
app.m_Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS);
app.m_Editor.UpdateScreen();
Jig.Destroy();
for (let i = 0; i < this.cuList.length; i++)
{
let cu = this.cuList[i];
let p = cu.GetPointAtParam(cu.EndParam / 2);
Jig.Draw(new Text(p, (i + 1).toString()).ApplyMatrix(br.OCS));
//显示对应设置的边
let refCu = cu.Clone();
refCu.ColorIndex = i + 1
Jig.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;
highSeal.length = 0;
infoEls.forEach(el =>
{
let size = parseFloat((el as HTMLInputElement).value);
highSeal.push({
size
})
edgeSealingNum.push(size * dir);
});
let calcCus = this.cuList;
let offsetCus: Curve[] = [];
for (let i = 0; i < calcCus.length; i++)
{
let cu = calcCus[i];
offsetCus.push(...cu.GetOffsetCurves(edgeSealingNum[i]));
}
calcEdgeSealing(offsetCus);
this.ShowSealingResult(offsetCus);
}
private ShowSealingResult = (offsetCus: Curve[]) =>
{
offsetCus.forEach((cu, i) =>
{
cu.ApplyMatrix(this.props.br.OCS);
Jig.Draw(cu);
})
app.m_Editor.UpdateScreen();
}
render()
{
let highSeal = this.props.br.BoardProcessOption.highSealed;
//兼容以前没有这个属性的版本
if (!highSeal)
{
this.props.br.BoardProcessOption.highSealed = [];
highSeal = [];
}
return (
<Popover
usePortal={false}
modifiers={{
arrow: { enabled: false },
flip: { enabled: true },
keepTogether: { enabled: true },
preventOverflow: { enabled: true, boundariesElement: "scrollParent" }
}}
content={
<div tabIndex={-1} className={Classes.CARD}>
<h6 className={Classes.HEADING}></h6>
<ul
className={Classes.LIST_UNSTYLED}
ref={el => this.ulList = el}
>
{
this.cuList.map((cu, i) =>
{
let defaultValue = "1.0";
if (highSeal.length > 0)
defaultValue = highSeal[i] ? highSeal[i].size.toString() : "1";
return (
<li>
<label className="bp3-label bp3-inline .modifier">
{"封边(" + (i + 1).toString() + ")"}
<input
defaultValue={defaultValue}
className="bp3-input"
placeholder="输入封边大小"
dir="auto" />
</label>
</li>
)
})
}
</ul>
<div style={{ display: "flex", justifyContent: "flex-end", marginTop: 15 }}>
<Button
onClick={this.CalcEdgeSealing}
text="确定"
className={Classes.POPOVER_DISMISS}
intent={Intent.SUCCESS}
style={{ marginRight: 10 }} />
<Button
text="取消"
onClick={() => Jig.Destroy()}
intent={Intent.DANGER}
className={Classes.POPOVER_DISMISS} />
</div>
</div>
}
target={
<Button
onClick={this.EditorEdgeSealing}
text="高级编辑"
intent="success"
/>
}
/>
)
}
}

@ -132,3 +132,32 @@
width: 5.5rem; width: 5.5rem;
} }
} }
#boardModal .edge-sealing span>button{
height: 14px;
font-size: 7px;
width: 6rem;
padding-top: 0px;
padding-bottom: 0px;
min-height: 14px;
}
#boardModal .edge-sealing{
display: flex;
justify-content: space-between;
margin-top: 10px;
ul{
padding: 10px;
}
.bp3-input{
width: 10rem;
}
}
#boardModal .bp3-dialog-body .option-header{
width: 15rem;
&>select{
height: 2rem;
}
.bp3-icon{
top: 4px;
}
}

@ -5,6 +5,7 @@ import { KeyBoard } from '../../../Common/KeyEnum';
import { Sleep } from '../../../Common/Utils'; import { Sleep } from '../../../Common/Utils';
import { commandMachine } from '../../../Editor/CommandMachine'; import { commandMachine } from '../../../Editor/CommandMachine';
import './ModalStyle/Modal.less'; import './ModalStyle/Modal.less';
import { Jig } from '../../../Editor/Jig';
export enum ModalPosition export enum ModalPosition
{ {
@ -207,6 +208,7 @@ export class ModalManage
this.m_IsModal = false; this.m_IsModal = false;
this.events.forEach(f => f()); this.events.forEach(f => f());
this.events.length = 0; this.events.length = 0;
Jig.Destroy();
} }
EndCmd() EndCmd()
{ {

@ -79,6 +79,7 @@ export interface BoardProcessOption extends BoardOption
bigHoleDir?: PXLFaceType;//大孔面 bigHoleDir?: PXLFaceType;//大孔面
drillType?: DrillType;//排钻类型 drillType?: DrillType;//排钻类型
composingFace?: ComposingType;//排版面 composingFace?: ComposingType;//排版面
highSealed?: { size: number, color?: number }[];
sealedUp?: string;//封边上下左右 sealedUp?: string;//封边上下左右
sealedDown?: string; sealedDown?: string;
sealedLeft?: string; sealedLeft?: string;

@ -24,10 +24,11 @@ export class BoardStore
bigHoleDir: PXLFaceType.Positive, bigHoleDir: PXLFaceType.Positive,
drillType: DrillType.Three, drillType: DrillType.Three,
composingFace: ComposingType.Arbitrary, composingFace: ComposingType.Arbitrary,
sealedUp: "1.0", highSealed: [],
sealedDown: "1.0", sealedUp: "1",
sealedLeft: "1.0", sealedDown: "1",
sealedRight: "1.0", sealedLeft: "1",
sealedRight: "1",
knifeRad: "0", knifeRad: "0",
grooveAddLength: "0", grooveAddLength: "0",
grooveAddWidth: "0", grooveAddWidth: "0",
@ -44,11 +45,11 @@ export class BoardStore
} }
GetBoardProcessOption(br: Board) GetBoardProcessOption(br: Board)
{ {
this.m_BoardProcessOption.roomName = br.m_BoardProcessOption.roomName; this.m_BoardProcessOption.roomName = br.BoardProcessOption.roomName;
this.m_BoardProcessOption.boardName = br.m_BoardProcessOption.boardName; this.m_BoardProcessOption.boardName = br.BoardProcessOption.boardName;
this.m_BoardProcessOption.material = br.m_BoardProcessOption.material; this.m_BoardProcessOption.material = br.BoardProcessOption.material;
this.m_BoardProcessOption.cabinetName = br.m_BoardProcessOption.cabinetName; this.m_BoardProcessOption.cabinetName = br.BoardProcessOption.cabinetName;
this.m_BoardProcessOption.color = br.m_BoardProcessOption.color; this.m_BoardProcessOption.color = br.BoardProcessOption.color;
} }
async OnOk(state: number, isClose: boolean = true) async OnOk(state: number, isClose: boolean = true)
{ {

Loading…
Cancel
Save