!2417 优化:拆单提交生产时检查排钻干涉,给出提示信息

pull/2510/MERGE
黄诗津 10 months ago committed by ChenX
parent 6259c16c13
commit 04beadad73

@ -16,8 +16,6 @@ export class CheckHoles implements Command
{
async exec()
{
const drillTool = DrawDrillingTool.GetInstance();
let brRes = await app.Editor.GetSelection({
Msg: "选择要检查排钻碰撞的板件",
Filter: { filterTypes: [Board] }
@ -26,152 +24,159 @@ export class CheckHoles implements Command
if (brRes.Status === PromptStatus.OK)
{
let brs = brRes.SelectSet.SelectEntityList as Board[];
let res = InterferenceCheck(brs);
let b2boxMap = new Map<Board, ObjectId[][]>();
if (res.length)
app.Editor.ModalManage.RenderModeless(CollsionModal, { faces: res }, { position: ModalPosition.Right, canMinimize: false });
else
AppToaster.show({
message: "排钻没有干涉!",
timeout: 5000,
intent: Intent.SUCCESS,
});
}
}
}
//干涉检查
export function InterferenceCheck(brs: Board[])
{
const drillTool = DrawDrillingTool.GetInstance();
let b2boxMap = new Map<Board, ObjectId[][]>();
for (let b of brs)
for (let b of brs)
{
let drills: ObjectId[][] = [];
for (let [, dss] of b.DrillList)
{
for (let ds of dss)
{
let drills: ObjectId[][] = [];
for (let [, dss] of b.DrillList)
if (ds.some(d => !d?.Object))
continue;
//仅用母板件上的排钻用作碰撞检测
let ds2 = ds.filter(d =>
{
for (let ds of dss)
if (d?.Object && !d.IsErase)
{
if (ds.some(d => !d?.Object))
continue;
//仅用母板件上的排钻用作碰撞检测
let ds2 = ds.filter(d =>
{
if (d?.Object && !d.IsErase)
{
let h = d.Object as Hole;
if (h.MId?.Index === b.Id.Index)
return true;
else if (h.MId?.Index < 0 && (h.MId.Index === b.Id.Index * -100 || h.MId.Index === b.Id.Index * -100 - 1)) //兼容旧关联错误排钻检测
return true;
}
return false;
});
if (ds2.length > 0)
drills.push(ds2);
let h = d.Object as Hole;
if (h.MId?.Index === b.Id.Index)
return true;
else if (h.MId?.Index < 0 && (h.MId.Index === b.Id.Index * -100 || h.MId.Index === b.Id.Index * -100 - 1)) //兼容旧关联错误排钻检测
return true;
}
}
b2boxMap.set(b, drills);
return false;
});
if (ds2.length > 0)
drills.push(ds2);
}
}
b2boxMap.set(b, drills);
}
let res: ICollsionBrs[] = [];
let res: ICollsionBrs[] = [];
//自身排钻碰撞检测
for (let [, dss] of b2boxMap)
//自身排钻碰撞检测
for (let [, dss] of b2boxMap)
{
if (dss.length === 0) continue;
for (let i = 0; i < dss.length; i++)
{
let ds1 = dss[i];
let ocsInv = (ds1[0].Object as Hole).OCSInv;
let boxes1 = drillTool.GetDrillsBox(ds1, ocsInv);
let j = i + 1;
for (; j < dss.length; j++)
{
if (dss.length === 0) continue;
for (let i = 0; i < dss.length; i++)
let ds2 = dss[j];
if ((ds1[0].Object as Hole).MId.Object !== (ds2[0].Object as Hole).MId.Object //如果是同一个板上的排钻(就不可能是通孔了)
&& IsThough(ds1)
&& IsThough(ds2))
continue;
let boxes2 = drillTool.GetDrillsBox(ds2, ocsInv);
if (IsCollsion([boxes1], [boxes2]))
{
let ds1 = dss[i];
let ocsInv = (ds1[0].Object as Hole).OCSInv;
let boxes1 = drillTool.GetDrillsBox(ds1, ocsInv);
let j = i + 1;
for (; j < dss.length; j++)
{
let ds2 = dss[j];
if ((ds1[0].Object as Hole).MId.Object !== (ds2[0].Object as Hole).MId.Object //如果是同一个板上的排钻(就不可能是通孔了)
&& this.IsThough(ds1)
&& this.IsThough(ds2))
continue;
let boxes2 = drillTool.GetDrillsBox(ds2, ocsInv);
if (this.IsCollsion([boxes1], [boxes2]))
{
let h = ds1[0].Object as Hole;
if (h.FId.Object && h.MId.Object)
res.push({
InterBoard: h.FId.Object as Board,
LocalBoard: h.MId.Object as Board,
});
break;
}
}
if (j < dss.length)
break;
let h = ds1[0].Object as Hole;
if (h.FId.Object && h.MId.Object)
res.push({
InterBoard: h.FId.Object as Board,
LocalBoard: h.MId.Object as Board,
});
break;
}
}
if (j < dss.length)
break;
}
}
for (let i = 0; i < brs.length; i++)
{
let b1 = brs[i];
let drills = b2boxMap.get(b1);
if (!drills || drills.length === 0) continue;
let ocsInv = (drills[0][0].Object as Hole).OCSInv;
let boxlist: Box3Ext[][] = [];
//通孔对应的穿孔板件
let tkHoleFidSet = new Set<ObjectId>();
for (let ds of drills)
{
boxlist.push(drillTool.GetDrillsBox(ds, ocsInv));
if (this.IsThough(ds))
tkHoleFidSet.add((ds[0].Object as CylinderHole).FId);
}
for (let j = i + 1; j < brs.length; j++)
{
let b2 = brs[j];
let drills2 = b2boxMap.get(b2);
for (let i = 0; i < brs.length; i++)
{
let b1 = brs[i];
let drills = b2boxMap.get(b1);
if (!drills || drills.length === 0) continue;
let ocsInv = (drills[0][0].Object as Hole).OCSInv;
let boxlist: Box3Ext[][] = [];
//通孔对应的穿孔板件
let tkHoleFidSet = new Set<ObjectId>();
for (let ds of drills)
{
boxlist.push(drillTool.GetDrillsBox(ds, ocsInv));
if (IsThough(ds))
tkHoleFidSet.add((ds[0].Object as CylinderHole).FId);
}
if (drills2.length === 0) continue;
const boxlist2: Box3Ext[][] = [];
for (let j = i + 1; j < brs.length; j++)
{
let b2 = brs[j];
let drills2 = b2boxMap.get(b2);
for (let ds of drills2)
{
let h1 = ds[0].Object as CylinderHole;
//同一穿孔板件的通孔不参与碰撞计算
if (this.IsThough(ds) && tkHoleFidSet.has(h1.FId))
continue;
boxlist2.push(drillTool.GetDrillsBox(ds, ocsInv));
}
if (drills2.length === 0) continue;
const boxlist2: Box3Ext[][] = [];
if (this.IsCollsion(boxlist, boxlist2))
{
res.push({
InterBoard: b1,
LocalBoard: b2,
});
}
}
for (let ds of drills2)
{
let h1 = ds[0].Object as CylinderHole;
//同一穿孔板件的通孔不参与碰撞计算
if (IsThough(ds) && tkHoleFidSet.has(h1.FId))
continue;
boxlist2.push(drillTool.GetDrillsBox(ds, ocsInv));
}
if (res.length)
app.Editor.ModalManage.RenderModeless(CollsionModal, { faces: res }, { position: ModalPosition.Right, canMinimize: false });
else
AppToaster.show({
message: "排钻没有干涉!",
timeout: 5000,
intent: Intent.SUCCESS,
if (IsCollsion(boxlist, boxlist2))
{
res.push({
InterBoard: b1,
LocalBoard: b2,
});
}
}
}
return res;
}
/**
/**
*
*/
private IsThough(ds: ObjectId[]): boolean
{
return ds.some(d => (d.Object as CylinderHole).Type === GangDrillType.TK);
}
private IsCollsion(boxlist: Box3Ext[][], boxlist2: Box3Ext[][])
{
const drillTool = DrawDrillingTool.GetInstance();
function IsThough(ds: ObjectId[]): boolean
{
return ds.some(d => (d.Object as CylinderHole).Type === GangDrillType.TK);
}
function IsCollsion(boxlist: Box3Ext[][], boxlist2: Box3Ext[][])
{
const drillTool = DrawDrillingTool.GetInstance();
for (let boxs of boxlist)
for (let boxs of boxlist)
{
for (let boxs2 of boxlist2)
{
for (let boxs2 of boxlist2)
if (boxs.some(bo => boxs2.some(bo2 => drillTool.DrillIsCollsion(bo, bo2))))
{
if (boxs.some(bo => boxs2.some(bo2 => drillTool.DrillIsCollsion(bo, bo2))))
{
return true;
}
return true;
}
}
return false;
}
return false;
}

@ -21,8 +21,11 @@ import { SelectSetBase } from "../../Editor/SelectBase";
import { userConfig } from "../../Editor/UserConfig";
import { IHardwareType } from "../../Production/Product";
import { AppConfirm } from "../../UI/Components/Common/Confirm";
import { ModalPosition } from "../../UI/Components/Modal/ModalInterface";
import { AppToaster } from "../../UI/Components/Toaster";
import { BoardStore } from "../../UI/Store/BoardStore";
import { InterferenceCheck } from "../CheckHoles";
import { CollsionModal } from "../DrawDrilling/CollisionModal";
import { Purge } from "../Purge";
import { blockBuilder, objectBuilder } from './CheckBuilder';
import { ErpGroupBy } from "./ErpGroupBy";
@ -139,9 +142,25 @@ async function ExecChaiDan(chaiDanRoute: ErpRoutes)
{
let selction = await GetProductsEntitys();
if (!selction) return;
let intSelfBoards = new Set<Board>();
let minBoardCount = 0;
const boardList = GetSelectionBoards(selction.selectEntityList, selction.selectRelativeHardware);
const interference = InterferenceCheck(boardList);
if (interference.length)
{
let res = await AppConfirm.show({
intent: Intent.WARNING,
message: "存在排钻碰撞,是否先排查?"
});
if (res)
{
app.Editor.ModalManage.RenderModeless(CollsionModal, { faces: interference }, { position: ModalPosition.Right, canMinimize: false });
return;
}
}
for (let br of boardList)
{
let b = br.__OriginalEnt__ ?? br;

Loading…
Cancel
Save