!1226 优化:封边轮廓的结果

pull/1226/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent c463a58bcf
commit 48b62e953f

@ -165,3 +165,18 @@ test("封边错误板件4", () =>
expect(con.Area).toMatchSnapshot(); expect(con.Area).toMatchSnapshot();
}); });
test("切割残留一个封边厚度的凸角的板件封边", () =>
{
let data = { "file": [2, "Board", 8, 2, 100, false, 1, 4, 0, [0, -1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 1, 0, 0, 0, 8353.923342626775, 3430.066255566897, 54.00000000000023, 1], 0, 0, true, [1, 0, 0, 0, 0, -1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 8353.923342626775, 3430.066255566897, 54.00000000000023, 1], 0, 3, 605, 54, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 605, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1.3642420526593924e-12, 0, 1], 0, 2, 6, [1.999999999999659, -605], 0, [0, -605], 0, [0, 0], 0, [54, 0], 0, [54, -587], 0, [1.999999999999659, -587], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "右收口条", "1", "主卧飘窗柜", "", "流金岁月零度实木多层板", "", 0, 0, "不排", 2, 0, "1", "1", "1", "1", "", "", "", 6, "不排", "不排", "不排", "不排", "不排", "不排", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, "Board", 8, 2, 119, false, 1, 4, 0, [0, -1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 1, 0, 0, 0, 8256.448416684603, 3420.712904620689, 54.000000000000114, 1], 0, 0, true, [1, 0, 0, 0, 0, -1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 8256.448416684603, 3420.712904620689, 54.000000000000114, 1], 0, 3, 605, 54, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 605, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1.3642420526593924e-12, 0, 1], 0, 2, 6, [1.999999999999659, -605], 0, [1.999999999999659, -587], 0, [54, -587], 0, [54, 0], 0, [0, 0], 0, [0, -605], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "右收口条", "1", "主卧飘窗柜", "", "流金岁月零度实木多层板", "", 0, 0, "不排", 2, 0, "1", "1", "1", "1", "", "", "", 6, "不排", "不排", "不排", "不排", "不排", "不排", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": 8256.448416684603, "y": 3420.712904620689, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let brs = LoadBoardsFromFileData(data);
let con = GetSealedBoardContour(brs[0], false);
expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot();
con = GetSealedBoardContour(brs[1], false);
expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot();
});

@ -4,6 +4,10 @@ exports[`丢失线段板件 1`] = `554052.5007766777`;
exports[`丢失线段板件 2`] = `398758.8789695821`; exports[`丢失线段板件 2`] = `398758.8789695821`;
exports[`切割残留一个封边厚度的凸角的板件封边 1`] = `30420`;
exports[`切割残留一个封边厚度的凸角的板件封边 2`] = `30420`;
exports[`封边错误板件 1`] = `130118.4094685434`; exports[`封边错误板件 1`] = `130118.4094685434`;
exports[`封边错误板件2 1`] = `779770.9650700318`; exports[`封边错误板件2 1`] = `779770.9650700318`;

@ -25,6 +25,8 @@ export class TestFb implements Command
brs.push(...e.SplitBoards); brs.push(...e.SplitBoards);
let showCus: Curve[] = []; let showCus: Curve[] = [];
let errBrs: Board[] = [];
for (let br of brs) for (let br of brs)
{ {
let pl = GetSealedBoardContour(br, false); let pl = GetSealedBoardContour(br, false);
@ -35,10 +37,13 @@ export class TestFb implements Command
} }
else else
{ {
errBrs.push(br);
app.Editor.Prompt("警告:该板件无法得到模拟封边结果!"); app.Editor.Prompt("警告:该板件无法得到模拟封边结果!");
} }
} }
app.Viewer.OutlinePass.selectedObjects = errBrs.map(b => b.DrawObject);
if (showCus.length === 0) if (showCus.length === 0)
return; return;

@ -134,12 +134,31 @@ export function CalcEdgeSealing(cus: Curve[])
if (!frontLine || !laterLine) if (!frontLine || !laterLine)
{ {
alert("获取封边错误,请提供图纸给相关人员"); alert("获取封边错误,请提供图纸给相关人员");
return; return false;
} }
let dist = frontLine.EndPoint.distanceToSquared(laterLine.StartPoint); let dist = frontLine.EndPoint.distanceToSquared(laterLine.StartPoint);
if (dist < LINK_FUZZ ** 2) if (dist < LINK_FUZZ ** 2)
{
if (frontLine instanceof Line && laterLine instanceof Line)
{
if (frontLine.PtOnCurve(laterLine.EndPoint))
{
cus.splice(laterIndex, 1);
if (laterIndex === 0)
firstLine = cus[0].Clone();
i -= 2;
}
else if (laterLine.PtOnCurve(frontLine.StartPoint))
{
cus.splice(i, 1);
i -= 2;
if (i < -1)
i = -1;
}
}
continue; continue;
}
let refLine = oldLine ?? frontLine; let refLine = oldLine ?? frontLine;
let refLine2 = i === cus.length - 1 ? firstLine : laterLine; let refLine2 = i === cus.length - 1 ? firstLine : laterLine;
@ -154,10 +173,10 @@ export function CalcEdgeSealing(cus: Curve[])
if (!iPt) if (!iPt)
{ {
alert("获取封边错误,请提供图纸给相关人员"); alert("获取封边错误,请提供图纸给相关人员");
return; return false;
} }
let par = frontLine.GetParamAtPoint(iPt); let par = frontLine.GetParamAtPoint(iPt);
if (par < 0) if (par < 1e-6)
{ {
cus.splice(i, 1); cus.splice(i, 1);
i -= 2; i -= 2;
@ -166,17 +185,25 @@ export function CalcEdgeSealing(cus: Curve[])
} }
else else
frontLine.EndPoint = iPt; frontLine.EndPoint = iPt;
oldLine = equalv3(iPt, laterLine.EndPoint) ? laterLine.Clone() : null;
par = laterLine.GetParamAtPoint(iPt); par = laterLine.GetParamAtPoint(iPt);
if (par > 1) if (par > 1 - 1e-6)
{ {
cus.splice(laterIndex, 1); cus.splice(laterIndex, 1);
i -= 1; if (laterIndex === 0)
{
firstLine = cus[0].Clone();
i -= 2;
}
else
i--;
if (i < -1)
i = -1;
} }
else else
laterLine.StartPoint = iPt; laterLine.StartPoint = iPt;
} }
return true;
} }
export function GetBoardHighSeal(br: Board, sealcus: Curve[]) export function GetBoardHighSeal(br: Board, sealcus: Curve[])
@ -305,7 +332,7 @@ export function GetSealedBoardContour(br: Board, hasSealing: boolean): Polyline
if (offsetCus.length === 1 && offsetCus[0] instanceof Circle) if (offsetCus.length === 1 && offsetCus[0] instanceof Circle)
return offsetCus[0] as Circle; return offsetCus[0] as Circle;
CalcEdgeSealing(offsetCus); if (!CalcEdgeSealing(offsetCus)) return;
let pl = Polyline.Combine(offsetCus, LINK_FUZZ); let pl = Polyline.Combine(offsetCus, LINK_FUZZ);
if (dir < 0) if (dir < 0)
pl.Reverse(); pl.Reverse();

Loading…
Cancel
Save