!1953 修复:镜像板修改板尺寸后,板边数据错误

pull/1941/MERGE
ChenX 2 years ago
parent ecdfb7b76b
commit fa8cf28bda

@ -12,5 +12,19 @@ test('板件镜像', () =>
br.ApplyMatrix(MakeMirrorMtx(new Vector3(0, 0, 1)));
let f = new CADFiler;
f.WriteObject(br);
expect(f).toMatchSnapshot();
expect(f.Data).toMatchSnapshot();
});
test('板镜像后板边数据错误', () =>
{
let d =
{ "file": [1, "Board", 8, 2, 100, false, 1, 8, 0, [0, 1, 0, 0, -1, 0, 1.2246467991473532e-16, 0, 1.2246467991473532e-16, 0, 1, 0, 523.6891679748768, 34.536891679748834, 0, 1], 0, 0, true, [1, 0, -1.2246467991473532e-16, 0, 0, 1, 0, 0, 1.2246467991473532e-16, 0, 1, 0, 1704.1891679749642, 34.536891679748834, 0, 1], 0, 3, 569.9999999999945, 65, 17.5, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 569.9999999999945, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 6, [26.888366718995428, -569.9999999999945], 0, [26.888366718995428, -526.2850109890051], 0, [65, -526.2850109890051], 0, [65, 0], 0, [0, 0], 0, [0, -569.9999999999945], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 0, "辅助条(上收口)", "", "", "", "", "", 0, 0, "**多种**", 2, 6, 1, 2, 1, 2, 3, 4, "2", "4", "3", "1", "", "", "", 6, "二合一", "铰链孔", "三合一", "二合一", "铰链孔", "不排", true, false, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": -46.31083202511775, "y": 34.536891679748834, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let br = LoadBoardsFromFileData(d)[0];
br.ApplyMatrix(MakeMirrorMtx(new Vector3(1, 0, 0)));
br.Width = 88;
let f = new CADFiler;
f.WriteObject(br);
expect(f.Data).toMatchSnapshot();
});

@ -1,8 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`板件镜像 1`] = `
CADFiler {
"_datas": Array [
Array [
"Board",
8,
2,
@ -176,7 +175,197 @@ CADFiler {
true,
0,
0,
]
`;
exports[`板镜像后板边数据错误 1`] = `
Array [
"Board",
8,
2,
0,
false,
0,
8,
0,
Array [
0,
1,
0,
0,
1,
0,
1.2246467991473532e-16,
0,
-1.2246467991473532e-16,
0,
1,
0,
-523.6891679748768,
34.536891679748834,
0,
1,
],
0,
0,
true,
Array [
-1,
0,
-1.2246467991473532e-16,
0,
0,
1,
0,
0,
-1.2246467991473532e-16,
0,
1,
0,
-1704.1891679749642,
34.536891679748834,
0,
1,
],
0,
3,
569.9999999999945,
88,
17.5,
false,
"Polyline",
8,
2,
0,
false,
0,
7,
0,
Array [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
569.9999999999945,
0,
1,
],
0,
0,
true,
Array [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
],
0,
2,
6,
Array [
26.888366718995428,
-569.9999999999945,
],
0,
Array [
26.888366718995428,
-526.2850109890051,
],
0,
Array [
88,
-526.2850109890051,
],
0,
Array [
88,
0,
],
0,
Array [
0,
0,
],
"readIndex": 0,
}
0,
Array [
0,
-569.9999999999945,
],
0,
true,
0,
3,
0,
0,
0,
0,
0,
10,
0,
"辅助条(上收口)",
"",
"",
"",
"",
"",
0,
0,
"**多种**",
2,
6,
1,
2,
1,
2,
3,
4,
"2",
"4",
"3",
"1",
"",
"",
"",
6,
"二合一",
"铰链孔",
"三合一",
"二合一",
"铰链孔",
"不排",
true,
false,
0,
0,
0,
0,
0,
0,
0,
0,
true,
0,
0,
]
`;

@ -874,13 +874,43 @@ export class Board extends ExtrudeSolid
return this;
}
let hasSplitSize = (this.BoardProcessOption[EBoardKeyList.SpliteHeight]
&& this.BoardProcessOption[EBoardKeyList.SpliteWidth]
&& this.BoardProcessOption[EBoardKeyList.SpliteThickness]
);
let highSeals = GetBoardHighSeal(this, GetBoardSealingCurves(this));
super.ApplyMirrorMatrix(m);
if (this.contourCurve && this.contourCurve.Area2 < 0)
{
this.contourCurve.Reverse();
highSeals.reverse();
this.BoardProcessOption.highSealed?.reverse();
this.BoardProcessOption.highDrill?.reverse();
if (hasSplitSize)
{
[
this.BoardProcessOption.sealedUp,
this.BoardProcessOption.sealedLeft,
this.BoardProcessOption.sealedDown,
this.BoardProcessOption.sealedRight,
]
=
[
this.BoardProcessOption.sealedUp,
this.BoardProcessOption.sealedRight,
this.BoardProcessOption.sealedDown,
this.BoardProcessOption.sealedLeft,
];
}
}
this.BoardProcessOption.highSealed = highSeals;
if (this.isRect)
if (!hasSplitSize && this.isRect)
HandleRectBoardSealingData(this, highSeals);
//重新构建SpaceOCS
this._SpaceOCS.multiplyMatrices(this._Matrix, new Matrix4().getInverse(this.RotateMat));

