!1238 修复:编辑层板钉后拆单数量不对问题

pull/1238/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent 2ff3686813
commit 3b599603dd

@ -278,12 +278,13 @@ class ActivityLayerBoardTool
private AppendBoard(br: Board, brNailMap: WeakMap<CylinderHole, Board>, nails: CylinderHole[])
{
let oldNailIds = br.LayerNails.filter(n => n?.Object);
this.HandleNailList(nails, oldNailIds, brNailMap);
for (let i = nails.length; i < oldNailIds.length; i++)
oldNailIds[i]?.Object?.Erase();
for (let i = 0; i < nails.length; i++)
{
let nId: ObjectId;
let otherBoard = brNailMap.get(nails[i]);
if (i < oldNailIds.length)
{
let nail = oldNailIds[i].Object as CylinderHole;
@ -301,13 +302,55 @@ class ActivityLayerBoardTool
br.Db.ModelSpace.Append(nails[i]);
nId = nails[i].Id;
br.AppendNails([nId]);
let otherBoard = brNailMap.get(nails[i]);
nails[i].MId = br.Id;
nails[i].FId = otherBoard.Id;
otherBoard.AppendNails([nId]);
}
}
}
private HandleNailList(newNails: CylinderHole[], oldNails: ObjectId[], naiMap: WeakMap<CylinderHole, Board>)
{
if (oldNails.length < newNails.length)
{
let temp: CylinderHole[] = [];
for (let i = 0; i < oldNails.length; i++)
{
let nail = oldNails[i].Object as CylinderHole;
if (newNails.length === 0) break;
let j = 0;
for (; j < newNails.length; j++)
{
let newNail = newNails[j] as CylinderHole;
let otherBoard = naiMap.get(newNail);
if (otherBoard.Id === nail.FId)
break;
}
if (j < newNails.length)
temp.push(...newNails.splice(j, 1));
}
newNails.unshift(...temp);
}
else
{
let temp: ObjectId[] = [];
for (let i = 0; i < newNails.length; i++)
{
let nail = newNails[i];
let otherBoard = naiMap.get(nail);
let j = 0;
for (; j < oldNails.length; j++)
{
let oldNail = oldNails[j].Object as CylinderHole;
if (oldNail.FId === otherBoard.Id)
break;
}
if (j < oldNails.length)
temp.push(...oldNails.splice(j, 1));
}
oldNails.unshift(...temp);
}
}
}
export const activityLayerBoardTool = new ActivityLayerBoardTool();

Loading…
Cancel
Save