From b0645ebd1935af5c788d1c11a042b356b7c835c6 Mon Sep 17 00:00:00 2001 From: ChenX Date: Wed, 8 May 2019 18:43:42 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#IWBW8=20=E4=BF=AE=E6=AD=A3=E5=88=87?= =?UTF-8?q?=E5=89=B2=E6=97=A0=E6=B3=95=E5=88=86=E8=A3=82=E6=88=90=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/Booloperate/BoardCutting.test.ts | 35 +++++++++++++++++++ .../__snapshots__/BoardCutting.test.ts.snap | 25 +++++++++++++ src/DatabaseServices/Extrude.ts | 3 +- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 __test__/Booloperate/BoardCutting.test.ts create mode 100644 __test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap diff --git a/__test__/Booloperate/BoardCutting.test.ts b/__test__/Booloperate/BoardCutting.test.ts new file mode 100644 index 000000000..2d99bd6a3 --- /dev/null +++ b/__test__/Booloperate/BoardCutting.test.ts @@ -0,0 +1,35 @@ +import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util"; +import { Board } from "../../src/DatabaseServices/Board"; + + +function CuttingBoard(orgBoard: Board, cutBoards: Board[]) +{ + for (let br of cutBoards) + { + let gs = orgBoard.ConverToLocalGroove(br.Clone()); + for (let g of gs) + orgBoard.AppendGroove(g); + } + let splitBoard: Board[] = []; + orgBoard.GrooveCheckAll(splitBoard); + return splitBoard; +} + +test('板件与板件切割_分裂成多个', () => +{ + let d = + [3, "Board", 3, 2, 101, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -331.4882673815591, 22.964750159997493, 0, 1], 2, 1200, 600, 18, true, "Polyline", 3, 2, 0, false, 0, 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, 1, 2, 560.6466, 189.21820000000014, 18, false, "Polyline", 3, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1827.9668979500452, -289.76232632197764, 0, 1], 2, 4, [1827.9668979500452, 755.7998263219777], 0, [1827.9668979500452, 289.76232632197764], 0, [2017.1850979500452, 289.76232632197764], 0, [2017.1850979500452, 755.7998263219777], 0.9999999999999999, true, 0, 3, 0, 0, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -331.4882673815591, 240.21531912679802, 487.0617703059633, 1], 3, 0, 0, 0, 2, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -331.4882673815591, 22.964750159997493, 0, 1], 1, "左侧板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highDrill\":[\"three\",\"three\",\"three\",\"three\",\"three\",\"three\"]}", 0, 0, "Board", 3, 2, 103, false, 1, 2, 0, [0, 0.7071067811865476, 0.7071067811865475, 0, -1, 0, 0, 0, 0, -0.7071067811865475, 0.7071067811865476, 0, 150.8430102636048, -52.19811424968327, 170.47952541755785, 1], 2, 783.3533043634961, 1175.1597867537462, 18, true, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 376.7045899568675, -325.59238647697345, 0, 1], 2, 4, [-376.7045899568675, 325.59238647697345], 0, [798.4551967968786, 325.59238647697345], 0, [798.4551967968786, 1108.9456908404695], 0, [-376.7045899568675, 1108.9456908404695], 0, true, 0, 3, 0, 0, 0, 2, [1, 0, 0, 0, 0, 0.7071067811865476, 0.7071067811865475, 0, 0, -0.7071067811865475, 0.7071067811865476, 0, 476.43539674057826, 214.17225581291558, 436.84989548015665, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highDrill\":[]}", 0, 0, "Board", 3, 2, 105, false, 1, 2, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 150.8430102636048, -84.04268340053818, 746.0908003894185, 1], 2, 1200, 1446.4691198791304, 18, true, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [1446.4691198791304, 0], 0, [1446.4691198791304, 1200], 0, [0, 1200], 0, true, 0, 3, 0, 0, 0, 2, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 150.8430102636048, -84.04268340053818, 746.0908003894185, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highDrill\":[]}", 0, 0]; + + let brs = LoadBoardsFromFileData(d); + let br = brs.shift() + let splitBrs = CuttingBoard(br, brs); + + splitBrs.push(br); + + for (let b of splitBrs) + { + expect(b.Width).toMatchSnapshot(); + expect(b.Height).toMatchSnapshot(); + expect(b.Thickness).toMatchSnapshot(); + } +}); diff --git a/__test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap b/__test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap new file mode 100644 index 000000000..230724db7 --- /dev/null +++ b/__test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap @@ -0,0 +1,25 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`板件与板件切割_分裂成多个 1`] = `600.0000000000049`; + +exports[`板件与板件切割_分裂成多个 2`] = `435.9091996105815`; + +exports[`板件与板件切割_分裂成多个 3`] = `18`; + +exports[`板件与板件切割_分裂成多个 4`] = `217.25056896680059`; + +exports[`板件与板件切割_分裂成多个 5`] = `474.99256643946615`; + +exports[`板件与板件切割_分裂成多个 6`] = `18`; + +exports[`板件与板件切割_分裂成多个 7`] = `81.55158943782021`; + +exports[`板件与板件切割_分裂成多个 8`] = `81.5515894378201`; + +exports[`板件与板件切割_分裂成多个 9`] = `18`; + +exports[`板件与板件切割_分裂成多个 10`] = `600`; + +exports[`板件与板件切割_分裂成多个 11`] = `746.0908003894186`; + +exports[`板件与板件切割_分裂成多个 12`] = `18`; diff --git a/src/DatabaseServices/Extrude.ts b/src/DatabaseServices/Extrude.ts index 7ed0e9141..be816770f 100644 --- a/src/DatabaseServices/Extrude.ts +++ b/src/DatabaseServices/Extrude.ts @@ -695,13 +695,12 @@ export class ExtureSolid extends Entity p.applyMatrix4(mi); let box = new Box3().setFromPoints(pts); let size = box.getSize(new Vector3()); - m.setPosition(box.min.applyMatrix4(m)); let ext = useClone ? target.Clone() : new ExtureSolid(); if (useClone) ext.grooves.length = 0; ext.ConverToRectSolid(size.x, size.y, size.z); - ext.OCS = m; + ext.OCS = m.clone().setPosition(box.min.applyMatrix4(m)); grooves.push(ext); }