!237 重构板件,分离出拉伸实体

Merge pull request !237 from ChenX/Extrude
pull/237/MERGE
ChenX 6 years ago
parent 5c39e4b0a5
commit 0716cd3533

@ -0,0 +1,14 @@
import { Region } from "../../src/DatabaseServices/Region";
import { LoadRegionsFromFileData } from "../Utils/LoadEntity.util";
import { BoolOpeartionType } from "../../src/GraphicsSystem/BoolOperateUtils";
test("#IRFL2面域消失", () =>
{
let data =
[2, "Region", 2, 1, 102, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -284.847850497852, -347.14497813089565, 0, 1], 1, 1, 1, 1, 1, "Polyline", 2, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -284.847850497852, -347.14497813089565, 0, 1], 0, 2, 4, [258.7734554093699, 1.1368683772161603e-13], 0, [674.3301771838924, 5.684341886080802e-14], 0, [674.3301771838924, 1091.0460568668868], 0, [258.7734554093699, 1091.0460568668868], 0, true, 0, "Region", 2, 1, 103, false, 7, 0, [-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 389.4823496974607, -74.09892126400852, 0, 1], 1, 1, 1, 1, 1, "Polyline", 2, 1, 0, false, 7, 0, [-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 389.4823496974607, -74.09892126400852, 0, 1], 0, 2, 4, [0, 0], 0, [415.5567321777343, 0], 0, [415.5567321777343, 18], 0, [0, 18], 0, true, 0]
let regs: Region[] = LoadRegionsFromFileData(data);
expect(regs.length).toBe(2);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Intersection);
expect(regs[0].ShapeManager.ShapeList.length).toBe(2);
});

@ -6,7 +6,7 @@ import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util";
function testBrSealing(br: Board, sealingSize: number[])
{
let originCurve = br.Shape.Outline.Curve;
let originCurve = br.ContourCurve;
let dir = Math.sign(originCurve.Area2) * -1;
let calcCus = originCurve.Explode() as Curve[];
paragraphCulist(calcCus);
@ -31,14 +31,14 @@ function testBrSealing(br: Board, sealingSize: number[])
test("常规板件,常规坐标系", () =>
{
let data =
[1, "Board", 1, 1, 0, false, 7, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 145.29914529914527, -290.5982905982906, 0, 1], 1, 1, "Polyline", 1, 1, 0, false, 7, 0, [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, 0]
[1, "Board", 2, 1, 0, false, 7, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 145.29914529914527, -290.5982905982906, 0, 1], 0, 1, 1200, 600, 1, true, "Polyline", 2, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, null, null, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], null, "", "{\"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]
let layerBr = LoadBoardsFromFileData(data)[0];
let sealingSize = [1, 1, 1, 1];
testBrSealing(layerBr, sealingSize);
sealingSize = [3, 2, 3, 2];
testBrSealing(layerBr, sealingSize);
data =
[1, "Board", 1, 1, 0, false, 7, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -292.022792022792, -213.67521367521368, 0, 1], 1, 1, "Polyline", 1, 1, 0, false, 7, 0, [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, 0]
[1, "Board", 2, 1, 0, false, 7, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -292.022792022792, -213.67521367521368, 0, 1], 0, 1, 1200, 600, 1, true, "Polyline", 2, 1, 0, false, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true, 0, null, null, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], null, "", "{\"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]
let vBr = LoadBoardsFromFileData(data)[0];
sealingSize = [2, 2, 2, 2];
testBrSealing(vBr, sealingSize);
@ -47,7 +47,7 @@ test("常规板件,常规坐标系", () =>
test("异型板件,常规坐标系", () =>
{
let data =
[1, "Board", 1, 1, 0, false, 7, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 3681.8686077049847, -1396.263281011676, 0, 1], 1, 1, "Polyline", 1, 1, 0, true, 7, 0, [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, 0]
[1, "Board", 2, 1, 0, false, 7, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 3681.8686077049847, -1396.263281011676, 0, 1], 0, 1, 1336.1737079222257, 2039.4230278812934, 1, false, "Polyline", 2, 1, 0, true, 7, 0, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 1396.2632810116759, 3681.8686077049847, 0, 1], 0, 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, null, null, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], null, "", "{\"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]
//第三段为圆弧
let br = LoadBoardsFromFileData(data)[0];
let sealingSize = [1, 1, 1];
@ -58,7 +58,7 @@ test("异型板件,常规坐标系", () =>
testBrSealing(br, sealingSize);
// 2,4,6,8段为圆弧
data =
[1, "Board", 1, 1, 0, false, 7, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 6239.212423224621, -1330.0896939146003, 0, 1], 1, 1, "Polyline", 1, 1, 0, true, 7, 0, [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, 0]
[1, "Board", 2, 1, 0, false, 7, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 6239.212423224621, -1330.0896939146003, 0, 1], 0, 1, 1275.546950115211, 2125.911583525353, 1, false, "Polyline", 2, 1, 0, true, 7, 0, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 1330.0896939146, 6239.212423224621, 0, 1], 0, 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, null, null, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], null, "", "{\"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]
br = LoadBoardsFromFileData(data)[0];
sealingSize = [1];
testBrSealing(br, sealingSize);
@ -69,7 +69,7 @@ test("异型板件,常规坐标系", () =>
test("异型板件,非常规坐标系", () =>
{
let data =
[1, "Board", 1, 1, 0, false, 7, 0, [0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0, 15844.064994449893, 0, -2833.834144511985, 1], 1, 1, "Polyline", 1, 1, 0, true, 7, 0, [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, 0]
[1, "Board", 2, 1, 0, false, 7, 0, [0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0, 15844.064994449893, 0, -2833.834144511985, 1], 0, 1, 10835.306755747779, 7823.377849356992, 1, false, "Polyline", 2, 1, 0, true, 7, 0, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 2833.8341445119845, 15844.064994449893, 0, 1], 0, 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, null, null, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], null, "", "{\"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,4段为圆弧
let br = LoadBoardsFromFileData(data)[0];
let sealingSize = [1, 1, 1, 1, 1, 1];

File diff suppressed because one or more lines are too long

@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`changev 1`] = `"[1,101,1,1,1,false,1,\\"\\",1,2,false,1,\\"Line\\",1,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[2,3,4],[0,0,0],1,4,false,1,0,1,3,false,1,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",1,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[1,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"\\",\\"\\",100]"`;
exports[`changev 1`] = `"[1,101,1,1,1,false,1,\\"\\",1,2,false,1,\\"Line\\",2,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[2,3,4],[0,0,0],1,4,false,1,0,1,3,false,1,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",2,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[2,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[0,0,0],[0,0,0]],\\"\\",\\"\\",100]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[1,101,1,1,1,false,1,\\"\\",1,2,false,1,\\"Line\\",1,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[1,2,3],[0,0,0],1,4,false,1,0,1,3,false,1,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",1,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[1,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"AllObjectData\\",1,[1,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[1,2,3],[0,0,0]],\\"\\",100]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[1,101,1,1,1,false,1,\\"\\",1,2,false,1,\\"Line\\",2,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,1,[1,2,3],[0,0,0],1,4,false,1,0,1,3,false,1,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",2,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[2,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,1,[0,0,0],[0,0,0]],\\"AllObjectData\\",1,[2,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,1,[1,2,3],[0,0,0]],\\"\\",100]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 2`] = `"[\\"HistoricManage\\",1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",1,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[1,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]],\\"AllObjectData\\",1,[1,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[1,2,3],[0,0,0]],\\"\\",100]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 2`] = `"[\\"HistoricManage\\",1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",2,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[2,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,1,[0,0,0],[0,0,0]],\\"AllObjectData\\",1,[2,1,100,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,1,[1,2,3],[0,0,0]],\\"\\",100]"`;
exports[`测试创建 1`] = `"[\\"AllObjectData\\",1,[]]"`;
@ -16,7 +16,7 @@ exports[`测试创建 4`] = `"[\\"CreateObjectData\\",1,[]]"`;
exports[`测试创建 5`] = `"[\\"HistorycRecord\\",1,\\"\\",\\"\\",\\"\\"]"`;
exports[`测试创建 6`] = `"[\\"Line\\",1,1,0,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],1,[0,0,0],[0,0,0]]"`;
exports[`测试创建 6`] = `"[\\"Line\\",2,1,0,false,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[0,0,0],[0,0,0]]"`;
exports[`测试创建 7`] = `"[\\"ObjectAllDataHistoryRecord\\",1,1,\\"\\",\\"\\",\\"\\",0]"`;

@ -84,7 +84,7 @@ export class LinearCutting implements Command
else
nnpts = [pts.map(p => p.clone())];
let brContour = br.Shape.Outline.Curve.Clone() as Polyline;//提取轮廓
let brContour = br.ContourCurve.Clone() as Polyline;//提取轮廓
let brOCSInv = br.OCSInv;
let allSplitPls: Polyline[] = [];
@ -137,16 +137,10 @@ export class LinearCutting implements Command
for (let i = 1; i < cus.length; i++)
{
let br2 = br.Clone();
let sp = br2.Shape;
sp.Outline = Contour.CreateContour([cus[i]]);
br2.Shape = sp;
br2.ContourCurve = cus[i];
app.m_Database.ModelSpace.Append(br2);
}
let sp = br.Shape.Clone();
sp.Outline = Contour.CreateContour([cus[0]]);
br.Shape = sp;
br.ContourCurve = cus[0];
}
}
}