@ -238,17 +238,32 @@ export function CalcEdgeSealing(cus: Curve[], highSeals?: IHighSealedItem[])
return true;
}
export function GetBoardHighSeal(br: Board, sealcus: Curve[])
//与GetBoardSealingCurves相关
export function GetBoardHighSeal(br: Board, sealcus: Curve[]): IHighSealedItem[]
{
if (br.BoardProcessOption[EBoardKeyList.SpliteHeight]
&& br.BoardProcessOption[EBoardKeyList.SpliteWidth]
&& br.BoardProcessOption[EBoardKeyList.SpliteThickness]
)
{
return [
{ size: parseFloat(br.BoardProcessOption.sealedDown) },
{ size: parseFloat(br.BoardProcessOption.sealedRight) },
{ size: parseFloat(br.BoardProcessOption.sealedUp) },
{ size: parseFloat(br.BoardProcessOption.sealedLeft) },
];
}
let highSeals = br.BoardProcessOption.highSealed.filter(d => d.size !== null && d.size !== undefined);
//若未设置高级封边,把上下左右封边存入高级封边
if (sealcus.length !== highSeals.length || !br.IsSpecialShape)
{
let highSeals = br.BoardProcessOption.highSealed.slice().filter(d => d.size !== null && d.size !== undefined);
let sealDown = parseFloat(br.BoardProcessOption[EBoardKeyList.DownSealed]);
let sealUp = parseFloat(br.BoardProcessOption[EBoardKeyList.UpSealed]);
let sealLeft = parseFloat(br.BoardProcessOption[EBoardKeyList.LeftSealed]);
let sealRight = parseFloat(br.BoardProcessOption[EBoardKeyList.RightSealed]);
//若未设置高级封边,把上下左右封边存入高级封边
if (sealcus.length !== highSeals.length || !br.IsSpecialShape)
{
highSeals.length = 0;
let dir = Math.sign(br.ContourCurve.Area2);
for (let c of sealcus)

@ -197,6 +197,14 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
return (obj as ProcessingGroupRecord).Name;
});
};
private isSplit()
{
return (
this.props.br.BoardProcessOption.spliteHeight
&& this.props.br.BoardProcessOption.spliteWidth
&& this.props.br.BoardProcessOption.spliteThickness
) ? true : false;
}
async UNSAFE_componentWillMount()
{
this.updateTags();
@ -381,7 +389,7 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
<h6 className={"edge-sealing " + Classes.HEADING}>
{
isShowHighEditor && this.props.isSpecial.get() &&
isShowHighEditor && this.props.isSpecial.get() && !this.isSplit() &&
<Button
text="高级编辑"
style={{
@ -397,7 +405,7 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
}
</h6>
{
(!this.props.br || !this.props.isSpecial.get()) && <Input5Or4Component
(!this.props.br || (!this.props.isSpecial.get() || this.isSplit())) && <Input5Or4Component
type={CheckObjectType.BR}
showDirectionIcon={true}
hasCenter={false}
@ -415,4 +423,5 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
</div>
);
}
}

Loading…
Cancel
Save