From 0fa17ab5960527bbb322f7bf63cf6ea4b92d3f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=89?= <940119273@qq.com> Date: Fri, 12 Jan 2024 07:05:32 +0000 Subject: [PATCH] =?UTF-8?q?!2554=20=E4=BF=AE=E5=A4=8D:=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E5=88=80=E8=B7=AF=E5=90=8C=E9=A2=9C=E8=89=B2=E4=B8=8B=E5=81=8F?= =?UTF-8?q?=E7=A7=BB=E7=9A=84=E8=B7=AF=E5=BE=84=E4=BD=BF=E7=94=A8=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E5=88=80=E5=85=B7=E6=97=B6=E5=BB=BA=E6=A8=A1=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UI/Components/Board/BoardConfigModal.tsx | 124 ++++++++++--------- 1 file changed, 67 insertions(+), 57 deletions(-) diff --git a/src/UI/Components/Board/BoardConfigModal.tsx b/src/UI/Components/Board/BoardConfigModal.tsx index 6d3cc0481..8dece0963 100644 --- a/src/UI/Components/Board/BoardConfigModal.tsx +++ b/src/UI/Components/Board/BoardConfigModal.tsx @@ -502,76 +502,86 @@ export class BoardConfigModal extends React.Component{ if (path) { - //获取真实刀半径 - let id = cd.items[0].knife.id; - //从刀库获取新的刀具(id有标识时) 否则使用缓存刀具轮廓 解决不同店铺编辑保存二维刀路时鉴权失败问题 - let useNewKnife = false; - - if (id.startsWith("_")) + //同颜色不同偏移 有多个刀具 + for (let i = 0; i < cd.items.length; i++) { - id = id.replace("_", ""); - useNewKnife = true; - } + //获取真实刀半径 + let id = cd.items[i].knife.id; + //从刀库获取新的刀具(id有标识时) 否则使用缓存刀具轮廓 解决不同店铺编辑保存二维刀路时鉴权失败问题 + let useNewKnife = false; - let halfWidth = knifeSizeMap.get(id); - if (!halfWidth) - { - //从刀库获取新的刀具 否则使用缓存刀具轮廓 解决不同店铺编辑保存二维刀路时鉴权失败问题 - let polyline = useNewKnife ? await this.getToplinesDetailPolyline(id) : br.KnifePolylineMap.get(id) ?? await this.getToplinesDetailPolyline(id); + if (cd.items[i].offset) + path = path.Clone().GetOffsetCurves(cd.items[i].offset)[0]; - //二维刀路时鉴权失败时 保存路径后退出 - if (!polyline) + if (id.startsWith("_")) { - path.ColorIndex = c.ColorIndex; - if (!pathMap.has(c.ColorIndex)) - pathMap.set(c.ColorIndex, [path]); - else - pathMap.get(c.ColorIndex).push(path); - break; + id = id.replace("_", ""); + useNewKnife = true; } - halfWidth = polyline.BoundingBox.getSize(new Vector3).x / 2; - knifeSizeMap.set(id, halfWidth); - knifeMap.set(id, polyline); - } - - //提示与板没有交集的刀路 - if (brCurveBox.intersectsBox(path.BoundingBox, halfWidth)) - { - //异型板情况 - if (!brCurve.IntersectWith(path, IntersectOption.ExtendNone).length) + let halfWidth = knifeSizeMap.get(id); + if (!halfWidth) { - //如果头尾不在误差轮廓内 就忽略 - let pl = brCurve as Polyline; - let offsetPolyine = pl.GetOffsetCurves(halfWidth * (pl.IsClockWise ? -1 : 1)); + //从刀库获取新的刀具 否则使用缓存刀具轮廓 解决不同店铺编辑保存二维刀路时鉴权失败问题 + let polyline = useNewKnife ? await this.getToplinesDetailPolyline(id) : br.KnifePolylineMap.get(id) ?? await this.getToplinesDetailPolyline(id); - let isInt = offsetPolyine.some(pl => pl.IntersectWith(path, IntersectOption.ExtendNone).length > 0 || pl.PtInCurve(path.StartPoint)); - if (!isInt) + //二维刀路时鉴权失败时 保存路径后退出 + if (!polyline && i === 0) { - AppToaster.show({ - message: "检测到刀路在板外,可能无法切割到板!", - timeout: 5000, - intent: Intent.WARNING, - }); + path.ColorIndex = c.ColorIndex; + if (!pathMap.has(c.ColorIndex)) + pathMap.set(c.ColorIndex, [path]); + else + pathMap.get(c.ColorIndex).push(path); + continue; } + + halfWidth = polyline.BoundingBox.getSize(new Vector3).x / 2; + knifeSizeMap.set(id, halfWidth); + knifeMap.set(id, polyline); + } + + //提示与板没有交集的刀路 + if (brCurveBox.intersectsBox(path.BoundingBox, halfWidth)) + { + //异型板情况 + if (!brCurve.IntersectWith(path, IntersectOption.ExtendNone).length) + { + //如果头尾不在误差轮廓内 就忽略 + let pl = brCurve as Polyline; + let offsetPolyine = pl.GetOffsetCurves(halfWidth * (pl.IsClockWise ? -1 : 1)); + + let isInt = offsetPolyine.some(pl => pl.IntersectWith(path, IntersectOption.ExtendNone).length > 0 || pl.PtInCurve(path.StartPoint)); + if (!isInt) + { + AppToaster.show({ + message: "检测到刀路在板外,可能无法切割到板!", + timeout: 5000, + intent: Intent.WARNING, + }); + } + } + } + else + { + AppToaster.show({ + message: "检测到刀路在板外,可能无法切割到板!(刀路包围盒没有交集)", + timeout: 5000, + intent: Intent.WARNING, + }); } - } - else - { - AppToaster.show({ - message: "检测到刀路在板外,可能无法切割到板!(刀路包围盒没有交集)", - timeout: 5000, - intent: Intent.WARNING, - }); - } - path.ColorIndex = c.ColorIndex; - if (!pathMap.has(c.ColorIndex)) - pathMap.set(c.ColorIndex, [path]); - else - pathMap.get(c.ColorIndex).push(path); + //不记录偏移的路径 + if (i > 0) continue; - break;// + path.ColorIndex = c.ColorIndex; + if (!pathMap.has(c.ColorIndex)) + pathMap.set(c.ColorIndex, [path]); + else + pathMap.get(c.ColorIndex).push(path); + } + + break; } } }