@ -1,16 +1,7 @@
import { Box3, Matrix4, Mesh, Vector3 } from "three";
import { app } from "../../ApplicationServices/Application";
import { ToFixed } from "../../Common/Utils";
import { Board } from "../../DatabaseServices/Board";
import { Contour } from "../../DatabaseServices/Contour";
import { Point } from "../../DatabaseServices/Point";
import { Polyline } from "../../DatabaseServices/Polyline";
import { Shape } from "../../DatabaseServices/Shape";
import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { equalv3, isParallelTo } from "../../Geometry/GeUtils";
import ThreeBSP, { Polygon } from "../../Geometry/ThreeCSG";
import { FaceDirection } from "../../UI/Store/BoardInterface";
export class NonAssociativeCutting implements Command
{
@ -52,200 +43,19 @@ export class NonAssociativeCutting implements Command
async CuttingBoard(orgBoard: Board, cutBoards: Board[])
{
let orgNormal = orgBoard.Normal;
let orgOcsInv = orgBoard.OCSInv;
let orgModeling = orgBoard.BoardModeling;
let mesh = orgBoard.Draw() as Mesh;
let csgOrg = new ThreeBSP(mesh);
for (let br of cutBoards)
{
if (isParallelTo(br.Normal, orgNormal))
{
let brP = br.Position.applyMatrix4(orgOcsInv);
let brz = [brP.z];
let faceDir: FaceDirection;
let thickness: number = 0;
if (equalv3(br.Normal, orgNormal))
brz.unshift(brP.z - br.Thickness);
else
brz.push(brP.z + br.Thickness);
if (brz[0] <= -(orgBoard.Thickness + 1e-2))
{
faceDir = FaceDirection.Back;
thickness = brz[1] + orgBoard.Thickness;
}
else if (brz[1] >= -1e-3 && brz[0] < 0)
{
faceDir = FaceDirection.Front;
thickness = 0 - brz[0];
}
if (thickness < 0.1)
continue;
let cu = br.Shape.Outline.Curve.Clone();
cu.ApplyMatrix(br.OCS)
.ApplyMatrix(orgOcsInv);
orgModeling.push({
shape: new Shape(Contour.CreateContour([cu])),
thickness,
dir: faceDir,
rad: 0,
addLen: 0
});
}
else
{
let mesh2 = br.Draw() as THREE.Mesh;
let csg2 = new ThreeBSP(mesh2);
let ncsg = csgOrg.intersect(csg2);
let polys = ncsg.tree.allPolygons();
let topology = new TopologyParse();
for (let p of polys)
topology.Add(p);
let yv = br.Normal;
let zv = orgNormal;
let xv = yv.clone().cross(zv);
let m = new Matrix4().makeBasis(xv, yv, zv).copyPosition(orgBoard.OCS);
let mi = new Matrix4().getInverse(m);
for (let pts of topology.Parse())
{
for (let p of pts)
p.applyMatrix4(mi);
let box = new Box3().setFromPoints(pts);
let faceDir: FaceDirection;
let thickness: number = 0;
if (box.min.z <= -(orgBoard.Thickness + 1e-2))
{
faceDir = FaceDirection.Back;
thickness = box.max.z + orgBoard.Thickness;
}
else if (box.max.z >= -1e-3 && box.min.z < 0)
{
faceDir = FaceDirection.Front;
thickness = 0 - box.min.z;
}
if (thickness < 0.1)
continue;
let pl = new Polyline().Create2Pt(box.min, box.max)
.ApplyMatrix(m).ApplyMatrix(orgOcsInv);
orgModeling.push({
shape: new Shape(Contour.CreateContour([pl])),
thickness,
dir: faceDir,
rad: 0,
addLen: 0
});
}
}
}
orgBoard.BoardModeling = orgModeling;
orgBoard.UpdateBoardShape();
}
}
interface Vec3
{
x: number;
y: number;
z: number;
}
class TopologyParse
{
constructor(public fractionDigits = 1)
{
}
Add(poly: Polygon)
{
let strs = poly.vertices.map(p => this.GenerateP(p));
let str0 = strs[0];
let s0 = this.Get(str0);
for (let i = 1; i < strs.length; i++)
{
let stri = strs[i];
s0.add(stri);
this.Get(stri).add(str0);
let gs = orgBoard.ConverToLocalGroove(br);
for (let g of gs)
orgBoard.AppendGroove(g);
}
}
Parse(): Vector3[][]
{
let set = new Set([...this.map.keys()]);
let splitBoard: Board[] = [];
orgBoard.GrooveCheckAll(splitBoard);
let res: Vector3[][] = [];
while (set.size > 0)
for (let br of splitBoard)
{
let fp = set[Symbol.iterator]().next().value;
set.delete(fp);
let cset = new Set();
cset.add(fp);
this.GetPts(fp, cset, set);
let pts = [...cset].map(str =>
{
let v3 = this.vecMap.get(str);
return new Vector3(v3.x, v3.y, v3.z);
});
res.push(pts);
app.m_Database.ModelSpace.Append(br);
}
return res;
}
private map = new Map<string, Set<string>>();
private Get(vstr: string): Set<string>
{
if (!this.map.has(vstr))
{
let s = new Set();
this.map.set(vstr, s);
return s;
}
return this.map.get(vstr);
}
private GetPts(p: string, cset: Set<string>, oset: Set<string>)
{
let strs = this.map.get(p);
for (let str of strs)
{
if (!cset.has(str))
{
cset.add(str);
oset.delete(str);
this.GetPts(str, cset, oset);
}
}
}
private vecMap = new Map();
private GenerateP(v: Vec3)
{
let str = [v.x, v.y, v.z].map(n => ToFixed(n, this.fractionDigits)).join(",");
this.vecMap.set(str, v);
return str;
}
}

@ -25,7 +25,7 @@ export class FeedingCommand implements Command
.filter((br: Board) => br.BoardModeling.length > 0) as Board[];
if (brs.length > 0)
{
let feedingTool = FeedingToolPath.GetInstance();
let feedingTool = FeedingToolPath.GetInstance() as FeedingToolPath;
let retCus = brs.map(br => feedingTool.CalcPath(br));

@ -113,7 +113,7 @@ export class DrawClosingStrip implements Command
}
opt.type = br.BoardType;
opt.height = br.Length;
opt.height = br.Height;
opt.width = br.Width;
br.Name = opt.name;

@ -1,110 +1,16 @@
import { Vector2, Matrix4 } from "three";
import { Matrix4, Vector3 } from "three";
import { app } from "../../ApplicationServices/Application";
import { arrayRemove } from "../../Common/ArrayExt";
import { curveLinkGroup } from "../../Common/CurveUtils";
import { Board } from "../../DatabaseServices/Board";
import { Circle } from "../../DatabaseServices/Circle";
import { Contour } from "../../DatabaseServices/Contour";
import { Curve } from "../../DatabaseServices/Curve";
import { Entity } from "../../DatabaseServices/Entity";
import { ExtureContour, ExtureContourCurve, ExtureSolid } from "../../DatabaseServices/Extrude";
import { Polyline } from "../../DatabaseServices/Polyline";
import { Region } from "../../DatabaseServices/Region";
import { Shape } from "../../DatabaseServices/Shape";
import { JigUtils } from "../../Editor/JigUtils";
import { PromptStatus } from "../../Editor/PromptResult";
import { SelectBox } from "../../Editor/SelectBox";
import { Filter } from "../../Editor/SelectFilter";
import { isParallelTo, MoveMatrix } from "../../Geometry/GeUtils";
import { JigUtils } from "../../Editor/JigUtils";
/**
*
* @isErase 线
* @originEns
*/
export async function getEntShape(msg: string = "请选择封闭曲线,面域或者板件", isErase = true, originEns?: Entity[]): Promise<Shape>
{
let conRes = await app.m_Editor.GetSelection({
Msg: msg,
Filter: { filterTypes: [Board, Curve, Region] }
})
if (conRes.Status === PromptStatus.Cancel)
return;
let enList = conRes.SelectSet.SelectEntityList;
if (originEns)
originEns.push(...enList);
return getCulistShape(enList, isErase);
}
/**
*
*/
export function getViewEntiy(filter?: Filter): Entity[]
{
//屏幕左上角点
let leftTopPt = new Vector2();
//屏幕右下角点
let rightBottomPt = new Vector2(app.m_Viewer.Width, app.m_Viewer.Height);
let selectBox = new SelectBox(app.m_Viewer, leftTopPt, rightBottomPt);
selectBox.Select(app.m_Viewer.Scene.children, filter)
return selectBox.SelectEntityList;
}
/**
*,
* @export
* @param {Entity[]} cus
* @param {boolean} [isErase=false] 线
* @returns
*/
export function getCulistShape(cus: Entity[], isErase = false): Shape
{
for (let c of cus)
{
if (c instanceof Board)
{
let s = c.Shape.Clone();;
let cu = s.Outline.Curve;
cu.ApplyMatrix(cu.OCSInv);
return s;
}
else if (c instanceof Region)
{
return c.ShapeManager.ShapeList[0].Clone();
}
else
{
if ((c instanceof Polyline && c.IsClose) || c instanceof Circle)
{
let shape = new Shape(Contour.CreateContour([c]));
if (isErase)
c.Erase();
return shape;
}
//获得屏幕内的曲线
let totalCulist = getViewEntiy({ filterTypes: [Curve] }) as Curve[];
let group = curveLinkGroup(totalCulist);
if (group.length === 0)
return;
for (let g of group)
{
if (g.includes(c as Curve))
{
let con = Contour.CreateContour(g);
if (con)
{
//TODO:应该在确定绘制后在删除构建曲线
if (isErase)
g.forEach(c => c.Erase())
return new Shape(con);
}
}
}
}
}
}
/**
*
@ -129,63 +35,109 @@ export async function selectOutlinePosition(cus: Curve[] | Curve)
if (ptRes.Status === PromptStatus.OK)
moveCus.forEach(cu => app.m_Database.ModelSpace.Append(cu));
}
/**
* @,线
* @2,
* @export
* @param {(Curve | Shape)} cu
* @param {Board} br
* @param {Matrix4} [ocsInv]
*
*/
export function changeShapeUCS(cu: Curve | Shape, br: Board, ocsInv?: Matrix4)
export function BoardApplyContour(contour: ExtureContour, brs: Board[], isKeepSize: boolean)
{
let [normal, cuOcsInv] =
cu instanceof Shape ?
[cu.Outline.Curve.Normal, cu.Outline.Curve.OCSInv] : [cu.Normal, cu.OCSInv];
//曲线和板件平行,把曲线转换到板件坐标系
if (isParallelTo(normal, br.Normal))
cu.ApplyMatrix(br.OCSInv);
else
for (let br of brs)
{
//如果2实体不平行,先把曲线转回二维平面
cu.ApplyMatrix(ocsInv ? ocsInv : cuOcsInv);
let oldLength = br.Height;
let oldWidth = br.Width;
ExtrudeApplyContour(br, contour);
if (isKeepSize)
{
br.Height = oldLength;
br.Width = oldWidth;
}
}
app.m_Editor.UpdateScreen();
}
/**
*
* @param shape
* @param brs
* @param isKeepSize
* .
*/
export function aplicateContour(shape: Shape, brs: Board[], isKeepSize: boolean)
export async function SelectExtrudeContour(selectInside = false)
: Promise<{
contour?: ExtureContour,
gourp?: Curve[][],
useCurves?: Curve[]
}>
{
if (!shape)
return;
for (let br of brs)
let ssRes = await app.m_Editor.GetSelection({
Msg: "请选择(拉伸实体,面域,曲线):",
Filter: {
filterTypes: [Region, ExtureSolid, Curve]
},
Once: true
});
if (ssRes.Status !== PromptStatus.OK)
return {};
let ens = ssRes.SelectSet.SelectEntityList as ExtureContourCurve[];
let en = ens[0];
if (en instanceof Curve && (selectInside || !en.IsClose))
{
let cloneShape = shape.Clone();
let cu = cloneShape.Outline.Curve;
let cus = app.m_Viewer.VisibleEntitys.filter(e => e instanceof Curve) as Curve[];
let cuGroups = curveLinkGroup(cus);
changeShapeUCS(cu, br);
for (let g of cuGroups)
{
if (g.includes(en))
{
let pl = Contour.Combine(g, false) as Polyline;
arrayRemove(cuGroups, g);
return { contour: pl, gourp: cuGroups, useCurves: g };
}
}
}
else return { contour: en };
}
let box = cu.BoundingBox;
cu.ApplyMatrix(MoveMatrix(box.min.clone().negate()));
/**
* ,WCS.
* @returns 线,线WCS
*/
export function ExtrudeApplyContour(ext: ExtureSolid, contour: ExtureContour): Matrix4 | undefined
{
if (contour instanceof ExtureSolid)
{
ext.ContourCurve = contour.ContourCurve.Clone();
}
else if (contour instanceof Region)
{
//清除所有的内部拉槽,应用面域的网洞. 忽略多组面域
}
else
{
let applyMatrix: Matrix4;
contour = contour.Clone();
if (isParallelTo(ext.Normal, contour.Normal))
applyMatrix = ext.OCSInv;
else if (isParallelTo(
contour.Normal,
new Vector3().setFromMatrixColumn(app.m_Editor.UCSMatrix, 2)
))
applyMatrix = app.m_Editor.UCSMatrixInv;
else
applyMatrix = contour.OCSInv;
let oldLength = br.Length;
let oldWidth = br.Width;
contour.ApplyMatrix(applyMatrix);
br.Shape = cloneShape;
let box = contour.BoundingBox;
contour.Position = contour.Position.sub(box.min);
ext.ContourCurve = contour;
if (isKeepSize)
{
br.Length = oldLength;
br.Width = oldWidth;
}
//修正矩阵的基点
applyMatrix.elements[12] -= box.min.x;
applyMatrix.elements[13] -= box.min.y;
applyMatrix.elements[14] -= box.min.z;
return applyMatrix;
}
app.m_Editor.UpdateScreen();
}

