From e3e11575a5f39135f93254bacdc812c8602d93e9 Mon Sep 17 00:00:00 2001 From: ChenX Date: Tue, 4 Jul 2023 18:35:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96:=E8=AE=A1=E7=AE=97=E5=B0=81?= =?UTF-8?q?=E8=BE=B9=E6=97=B6=E4=BD=BF=E7=94=A8=E6=AD=A3=E7=A1=AE=E7=9A=84?= =?UTF-8?q?=E8=A3=81=E5=89=AA=E5=9C=86=E5=8D=8A=E5=BE=84,=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E5=B1=80=E9=83=A8=E5=81=8F=E7=A7=BB=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EdgeSealing/__snapshots__/seal.test.ts.snap | 10 ++++++++++ __test__/EdgeSealing/seal.test.ts | 17 +++++++++++++++++ src/GraphicsSystem/CalcEdgeSealing.ts | 16 ++++++++-------- src/GraphicsSystem/OffsetPolyline.ts | 4 +++- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap b/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap index fd050fc90..f9c6b87cc 100644 --- a/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap +++ b/__test__/EdgeSealing/__snapshots__/seal.test.ts.snap @@ -21,3 +21,13 @@ exports[`小圆弧封边 4`] = `"5"`; exports[`小圆弧封边 5`] = `"5"`; exports[`无法计算封边 1`] = `"4166.00000"`; + +exports[`特殊链接 圆弧间 1`] = `"187815.39618"`; + +exports[`特殊链接 圆弧间 2`] = `"190259.30510"`; + +exports[`特殊链接 圆弧间 3`] = `"6"`; + +exports[`特殊链接 圆弧间 4`] = `"6"`; + +exports[`特殊链接 圆弧间 5`] = `"6"`; diff --git a/__test__/EdgeSealing/seal.test.ts b/__test__/EdgeSealing/seal.test.ts index 0c7bb42c4..3cee05c7a 100644 --- a/__test__/EdgeSealing/seal.test.ts +++ b/__test__/EdgeSealing/seal.test.ts @@ -47,3 +47,20 @@ test('小圆弧封边', () => expect(seald.highSeals.length).toMatchNumberSnapshot(0); }); + +test('特殊链接 圆弧间', () => +{ + let d = + { "file": [1, "Board", 10, 2, 100, 0, 1, 2, 71, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1259.5443313570531, 375.21311475409846, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1259.5443313570531, 375.21311475409846, 0, 1], 0, 0, 1, 3, 404.0689215209877, 600.0000000000003, 18, false, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -610.8739531813568, 7260.612476120086, 0, 1], 0, 0, 1, 2, 6, [2.2737367544323206e-13, 57.83551241479472], 0, [121.15231478518581, 178.98782719999963], -0.44349303569486936, [376.8492107851855, 0], 0, [600.0000000000003, 0], 0, [600.0000000000003, 404.0689215209877], 0, [0, 404.0689215209877], 0, true, 0, 3, 0, 0, 0, 0, 0, 11, 0, "层板", "", "", "", "", "", 0, 0, "三合一", 2, 6, 1, 2, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 6, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null], "basePt": { "x": 855.4754098360654, "y": 375.21311475409846, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + + let br = LoadEntityFromFileData(d)[0] as Board; + + let seald = GetSealedBoardContour(br); + expect(seald.sealedContour.Area2).toMatchNumberSnapshot(); + expect(seald.brContour.Area2).toMatchNumberSnapshot(); + + expect(seald.sealedContour.EndParam).toMatchNumberSnapshot(0); + expect(seald.brContour.EndParam).toMatchNumberSnapshot(0); + + expect(seald.highSeals.length).toMatchNumberSnapshot(0); +}); diff --git a/src/GraphicsSystem/CalcEdgeSealing.ts b/src/GraphicsSystem/CalcEdgeSealing.ts index e8b9d02e9..bca175ca1 100644 --- a/src/GraphicsSystem/CalcEdgeSealing.ts +++ b/src/GraphicsSystem/CalcEdgeSealing.ts @@ -2,6 +2,7 @@ import { Vector3 } from "three"; import { arrayRemoveIf } from "../Common/ArrayExt"; import { EBoardKeyList } from "../Common/BoardKeyList"; import { MergeCurvelist } from "../Common/CurveUtils"; +import { FixIndex } from "../Common/Utils"; import { Contour } from "../DatabaseServices/Contour"; import { Board } from "../DatabaseServices/Entity/Board"; import { Circle } from "../DatabaseServices/Entity/Circle"; @@ -259,12 +260,11 @@ class OffsetPolyline2 extends OffsetPolyline { override InitSubCurves() { + this._IsTopoOffset = true; return this; } - protected override OffsetSubCurves(): void - { + protected override OffsetSubCurves(): void { } - } protected override GeneralCirclesAndVertexs(): void { } protected override GeneralTrimContours(): void @@ -329,20 +329,20 @@ export function GetSealedBoardContour(br: Board): BrSealedData | undefined let curve = curves[i];//曲线组 let seal = highSeals[i];//封边 + let preSeal = highSeals[FixIndex(i - 1, curves)]; + if (curve instanceof Polyline) { - let curveExpds = curve.Explode(); + let curveExpds = curve.Explode().filter(c => c.Length >= 1e-4); for (let j = 0; j < curveExpds.length; j++) { let c = curveExpds[j]; - if (c.Length < 1e-4) continue; - polylineOffset._SubCurves.push(c);//sub //trim Circle - polylineOffset._Circles.push(new Circle(c.StartPoint, seal.size)); + polylineOffset._Circles.push(new Circle(c.StartPoint, j === 0 ? Math.min(preSeal.size, seal.size) : seal.size)); //offset let offsetC = c.GetOffsetCurves(dir * -seal.size)[0]; @@ -364,7 +364,7 @@ export function GetSealedBoardContour(br: Board): BrSealedData | undefined polylineOffset._SubCurves.push(curve);//sub //trim Circle - polylineOffset._Circles.push(new Circle(curve.StartPoint, seal.size)); + polylineOffset._Circles.push(new Circle(curve.StartPoint, Math.min(preSeal.size, seal.size))); //offset let offsetC = curve.GetOffsetCurves(dir * -seal.size)[0]; diff --git a/src/GraphicsSystem/OffsetPolyline.ts b/src/GraphicsSystem/OffsetPolyline.ts index c5d24e90f..d2eb1e35b 100644 --- a/src/GraphicsSystem/OffsetPolyline.ts +++ b/src/GraphicsSystem/OffsetPolyline.ts @@ -154,6 +154,8 @@ export class OffsetPolyline _IsClose: boolean; _OffsetDistSign: number; + _IsTopoOffset = false;//局部偏移,允许特殊延伸,参考测试用例 + constructor(public _Polyline: Polyline, public _OffsetDist: number, public _ToolPath = false, private _OffsetDistSq = (_OffsetDist ** 2) * 2.1//对直角走刀不进行圆弧过度 ) @@ -367,7 +369,7 @@ export class OffsetPolyline if (curveResNext.ep) curveNext.EndPoint = oldp2; - if (onPre && onNext) + if (this._IsTopoOffset || onPre && onNext) tp = p; else curveResNow.paddingCurve = [this.CreateArc(refP, sp, ep)];//补圆弧