From fc15b7ee67c8d1499adae2f86412663bd89297d7 Mon Sep 17 00:00:00 2001 From: ChenX Date: Tue, 27 Apr 2021 11:01:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=E5=90=8C=E5=BF=83=E5=9C=86?= =?UTF-8?q?=E5=B8=83=E5=B0=94=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/board_circle.test.ts.snap | 6 +++++ __test__/Booloperate/board_circle.test.ts | 22 ++++++++++++++++++- __test__/Utils/LoadEntity.util.ts | 2 +- src/DatabaseServices/Contour.ts | 4 ++-- src/UI/Components/Board/BoardConfigModal.tsx | 2 ++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/__test__/Booloperate/__snapshots__/board_circle.test.ts.snap b/__test__/Booloperate/__snapshots__/board_circle.test.ts.snap index 06c84975f..ead533cbd 100644 --- a/__test__/Booloperate/__snapshots__/board_circle.test.ts.snap +++ b/__test__/Booloperate/__snapshots__/board_circle.test.ts.snap @@ -1,5 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`同心圆 1`] = `"101735.59416"`; + +exports[`同心圆 2`] = `"322593.41488"`; + +exports[`同心圆 3`] = `"220857.82072"`; + exports[`造型里面有重复的圆造型 1`] = `2782`; exports[`造型里面有重复的圆造型 2`] = `0`; diff --git a/__test__/Booloperate/board_circle.test.ts b/__test__/Booloperate/board_circle.test.ts index 57fe4f4ac..8e2b72327 100644 --- a/__test__/Booloperate/board_circle.test.ts +++ b/__test__/Booloperate/board_circle.test.ts @@ -1,5 +1,8 @@ +import { BoolOpeartionType } from "../../src/api"; import { Board } from "../../src/DatabaseServices/Entity/Board"; -import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; +import { Region } from "../../src/DatabaseServices/Entity/Region"; +import "../Utils/jest.util"; +import { LoadEntityFromFileData, LoadRegionsFromFileData } from "../Utils/LoadEntity.util"; test('造型里面有重复的圆造型', () => { @@ -13,3 +16,20 @@ test('造型里面有重复的圆造型', () => expect(br.Grooves.length).toMatchSnapshot(); expect(split.length).toMatchSnapshot(); }); + +test('同心圆', () => +{ + let f = { "file": [2, "Region", 8, 2, 506, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 1, 1, 1, 1, "Circle", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, 320.4444931257359, 0, "Region", 8, 2, 507, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 1, 1, 1, 1, "Circle", 8, 2, 0, false, 0, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, 179.954009116518, 0], "basePt": { "x": 1623.8278194823188, "y": 1169.183093664109, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let regs = LoadRegionsFromFileData(f) as Region[]; + let regs2 = regs.map(r => r.Clone()); + let regs3 = regs.map(r => r.Clone()); + + regs[0].BooleanOper(regs[1], BoolOpeartionType.Intersection); + expect(regs[0].Area).toMatchNumberSnapshot(); + + regs2[0].BooleanOper(regs2[1], BoolOpeartionType.Union); + expect(regs2[0].Area).toMatchNumberSnapshot(); + + regs3[0].BooleanOper(regs3[1], BoolOpeartionType.Subtract); + expect(regs3[0].Area).toMatchNumberSnapshot(); +}); diff --git a/__test__/Utils/LoadEntity.util.ts b/__test__/Utils/LoadEntity.util.ts index 1e79af7c1..7efd5a715 100644 --- a/__test__/Utils/LoadEntity.util.ts +++ b/__test__/Utils/LoadEntity.util.ts @@ -44,7 +44,7 @@ export function LoadBoardsFromFileData(data) return LoadEntityFromFileData(data) as Board[]; } -export function LoadRegionsFromFileData(data) +export function LoadRegionsFromFileData(data): Region[] { return LoadEntityFromFileData(data) as Region[]; } diff --git a/src/DatabaseServices/Contour.ts b/src/DatabaseServices/Contour.ts index 8a39a51c1..06663456f 100644 --- a/src/DatabaseServices/Contour.ts +++ b/src/DatabaseServices/Contour.ts @@ -218,9 +218,9 @@ export class Contour if (this._Curve instanceof Circle && target._Curve instanceof Circle && equalv2(this._Curve.Center, target._Curve.Center, 1e-3)) { if (this._Curve.Radius > target._Curve.Radius) - return { intersectionList: [this._Curve], unionList: [target._Curve] }; - else return { intersectionList: [target._Curve], unionList: [this._Curve] }; + else + return { intersectionList: [this._Curve], unionList: [target._Curve] }; } let intersectionList: Curve[] = []; diff --git a/src/UI/Components/Board/BoardConfigModal.tsx b/src/UI/Components/Board/BoardConfigModal.tsx index be9bb2e34..783a29786 100644 --- a/src/UI/Components/Board/BoardConfigModal.tsx +++ b/src/UI/Components/Board/BoardConfigModal.tsx @@ -373,6 +373,8 @@ export class BoardConfigModal extends React.Component{ app.Viewer.ZoomAll(); }, "提取三维刀路"); }; + + //应用异形+造型 private ChangeModeling = async () => { await app.Editor.ModalManage.EndExecingCmd();