@ -1,102 +1,70 @@
import { Matrix4, Vector3 } from "three";
import { app } from "../../ApplicationServices/Application";
import { FixedNotZero } from "../../Common/Utils";
import { Arc } from "../../DatabaseServices/Arc";
import { Board, BoardType } from "../../DatabaseServices/Board";
import { Circle } from "../../DatabaseServices/Circle";
import { Curve } from "../../DatabaseServices/Curve";
import { Line } from "../../DatabaseServices/Line";
import { Polyline } from "../../DatabaseServices/Polyline";
import { BoardType, Board } from "../../DatabaseServices/Board";
import { ExtureSolid } from "../../DatabaseServices/Extrude";
import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { MoveMatrix } from "../../Geometry/GeUtils";
import { SpecialShapeBoardModal } from "../../UI/Components/Board/SpecialBoardModal";
import { ModalPosition } from "../../UI/Components/Modal/ModalsManage";
import { SpecialShapeStore } from "../../UI/Store/BoardStore";
import { getCulistShape } from "./DrawSpecialShapeBoardTool";
import { ExtrudeApplyContour, SelectExtrudeContour } from "./DrawSpecialShapeBoardTool";
import { Matrix4 } from "three";
export class DrawSpecialShapedBoard implements Command
{
ext = new ExtureSolid();
async exec()
{
let cuRes = await app.m_Editor.GetSelection({
Msg: "选择对象",
Filter: { filterTypes: [Polyline, Line, Arc, Circle] }
})
if (cuRes.Status === PromptStatus.Cancel)
return;
let culist = cuRes.SelectSet.SelectEntityList as Curve[];
let { contour } = await SelectExtrudeContour(false);
let shape = getCulistShape(culist, true);
if (shape)
if (contour)
{
shape = shape.Clone();
const store = SpecialShapeStore.GetInstance();
let applyMatrix4 = ExtrudeApplyContour(this.ext, contour);
let toCurve = new Matrix4().getInverse(applyMatrix4);
let cu = shape.Outline.Curve;
let cuOcs = cu.OCS;
cu.ApplyMatrix(cu.OCSInv);
let box = cu.BoundingBox;
let size = box.getSize(new Vector3());
cu.ApplyMatrix(MoveMatrix(box.min.clone().negate()));
store.m_Option.height = parseFloat(FixedNotZero(size.x, 2));
store.m_Option.width = parseFloat(FixedNotZero(size.y, 2));
const store = SpecialShapeStore.GetInstance() as SpecialShapeStore;
store.m_Option.height = parseFloat(FixedNotZero(this.ext.Height, 2));
store.m_Option.width = parseFloat(FixedNotZero(this.ext.Width, 2));
app.m_Editor.m_ModalManage.RenderModeless(SpecialShapeBoardModal, ModalPosition.Center, { store });
app.m_Editor.m_ModalManage.Callback = async () =>
{
let thickness = store.m_Option.thickness;
let min = box.min.clone().setZ(-thickness);
min.applyMatrix4(cuOcs);
let length: number;
let width: number;
[length, width] = [size.y, size.x];
let br = new Board();
br.BoardType = store.m_Option.type;
br.ApplyMatrix(br.OCSInv);
br.Thickness = store.m_Option.thickness;
if (store.m_Option.type === BoardType.Layer)
{
cu.ApplyMatrix(new Matrix4().makeRotationZ(-Math.PI / 2));
cu.ApplyMatrix(MoveMatrix(new Vector3(0, box.getSize(new Vector3()).x)));
[length, width] = [size.x, size.y];
let xv = new Vector3();
let yv = new Vector3();
let zv = new Vector3();
cuOcs.extractBasis(xv, yv, zv);
cuOcs.makeBasis(yv, xv.negate(), zv);
//基点修改
toCurve.elements[12] += toCurve.elements[0] * this.ext.Width;
toCurve.elements[13] += toCurve.elements[1] * this.ext.Width;
toCurve.elements[14] += toCurve.elements[2] * this.ext.Width;
//xy互换
[
toCurve.elements[0],
toCurve.elements[1],
toCurve.elements[2],
toCurve.elements[4],
toCurve.elements[5],
toCurve.elements[6]
]
=
[
toCurve.elements[4],
toCurve.elements[5],
toCurve.elements[6],
-toCurve.elements[0],
-toCurve.elements[1],
-toCurve.elements[2],
];
}
//创建板件
let br = Board.CreateBoard(length, width, thickness, store.m_Option.type);
br.Name = store.m_Option.name;
br.BoardProcessOption = store.m_BoardProcessOption;
br.ApplyMatrix(br.OCSInv);
br.ApplyMatrix(MoveMatrix(br.MinPoint.negate()));
cuOcs.setPosition(min);
br.ApplyMatrix(cuOcs);
//应用轮廓
br.Shape = shape;
br.Length = store.m_Option.height;
br.Width = store.m_Option.width;
br.ApplyMatrix(toCurve);
ExtrudeApplyContour(br, contour);
app.m_Database.ModelSpace.Append(br);
culist.forEach(cu => cu.Erase());
}
}
else
{
app.m_Editor.Prompt('选择对象无效')
}
}
}

@ -2,7 +2,7 @@ import { app } from "../../ApplicationServices/Application";
import { Board } from "../../DatabaseServices/Board";
import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { aplicateContour, getEntShape } from "./DrawSpecialShapeBoardTool";
import { SelectExtrudeContour, BoardApplyContour } from "./DrawSpecialShapeBoardTool";
export class DrawSpecialShapedBoardByContour implements Command
{
@ -16,16 +16,16 @@ export class DrawSpecialShapedBoardByContour implements Command
return;
let targetBoards = brRes.SelectSet.SelectEntityList as Board[];
let shape = await getEntShape();
if (!shape)
return;
let { contour } = await SelectExtrudeContour(false);
let keyWord = await app.m_Editor.GetKeyWords({
Msg: "不改变板件大小:",
KeyWordList: [{ key: "Y", msg: "是" }, { key: "N", msg: "否" }]
});
if (keyWord.Status !== PromptStatus.Keyword) return;
aplicateContour(shape, targetBoards, keyWord.StringResult === "Y")
BoardApplyContour(contour, targetBoards, keyWord.StringResult === "Y");
}
}

@ -75,7 +75,7 @@ export class DrawTopBottomBoard implements Command
basePoint.set(
max.x + spc.m_RightBoard.Thickness,
min.y,
max.z + opt.thickness
max.z
)
}
else
@ -83,7 +83,7 @@ export class DrawTopBottomBoard implements Command
basePoint.set(
max.x,
min.y,
max.z - opt.offset
max.z - (opt.thickness + opt.offset)
)
}
return basePoint;
@ -99,7 +99,7 @@ export class DrawTopBottomBoard implements Command
basePoint.set(
max.x + spc.m_RightBoard.Thickness,
min.y,
min.z
min.z - opt.thickness
);
}
else
@ -107,7 +107,7 @@ export class DrawTopBottomBoard implements Command
basePoint.set(
max.x,
min.y,
min.z + opt.thickness + opt.offset
min.z + opt.offset
);
}
return basePoint;
@ -155,7 +155,7 @@ export class DrawTopBottomBoard implements Command
footBoard.BoardProcessOption = this.store.m_BoardProcessOption;
footBoard.BoardProcessOption.composingFace = ComposingType.Reverse;
footBoard.BoardProcessOption.bigHoleDir = FaceDirection.Back;
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 + opt.thickness))));
footBoard.ApplyMatrix(spaceParse.m_SpaceOCS);
app.m_Database.ModelSpace.Append(footBoard);
}

