From fa8cf28bda4cda0e8d3c0f963513fd621874155a Mon Sep 17 00:00:00 2001 From: ChenX Date: Mon, 4 Jul 2022 02:21:55 +0000 Subject: [PATCH] =?UTF-8?q?!1953=20=E4=BF=AE=E5=A4=8D:=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E6=9D=BF=E4=BF=AE=E6=94=B9=E6=9D=BF=E5=B0=BA=E5=AF=B8=E5=90=8E?= =?UTF-8?q?,=E6=9D=BF=E8=BE=B9=E6=95=B0=E6=8D=AE=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/Board/Mirror.test.ts | 16 +- .../Board/__snapshots__/Mirror.test.ts.snap | 485 ++++++++++++------ src/DatabaseServices/Entity/Board.ts | 32 +- src/GraphicsSystem/CalcEdgeSealing.ts | 27 +- src/UI/Components/Board/BoardProcessModal.tsx | 13 +- 5 files changed, 415 insertions(+), 158 deletions(-) diff --git a/__test__/Board/Mirror.test.ts b/__test__/Board/Mirror.test.ts index 4f6db9bcb..40399d861 100644 --- a/__test__/Board/Mirror.test.ts +++ b/__test__/Board/Mirror.test.ts @@ -12,5 +12,19 @@ test('板件镜像', () => br.ApplyMatrix(MakeMirrorMtx(new Vector3(0, 0, 1))); let f = new CADFiler; f.WriteObject(br); - expect(f).toMatchSnapshot(); + expect(f.Data).toMatchSnapshot(); +}); + + +test('板镜像后板边数据错误', () => +{ + let d = + { "file": [1, "Board", 8, 2, 100, false, 1, 8, 0, [0, 1, 0, 0, -1, 0, 1.2246467991473532e-16, 0, 1.2246467991473532e-16, 0, 1, 0, 523.6891679748768, 34.536891679748834, 0, 1], 0, 0, true, [1, 0, -1.2246467991473532e-16, 0, 0, 1, 0, 0, 1.2246467991473532e-16, 0, 1, 0, 1704.1891679749642, 34.536891679748834, 0, 1], 0, 3, 569.9999999999945, 65, 17.5, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 569.9999999999945, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 6, [26.888366718995428, -569.9999999999945], 0, [26.888366718995428, -526.2850109890051], 0, [65, -526.2850109890051], 0, [65, 0], 0, [0, 0], 0, [0, -569.9999999999945], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 0, "辅助条(上收口)", "", "", "", "", "", 0, 0, "**多种**", 2, 6, 1, 2, 1, 2, 3, 4, "2", "4", "3", "1", "", "", "", 6, "二合一", "铰链孔", "三合一", "二合一", "铰链孔", "不排", true, false, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": -46.31083202511775, "y": 34.536891679748834, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let br = LoadBoardsFromFileData(d)[0]; + br.ApplyMatrix(MakeMirrorMtx(new Vector3(1, 0, 0))); + + br.Width = 88; + let f = new CADFiler; + f.WriteObject(br); + expect(f.Data).toMatchSnapshot(); }); diff --git a/__test__/Board/__snapshots__/Mirror.test.ts.snap b/__test__/Board/__snapshots__/Mirror.test.ts.snap index 42ce933f1..335bff186 100644 --- a/__test__/Board/__snapshots__/Mirror.test.ts.snap +++ b/__test__/Board/__snapshots__/Mirror.test.ts.snap @@ -1,182 +1,371 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`板件镜像 1`] = ` -CADFiler { - "_datas": Array [ - "Board", - 8, - 2, - 0, - false, - 0, - 2, - 0, - Array [ - 0, - 1, - 0, - 0, - -1, - 0, - 0, - 0, - 0, - 0, - -1, - 0, - 3435.3422864514687, - 444.811074718357, - -21.352872036479766, - 1, - ], - 0, - 0, - true, - Array [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - -1, - 0, - 2671.3422864514687, - 444.811074718357, - -21.352872036479766, - 1, - ], - 0, - 3, +Array [ + "Board", + 8, + 2, + 0, + false, + 0, + 2, + 0, + Array [ + 0, + 1, + 0, + 0, + -1, + 0, + 0, + 0, + 0, + 0, + -1, + 0, + 3435.3422864514687, + 444.811074718357, + -21.352872036479766, + 1, + ], + 0, + 0, + true, + Array [ + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + -1, + 0, + 2671.3422864514687, + 444.811074718357, + -21.352872036479766, + 1, + ], + 0, + 3, + 764, + 500.00000000000006, + 18, + true, + "Polyline", + 8, + 2, + 0, + false, + 0, + 7, + 0, + Array [ + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + ], + 0, + 0, + true, + Array [ + 6.123233995736766e-17, + -1, + 0, + 0, + 1, + 6.123233995736766e-17, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 764, + 0, + 1, + ], + 0, + 2, + 4, + Array [ + 0, 764, + ], + 0, + Array [ + 500, + 764, + ], + 0, + Array [ 500.00000000000006, - 18, - true, - "Polyline", - 8, - 2, - 0, - false, - 0, - 7, - 0, - Array [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - ], 0, + ], + 0, + Array [ + 4.678150772742889e-14, 0, - true, - Array [ - 6.123233995736766e-17, - -1, - 0, - 0, - 1, - 6.123233995736766e-17, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 764, - 0, - 1, - ], + ], + 0, + true, + 0, + 3, + 1, + 1, + 1, + 0, + 0, + 10, + 0, + "晨丰顶板", + "未命名", + "晨丰一字柜测试", + "", + "水曲柳(默认材质)", + "", + 0, + 1, + "**多种**", + 2, + 4, + 2, + 1, + 4, + 3, + "2", + "4", + "3", + "1", + "", + "", + "", + 4, + "三合一", + "铰链孔", + "二合一", + "不排", + true, + true, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + true, + 0, + 0, +] +`; + +exports[`板镜像后板边数据错误 1`] = ` +Array [ + "Board", + 8, + 2, + 0, + false, + 0, + 8, + 0, + Array [ 0, - 2, - 4, - Array [ - 0, - 764, - ], + 1, 0, - Array [ - 500, - 764, - ], 0, - Array [ - 500.00000000000006, - 0, - ], + 1, 0, - Array [ - 4.678150772742889e-14, - 0, - ], + 1.2246467991473532e-16, 0, - true, + -1.2246467991473532e-16, 0, - 3, 1, + 0, + -523.6891679748768, + 34.536891679748834, + 0, 1, + ], + 0, + 0, + true, + Array [ + -1, + 0, + -1.2246467991473532e-16, + 0, + 0, 1, 0, 0, - 10, + -1.2246467991473532e-16, + 0, + 1, 0, - "晨丰顶板", - "未命名", - "晨丰一字柜测试", - "", - "水曲柳(默认材质)", - "", + -1704.1891679749642, + 34.536891679748834, 0, 1, - "**多种**", - 2, - 4, - 2, + ], + 0, + 3, + 569.9999999999945, + 88, + 17.5, + false, + "Polyline", + 8, + 2, + 0, + false, + 0, + 7, + 0, + Array [ 1, - 4, - 3, - "2", - "4", - "3", - "1", - "", - "", - "", - 4, - "三合一", - "铰链孔", - "二合一", - "不排", - true, - true, 0, 0, 0, 0, + 1, + 0, + 0, 0, 0, + 1, 0, 0, - true, + 569.9999999999945, 0, + 1, + ], + 0, + 0, + true, + Array [ + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + ], + 0, + 2, + 6, + Array [ + 26.888366718995428, + -569.9999999999945, + ], + 0, + Array [ + 26.888366718995428, + -526.2850109890051, + ], + 0, + Array [ + 88, + -526.2850109890051, + ], + 0, + Array [ + 88, + 0, + ], + 0, + Array [ + 0, + 0, + ], + 0, + Array [ 0, + -569.9999999999945, ], - "readIndex": 0, -} + 0, + true, + 0, + 3, + 0, + 0, + 0, + 0, + 0, + 10, + 0, + "辅助条(上收口)", + "", + "", + "", + "", + "", + 0, + 0, + "**多种**", + 2, + 6, + 1, + 2, + 1, + 2, + 3, + 4, + "2", + "4", + "3", + "1", + "", + "", + "", + 6, + "二合一", + "铰链孔", + "三合一", + "二合一", + "铰链孔", + "不排", + true, + false, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + true, + 0, + 0, +] `; diff --git a/src/DatabaseServices/Entity/Board.ts b/src/DatabaseServices/Entity/Board.ts index 9c8f6ab9b..25ccd8682 100644 --- a/src/DatabaseServices/Entity/Board.ts +++ b/src/DatabaseServices/Entity/Board.ts @@ -874,13 +874,43 @@ export class Board extends ExtrudeSolid return this; } + let hasSplitSize = (this.BoardProcessOption[EBoardKeyList.SpliteHeight] + && this.BoardProcessOption[EBoardKeyList.SpliteWidth] + && this.BoardProcessOption[EBoardKeyList.SpliteThickness] + ); + let highSeals = GetBoardHighSeal(this, GetBoardSealingCurves(this)); super.ApplyMirrorMatrix(m); + if (this.contourCurve && this.contourCurve.Area2 < 0) + { + this.contourCurve.Reverse(); + highSeals.reverse(); + this.BoardProcessOption.highSealed?.reverse(); + this.BoardProcessOption.highDrill?.reverse(); + + if (hasSplitSize) + { + [ + this.BoardProcessOption.sealedUp, + this.BoardProcessOption.sealedLeft, + this.BoardProcessOption.sealedDown, + this.BoardProcessOption.sealedRight, + ] + = + [ + this.BoardProcessOption.sealedUp, + this.BoardProcessOption.sealedRight, + this.BoardProcessOption.sealedDown, + this.BoardProcessOption.sealedLeft, + ]; + } + } + this.BoardProcessOption.highSealed = highSeals; - if (this.isRect) + if (!hasSplitSize && this.isRect) HandleRectBoardSealingData(this, highSeals); //重新构建SpaceOCS this._SpaceOCS.multiplyMatrices(this._Matrix, new Matrix4().getInverse(this.RotateMat)); diff --git a/src/GraphicsSystem/CalcEdgeSealing.ts b/src/GraphicsSystem/CalcEdgeSealing.ts index 60f48d211..db1ed0b80 100644 --- a/src/GraphicsSystem/CalcEdgeSealing.ts +++ b/src/GraphicsSystem/CalcEdgeSealing.ts @@ -238,17 +238,32 @@ export function CalcEdgeSealing(cus: Curve[], highSeals?: IHighSealedItem[]) return true; } -export function GetBoardHighSeal(br: Board, sealcus: Curve[]) +//与GetBoardSealingCurves相关 +export function GetBoardHighSeal(br: Board, sealcus: Curve[]): IHighSealedItem[] { - let highSeals = br.BoardProcessOption.highSealed.slice().filter(d => d.size !== null && d.size !== undefined); - let sealDown = parseFloat(br.BoardProcessOption[EBoardKeyList.DownSealed]); - let sealUp = parseFloat(br.BoardProcessOption[EBoardKeyList.UpSealed]); - let sealLeft = parseFloat(br.BoardProcessOption[EBoardKeyList.LeftSealed]); - let sealRight = parseFloat(br.BoardProcessOption[EBoardKeyList.RightSealed]); + if (br.BoardProcessOption[EBoardKeyList.SpliteHeight] + && br.BoardProcessOption[EBoardKeyList.SpliteWidth] + && br.BoardProcessOption[EBoardKeyList.SpliteThickness] + ) + { + return [ + { size: parseFloat(br.BoardProcessOption.sealedDown) }, + { size: parseFloat(br.BoardProcessOption.sealedRight) }, + { size: parseFloat(br.BoardProcessOption.sealedUp) }, + { size: parseFloat(br.BoardProcessOption.sealedLeft) }, + ]; + } + + let highSeals = br.BoardProcessOption.highSealed.filter(d => d.size !== null && d.size !== undefined); //若未设置高级封边,把上下左右封边存入高级封边 if (sealcus.length !== highSeals.length || !br.IsSpecialShape) { + let sealDown = parseFloat(br.BoardProcessOption[EBoardKeyList.DownSealed]); + let sealUp = parseFloat(br.BoardProcessOption[EBoardKeyList.UpSealed]); + let sealLeft = parseFloat(br.BoardProcessOption[EBoardKeyList.LeftSealed]); + let sealRight = parseFloat(br.BoardProcessOption[EBoardKeyList.RightSealed]); + highSeals.length = 0; let dir = Math.sign(br.ContourCurve.Area2); for (let c of sealcus) diff --git a/src/UI/Components/Board/BoardProcessModal.tsx b/src/UI/Components/Board/BoardProcessModal.tsx index a1af7a365..69ca6556e 100644 --- a/src/UI/Components/Board/BoardProcessModal.tsx +++ b/src/UI/Components/Board/BoardProcessModal.tsx @@ -197,6 +197,14 @@ export class BoardProcessModal extends React.Component{ return (obj as ProcessingGroupRecord).Name; }); }; + private isSplit() + { + return ( + this.props.br.BoardProcessOption.spliteHeight + && this.props.br.BoardProcessOption.spliteWidth + && this.props.br.BoardProcessOption.spliteThickness + ) ? true : false; + } async UNSAFE_componentWillMount() { this.updateTags(); @@ -381,7 +389,7 @@ export class BoardProcessModal extends React.Component{
封边 { - isShowHighEditor && this.props.isSpecial.get() && + isShowHighEditor && this.props.isSpecial.get() && !this.isSplit() &&
{ - (!this.props.br || !this.props.isSpecial.get()) && { ); } + }