From 8eb4f7bbbf5fb5623a26e310ee8c00097b09d321 Mon Sep 17 00:00:00 2001 From: ChenX Date: Fri, 29 Jul 2022 02:27:26 +0000 Subject: [PATCH] =?UTF-8?q?!1605=20=E4=BF=AE=E5=A4=8D:=E5=B0=81=E8=BE=B9?= =?UTF-8?q?=E5=92=8C=E6=8E=92=E9=92=BB=E7=9A=84=E6=96=B9=E5=90=91=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E6=94=B9=E6=88=90=E7=9B=B4=E6=8E=A5=E5=AF=B9=E6=AF=94?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/EdgeSealing/OneEdgeSealing.test.ts | 14 ++++++ .../__snapshots__/OneEdgeSealing.test.ts.snap | 4 ++ src/Add-on/DrawDrilling/HoleUtils.ts | 50 +++++++++++-------- src/GraphicsSystem/CalcEdgeSealing.ts | 25 ++++++---- 4 files changed, 61 insertions(+), 32 deletions(-) diff --git a/__test__/EdgeSealing/OneEdgeSealing.test.ts b/__test__/EdgeSealing/OneEdgeSealing.test.ts index 602ca5b1b..0ac9c24a3 100644 --- a/__test__/EdgeSealing/OneEdgeSealing.test.ts +++ b/__test__/EdgeSealing/OneEdgeSealing.test.ts @@ -34,6 +34,20 @@ test('只有一个封边,并且失败的案例(展示这个改进的缺陷的地 } }); +test('矩形板解析封边错误', () => +{ + let d = { "file": [1, "Board", 8, 2, 100, false, 1, 2, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -152.34375, 18, -167.96874999976717, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -152.34375, 18, -167.96874999976717, 1], 0, 3, 1515.0003295573406, 406, 18, true, "Polyline", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -899.9973051166162, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -899.9973051166162, 0, 1], 0, 2, 4, [406, 2414.9973051175475], 0, [0, 2414.997634673957], 0, [0, 899.9976346730255], 0, [406, 899.9973051166162], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "假门", "4-5装饰柜2", "1号柜", "南亚柚木", "夹板", "南亚柚木", 0, 1, "不排", 2, 4, 0, 1.5, 1.5, 1.5, "0", "0", "1.5", "1.5", "", "", "", 4, "不排", "不排", "不排", "不排", false, false, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": -152.34375, "y": 0, "z": -167.96874999976717 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let brs = LoadBoardsFromFileData(d); + + for (let br of brs) + { + let con = GetSealedBoardContour(br, false); + expect(con.IsClose).toBeTruthy(); + expect(con.Area2).toMatchNumberSnapshot(); + expect(con.Length).toMatchNumberSnapshot(); + } +}); + test('偏移后曲线不闭合的问题', () => { let d = diff --git a/__test__/EdgeSealing/__snapshots__/OneEdgeSealing.test.ts.snap b/__test__/EdgeSealing/__snapshots__/OneEdgeSealing.test.ts.snap index cbeb998a1..65cb3dd75 100644 --- a/__test__/EdgeSealing/__snapshots__/OneEdgeSealing.test.ts.snap +++ b/__test__/EdgeSealing/__snapshots__/OneEdgeSealing.test.ts.snap @@ -23,3 +23,7 @@ exports[`只有一个封边,并且失败的案例 8`] = `"4881.66371"`; exports[`只有一个封边,并且失败的案例(展示这个改进的缺陷的地方) 1`] = `"368500.00000"`; exports[`只有一个封边,并且失败的案例(展示这个改进的缺陷的地方) 2`] = `"2440.00000"`; + +exports[`矩形板解析封边错误 1`] = `"610545.00000"`; + +exports[`矩形板解析封边错误 2`] = `"3836.00000"`; diff --git a/src/Add-on/DrawDrilling/HoleUtils.ts b/src/Add-on/DrawDrilling/HoleUtils.ts index d30763743..136b48c28 100644 --- a/src/Add-on/DrawDrilling/HoleUtils.ts +++ b/src/Add-on/DrawDrilling/HoleUtils.ts @@ -9,7 +9,7 @@ import { Circle } from "../../DatabaseServices/Entity/Circle"; import { Curve } from "../../DatabaseServices/Entity/Curve"; import { Line } from "../../DatabaseServices/Entity/Line"; import { Polyline } from "../../DatabaseServices/Entity/Polyline"; -import { angle, clampRad, isParallelTo, rotatePoint, ZAxis } from "../../Geometry/GeUtils"; +import { isParallelTo, rotatePoint, ZAxis } from "../../Geometry/GeUtils"; import { DrillType } from "../../UI/Store/BoardInterface"; export const SCALAR = 0.1; @@ -165,17 +165,21 @@ export function InitRectBoardHoleOption(br: Board, option: IRectHoleOption) { let c = cus[i]; let derv = c.GetFistDeriv(0).multiplyScalar(dir); - let an = angle(derv); - an = clampRad(an); - - if (an < Math.PI / 4 + 1e-8 || an > Math.PI * 7 / 4) - option.down = hightDrill[i]; - else if (an > Math.PI / 4 && an < Math.PI * 3 / 4 + 1e-8) - option.right = hightDrill[i]; - else if (an > Math.PI * 3 / 4 && an < Math.PI * 5 / 4 + 1e-8) - option.up = hightDrill[i]; + + if (Math.abs(derv.x) > Math.abs(derv.y)) + { + if (derv.x > 0) + option.down = hightDrill[i]; + else + option.up = hightDrill[i]; + } else - option.left = hightDrill[i]; + { + if (derv.y > 0) + option.right = hightDrill[i]; + else + option.left = hightDrill[i]; + } } } export function ExtureHoleInBoard(holes: ExtrudeHole[], board: Board, ocs: Matrix4) @@ -208,17 +212,21 @@ export function SetRectHighHole(br: Board, option: IRectHoleOption) { let c = cus[i]; let derv = c.GetFistDeriv(0).multiplyScalar(dir); - let an = angle(derv); - an = clampRad(an); - - if (an < Math.PI / 4 + 1e-8 || an > Math.PI * 7 / 4) - highDrill.push(option.down); - else if (an > Math.PI / 4 && an < Math.PI * 3 / 4 + 1e-8) - highDrill.push(option.right); - else if (an > Math.PI * 3 / 4 && an < Math.PI * 5 / 4 + 1e-8) - highDrill.push(option.up); + + if (Math.abs(derv.x) > Math.abs(derv.y)) + { + if (derv.x > 0) + highDrill.push(option.down); + else + highDrill.push(option.up); + } else - highDrill.push(option.left); + { + if (derv.y > 0) + highDrill.push(option.right); + else + highDrill.push(option.left); + } } let types = new Set(highDrill); if (types.size === 1 && highDrill[0] !== DrillType.None) diff --git a/src/GraphicsSystem/CalcEdgeSealing.ts b/src/GraphicsSystem/CalcEdgeSealing.ts index ca014408e..269209ff9 100644 --- a/src/GraphicsSystem/CalcEdgeSealing.ts +++ b/src/GraphicsSystem/CalcEdgeSealing.ts @@ -10,7 +10,7 @@ import { ExtrudeContourCurve } from "../DatabaseServices/Entity/Extrude"; import { Line } from "../DatabaseServices/Entity/Line"; import { Polyline } from "../DatabaseServices/Entity/Polyline"; import { CreateContour2 } from "../Geometry/CreateContour2"; -import { angle, clampRad, equaln, equalv3, isParallelTo, SelectNearP, XAxis } from "../Geometry/GeUtils"; +import { equaln, equalv3, isParallelTo, SelectNearP, XAxis } from "../Geometry/GeUtils"; import { Production } from "../Production/Product"; import { IHighSealedItem, ISealingData } from "../UI/Store/BoardInterface"; import { IntersectOption } from "./IntersectWith"; @@ -269,18 +269,21 @@ export function GetBoardHighSeal(br: Board, sealcus: Curve[]): IHighSealedItem[] for (let c of sealcus) { let derv = c.GetFistDeriv(0).multiplyScalar(dir); - let an = angle(derv); - an = clampRad(an); - - if ((an < Math.PI / 4 + 1e-8) || (an > Math.PI * 7 / 4)) - highSeals.push({ size: sealDown }); - else if (an > Math.PI / 4 && an < Math.PI * 3 / 4 + 1e-8) - highSeals.push({ size: sealRight }); - else if (an > Math.PI * 3 / 4 && an < Math.PI * 5 / 4 + 1e-8) - highSeals.push({ size: sealUp }); + if (Math.abs(derv.x) > Math.abs(derv.y)) + { + if (derv.x > 0) + highSeals.push({ size: sealDown }); + else + highSeals.push({ size: sealUp }); + } else - highSeals.push({ size: sealLeft }); + { + if (derv.y > 0) + highSeals.push({ size: sealRight }); + else + highSeals.push({ size: sealLeft }); + } } }