!2993 优化:切割分裂后的板重新分配原板件的关联五金

pull/3002/MERGE
林三 1 month ago committed by ChenX
parent 896d995b05
commit 65487120e6

@ -1,13 +1,12 @@
import { Intent } from "@blueprintjs/core";
import { Line3, Matrix4, Quaternion, Vector3 } from "three";
import { app } from "../../ApplicationServices/Application";
import { arrayLast, arrayRemoveIf } from "../../Common/ArrayExt";
import { arrayLast } from "../../Common/ArrayExt";
import { AlignLineGroupRecord } from "../../DatabaseServices/AlignLine/AlignLineGroupRecord";
import { Contour } from "../../DatabaseServices/Contour";
import { Board, I2DModeling } from "../../DatabaseServices/Entity/Board";
import { ExtrudeContourCurve } from "../../DatabaseServices/Entity/Extrude";
import { BUL_IS_LINE_FUZZ, Polyline } from "../../DatabaseServices/Entity/Polyline";
import { HardwareCompositeEntity } from "../../DatabaseServices/Hardware/HardwareCompositeEntity";
import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { CreateContour2 } from "../../Geometry/CreateContour2";
@ -280,34 +279,6 @@ export class LinearCutting implements Command
br.HandleSpliteEntitys(spliteEnts);
br.GrooveCheckAllAutoSplit();
//关联复合实体 重新关联
arrayRemoveIf(br.RelativeHardware, (hwdObjId) =>
{
if (!hwdObjId || hwdObjId.IsErase) return true;
for (let ent of spliteEnts)
{
let hwd = (hwdObjId.Object as HardwareCompositeEntity);
if (ent.BoundingBox.intersectsBox(hwd.BoundingBox))
{
arrayRemoveIf(hwd.RelevanceBoards, (rbr) =>
{
return rbr && rbr.Object === br;
});
hwd.RelevanceBoards.push(ent.objectId);
ent.RelativeHardware.push(hwdObjId);
if (br.RelativeHandle.includes(hwdObjId))
{
arrayRemoveIf(br.RelativeHandle, (handle) => handle === hwdObjId);
ent.RelativeHandle.push(hwdObjId);
}
return true;
}
}
});
fixPath.SetBoardPath2d(br);
}

@ -1,11 +1,9 @@
import { app } from "../../ApplicationServices/Application";
import { arrayRemoveIf } from "../../Common/ArrayExt";
import { InteractionLog, LogType } from "../../Common/Log";
import { Board } from "../../DatabaseServices/Entity/Board";
import { BoardType } from "../../DatabaseServices/Entity/BoardInterface";
import { Line } from "../../DatabaseServices/Entity/Line";
import { Polyline } from "../../DatabaseServices/Entity/Polyline";
import { HardwareCompositeEntity } from "../../DatabaseServices/Hardware/HardwareCompositeEntity";
import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { ZeroVec, equaln } from "../../Geometry/GeUtils";
@ -173,34 +171,6 @@ export class ReferenceCutting implements Command
br.ContourCurve = contours[0];
br.HandleSpliteEntitys(spliteEntitys);
br.GrooveCheckAllAutoSplit();
//关联复合实体 重新关联
arrayRemoveIf(br.RelativeHardware, (hwdObjId) =>
{
if (!hwdObjId || hwdObjId.IsErase) return true;
for (let ent of spliteEntitys)
{
let hwd = (hwdObjId.Object as HardwareCompositeEntity);
if (ent.BoundingBox.intersectsBox(hwd.BoundingBox))
{
arrayRemoveIf(hwd.RelevanceBoards, (rbr) =>
{
return rbr && rbr.Object === br;
});
hwd.RelevanceBoards.push(ent.objectId);
ent.RelativeHardware.push(hwdObjId);
if (br.RelativeHandle.includes(hwdObjId))
{
arrayRemoveIf(br.RelativeHandle, (handle) => handle === hwdObjId);
ent.RelativeHandle.push(hwdObjId);
}
return true;
}
}
});
}
app.Editor.Prompt(`切割成功: 有效${brs.length - failCount}个, 无效${failCount}`, LogType.Info, Array.from(failList));
}

@ -2133,7 +2133,7 @@ export class Board extends ExtrudeSolid
}
//del_exp2_end
//分裂后重新将排钻实体设置给不同的实体
//分裂后重新将排钻实体 关联五金 设置给不同的实体
override HandleSpliteEntitys(splitEntitys: this[])
{
if (!splitEntitys.length) return;
@ -2250,9 +2250,7 @@ export class Board extends ExtrudeSolid
d[1] = drIdss;
}
}
}
//删除无父母的排钻
@ -2266,6 +2264,33 @@ export class Board extends ExtrudeSolid
object.Erase();
}
}
//重新关联复合实体
arrayRemoveIf(this.RelativeHardware, (hwdObjId) =>
{
if (!hwdObjId || hwdObjId.IsErase) return true;
for (let ent of splitEntitys)
{
let hwd = (hwdObjId.Object as HardwareCompositeEntity);
if (ent.BoundingBox.intersectsBox(hwd.BoundingBox))
{
//原始板件删除这个五金
arrayRemoveIf(hwd.RelevanceBoards, (rbr) => rbr?.Object === this);
//五金与分裂的板关联
hwd.RelevanceBoards.push(ent.objectId);
ent.RelativeHardware.push(hwdObjId);
//如果五金是把手 写入分裂的板的RelativeHandle
if (this.RelativeHandle.includes(hwdObjId))
{
arrayRemoveIf(this.RelativeHandle, (handle) => handle === hwdObjId);
ent.RelativeHandle.push(hwdObjId);
}
return true;
}
}
});
}
private BuildArcGeometry()

Loading…
Cancel
Save