优化:计算封边时使用正确的裁剪圆半径,允许局部偏移直接连接

pull/2281/MERGE
ChenX 1 year ago
parent 3207daa30d
commit e3e11575a5

@ -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"`;

@ -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);
});

@ -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];

@ -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)];//补圆弧

Loading…
Cancel
Save