@ -39,7 +39,6 @@ export class Entsel implements Command
dyn.Destroy();
window["debugEn"] = en;
console.log('debugEn: ', en);
window["en"] = en.Entity;
}
}

@ -86,9 +86,7 @@ export class CommandFilletBoard implements Command
//-----5.应用轮廓
brContour.ApplyMatrix(brOCSInv);
let sp = br.Shape.Clone();
sp.Outline = Contour.CreateContour([brContour]);
br.Shape = sp;
br.ContourCurve = brContour;
brContour.Erase();
}
UpdateFilletRadius(newRadius: number)

@ -1,33 +1,10 @@
import { app } from "../../ApplicationServices/Application";
import { Board } from "../../DatabaseServices/Board";
import { PhysicalMaterialRecord } from "../../DatabaseServices/PhysicalMaterialRecord";
import { TextureTableRecord } from "../../DatabaseServices/Texture";
import { Command } from "../../Editor/CommandMachine";
import { HotCMD } from "../../Hot/HotCommand";
import { Command } from "../../Editor/CommandMachine";
@HotCMD
export class Test implements Command
{
async exec()
{
let texture = new TextureTableRecord();
texture.imageUrl = `https://cdn.jsdelivr.net/gh/FishOrBear/CDNResources/Default.jpg`;
texture.Name = app.m_Database.TextureTable.AllocateName();
await texture.Update();
app.m_Database.TextureTable.Add(texture);
let material = new PhysicalMaterialRecord();
material.map = texture.Id;
material.Update();
app.m_Database.MaterialTable.Add(material);
let br = new Board();
br.InitBoard(600, 1200, 18);
br.Material = material.Id;
app.m_Database.ModelSpace.Append(br);
}
}

@ -157,3 +157,8 @@ export function equalArray<T>(a: T[], b: T[], checkF = checkEqual)
if (!checkF(a[i], b[i])) return false;
return true;
}
export function arrayClone<T>(arr: T[]): T[]
{
return arr.slice();
}

