From 07d6fb7e254d2beec21a454f52297d2f40f888b0 Mon Sep 17 00:00:00 2001 From: ChenX Date: Thu, 18 Oct 2018 10:09:59 +0800 Subject: [PATCH] =?UTF-8?q?!172=20=E5=B0=81=E8=BE=B9=E8=AE=A1=E7=AE=97=20M?= =?UTF-8?q?erge=20pull=20request=20!172=20from=20ZoeLeeFZ/edgesealing2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/EdgeSealing/EdgeSealing.test.ts | 92 +++++ .../__snapshots__/EdgeSealing.test.ts.snap | 25 ++ __test__/Geometry/angle.test.ts | 18 - __test__/Line/__snapshots__/line.test.ts.snap | 14 +- .../__snapshots__/offset.test.ts.snap | 34 +- .../__snapshots__/offsetbug.test.ts.snap | 18 +- src/Add-on/DrawBoard/DrawBehindBoard.ts | 2 +- src/Add-on/DrawBoard/DrawClosingStrip.ts | 2 +- src/Add-on/DrawBoard/DrawLayerBoard.ts | 2 +- src/Add-on/DrawBoard/DrawLeftRightBoard.ts | 4 +- src/Add-on/DrawBoard/DrawSingleBoard.ts | 2 +- .../DrawBoard/DrawSpecialShapeBoardTool.ts | 16 +- .../DrawBoard/DrawSpecialShapedBoard.ts | 2 +- src/Add-on/DrawBoard/DrawTopBottomBoard.ts | 8 +- src/Add-on/DrawBoard/DrawVerticalBoard.ts | 2 +- src/Add-on/DrawDrilling/DrawDrillingTool.ts | 2 +- src/Common/CheckoutVaildValue.ts | 3 + src/DatabaseServices/Board.ts | 43 ++- src/DatabaseServices/Polyline.ts | 3 +- src/DatabaseServices/Text/Text.ts | 2 +- src/Editor/DbClick/DBClickPolyline.ts | 15 +- src/Editor/DbClick/DbClick.ts | 1 + src/Editor/Jig.ts | 1 + src/GraphicsSystem/CalcEdgeSealing.ts | 32 ++ src/GraphicsSystem/OffsetPolyline.ts | 14 +- src/UI/Components/Board/BoardConfigModal.tsx | 11 +- src/UI/Components/Board/BoardOptionModal.tsx | 46 ++- src/UI/Components/Board/BoardProcessModal.tsx | 317 ++++++++++-------- .../Components/Board/EdgeSealingComponent.tsx | 218 ++++++++++++ .../Modal/ModalStyle/BoardModal.less | 29 ++ src/UI/Components/Modal/ModalsManage.tsx | 2 + src/UI/Store/BoardInterface.ts | 1 + src/UI/Store/BoardStore.ts | 19 +- 33 files changed, 732 insertions(+), 268 deletions(-) create mode 100644 __test__/EdgeSealing/EdgeSealing.test.ts create mode 100644 __test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap delete mode 100644 __test__/Geometry/angle.test.ts create mode 100644 src/GraphicsSystem/CalcEdgeSealing.ts create mode 100644 src/UI/Components/Board/EdgeSealingComponent.tsx diff --git a/__test__/EdgeSealing/EdgeSealing.test.ts b/__test__/EdgeSealing/EdgeSealing.test.ts new file mode 100644 index 000000000..5496a82c6 --- /dev/null +++ b/__test__/EdgeSealing/EdgeSealing.test.ts @@ -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); +}) diff --git a/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap new file mode 100644 index 000000000..def6b250b --- /dev/null +++ b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap @@ -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`; diff --git a/__test__/Geometry/angle.test.ts b/__test__/Geometry/angle.test.ts deleted file mode 100644 index d836010bc..000000000 --- a/__test__/Geometry/angle.test.ts +++ /dev/null @@ -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)); -}) - diff --git a/__test__/Line/__snapshots__/line.test.ts.snap b/__test__/Line/__snapshots__/line.test.ts.snap index 584b4cba8..fd9848f65 100644 --- a/__test__/Line/__snapshots__/line.test.ts.snap +++ b/__test__/Line/__snapshots__/line.test.ts.snap @@ -66,7 +66,7 @@ Vector3 { exports[`直线偏移 3`] = ` Vector3 { - "x": -7.0710678118654755, + "x": -7.071067811865475, "y": 7.071067811865475, "z": 0, } @@ -74,7 +74,7 @@ Vector3 { exports[`直线偏移 4`] = ` Vector3 { - "x": -2.0710678118654755, + "x": -2.0710678118654746, "y": 12.071067811865476, "z": 0, } @@ -82,7 +82,7 @@ Vector3 { exports[`直线偏移 5`] = ` Vector3 { - "x": 7.0710678118654755, + "x": 7.071067811865475, "y": -7.071067811865475, "z": 0, } @@ -98,7 +98,7 @@ Vector3 { exports[`直线偏移 7`] = ` Vector3 { - "x": -7.071067811865477, + "x": -7.071067811865475, "y": 7.071067811865475, "z": 0, } @@ -106,7 +106,7 @@ Vector3 { exports[`直线偏移 8`] = ` Vector3 { - "x": -12.071067811865477, + "x": -12.071067811865476, "y": 2.0710678118654746, "z": 0, } @@ -114,7 +114,7 @@ Vector3 { exports[`直线偏移 9`] = ` Vector3 { - "x": 7.071067811865477, + "x": 7.071067811865475, "y": -7.071067811865475, "z": 0, } @@ -122,7 +122,7 @@ Vector3 { exports[`直线偏移 10`] = ` Vector3 { - "x": 2.0710678118654773, + "x": 2.0710678118654746, "y": -12.071067811865476, "z": 0, } diff --git a/__test__/Polyline/__snapshots__/offset.test.ts.snap b/__test__/Polyline/__snapshots__/offset.test.ts.snap index d43d5198a..caed51f96 100644 --- a/__test__/Polyline/__snapshots__/offset.test.ts.snap +++ b/__test__/Polyline/__snapshots__/offset.test.ts.snap @@ -2,19 +2,19 @@ exports[`IKKGK圆与直线补圆弧 1`] = `1`; -exports[`IKKGK圆与直线补圆弧 2`] = `44.99893545255324`; +exports[`IKKGK圆与直线补圆弧 2`] = `44.99893545255323`; exports[`IKKGK圆与直线补圆弧 3`] = `1`; -exports[`IKKGK圆与直线补圆弧 4`] = `44.99893545255324`; +exports[`IKKGK圆与直线补圆弧 4`] = `44.998935452553226`; exports[`IKKGK圆与直线补圆弧 5`] = `1`; -exports[`IKKGK圆与直线补圆弧 6`] = `52.52699197436397`; +exports[`IKKGK圆与直线补圆弧 6`] = `52.526991974363945`; exports[`中间区域需要圆裁剪 1`] = `1`; -exports[`中间区域需要圆裁剪 2`] = `24.711300177432424`; +exports[`中间区域需要圆裁剪 2`] = `24.711300177432427`; exports[`圆求交错误导致的线丢失 1`] = `4148.6552839918695`; @@ -70,7 +70,7 @@ exports[`多段线因为合并问题造成的错误 2`] = `2210.3833040297095`; exports[`多段线存在0长度线段导致偏移错误 1`] = `1`; -exports[`多段线存在0长度线段导致偏移错误 2`] = `81933.70549460054`; +exports[`多段线存在0长度线段导致偏移错误 2`] = `81933.70549460052`; exports[`多段线存在0长度线段导致偏移错误 3`] = `1`; @@ -86,13 +86,13 @@ exports[`拱门偏移 4`] = `6.827433388230814`; exports[`海豚圆选点导致的错误 1`] = `1`; -exports[`海豚圆选点导致的错误 2`] = `1591.1982232513824`; +exports[`海豚圆选点导致的错误 2`] = `1591.1982232513815`; exports[`海豚圆选点导致的错误 3`] = `1`; -exports[`海豚圆选点导致的错误 4`] = `1827.6352392619829`; +exports[`海豚圆选点导致的错误 4`] = `1827.6352392619826`; -exports[`简单图形因为点在线内算法错误导致的丢失 1`] = `8.675189454805246`; +exports[`简单图形因为点在线内算法错误导致的丢失 1`] = `8.675189454805244`; exports[`简单图形因为点在线内算法错误导致的丢失 2`] = `8.252841733482935`; @@ -108,9 +108,9 @@ exports[`纯圆生成的多段线偏移 3`] = `1`; 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`; @@ -122,7 +122,7 @@ exports[`补圆弧测试 补圆弧测试1 4`] = `202.97120101469034`; exports[`补圆弧测试 补圆弧测试1 5`] = `1`; -exports[`补圆弧测试 补圆弧测试1 6`] = `203.63368101398322`; +exports[`补圆弧测试 补圆弧测试1 6`] = `203.6336810139832`; exports[`补圆弧测试 补圆弧测试1 7`] = `1`; @@ -130,7 +130,7 @@ exports[`补圆弧测试 补圆弧测试1 8`] = `204.40243508941455`; exports[`补圆弧测试 补圆弧测试1 9`] = `1`; -exports[`补圆弧测试 补圆弧测试1 10`] = `205.30936570465025`; +exports[`补圆弧测试 补圆弧测试1 10`] = `205.30936570465022`; exports[`补圆弧测试 补圆弧测试1 11`] = `1`; @@ -194,18 +194,18 @@ exports[`补圆弧测试 补圆弧测试1 40`] = `193.2116587563558`; exports[`补圆弧测试 补圆弧测试1 41`] = `1`; -exports[`补圆弧测试 补圆弧测试1 42`] = `192.84673020284995`; +exports[`补圆弧测试 补圆弧测试1 42`] = `192.84673020284998`; exports[`补圆弧测试 补圆弧测试1 43`] = `1`; 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[`闭合多段线判断精度和重复交点参数导致偏移丢失 5`] = `57859.37443960541`; +exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 5`] = `57859.374439605526`; diff --git a/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap b/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap index 22223fbd8..e618b9908 100644 --- a/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap +++ b/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap @@ -1,25 +1,25 @@ // 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 7`] = `14.067113755971715`; +exports[`补充bug测试#IKWGF 7`] = `14.067113755971711`; 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`; diff --git a/src/Add-on/DrawBoard/DrawBehindBoard.ts b/src/Add-on/DrawBoard/DrawBehindBoard.ts index 8b027b075..722a89df4 100644 --- a/src/Add-on/DrawBoard/DrawBehindBoard.ts +++ b/src/Add-on/DrawBoard/DrawBehindBoard.ts @@ -65,7 +65,7 @@ export class DrawBehindBoard extends DrawBoardTool { let b = board.Clone(); b.Name = opt.name; - b.m_BoardProcessOption = Object.assign({}, data.boardProcess); + b.BoardProcessOption = data.boardProcess; if (relPos === BrRelativePos.Front) b.ApplyMatrix(MoveMatrix(newBox.min.clone().add(new Vector3(0, spaceSize * i + (i - 1) * thickness, 0)))); diff --git a/src/Add-on/DrawBoard/DrawClosingStrip.ts b/src/Add-on/DrawBoard/DrawClosingStrip.ts index f11d07f43..9713e0a49 100644 --- a/src/Add-on/DrawBoard/DrawClosingStrip.ts +++ b/src/Add-on/DrawBoard/DrawClosingStrip.ts @@ -118,7 +118,7 @@ export class DrawClosingStrip implements Command opt.width = br.Width; br.Name = opt.name; - br.m_BoardProcessOption = Object.assign({}, this.store.m_BoardProcessOption); + br.BoardProcessOption = this.store.m_BoardProcessOption; //收口条颜色 br.ColorIndex = 4; diff --git a/src/Add-on/DrawBoard/DrawLayerBoard.ts b/src/Add-on/DrawBoard/DrawLayerBoard.ts index 2acd255d3..c4221b452 100644 --- a/src/Add-on/DrawBoard/DrawLayerBoard.ts +++ b/src/Add-on/DrawBoard/DrawLayerBoard.ts @@ -48,7 +48,7 @@ export class DrawLayerBoard extends DrawBoardTool { let b = board.Clone() as Board; b.Name = opt.name; - b.m_BoardProcessOption = Object.assign({}, data.boardProcess); + b.BoardProcessOption = data.boardProcess; if (type === BrRelativePos.Top) b.ApplyMatrix(MoveMatrix(box.min.clone().add( diff --git a/src/Add-on/DrawBoard/DrawLeftRightBoard.ts b/src/Add-on/DrawBoard/DrawLeftRightBoard.ts index 59d06c7d8..7a8afc8b3 100644 --- a/src/Add-on/DrawBoard/DrawLeftRightBoard.ts +++ b/src/Add-on/DrawBoard/DrawLeftRightBoard.ts @@ -50,10 +50,10 @@ export class DrawLeftRight implements Command rightBoard.ApplyMatrix(MoveMatrix(vec)); leftBoard.Name = "左侧板" - leftBoard.m_BoardProcessOption = Object.assign({}, store.m_BoardProcessOption); + leftBoard.BoardProcessOption = store.m_BoardProcessOption; 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(rightBoard); diff --git a/src/Add-on/DrawBoard/DrawSingleBoard.ts b/src/Add-on/DrawBoard/DrawSingleBoard.ts index 587e20bad..0514a0d38 100644 --- a/src/Add-on/DrawBoard/DrawSingleBoard.ts +++ b/src/Add-on/DrawBoard/DrawSingleBoard.ts @@ -21,7 +21,7 @@ export class DrawSingleBoard implements Command { const opt = store.m_Option; 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 ry = Math.degToRad(opt.rotateY); let rz = Math.degToRad(opt.rotateZ); diff --git a/src/Add-on/DrawBoard/DrawSpecialShapeBoardTool.ts b/src/Add-on/DrawBoard/DrawSpecialShapeBoardTool.ts index ddf6301ec..26e786510 100644 --- a/src/Add-on/DrawBoard/DrawSpecialShapeBoardTool.ts +++ b/src/Add-on/DrawBoard/DrawSpecialShapeBoardTool.ts @@ -1,6 +1,6 @@ -import { Vector3 } from "three"; +import { Vector2 } from "three"; import { app } from "../../ApplicationServices/Application"; -import { curveLinkGroup, Vec3DTo2D } from "../../Common/CurveUtils"; +import { curveLinkGroup } from "../../Common/CurveUtils"; import { Board } from "../../DatabaseServices/Board"; import { Circle } from "../../DatabaseServices/Circle"; import { Contour } from "../../DatabaseServices/Contour"; @@ -32,13 +32,11 @@ export async function getEntShape() export function getViewEntiy(filter?: Filter) { //屏幕左上角点 - let leftTopPt = new Vector3(); - app.m_Viewer.ScreenToWorld(leftTopPt); + let leftTopPt = new Vector2(); //屏幕右下角点 - let rightBottomPt = new Vector3(app.m_Viewer.Width, app.m_Viewer.Height); - app.m_Viewer.ScreenToWorld(rightBottomPt); + let rightBottomPt = new Vector2(app.m_Viewer.Width, app.m_Viewer.Height); - 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) return selectBox.SelectEntityList; } @@ -70,9 +68,10 @@ export function getCulistShape(cus: Entity[], isErase = false) { if ((c instanceof Polyline && c.IsClose) || c instanceof Circle) { + let shape = new Shape(Contour.CreateContour([c.Clone()])); if (isErase) c.Erase(); - return new Shape(Contour.CreateContour([c.Clone()])); + return shape; } //获得屏幕内的曲线 let totalCulist = getViewEntiy({ filterTypes: [Curve] }) as Curve[]; @@ -89,6 +88,7 @@ export function getCulistShape(cus: Entity[], isErase = false) let con = Contour.CreateContour(g); if (con) { + //TODO:应该在确定绘制后在删除构建曲线 if (isErase) g.forEach(c => c.Erase()) return new Shape(con); diff --git a/src/Add-on/DrawBoard/DrawSpecialShapedBoard.ts b/src/Add-on/DrawBoard/DrawSpecialShapedBoard.ts index 9822c4b7e..02dc3debd 100644 --- a/src/Add-on/DrawBoard/DrawSpecialShapedBoard.ts +++ b/src/Add-on/DrawBoard/DrawSpecialShapedBoard.ts @@ -78,7 +78,7 @@ export class DrawSpecialShapedBoard implements Command //创建板件 let br = Board.CreateBoard(length, width, thickness, store.m_Option.type); br.Name = store.m_Option.name; - br.m_BoardProcessOption = store.m_BoardProcessOption; + br.BoardProcessOption = store.m_BoardProcessOption; br.ApplyMatrix(br.OCSInv); br.ApplyMatrix(MoveMatrix(br.MinPoint.negate())); diff --git a/src/Add-on/DrawBoard/DrawTopBottomBoard.ts b/src/Add-on/DrawBoard/DrawTopBottomBoard.ts index bd0ede393..225fee0a6 100644 --- a/src/Add-on/DrawBoard/DrawTopBottomBoard.ts +++ b/src/Add-on/DrawBoard/DrawTopBottomBoard.ts @@ -138,7 +138,7 @@ export class DrawTopBottomBoard implements Command 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)); @@ -153,9 +153,9 @@ export class DrawTopBottomBoard implements Command if (offset > 0) { let footBoard = Board.CreateBoard(offset, spaceParse.Size.x, opt.footThickness, BoardType.Behind); - footBoard.m_BoardProcessOption = Object.assign({}, this.store.m_BoardProcessOption); - footBoard.m_BoardProcessOption.composingFace = ComposingType.Reverse; - footBoard.m_BoardProcessOption.bigHoleDir = PXLFaceType.Reverse; + footBoard.BoardProcessOption = this.store.m_BoardProcessOption; + footBoard.BoardProcessOption.composingFace = ComposingType.Reverse; + footBoard.BoardProcessOption.bigHoleDir = PXLFaceType.Reverse; footBoard.ApplyMatrix(MoveMatrix(spaceParse.m_SpaceBox.min.add(new Vector3(0, opt.footBehindShrink)))); footBoard.ApplyMatrix(spaceParse.m_SpaceOCS); app.m_Database.ModelSpace.Append(footBoard); diff --git a/src/Add-on/DrawBoard/DrawVerticalBoard.ts b/src/Add-on/DrawBoard/DrawVerticalBoard.ts index 5a67c0ed2..06af0bb9d 100644 --- a/src/Add-on/DrawBoard/DrawVerticalBoard.ts +++ b/src/Add-on/DrawBoard/DrawVerticalBoard.ts @@ -53,7 +53,7 @@ export class DrawVerticalBoard extends DrawBoardTool { let b = board.Clone() as Board; b.Name = opt.name; - b.m_BoardProcessOption = Object.assign({}, data.boardProcess); + b.BoardProcessOption = data.boardProcess; if (type === BrRelativePos.Left) b.ApplyMatrix(MoveMatrix(box.min.clone().add( diff --git a/src/Add-on/DrawDrilling/DrawDrillingTool.ts b/src/Add-on/DrawDrilling/DrawDrillingTool.ts index 776adf65c..03e4bc84c 100644 --- a/src/Add-on/DrawDrilling/DrawDrillingTool.ts +++ b/src/Add-on/DrawDrilling/DrawDrillingTool.ts @@ -70,7 +70,7 @@ export class DrawDrillingTool { //偏心轮下偏距离 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( new Vector3(0, isPostive ? this.m_Face.m_Width - pxlOffestDist : pxlDepth - pxlOffestDist) )); diff --git a/src/Common/CheckoutVaildValue.ts b/src/Common/CheckoutVaildValue.ts index 07bc80f4a..df2eab6a4 100644 --- a/src/Common/CheckoutVaildValue.ts +++ b/src/Common/CheckoutVaildValue.ts @@ -47,6 +47,9 @@ export namespace CheckoutValid case "material": case "color": case "striptype": + case "spliteHeight": + case "spliteWidth": + case "spliteThickness": return ""; case "height": case "width": diff --git a/src/DatabaseServices/Board.ts b/src/DatabaseServices/Board.ts index 9f077e817..df9bfc442 100644 --- a/src/DatabaseServices/Board.ts +++ b/src/DatabaseServices/Board.ts @@ -3,7 +3,7 @@ import { ExtrudeGeometry, Matrix4, Mesh, MeshNormalMaterial, Object3D, Vector2, import { Box3Ext } from '../Geometry/Box'; import { equaln, rotatePoint } from '../Geometry/GeUtils'; 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 { CADFile } from './CADFile'; import { Circle } from './Circle'; @@ -58,7 +58,7 @@ export class Board extends Entity private m_BoardType: BoardType; private m_Name = ""; private m_SpecOCS: Matrix4 = new Matrix4(); //板件的标系 - m_BoardProcessOption: BoardProcessOption = {}; + private m_BoardProcessOption: BoardProcessOption = {}; //板件排钻表,与之碰撞板件为key private m_DrillList: Map = new Map(); constructor(shape?: Shape, thickness?: number) @@ -89,6 +89,29 @@ export class Board extends Entity { let board = new Board(); 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 board.ApplyMatrix(roMat); board.m_SpecOCS.identity(); @@ -99,6 +122,16 @@ export class Board extends Entity { 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[][]) { this.WriteAllObjectRecord(); @@ -308,6 +341,12 @@ export class Board extends Entity this.m_Width = size.x ? size.x : size.z; 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() { return this.m_Name; diff --git a/src/DatabaseServices/Polyline.ts b/src/DatabaseServices/Polyline.ts index 27061daad..a7aeac931 100644 --- a/src/DatabaseServices/Polyline.ts +++ b/src/DatabaseServices/Polyline.ts @@ -1,5 +1,5 @@ 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 { arrayLast, arrayRemoveDuplicateBySort } from '../Common/ArrayExt'; import { ColorMaterial } from '../Common/ColorPalette'; @@ -873,6 +873,7 @@ export class Polyline extends Curve let d1 = this.m_LineData[i]; let d2 = this.m_LineData[FixIndex(i + 1, this.m_LineData)]; + if (equaln(d1.bul, 0, 1e-8)) { return new Line(Vec2DTo3D(d1.pt), Vec2DTo3D(d2.pt)).ApplyMatrix(this.OCS); diff --git a/src/DatabaseServices/Text/Text.ts b/src/DatabaseServices/Text/Text.ts index e6e14b38b..391d749e6 100644 --- a/src/DatabaseServices/Text/Text.ts +++ b/src/DatabaseServices/Text/Text.ts @@ -30,7 +30,7 @@ export class Text extends Entity pos && this.m_Matrix.setPosition(pos); ro && setRotationOnAxis(this.m_Matrix, this.Normal, Math.degToRad(ro)); this.m_TextString = str || ""; - this.m_Height = h || 0; + this.m_Height = h || 60; this.m_TextRotation = ro || 0; } diff --git a/src/Editor/DbClick/DBClickPolyline.ts b/src/Editor/DbClick/DBClickPolyline.ts index f8b4d3299..30ecb9b1a 100644 --- a/src/Editor/DbClick/DBClickPolyline.ts +++ b/src/Editor/DbClick/DBClickPolyline.ts @@ -238,16 +238,19 @@ export class DBClickPolyline let groups = curveLinkGroup(cus); for (let g of groups) { - if (!g.includes(pl)) + let i = g.indexOf(pl); + if (i === -1) continue; + if (i !== 0) + g.unshift(...g.splice(i)); + + g.shift(); + for (let cu of g) { - if (cu !== pl) - { - pl.Join(cu); - cu.Erase(); - } + pl.Join(cu); + cu.Erase(); } } return PromptStatus.OK; diff --git a/src/Editor/DbClick/DbClick.ts b/src/Editor/DbClick/DbClick.ts index a8af20a4d..0e9a38b4d 100644 --- a/src/Editor/DbClick/DbClick.ts +++ b/src/Editor/DbClick/DbClick.ts @@ -48,6 +48,7 @@ export class DbClickManager } else if (obj3d.userData instanceof Board) { + app.m_Editor.m_ModalManage.Clear(); app.m_Editor.m_ModalManage.RenderModeless( BoardOptionModal, ModalPosition.Right, diff --git a/src/Editor/Jig.ts b/src/Editor/Jig.ts index d1596a5a5..f79bf7ebc 100644 --- a/src/Editor/Jig.ts +++ b/src/Editor/Jig.ts @@ -98,5 +98,6 @@ export class Jig e.GoodBye(); }); this.m_JigEnts.length = 0; + app.m_Editor.UpdateScreen(); } } diff --git a/src/GraphicsSystem/CalcEdgeSealing.ts b/src/GraphicsSystem/CalcEdgeSealing.ts new file mode 100644 index 000000000..7367f1ec6 --- /dev/null +++ b/src/GraphicsSystem/CalcEdgeSealing.ts @@ -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; + } +} diff --git a/src/GraphicsSystem/OffsetPolyline.ts b/src/GraphicsSystem/OffsetPolyline.ts index 5d8856541..27a9b499e 100644 --- a/src/GraphicsSystem/OffsetPolyline.ts +++ b/src/GraphicsSystem/OffsetPolyline.ts @@ -318,7 +318,7 @@ export class PolyOffsetUtil if (tPts.length > 0)//存在真交点情况下直接修剪 { - let iPt = this.selectFitInterPt(tPts, frontLine.EndPoint); + let iPt = PolyOffsetUtil.selectFitInterPt(tPts, frontLine.EndPoint); if (isFillArc) { //用丢失圆弧和交点构建扇形轮廓 @@ -339,7 +339,7 @@ export class PolyOffsetUtil } 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); } @@ -450,7 +450,7 @@ export class PolyOffsetUtil * @param {Curve} frontLine * @param {Curve} laterLine * @returns - * @memberof PolyOffestUtil3 + * @memberof PolyOffestUtil */ fillArc(startIndex: number, endIndex: number, nextPt: Vector3, @@ -490,7 +490,7 @@ export class PolyOffsetUtil else iPts = [frontLine.EndPoint]; - let iPt = this.selectFitInterPt(iPts, frontLine.EndPoint); + let iPt = PolyOffsetUtil.selectFitInterPt(iPts, frontLine.EndPoint); this.appendNewCuAndContour(frontLine, nextPt, iPt, startIndex); //连接剩下的圆. @@ -514,7 +514,7 @@ export class PolyOffsetUtil 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); return; } @@ -522,7 +522,7 @@ export class PolyOffsetUtil let c2 = cirs[index + 1]; 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); } @@ -679,7 +679,7 @@ export class PolyOffsetUtil * @returns * @memberof PolyOffestUtil */ - private selectFitInterPt(pts: Vector3[], refPt: Vector3) + static selectFitInterPt(pts: Vector3[], refPt: Vector3) { if (pts.length > 1) { diff --git a/src/UI/Components/Board/BoardConfigModal.tsx b/src/UI/Components/Board/BoardConfigModal.tsx index 3531fcadd..c3ba4da0e 100644 --- a/src/UI/Components/Board/BoardConfigModal.tsx +++ b/src/UI/Components/Board/BoardConfigModal.tsx @@ -1,8 +1,11 @@ import { Button, Checkbox } from "@blueprintjs/core"; +import { IObservableValue, observable } from "mobx"; import * as React from 'react'; import { Matrix4 } from "three"; import { aplicateContour, getEntShape } from "../../../Add-on/DrawBoard/DrawSpecialShapeBoardTool"; import { app } from "../../../ApplicationServices/Application"; +import { CheckObjectType } from "../../../Common/CheckoutVaildValue"; +import { DataAdapter } from "../../../Common/DataAdapter"; import { Board } from "../../../DatabaseServices/Board"; import { commandMachine } from "../../../Editor/CommandMachine"; import { Jig } from "../../../Editor/Jig"; @@ -10,15 +13,13 @@ import { PromptStatus } from "../../../Editor/PromptResult"; import { MoveMatrix } from "../../../Geometry/GeUtils"; import { BoardConfigOption, BoardProcessOption } from '../../Store/BoardInterface'; import { BoardTypeComponent, ItemName, SetBoardDataBlock } from "./BoardCommon"; -import { DataAdapter } from "../../../Common/DataAdapter"; -import { observable } from "mobx"; -import { CheckObjectType } from "../../../Common/CheckoutVaildValue"; interface BoardConfigProps { boardConfig: BoardConfigOption; boardProcess: BoardProcessOption; br: Board; + isSpecial: IObservableValue; } export class BoardConfigModal extends React.Component{ private pars = [["height", "显示高"], ["width", "显示宽"], ["thickness", "显示厚"], @@ -46,8 +47,6 @@ export class BoardConfigModal extends React.Component{ app.m_Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS); let cu = Jig.Draw(br.Shape.Outline.Curve.Clone().ApplyMatrix(br.OCS)); - - let ptRes = await app.m_Editor.GetPoint({ Msg: "点取位置", Callback: v => @@ -72,7 +71,7 @@ export class BoardConfigModal extends React.Component{ aplicateContour(shape, [br], false); app.m_Editor.m_ModalManage.ToggleShow(); - + this.props.isSpecial.set(br.IsSpecialShape); commandMachine.CommandEnd("selectlk"); } render() diff --git a/src/UI/Components/Board/BoardOptionModal.tsx b/src/UI/Components/Board/BoardOptionModal.tsx index 6b70f235e..38cca8659 100644 --- a/src/UI/Components/Board/BoardOptionModal.tsx +++ b/src/UI/Components/Board/BoardOptionModal.tsx @@ -19,24 +19,26 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}> @observable private m_ConfigOption: SingleBoardOption; @observable private m_ProcessOption: BoardProcessOption; private m_BoardMap: Map = new Map(); - private currentBoard: Board; + private m_CurrentBoard: Board; + private m_IsSpecialBoard = observable.box(false); constructor(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.m_ProcessOption = Object.assign({}, this.currentBoard.m_BoardProcessOption); + this.m_ProcessOption = Object.assign({}, this.m_CurrentBoard.BoardProcessOption); } SetBrConfig = () => { - let ro = this.currentBoard.Rotation; + let ro = this.m_CurrentBoard.Rotation; let newConfig = { - name: this.currentBoard.Name, - type: this.currentBoard.BoardType, - height: parseFloat(FixedNotZero(this.currentBoard.Length, 2)), - width: parseFloat(FixedNotZero(this.currentBoard.Width, 2)), - thickness: parseFloat(FixedNotZero(this.currentBoard.Thickness, 2)), + name: this.m_CurrentBoard.Name, + type: this.m_CurrentBoard.BoardType, + height: parseFloat(FixedNotZero(this.m_CurrentBoard.Length, 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)), rotateY: parseFloat(FixedNotZero(Math.radToDeg(ro.y), 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; app.m_Database.hm.StartCmd("changeSize"); - let board = this.currentBoard; - Object.assign(board.m_BoardProcessOption, this.m_ProcessOption); + let board = this.m_CurrentBoard; + board.BoardProcessOption = this.m_ProcessOption; board.Name = this.m_ConfigOption.name; board.Length = this.m_ConfigOption.height; @@ -82,7 +84,6 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}> { board.RotateBoard(newRoX, newRoY, newRoZ); } - app.m_Editor.UpdateScreen(); app.m_Editor.m_ModalManage.Clear(); commandMachine.CommandEnd("changeSize"); @@ -95,7 +96,7 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}> let br = en.userData; if (en.visible && br && 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); } @@ -128,13 +129,13 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}> >
{ return { - label: "板件名" + b.Name + "柜名" + b.m_BoardProcessOption.boardName, + label: "板件名" + b.Name + "柜名" + b.BoardProcessOption.boardName, 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); this.SetBrConfig(); - Object.assign(this.m_ProcessOption, br.m_BoardProcessOption); + Object.assign(this.m_ProcessOption, br.BoardProcessOption); }} />
- +
- +
diff --git a/src/UI/Components/Board/BoardProcessModal.tsx b/src/UI/Components/Board/BoardProcessModal.tsx index c2af4993e..30eb62582 100644 --- a/src/UI/Components/Board/BoardProcessModal.tsx +++ b/src/UI/Components/Board/BoardProcessModal.tsx @@ -2,169 +2,194 @@ import { Classes, HTMLSelect } from '@blueprintjs/core'; import { observer } from 'mobx-react'; import * as React from 'react'; import { CheckObjectType } from '../../../Common/CheckoutVaildValue'; +import { Board } from '../../../DatabaseServices/Board'; import { BoardProcessOption, ComposingType, DrillType, LinesType, PXLFaceType } from '../../Store/BoardInterface'; import { ToasterInput } from '../Toaster'; 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; + br?: Board; +} +@observer +export class BoardProcessModal extends React.Component{ + private matPars = [ ["boardName", "板材名"], ["material", "材料"], ["color", "颜色"] ]; - return ( -
- - -
- + - -
-
- - - - -
-
材料封边
-
- +
+ + +
+ + + + +
+
+ 封边 + { + isShowHighEditor ? ( + + ) + : null + } +
+
- +
+ + + +
-
-
- ) -}) + ) + } +} diff --git a/src/UI/Components/Board/EdgeSealingComponent.tsx b/src/UI/Components/Board/EdgeSealingComponent.tsx new file mode 100644 index 000000000..5e19b0fb3 --- /dev/null +++ b/src/UI/Components/Board/EdgeSealingComponent.tsx @@ -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 = 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 ( + +
封边编辑
+
    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 ( +
  • + +
  • + ) + }) + } +
+
+
+
+ } + target={ +