修复:封边编辑错误

pull/1948/MERGE
ChenX 2 years ago
parent 0a05343b60
commit 9537d95d54

@ -268,3 +268,17 @@ test('封边数据个数不匹配2', () =>
expect(orgPtsBul.pts.length === sealData.length).toBeTruthy(); expect(orgPtsBul.pts.length === sealData.length).toBeTruthy();
} }
}); });
test('封边编辑错误', () =>
{
let d =
{ "file": [1, "Board", 8, 2, 100, false, 1, 2, 0, [6.123233995736766e-17, 0, 1, 0, -1, 0, 6.123233995736766e-17, 0, 0, -1, 0, 0, 1322.7570621468913, 18, -149.71751412407139, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -659.2429378531087, 18, -1044.7176374870523, 1], 0, 3, 1964, 39.999976675015674, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 39.999976675014835, 803.6000000000058, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4.547473508864641e-13, 803.6000000000058, 0, 1], 0, 2, 6, [-0.00010003799802404929, 1160.3999999999942], 0, [8.384406944863992e-13, 1160.3999999999942], 0, [-0.00010003799801694413, 1160.3999999999942], 0, [-39.999976675013876, 1160.3999999999937], 0, [-39.999976675014835, -803.6000000000058], 0, [-4.547473508864641e-13, -803.6000000000058], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "收口", "鞋柜", " 柜1", "兔宝宝烟熏橡木(灰)生态板", "生态板", "烟熏橡木(灰)", 0, 0, "不排", 2, 0, "1", "1", "1", "1", "", "", "", 6, "不排", "不排", "不排", "不排", "不排", "不排", false, false, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": -641.2429378531087, "y": 0, "z": -149.71751412407139 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] };
let brs = LoadBoardsFromFileData(d);
for (let br of brs)
{
let orgContour = GetSealedBoardContour(br, true, true);
expect(orgContour.Length).toMatchNumberSnapshot();
}
});

@ -24,6 +24,8 @@ exports[`切割残留一个小于封边厚度的凸角的板件封边 3`] = `"30
exports[`切割残留一个小于封边厚度的凸角的板件封边 4`] = `"1273.00000"`; exports[`切割残留一个小于封边厚度的凸角的板件封边 4`] = `"1273.00000"`;
exports[`封边编辑错误 1`] = `"4007.99985"`;
exports[`封边错误板件 1`] = `"130118.40950"`; exports[`封边错误板件 1`] = `"130118.40950"`;
exports[`封边错误板件2 1`] = `"779770.96110"`; exports[`封边错误板件2 1`] = `"779770.96110"`;

@ -15,7 +15,7 @@ import { Orbit } from '../Geometry/Orbit';
import { PlaneExt } from '../Geometry/Plane'; import { PlaneExt } from '../Geometry/Plane';
import { IntersectOption, IntersectResult } from '../GraphicsSystem/IntersectWith'; import { IntersectOption, IntersectResult } from '../GraphicsSystem/IntersectWith';
import { OffsetPolyline } from '../GraphicsSystem/OffsetPolyline'; import { OffsetPolyline } from '../GraphicsSystem/OffsetPolyline';
import { arrayLast, arrayRemoveDuplicateBySort, changeArrayStartIndex, equalArray } from './ArrayExt'; import { arrayLast, arrayRemoveDuplicateBySort, arrayRemoveIf, changeArrayStartIndex, equalArray } from './ArrayExt';
import { Status } from './Status'; import { Status } from './Status';
import { FixIndex, LINK_FUZZ } from './Utils'; import { FixIndex, LINK_FUZZ } from './Utils';
@ -571,25 +571,27 @@ export function getRectFrom4Pts(pts: Vector3[])
export function MergeCurvelist(cus: Curve[]) export function MergeCurvelist(cus: Curve[])
{ {
for (let i = 0; i < cus.length; i++) arrayRemoveIf(cus, c => c.Length < LINK_FUZZ);
let cir: Circle;
arrayRemoveDuplicateBySort(cus, (c1, c2) =>
{ {
let c1 = cus[i]; if (cir) return true;
let nextI = FixIndex(i + 1, cus);
let c2 = cus[nextI];
let status = equaln(c2.Length, 0, LINK_FUZZ) ? Status.True : c1.Join(c2, false, LINK_FUZZ); let status = c1.Join(c2, false, LINK_FUZZ);
if (status === Status.True) if (status === Status.ConverToCircle)
{
cus.splice(nextI, 1);
i--;
}
else if (status === Status.ConverToCircle)
{ {
cus.length = 0; let arc = c1 as Arc;
let a = c1 as Arc; cir = new Circle(arc.Center, arc.Radius);
cus.push(new Circle(a.Center, a.Radius)); return true;
break;
} }
return status === Status.True;
});
if (cir)
{
cus.length = 0;
cus.push(cir);
} }
return cus; return cus;
} }

Loading…
Cancel
Save