@ -1,4 +1,4 @@
import { Color, DoubleSide, LineBasicMaterial, LineDashedMaterial, MeshBasicMaterial } from 'three';
import { Color, DoubleSide, LineBasicMaterial, LineDashedMaterial, MeshBasicMaterial, Mesh } from 'three';
const ColorPalette = [
[255, 0, 0, 255], //----- 0 - lets make it red for an example
@ -290,6 +290,11 @@ export class ColorMaterial
return mat;
}
static SolidJigMaterial()
{
return new MeshBasicMaterial({ transparent: true, opacity: 0.1 });
}
static GetColor(index: number)
{
let rgb = ColorPalette[index];

@ -31,6 +31,7 @@ export class BlockTableRecord extends SymbolTableRecord
Append(entity: Entity, isCheckObjectCleanly = true)
{
this.EntityCol.Append(entity, isCheckObjectCleanly);
entity.Owner = this.objectId;
}
AppendEvent(entity: Entity)

@ -1,24 +1,16 @@
import * as THREE from 'three';
import { ExtrudeGeometry, Matrix3, Matrix4, Mesh, Object3D, Vector2, Vector3, MeshPhysicalMaterial } from 'three';
import { arrayRemoveIf } from '../Common/ArrayExt';
import { Matrix4, Mesh, Object3D, Vector3 } from 'three';
import { UpdateDraw } from '../Common/Status';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
import { Box3Ext } from '../Geometry/Box';
import { cZeroVec, equaln, equalv3, isParallelTo, MoveMatrix, rotatePoint } from '../Geometry/GeUtils';
import ThreeBSP from '../Geometry/ThreeCSG';
import { equaln, MoveMatrix } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/RenderType';
import { BoardProcessOption, ComposingType, DrillType, LinesType, FaceDirection } from '../UI/Store/BoardInterface';
import { BoardProcessOption, ComposingType, DrillType, FaceDirection, LinesType } from '../UI/Store/BoardInterface';
import { Factory } from './CADFactory';
import { CADFiler } from './CADFiler';
import { Circle } from './Circle';
import { Contour } from './Contour';
import { Curve } from './Curve';
import { DefaultBoardMaterial } from './DefaultBoardMaterial';
import { Entity } from './Entity';
import { Line } from './Line';
import { PhysicalMaterialRecord } from './PhysicalMaterialRecord';
import { ExtureSolid } from './Extrude';
import { ObjectId } from './ObjectId';
import { Polyline } from './Polyline';
import { PhysicalMaterialRecord } from './PhysicalMaterialRecord';
import { Shape } from './Shape';
export enum BoardType
@ -47,7 +39,7 @@ export interface IModeling
shape: Shape;
thickness: number;
dir: FaceDirection;
rad: number;
knifeRadius: number;
addLen: number;
}
@ -58,56 +50,28 @@ export interface IModeling
* @extends {Entity}
*/
@Factory
export class Board extends Entity
export class Board extends ExtureSolid
{
//板件厚度
private m_Thickness: number;
private m_Length: number;
private m_Width: number;
private m_Rotation = {
x: 0,
y: 0,
z: 0
}
private m_Shape: Shape;
private m_BoardType: BoardType;
private m_Name = "";
private m_SpecOCS: Matrix4 = new Matrix4(); //板件的标系
private m_BoardProcessOption: BoardProcessOption = {};
private m_BoardModeling: IModeling[] = [];
//板件排钻表,与之碰撞板件为key
private m_DrillList: Map<ObjectId, ObjectId[][]> = new Map();
constructor(shape?: Shape, thickness?: number)
{
super();
this.m_Shape = shape || new Shape();
this.m_Thickness = thickness || 0;
this.InitBoardData();
}
//初始化板件 来自长宽高
InitBoard(length: number, width: number, thickness: number, boardType: BoardType = BoardType.Layer)
private InitBoardData()
{
this.m_BoardType = boardType;
this.m_Length = length;
this.m_Width = width;
this.m_Thickness = thickness;
let pl = new Polyline([
{ pt: new Vector2(), bul: 0 },
{ pt: new Vector2(width, 0), bul: 0 },
{ pt: new Vector2(width, length), bul: 0 },
{ pt: new Vector2(0, length), bul: 0 },
]);
pl.CloseMark = true;
this.m_Shape = new Shape(Contour.CreateContour([pl]));
this.Update(UpdateDraw.Geometry);
}
static CreateBoard(length: number, width: number, thickness: number, boardType: BoardType = BoardType.Layer)
{
let board = new Board();
board.InitBoard(length, width, thickness, boardType);
board.m_BoardProcessOption = {
this.m_BoardProcessOption = {
roomName: "",
cabinetName: "",
boardName: "",
@ -129,7 +93,20 @@ export class Board extends Entity
spliteHeight: "",
spliteWidth: "",
spliteThickness: ""
}
};
}
//初始化板件 来自长宽高
InitBoard(length: number, width: number, thickness: number, boardType: BoardType = BoardType.Layer)
{
this.m_BoardType = boardType;
this.ConverToRectSolid(width, length, thickness);
this.Update(UpdateDraw.Geometry);
}
static CreateBoard(length: number, width: number, thickness: number, boardType: BoardType = BoardType.Layer)
{
let board = new Board();
board.InitBoard(length, width, thickness, boardType);
board.ApplyMatrix(board.RotateMat);
board.m_SpecOCS.identity();
// board.ColorIndex = boardType + 1;
@ -151,18 +128,66 @@ export class Board extends Entity
}
get BoardModeling()
{
return this.m_BoardModeling.slice();
let models: IModeling[] = [];
for (let g of this.grooves)
{
let cu = g.ContourCurve.Clone().ApplyMatrix(this.OCSInv.multiply(g.OCS));
let outline = Contour.CreateContour(cu, false);
let holes: Contour[] = [];
for (let subG of g.Grooves)
{
let holeCu = subG.ContourCurve.Clone().ApplyMatrix(this.OCSInv.multiply(subG.OCS));
holes.push(Contour.CreateContour(holeCu, false));
}
let s = new Shape(outline, holes);
models.push({
shape: s,
thickness: g.Thickness,
dir: equaln(g.Position.applyMatrix4(this.OCSInv).z, 0) ? FaceDirection.Back : FaceDirection.Front,
knifeRadius: g.KnifeRadius,
addLen: g.GroovesAddLength
});
}
return models;
}
set BoardModeling(items: IModeling[])
set BoardModeling(models: IModeling[])
{
this.WriteAllObjectRecord();
this.m_BoardModeling = items;
this.Update(UpdateDraw.Geometry);
this.grooves.length = 0;
for (let model of models)
{
let g = new ExtureSolid();
g.OCS = this.OCS;
g.ContourCurve = model.shape.Outline.Curve;
g.Thickness = model.thickness;
g.GroovesAddLength = model.addLen;
g.KnifeRadius = model.knifeRadius;
for (let hole of model.shape.Holes)
{
let subG = new ExtureSolid();
subG.OCS = this.OCS;
subG.ContourCurve = hole.Curve;
subG.Thickness = model.thickness;
g.AppendGroove(subG);
}
if (model.dir === FaceDirection.Front)
g.ApplyMatrix(MoveMatrix(new Vector3(0, 0, this.thickness - g.Thickness)));
this.grooves.push(g);
}
this.Update();
}
ClearBoardModeling()
{
this.WriteAllObjectRecord();
this.m_BoardModeling.length = 0;
this.grooves.length = 0;
this.Update(UpdateDraw.Geometry);
}
AppendDrillList(k: ObjectId, drs: ObjectId[][])
@ -244,61 +269,61 @@ export class Board extends Entity
}
get Thickness()
{
return this.m_Thickness;
return this.thickness;
}
set Thickness(v: number)
{
if (!equaln(v, this.m_Thickness, 1e-2))
if (!equaln(v, this.thickness, 1e-2))
{
this.m_Thickness = v;
this.WriteAllObjectRecord();
this.thickness = v;
this.Update();
}
}
get Length()
get Height()
{
return this.m_Length
return this.height;
}
set Length(v: number)
set Height(v: number)
{
this.WriteAllObjectRecord();
if (this.m_Shape.Outline.Curve instanceof Circle)
if (this.ContourCurve instanceof Circle)
return;
if (!equaln(v, this.m_Length, 1e-2))
if (!equaln(v, this.height, 1e-2))
{
let refHeight = this.m_Length / 2;
let dist = v - this.m_Length;
this.WriteAllObjectRecord();
let refHeight = this.height / 2;
let dist = v - this.height;
let isSuccess = this.m_Shape.Outline.UnEqualProportionScale(refHeight, dist, "y");
let contour = Contour.CreateContour([this.contourCurve], false);
let isSuccess = contour.UnEqualProportionScale(refHeight, dist, "y");
if (isSuccess)
{
this.m_Length = v;
this.height = v;
this.Update();
}
}
}
get Width()
{
return this.m_Width;
return this.width;
}
set Width(v: number)
{
this.WriteAllObjectRecord();
if (this.m_Shape.Outline.Curve instanceof Circle)
if (this.ContourCurve instanceof Circle)
return;
if (!equaln(v, this.m_Width, 1e-2))
if (!equaln(v, this.width, 1e-2))
{
let refDist = this.m_Width / 2;
let dist = v - this.m_Width;
let isSuccess = this.m_Shape.Outline.UnEqualProportionScale(refDist, dist, "x");
this.WriteAllObjectRecord();
let refDist = this.width / 2;
let dist = v - this.width;
let contour = Contour.CreateContour([this.contourCurve], false);
let isSuccess = contour.UnEqualProportionScale(refDist, dist, "x");
if (isSuccess)
{
this.m_Width = v;
this.width = v;
this.Update();
}
}
@ -328,25 +353,18 @@ export class Board extends Entity
//最左下角的点
get MinPoint(): Vector3
{
let pt;
switch (this.m_BoardType)
{
case BoardType.Layer:
pt = new Vector3(0, this.m_Length, -this.m_Thickness);
break;
return new Vector3(0, this.height).applyMatrix4(this.OCS);
case BoardType.Vertical:
pt = new Vector3(0, 0, -this.m_Thickness);
break;
case BoardType.Behind:
pt = new Vector3(0, 0, 0);
return this.Position;
}
pt.applyMatrix4(this.OCS)
return pt;
}
get MaxPoint(): Vector3
{
let pt = new Vector3(this.m_Width, this.m_Length, -this.m_Thickness);
let pt = new Vector3(this.width, this.height, -this.thickness);
pt.applyMatrix4(this.OCS);
return pt;
}
@ -365,27 +383,31 @@ export class Board extends Entity
}
get BoundingBox()
{
let box = new Box3Ext(new Vector3(0, 0, -this.m_Thickness), new Vector3(this.m_Width, this.m_Length));
let box = new Box3Ext(new Vector3(0, 0, -this.thickness), new Vector3(this.width, this.height));
box.applyMatrix4(this.OCS);
return box;
}
get Shape()
// get Shape()
// {
// return this.ContourCurve;
// }
// set Shape(s: Shape)
// {
// this.WriteAllObjectRecord();
// // this.m_Shape = s;
// this.UpdateBoardSize();
// this.Update();
// }
get IsSpecialShape()
{
return this.m_Shape;
return !this.isRect;
}
set Shape(s: Shape)
{
this.WriteAllObjectRecord();
this.m_Shape = s;
this.UpdateBoardSize();
this.Update();
}
get IsSpecialShape()
get HasGroove()
{
let refArea = this.m_Length * this.m_Width;
let cuArea = this.m_Shape.Outline.Area;
return !equaln(refArea, cuArea, 1);
return this.grooves.length > 0;
}
get Name()
{
return this.m_Name;
@ -397,40 +419,14 @@ export class Board extends Entity
}
GetBoardBoxInMat(mat)
{
let min = new Vector3(0, 0, -this.m_Thickness).applyMatrix4(this.OCS).applyMatrix4(mat);
let max = new Vector3(this.m_Width, this.m_Length).applyMatrix4(this.OCS).applyMatrix4(mat);
let min = new Vector3(0, 0, 0).applyMatrix4(this.OCS).applyMatrix4(mat);
let max = new Vector3(this.width, this.height, this.thickness).applyMatrix4(this.OCS).applyMatrix4(mat);
return new Box3Ext().setFromPoints([min, max]);
}
Explode()
{
return this.m_Shape.Explode().map(cu => cu.ApplyMatrix(this.OCS));
}
Join(target: this): boolean
{
if (equaln(this.m_Thickness, target.m_Thickness)
&& isParallelTo(this.Normal, target.Normal)
&& this.IsCoplaneTo(target))
{
let cloneTar = target.Clone();
let mat = this.OCSInv.multiply(target.OCS)
cloneTar.m_Shape.ApplyMatrix(mat);
let shapes = this.m_Shape.UnionBoolOperation(cloneTar.m_Shape);
if (shapes.length === 1)
{
this.WriteAllObjectRecord();
cloneTar.m_BoardModeling.forEach(m =>
{
m.shape.ApplyMatrix(mat);
});
this.m_BoardModeling.push(...cloneTar.m_BoardModeling);
this.Shape = shapes[0];
this.UpdateOutlineShape();
return true;
}
}
return false;
return [];
// return this.m_Shape.Explode().map(cu => cu.ApplyMatrix(this.OCS));
}
RotateBoard(rox: number, roy: number, roz: number)
{
@ -466,10 +462,10 @@ export class Board extends Entity
protected ApplyScaleMatrix(m: Matrix4): this
{
this.WriteAllObjectRecord();
let cu = this.m_Shape.Outline.Curve;
cu.ApplyMatrix(this.OCS);
cu.ApplyMatrix(m);
cu.ApplyMatrix(this.OCSInv);
// let cu = this.m_Shape.Outline.Curve;
// cu.ApplyMatrix(this.OCS);
// cu.ApplyMatrix(m);
// cu.ApplyMatrix(this.OCSInv);
this.Update(UpdateDraw.Geometry);
return this;
@ -478,378 +474,6 @@ export class Board extends Entity
{
return this;
}
GetObjectSnapPoints(
snapMode: ObjectSnapMode,
pickPoint: Vector3,
lastPoint: Vector3,
viewXform?: Matrix3
): Vector3[]
{
switch (snapMode)
{
case ObjectSnapMode.End:
return this.GetStretchPoints();
case ObjectSnapMode.Mid:
case ObjectSnapMode.Cen:
case ObjectSnapMode.Nea:
case ObjectSnapMode.Ext:
case ObjectSnapMode.Per:
case ObjectSnapMode.Tan:
{
let cu = this.m_Shape.Outline.Curve.Clone().ApplyMatrix(this.OCS);
let zVec = new Vector3(0, 0, -this.m_Thickness).applyMatrix4(this.OCS.setPosition(cZeroVec));
let cu1 = cu.Clone().ApplyMatrix(MoveMatrix(zVec));
let cuOrShapes: (Curve | Shape)[] = [cu, cu1];
let cuPts = cu.GetStretchPoints();
for (let p of cuPts)
cuOrShapes.push(new Line(p, p.clone().add(zVec)));
//添加造型捕捉
for (let m of this.m_BoardModeling)
{
let s1 = m.shape.Clone();
if (m.dir == FaceDirection.Back)
s1.ApplyMatrix(MoveMatrix(new Vector3(0, 0, -this.m_Thickness + m.thickness)));
let s2 = s1.Clone().ApplyMatrix(MoveMatrix(new Vector3(0, 0, -m.thickness)));
cuOrShapes.push(s1.ApplyMatrix(this.OCS), s2.ApplyMatrix(this.OCS));
}
let pts: Vector3[] = [];
for (let en of cuOrShapes)
pts.push(...en.GetObjectSnapPoints(snapMode, pickPoint, lastPoint, viewXform));
return pts;
}
default:
break;
}
return [];
}
private GetGripOrStrechPts(isGrip: boolean)
{
let pts = isGrip ? this.m_Shape.GetGripPoints() : this.m_Shape.GetStretchPoints();
let revPts: Vector3[] = [];
let vec = new Vector3(0, 0, -this.m_Thickness);
revPts.push(...pts.map(p => p.clone().add(vec)));
for (let m of this.m_BoardModeling)
{
let tmpPts = isGrip ? m.shape.GetGripPoints() : m.shape.GetStretchPoints();
if (m.dir === FaceDirection.Back)
{
tmpPts = tmpPts.map(p => p.add(new Vector3(0, 0, -this.m_Thickness + m.thickness)));
}
pts.push(...tmpPts);
let v = new Vector3(0, 0, -m.thickness);
revPts.push(...tmpPts.map(p => p.clone().add(v)));
}
pts = pts.concat(revPts);
return pts.map(p => p.applyMatrix4(this.OCS));
}
GetGripPoints()
{
return this.GetGripOrStrechPts(true);
}
MoveGripPoints(indexList: Array<number>, vec: Vector3)
{
this.WriteAllObjectRecord();
//修正移动向量
let vl = vec.clone();
vl.applyMatrix4(new Matrix4().extractRotation(this.OCSInv)).setZ(0);
//统一上下2层夹点
let len = this.GetGripPoints().length;
let i = Math.min(...indexList);
if (i > len / 2 - 1)
{
i -= len / 2;
}
indexList = [i];
let cur = this.m_Shape.Outline.Curve;
let outlineIndex = cur.GetGripPoints().length;
let gripShape: Shape = this.m_Shape;
if (indexList[0] >= outlineIndex)
{
for (let m of this.m_BoardModeling)
{
let len = m.shape.GetGripPoints().length;
if (indexList[0] < outlineIndex + len)
{
indexList = [indexList[0] - outlineIndex]
gripShape = m.shape;
break;
}
outlineIndex += len;
}
}
else if (indexList[0] & 1)
{
let derv = cur.GetFistDeriv(indexList[0] / 2).normalize();
rotatePoint(derv, Math.PI / 2);
derv.multiplyScalar(derv.dot(vl));
vl.copy(derv);
}
gripShape.MoveGripPoints(indexList, vl);
this.UpdateBoardShape();
this.UpdateBoardSize();
this.Update(UpdateDraw.Geometry);
}
GetStretchPoints()
{
return this.GetGripOrStrechPts(false);
}
MoveStretchPoints(indexList: Array<number>, vec: Vector3)
{
this.WriteAllObjectRecord();
let vl = vec.clone()
.applyMatrix4(new Matrix4().extractRotation(this.OCSInv));
indexList.sort((a, b) => a - b);
let totalCount = this.GetStretchPoints().length;
//当前遍历形状之前索引数
let outlen = 0;
//用于判断是否拉伸了板件厚度
let oldThickness = this.m_Thickness;
//遍历板件所有形状,包括造型形状,分配对应拉伸点索引
for (let i = 0, ss = [this.m_Shape, ...this.m_BoardModeling.map(m => m.shape)]; i < ss.length; i++)
{
// 形状拉伸点数量
let count = ss[i].GetStretchPoints().length;
//参考索引数
let refIndex = outlen + count;
//属于当前形状的索引数组
let curIndexs = [];
for (let i of indexList)
{
//用于比较的索引,下层索引需修正
let compareIndex = i;
//下层索引需+fuzz
let fuzz = 0;
if (i > totalCount / 2 - 1)
{
fuzz = count;
compareIndex = i - totalCount / 2;
}
if (compareIndex < refIndex && compareIndex >= outlen)
curIndexs.push(compareIndex - outlen + fuzz);
}
let minIndex = Math.min(...curIndexs);
let maxIndex = Math.max(...curIndexs);
//是否全选了一层索引,是就改变厚度
if (curIndexs.length === count
&& ((minIndex === 0 && maxIndex === count - 1)
|| (minIndex === count && maxIndex === 2 * count - 1)))
{
let dir = minIndex === 0 ? -1 : 1;
//修改板件厚度
if (i === 0)
{
//如果是上层,则需要将板件移动修正板件位置
if (minIndex === 0)
{
let v = vl.clone().setX(0).setY(0)
.applyMatrix4(new Matrix4().extractRotation(this.OCS));
this.ApplyMatrix(MoveMatrix(v));
}
this.m_Thickness -= vl.z * dir;
}
else
this.m_BoardModeling[i - 1].thickness -= vl.z * dir;
}
else if (curIndexs.length === count * 2)
{
//仅改变造型的位置
if (oldThickness === this.m_Thickness)
ss[i].ApplyMatrix(MoveMatrix(vl));
}
else //拉伸对应的形状
{
//统一上下层拖拽点
curIndexs = curIndexs.map(i =>
{
if (i > count - 1)
{
return i - count;
}
return i;
})
curIndexs = [...new Set(curIndexs)];
ss[i].MoveStretchPoints(curIndexs, vl.clone().setZ(0));
}
outlen += count;
}
this.UpdateBoardShape();
this.UpdateBoardSize();
this.Update(UpdateDraw.Geometry);
}
private UpdateBoardSize()
{
let size = this.Shape.BoundingBox.getSize(new Vector3());
this.m_Length = size.y;
this.m_Width = size.x;
}
/**
* ,
*/
UpdateBoardShape()
{
let deleteModel: Set<IModeling> = new Set();
for (let m of this.m_BoardModeling)
{
let shapeZ = m.shape.Outline.Curve.Position.z;
if (this.m_Thickness * m.thickness < 0)
deleteModel.add(m);
else if (m.dir === FaceDirection.Front)
{
if (shapeZ < 0 || shapeZ > m.thickness)
deleteModel.add(m);
}
else
{
if (shapeZ < - m.thickness || shapeZ > 0)
deleteModel.add(m);
}
if (!deleteModel.has(m) && m.thickness >= this.m_Thickness)
{
//TODO:有可能变成多块板,暂不处理这种情况
//改变异型轮廓
let specialShape = this.m_Shape.SubstactBoolOperation(m.shape)[0];
if (specialShape)
{
if (specialShape.Holes.length > 0)
specialShape.Holes.length = 0;
else
deleteModel.add(m);
this.Shape = specialShape;
}
}
if (!deleteModel.has(m))
{
//改变造型轮廓
let modelShape = m.shape.IntersectionBoolOperation(this.m_Shape)[0];
if (modelShape)
m.shape = modelShape;
}
}
arrayRemoveIf(this.m_BoardModeling, m => deleteModel.has(m));
this.UpdateOutlineShape();
}
private UpdateOutlineShape()
{
//源形状min应在0点
let min = this.m_Shape.BoundingBox.min;
if (!equalv3(min, new Vector3()))
{
let matVec = MoveMatrix(min.clone().negate());
this.m_Shape.ApplyMatrix(matVec);
for (let m of this.BoardModeling)
m.shape.ApplyMatrix(matVec);
this.ApplyMatrix(
MoveMatrix(min.applyMatrix4(new Matrix4().extractRotation(this.OCS))));
this.Update(UpdateDraw.Geometry);
}
}
InitDrawObject(renderType: RenderType = RenderType.Wireframe): Object3D
{
let br = new THREE.Mesh(this.UpdateGeometry(), DefaultBoardMaterial.Material);
this.UpdateDrawObjectMaterial(renderType, br);
br.castShadow = true;
return br;
}
private UpdateGeometry()
{
if (!this.m_Shape)
{
//避免空的板件生成
this.InitBoard(1e-5, 1e-5, 1e-5);
}
let extrudeSettings = {
steps: 1,
bevelEnabled: false,
depth: this.m_Thickness
};
let geo = new ExtrudeGeometry(this.m_Shape.Shape, extrudeSettings);
geo.translate(0, 0, -this.m_Thickness);
geo.applyMatrix(this.m_Shape.Outline.Curve.OCS);
this.Modeling(geo);
return geo;
}
private Modeling(geo: ExtrudeGeometry)
{
let outlineCons: ExtrudeGeometry[] = [];
let holes: ExtrudeGeometry[] = [];
//形状孔洞分开计算,轮廓用来减,洞用来加
for (let model of this.m_BoardModeling)
{
let outlineGeo = new ExtrudeGeometry(model.shape.Outline.Shape, {
steps: 1,
bevelEnabled: false,
depth: model.thickness
});
outlineGeo.translate(0, 0, model.dir === FaceDirection.Back ? -this.m_Thickness : - model.thickness);
outlineGeo.applyMatrix(model.shape.Outline.Curve.OCS);
outlineCons.push(outlineGeo);
holes.push(...model.shape.Holes.map(h =>
{
let geo = new ExtrudeGeometry(h.Shape, {
steps: 1,
bevelEnabled: false,
depth: model.thickness
});
geo.translate(0, 0, model.dir === FaceDirection.Back ? -this.m_Thickness : - model.thickness);
geo.applyMatrix(h.Curve.OCS);
return geo;
}))
}
let bsg = new ThreeBSP(geo);
for (let outgeo of outlineCons)
{
let bsg2 = new ThreeBSP(outgeo);
bsg = bsg.subtract(bsg2);
}
for (let hgeo of holes)
{
let bsg2 = new ThreeBSP(hgeo);
bsg = bsg.union(bsg2);
}
geo.copy(bsg.toGeometry() as ExtrudeGeometry);
}
UpdateDrawObject(type: RenderType, obj: Object3D)
{
let mesh = obj as Mesh;
mesh.geometry.dispose();
mesh.geometry = this.UpdateGeometry();
if (this.materialId)
{
let material = this.materialId.Object as PhysicalMaterialRecord;
mesh.material = material.Material;
}
}
/**
* ,
@ -873,11 +497,6 @@ export class Board extends Entity
{
super.ReadFile(file);
let ver = file.Read();
this.m_Shape = new Shape();
this.m_Shape.ReadFile(file);
this.m_Length = file.Read();
this.m_Width = file.Read();
this.m_Thickness = file.Read();
this.m_SpecOCS.fromArray(file.Read());
this.m_BoardType = file.Read();
this.m_Name = file.Read();
@ -903,32 +522,12 @@ export class Board extends Entity
}
this.m_DrillList.set(id, drIdList);
}
//读取造型数据
let modelCount = file.Read();
this.m_BoardModeling.length = 0;
for (let i = 0; i < modelCount; i++)
{
let shape = new Shape();
shape.ReadFile(file);
let thickness = file.Read();
let dir = file.Read();
let rad = file.Read();
let addLen = file.Read();
this.m_BoardModeling.push({
shape, thickness, dir, rad, addLen
})
}
this.Update();
}
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(1);
this.m_Shape.WriteFile(file);
file.Write(this.m_Length);
file.Write(this.m_Width);
file.Write(this.m_Thickness);
file.Write(this.m_SpecOCS.toArray())
file.Write(this.m_BoardType);
file.Write(this.m_Name);
@ -950,17 +549,5 @@ export class Board extends Entity
}
}
}
//写入造型数据
file.Write(this.m_BoardModeling.length);
for (let data of this.m_BoardModeling)
{
data.shape.WriteFile(file);
file.Write(data.thickness);
file.Write(data.dir);
file.Write(data.rad);
file.Write(data.addLen);
}
}
}

@ -18,8 +18,19 @@ let cache = new WeakMap();
export class Contour
{
private m_Curve: Polyline | Circle;
static CreateContour(cus: Curve[], needLink = true)
static CreateContour(cus: Curve[] | Polyline | Circle, needLink = true)
{
if (cus instanceof Curve)
{
if (cus.IsClose)
{
let c = new Contour();
c.m_Curve = cus;
return c;
}
return;
}
let closeCurve = Contour.Combine(cus, needLink) as Polyline | Circle;
if (closeCurve && closeCurve.IsClose)
{
@ -47,7 +58,7 @@ export class Contour
return this.m_Curve.BoundingBox;
}
/**
*
*
* @param {number} ref ,
* @param {number} dist
* @param {string} dir x y z

@ -1,16 +1,16 @@
import { Box3, Geometry, Matrix4, Object3D, Vector3, Material, Matrix3 } from 'three';
import { Box3, Geometry, Material, Matrix3, Matrix4, Object3D, Vector3 } from 'three';
import { iaop } from 'xaop';
import { DisposeThreeObj } from '../Common/Dispose';
import { matrixIsCoplane } from '../Common/Matrix4Utils';
import { UpdateDraw } from '../Common/Status';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
import { equaln, equalv3 } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/RenderType';
import { IntersectOption } from '../GraphicsSystem/IntersectWith';
import { RenderType } from '../GraphicsSystem/RenderType';
import { Factory } from './CADFactory';
import { CADFiler } from './CADFiler';
import { CADObject } from './CADObject';
import { ObjectId } from './ObjectId';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
import { UpdateDraw } from '../Common/Status';
import { iaop } from 'xaop';
/**
* Entity ,.
@ -30,6 +30,13 @@ export class Entity extends CADObject
//自身坐标系
protected m_Matrix = new Matrix4();
protected m_Owner: ObjectId;//BlockTableRecord
set Owner(owner: ObjectId)
{
this.m_Owner = owner;
}
/**
* AutoUpdatefalse,.
* 便.
@ -405,15 +412,20 @@ export class Entity extends CADObject
this.m_Color = file.Read();
this.materialId = file.ReadObjectId();
this.m_Matrix.fromArray(file.Read());
if (ver > 1)
this.m_Owner = file.ReadObjectId();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFiler)
{
file.Write(1);
file.Write(2);
super.WriteFile(file);
file.Write(this.m_Color);
file.WriteObjectId(this.materialId);
file.Write(this.m_Matrix.toArray());
file.WriteObjectId(this.m_Owner);
}
//局部撤销
ApplyPartialUndo(undoData: CADObject)

File diff suppressed because it is too large Load Diff

@ -241,8 +241,9 @@ export class Polyline extends Curve
{ pt: px1, bul: 0 },
{ pt: px2, bul: 0 },
{ pt: px3, bul: 0 },
{ pt: px4, bul: 0 },
{ pt: px1, bul: 0 }];
{ pt: px4, bul: 0 }];
this.CloseMark = true;
return this;
}
//多段线起点

@ -58,13 +58,7 @@ export class Region extends Entity
let shapeList = this.m_ShapeManager.ShapeList;
if (shapeList.length <= 1)
{
let cus = shapeList[0].Explode();
cus.forEach(c =>
{
if (!(c instanceof Circle) && !(c instanceof Arc))
c.ApplyMatrix(c.OCSInv).ApplyMatrix(this.OCS)
});
return cus;
return shapeList[0].Explode();
}
else
{
@ -186,12 +180,19 @@ export class Region extends Entity
{
let regionGroup = en as Group;
DisposeThreeObj(en);
this.m_ShapeManager.ShapeList.forEach(shape =>
let shapeList = this.m_ShapeManager.ShapeList;
for (let i = 0; i < shapeList.length; i++)
{
let shape = shapeList[i];
//多形状面域,需把geo移动到相对
let geometry = new ShapeBufferGeometry(shape.Shape, 60);//60 可以优化.
let diffMat = this.OCSInv.clone().multiply(shape.Outline.Curve.OCS);
geometry.applyMatrix(diffMat);
let mesh = new THREE.Mesh(geometry, mat);
regionGroup.add(mesh);
})
}
}
ReadFile(file: CADFiler)
{

@ -76,11 +76,13 @@ export class Shape
{
let cus: Curve[] = [];
let contours: Contour[] = [this.m_Outline, ...this.m_Holes];
contours.forEach(h =>
for (let con of contours)
{
h.Curve instanceof Polyline
? cus.push(...h.Curve.Explode()) : cus.push(h.Curve.Clone())
});
if (con.Curve instanceof Polyline)
cus.push(...con.Curve.Explode());
else
cus.push(con.Curve.Clone());
}
return cus;
}
Clone()

@ -97,3 +97,6 @@ class CommandMachine
}
export const commandMachine = new CommandMachine();
window["end"] = commandMachine.CommandEnd;

@ -0,0 +1,96 @@
import { Vector3 } from "three";
import { ToFixed } from "../Common/Utils";
import ThreeBSP, { Polygon } from "./ThreeCSG";
interface Vec3
{
x: number;
y: number;
z: number;
}
/**
* THREEBSP(CSG) .
* THREEBSP.
*
* Example:
*
* let topology = new BSPGroupParse(csg);
* topology.parse();
*/
export class BSPGroupParse
{
constructor(bsp?: ThreeBSP, public fractionDigits = 1)
{
if (bsp)
for (let poly of bsp.tree.allPolygons())
this.Add(poly);
}
Add(poly: Polygon)
{
let strs = poly.vertices.map(p => this.GenerateP(p));
let str0 = strs[0];
let s0 = this.Get(str0);
for (let i = 1; i < strs.length; i++)
{
let stri = strs[i];
s0.add(stri);
this.Get(stri).add(str0);
}
}
/**
*
*/
Parse(): Vector3[][]
{
let set = new Set([...this.map.keys()]);
let res: Vector3[][] = [];
while (set.size > 0)
{
let fp = set[Symbol.iterator]().next().value;
set.delete(fp);
let cset = new Set();
cset.add(fp);
this.GetPts(fp, cset, set);
let pts = [...cset].map(str =>
{
let v3 = this.vecMap.get(str);
return new Vector3(v3.x, v3.y, v3.z);
});
res.push(pts);
}
return res;
}
private map = new Map<string, Set<string>>();
private Get(vstr: string): Set<string>
{
if (!this.map.has(vstr))
{
let s = new Set();
this.map.set(vstr, s);
return s;
}
return this.map.get(vstr);
}
private GetPts(p: string, cset: Set<string>, oset: Set<string>)
{
let strs = this.map.get(p);
for (let str of strs)
{
if (!cset.has(str))
{
cset.add(str);
oset.delete(str);
this.GetPts(str, cset, oset);
}
}
}
private vecMap = new Map();
private GenerateP(v: Vec3)
{
let str = [v.x, v.y, v.z].map(n => ToFixed(n, this.fractionDigits)).join(",");
this.vecMap.set(str, v);
return str;
}
}

@ -45,7 +45,7 @@ export class BoardGetFace
}
GetTopAndBottomFace()
{
let curve = this.m_Board.Shape.Outline.Curve;
let curve = this.m_Board.ContourCurve;
let box = curve.BoundingBox;
let size = box.getSize(new Vector3());
@ -84,9 +84,9 @@ export class BoardGetFace
GetSideFaces()
{
// 判断板件构建曲线方向
let cus = this.m_Board.Shape.Outline.Curve.Explode() as Curve[];
let cus = this.m_Board.ContourCurve.Explode() as Curve[];
//板构建曲线方向
let dir = Math.sign(this.m_Board.Shape.Outline.Curve.Area2)
let dir = Math.sign(this.m_Board.ContourCurve.Area2)
cus.forEach(cu =>
{

@ -71,9 +71,9 @@ export class ClampSpaceParse extends ISpaceParse
let mat = br.RotateMat;
let p1 = new Vector3(0, 0, -br.Thickness).applyMatrix4(mat);
let p2 = new Vector3(br.Width, br.Length, -dist).applyMatrix4(mat);
let p2 = new Vector3(br.Width, br.Height, -dist).applyMatrix4(mat);
let p3 = new Vector3(0, 0, 0).applyMatrix4(mat);
let p4 = new Vector3(br.Width, br.Length, br.Thickness + dist).applyMatrix4(mat);
let p4 = new Vector3(br.Width, br.Height, br.Thickness + dist).applyMatrix4(mat);
let boxs = [new Box3Ext().setFromPoints([p1, p2]), new Box3Ext().setFromPoints([p3, p4])];

@ -1,4 +1,4 @@
import { Face3, Face4, Geometry, Material, Matrix4, Mesh, Vector2, Vector3 } from "three";
import { Face3, Face4, Geometry, Material, Matrix4, Mesh, Vector2, Vector3, BufferGeometry } from "three";
const EPSILON = 1e-5,
COPLANAR = 0, //共面
@ -33,7 +33,12 @@ export default class ThreeBSP
{
// #todo: add hierarchy support
this.matrix = obj.matrix.clone();
geometry = obj.geometry as Geometry;
let geo = obj.geometry;
if (geo instanceof BufferGeometry)
geometry = new Geometry().fromBufferGeometry(geo);
else
geometry = geo;
}
else if (obj instanceof Node)
{

@ -112,10 +112,11 @@ export class FeedingToolPath extends Singleton
*/
CalcPath(br: Board): Curve[]
{
let cus: Curve[] = [br.Shape.Outline.Curve.Clone()];
let cus: Curve[] = [br.ContourCurve.Clone()];
let modelings = br.BoardModeling;
for (let { shape, thickness, rad } of modelings)
for (let { shape, thickness, knifeRadius } of modelings)
{
if (!knifeRadius) knifeRadius = 3;
if (thickness >= br.Thickness)
{
//通孔只切一刀
@ -123,19 +124,19 @@ export class FeedingToolPath extends Singleton
let dir = this.GetCurveToInDir(outline);
let paths: Curve[];
if (outline instanceof Circle)
paths = outline.GetOffsetCurves(dir * rad);
paths = outline.GetOffsetCurves(dir * knifeRadius);
else
paths = outline.GetFeedingToolPath(dir * rad);
paths = outline.GetFeedingToolPath(dir * knifeRadius);
paths.forEach(p => p.ColorIndex = outline.ColorIndex);
outline.ColorIndex++;
cus.push(outline, ...paths);
}
else
{
let offsetCus = this.HandleShape(shape, rad);
let offsetCus = this.HandleShape(shape, knifeRadius);
if (offsetCus.length > 1)
cus.push(
...OptimizeToolPath(offsetCus, shape, rad)
...OptimizeToolPath(offsetCus, shape, knifeRadius)
);
}
}

@ -12,7 +12,7 @@ textureLoader.load(`https://cdn.jsdelivr.net/gh/FishOrBear/CDNResources/Default.
map.wrapS = MirroredRepeatWrapping;
map.wrapT = MirroredRepeatWrapping;
map.anisotropy = 4;
map.repeat.set(0.0005, 0.0005);
map.repeat.set(1, 1);
brMat.map = map;
brMat.needsUpdate = true;
})

@ -1,27 +1,24 @@
import { Button, Checkbox, Intent } from "@blueprintjs/core";
import { IObservableValue, observable } from "mobx";
import { observer } from "mobx-react";
import * as React from 'react';
import { Matrix4 } from "three";
import { aplicateContour, changeShapeUCS, getEntShape, selectOutlinePosition } from "../../../Add-on/DrawBoard/DrawSpecialShapeBoardTool";
import { ExtrudeApplyContour, SelectExtrudeContour, selectOutlinePosition } from "../../../Add-on/DrawBoard/DrawSpecialShapeBoardTool";
import { app } from "../../../ApplicationServices/Application";
import { CheckObjectType } from "../../../Common/CheckoutVaildValue";
import { Vec3DTo2D } from "../../../Common/CurveUtils";
import { DataAdapter } from "../../../Common/DataAdapter";
import { Singleton } from "../../../Common/Singleton";
import { Board, IModeling } from "../../../DatabaseServices/Board";
import { Circle } from "../../../DatabaseServices/Circle";
import { Board } from "../../../DatabaseServices/Board";
import { Contour } from "../../../DatabaseServices/Contour";
import { Curve } from "../../../DatabaseServices/Curve";
import { Polyline } from "../../../DatabaseServices/Polyline";
import { ExtureSolid } from "../../../DatabaseServices/Extrude";
import { Shape } from "../../../DatabaseServices/Shape";
import { commandMachine } from "../../../Editor/CommandMachine";
import { JigUtils } from "../../../Editor/JigUtils";
import { SelectBox, SelectType } from "../../../Editor/SelectBox";
import { equalv3, MoveMatrix } from "../../../Geometry/GeUtils";
import { BoardConfigOption, BoardProcessOption } from '../../Store/BoardInterface';
import { MoveMatrix } from "../../../Geometry/GeUtils";
import { BoardConfigOption, BoardProcessOption, FaceDirection } from '../../Store/BoardInterface';
import { RightPanelStore } from "../../Store/RightPanelStore";
import { BoardTypeComponent, ItemName, SetBoardDataBlock } from "./BoardCommon";
import { observer } from "mobx-react";
interface BoardConfigProps
{
@ -55,104 +52,101 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
await app.m_Editor.m_ModalManage.EndExecingCmd();
if (!commandMachine.CommandStart("zx"))
return;
app.m_Editor.m_ModalManage.ToggleShow();
//储存选择的外轮廓实体
let originEns = [];
let shape = await getEntShape("请选择外轮廓", true, originEns);
let br = this.props.br;
aplicateContour(shape, [br], false);
app.m_Editor.m_ModalManage.ToggleShow();
if (shape)
let exec = async () =>
{
let box = shape.BoundingBox;
let min = box.min.clone();
let max = box.max.clone();
app.m_Viewer.WorldToScreen(min);
app.m_Viewer.WorldToScreen(max);
//用包围盒构建选择框
let selectBox = new SelectBox(app.m_Viewer, Vec3DTo2D(min), Vec3DTo2D(max), SelectType.C);
selectBox.Select(app.m_Viewer.Scene.children, { filterTypes: [Polyline, Circle] });
let cus = selectBox.SelectEntityList.filter((cu: Polyline | Circle) => cu.IsClose) as Curve[];
let { contour, gourp: cuGourp } = await SelectExtrudeContour(true);
if (!contour) return;
const rightStore = RightPanelStore.GetInstance();
let br = this.props.br;
let applyMatrix = ExtrudeApplyContour(br, contour);
br.ClearBoardModeling();
//曲线按颜色分类
let cuMap: Map<number, Contour[]> = new Map();
for (let cu of cus)
if (cuGourp)
{
if (originEns.length > 0 && (cu === originEns[0] || !equalv3(cu.Normal, originEns[0].Normal)))
continue;
let box = contour.BoundingBox;
app.m_Viewer.WorldToScreen(box.min);
app.m_Viewer.WorldToScreen(box.max);
let selectBox = new SelectBox(app.m_Viewer, Vec3DTo2D(box.min), Vec3DTo2D(box.max), SelectType.C);
let colorIndex = cu.ColorIndex;
let modelData = rightStore.modelingItems[colorIndex - 1];
if (modelData.height > 0)
{
if (cuMap.has(colorIndex))
cuMap.get(colorIndex).push(Contour.CreateContour([cu]));
else
cuMap.set(colorIndex, [Contour.CreateContour([cu])]);
cu.Erase();
}
}
// 将外轮廓转移到板件坐标系或者是二维平面
let oldOcsInv = shape.Outline.Curve.OCSInv;
const rightStore = RightPanelStore.GetInstance() as RightPanelStore;
changeShapeUCS(shape, br);
let contourMap = new Map<number, Contour[]>();
box = shape.BoundingBox;
let modelings: IModeling[] = [];
for (let [i, cons] of cuMap)
{
let oldOcs = cons[0].Curve.OCS;
let ocsInv = cons[0].Curve.OCSInv;
//将轮廓转移到二维屏幕构建形状
cons.forEach(c => c.Curve.ApplyMatrix(ocsInv));
let shapes = Shape.pairHoleAndOutline(cons);
for (let g of cuGourp)
{
for (let c of g)
{
let cd = rightStore.modelingItems[c.ColorIndex - 1];
if (cd.height <= 0)
break;
let modelData = rightStore.modelingItems[i - 1];
if (selectBox.CheckSelect(c.Draw()))
{
let con = Contour.CreateContour(g, false);
if (!contourMap.has(c.ColorIndex))
contourMap.set(c.ColorIndex, [con]);
else
contourMap.get(c.ColorIndex).push(con);
break;
}
}
}
for (let s of shapes)
if (contourMap.size > 0)
{
if (modelData.height >= br.Thickness)
for (let [color, contours] of contourMap)
{
modelData.height = br.Thickness;
s.Holes.length = 0;
}
//还原构建形状到原来的坐标系,在转换到外轮廓所在位置
s.ApplyMatrix(oldOcs);
for (let con of contours)
con.Curve.ApplyMatrix(applyMatrix);
changeShapeUCS(s, br, oldOcsInv);
let cd = rightStore.modelingItems[color - 1];
let shapes = Shape.pairHoleAndOutline(contours);
for (let shape of shapes)
{
let groove = new ExtureSolid();
groove.Thickness = cd.height;
groove.ContourCurve = shape.Outline.Curve;
for (let hole of shape.Holes)
{
let holeSolid = new ExtureSolid();
holeSolid.Thickness = cd.height;
holeSolid.ContourCurve = hole.Curve;
groove.AppendGroove(holeSolid);
}
groove.ApplyMatrix(br.OCS);
if (cd.dir === FaceDirection.Front)
groove.ApplyMatrix(MoveMatrix(br.Normal.multiplyScalar(br.Thickness - groove.Thickness)));
br.AppendGroove(groove);
}
}
s.ApplyMatrix(MoveMatrix(box.min.clone().negate()));
let splits: Board[] = [];
br.GrooveCheckAll(splits);
for (let br of splits)
app.m_Database.ModelSpace.Append(br);
let ss = s.IntersectionBoolOperation(br.Shape);
for (let s1 of ss)
{
s1.SetColor(i);
modelings.push({
shape: s1,
thickness: modelData.height,
dir: modelData.dir,
rad: modelData.rad,
addLen: modelData.length
});
}
br.Update();
}
}
br.BoardModeling = modelings;
this.props.canDrawSpeical.set(br.IsSpecialShape);
this.props.canModeling.set(modelings.length > 0);
}
};
await exec();
app.m_Editor.m_ModalManage.ToggleShow();
commandMachine.CommandEnd();
return;
}
/**
*
*/
private PickUpModelingOutline = async () =>
{
app.m_Editor.m_ModalManage.ToggleShow();
@ -161,7 +155,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
app.m_Viewer.m_CameraCtrl.LookAt(br.Normal.negate());
app.m_Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS);
let cu = JigUtils.Draw(br.Shape.Outline.Curve.Clone().ApplyMatrix(br.OCS));
let cu = JigUtils.Draw(br.ContourCurve.Clone().ApplyMatrix(br.OCS));
let moveCus = [cu];
let store = RightPanelStore.GetInstance();
@ -253,4 +247,3 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
)
}
}

@ -41,7 +41,7 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
let newConfig = {
name: this.m_CurrentBoard.Name,
type: this.m_CurrentBoard.BoardType,
height: parseFloat(FixedNotZero(this.m_CurrentBoard.Length, 2)),
height: parseFloat(FixedNotZero(this.m_CurrentBoard.Height, 2)),
width: parseFloat(FixedNotZero(this.m_CurrentBoard.Width, 2)),
thickness: parseFloat(FixedNotZero(this.m_CurrentBoard.Thickness, 2)),
rotateX: parseFloat(FixedNotZero(Math.radToDeg(ro.x), 2)),
@ -72,7 +72,7 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
board.BoardProcessOption = this.m_ProcessOption;
board.Name = this.m_ConfigOption.name;
board.Length = this.m_ConfigOption.height;
board.Height = this.m_ConfigOption.height;
board.Width = this.m_ConfigOption.width;
board.Thickness = this.m_ConfigOption.thickness;
board.BoardType = this.m_ConfigOption.type;
@ -91,12 +91,12 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
}
//取消勾选造型,清除造型
if (!this.canModeling.get() && board.BoardModeling.length > 0)
if (!this.canModeling.get() && board.HasGroove)
board.ClearBoardModeling();
//取消勾选异型,板件回复正常形状
if (!this.canDrawSpecial.get())
board.InitBoard(board.Length, board.Width, board.Thickness, board.BoardType);
board.InitBoard(board.Height, board.Width, board.Thickness, board.BoardType);
app.m_Editor.m_ModalManage.Clear();
@ -117,7 +117,7 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
app.m_Viewer.Scene.children.forEach(obj => CheckFilter(obj, f));
this.canDrawSpecial.set(this.m_CurrentBoard.IsSpecialShape);
this.canModeling.set(this.m_CurrentBoard.BoardModeling.length > 0);
this.canModeling.set(this.m_CurrentBoard.HasGroove);
}
render()
{

@ -23,7 +23,7 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
render()
{
let isShowHighEditor = this.props.br
&& !(this.props.br.Shape.Outline.Curve instanceof Circle)
&& !(this.props.br.ContourCurve instanceof Circle)
&& this.props.isSpecial.get();
return (

@ -22,7 +22,7 @@ export class EdgeSealingComponent extends React.Component<{ br: Board }, {}>
private EditorEdgeSealing = () =>
{
let br = this.props.br;
let cus = br.Shape.Outline.Curve.Explode() as Curve[];
let cus = br.ContourCurve.Explode() as Curve[];
//曲线分段
paragraphCulist(cus);
@ -48,7 +48,7 @@ export class EdgeSealingComponent extends React.Component<{ br: Board }, {}>
private CalcEdgeSealing = () =>
{
let originCurve = this.props.br.Shape.Outline.Curve;
let originCurve = this.props.br.ContourCurve;
let dir = Math.sign(originCurve.Area2) * -1;
let infoEls = this.ulList.querySelectorAll('li input');
let edgeSealingNum: number[] = [];

Loading…
Cancel
Save