修复:异形带圆弧的板在镜像后封边对应错误

pull/1911/MERGE
ChenX 2 years ago
parent 71c148ffd5
commit 5ad2c7251f

@ -1,6 +1,7 @@
import { Vector3 } from "three";
import { CADFiler } from "../../src/api";
import { MakeMirrorMtx } from "../../src/Common/Matrix4Utils";
import { XAxis } from "../../src/Geometry/GeUtils";
import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util";
test('板件镜像', () =>
@ -28,3 +29,21 @@ test('板镜像后板边数据错误', () =>
f.WriteObject(br);
expect(f.Data).toMatchSnapshot();
});
test('板件镜像后封边错误(异形带圆弧)', () =>
{
//错误原因: ...-直线-起点-圆弧-...
//因为起点夹在圆弧中,所以如果只是简单的翻转(reverse)封边,则会造成第一段封边错误的问题
let d =
{ "file": [1, "Board", 8, 2, 110, false, 1, 2, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 466.9546629560559, 50.4951757024906, 1182, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 466.9546629560559, 50.4951757024906, 1182, 1], 0, 3, 300.00000000000006, 532, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 5, [200, 0], 0, [532, 0], 0, [532, 300], 0, [0, 300], 0, [0, 200.00000000000003], 0.41421356237309503, true, 0, 3, 0, 0, 0, 0, 0, 10, 0, "顶板", "F01", "G01", "", "", "", 1, 0, "三合一", 2, 3, 1.2, 0.6, 0.6, "0.6", "1.2", "1.2", "0.6", "", "", "", 5, "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": 166.95466295605587, "y": 50.4951757024906, "z": 1182 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let br = LoadBoardsFromFileData(d)[0];
let mirror = MakeMirrorMtx(XAxis);
br.ApplyMatrix(mirror);
expect(br.BoardProcessOption.highSealed).toMatchSnapshot();
});

@ -178,6 +178,20 @@ Array [
]
`;
exports[`板件镜像后封边错误(异形带圆弧) 1`] = `
Array [
Object {
"size": 1.2,
},
Object {
"size": 0.6,
},
Object {
"size": 0.6,
},
]
`;
exports[`板镜像后板边数据错误 1`] = `
Array [
"Board",

@ -938,7 +938,9 @@ export class Board extends ExtrudeSolid
&& this.BoardProcessOption[EBoardKeyList.SpliteThickness]
);
let highSeals = GetBoardHighSeal(this, GetBoardSealingCurves(this));
let highSealsCurves = GetBoardSealingCurves(this);
let highSeals = GetBoardHighSeal(this, highSealsCurves);
let isStartSealToBack = !equalv3(highSealsCurves[0].StartPoint, this.contourCurve.StartPoint, 1e-4);//第一段封边往后搜索了
super.ApplyMirrorMatrix(m);
@ -946,7 +948,10 @@ export class Board extends ExtrudeSolid
{
this.contourCurve.Reverse();
highSeals.reverse();
this.BoardProcessOption.highSealed?.reverse();
if (isStartSealToBack)//如果第一段封边往后搜索了,那么封边在镜像后 第一段封边保持不变
highSeals.unshift(highSeals.pop());
this.BoardProcessOption.highDrill?.reverse();
if (hasSplitSize)

@ -22,7 +22,7 @@ import { ParseEdgeSealDir } from "./ParseEdgeSealDir";
*/
export function ParagraphCulist(cus: Curve[])
{
let newCulist: Curve[][] = [];
let newCulist: (Curve[])[] = [];
let usedCu: WeakSet<Curve> = new WeakSet();
//归类曲线,返回归类是否成功
@ -81,7 +81,8 @@ export function ParagraphCulist(cus: Curve[])
usedCu.add(cu);
return true;
};
let caclCus = cus.slice().filter(c => !equaln(c.Length, 0));
let caclCus = cus.filter(c => !equaln(c.Length, 0));
while (caclCus.length > 0)
{

Loading…
Cancel
Save