|
|
@ -278,12 +278,13 @@ class ActivityLayerBoardTool
|
|
|
|
private AppendBoard(br: Board, brNailMap: WeakMap<CylinderHole, Board>, nails: CylinderHole[])
|
|
|
|
private AppendBoard(br: Board, brNailMap: WeakMap<CylinderHole, Board>, nails: CylinderHole[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let oldNailIds = br.LayerNails.filter(n => n?.Object);
|
|
|
|
let oldNailIds = br.LayerNails.filter(n => n?.Object);
|
|
|
|
|
|
|
|
this.HandleNailList(nails, oldNailIds, brNailMap);
|
|
|
|
for (let i = nails.length; i < oldNailIds.length; i++)
|
|
|
|
for (let i = nails.length; i < oldNailIds.length; i++)
|
|
|
|
oldNailIds[i]?.Object?.Erase();
|
|
|
|
oldNailIds[i]?.Object?.Erase();
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < nails.length; i++)
|
|
|
|
for (let i = 0; i < nails.length; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let nId: ObjectId;
|
|
|
|
let nId: ObjectId;
|
|
|
|
|
|
|
|
let otherBoard = brNailMap.get(nails[i]);
|
|
|
|
if (i < oldNailIds.length)
|
|
|
|
if (i < oldNailIds.length)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let nail = oldNailIds[i].Object as CylinderHole;
|
|
|
|
let nail = oldNailIds[i].Object as CylinderHole;
|
|
|
@ -301,13 +302,55 @@ class ActivityLayerBoardTool
|
|
|
|
br.Db.ModelSpace.Append(nails[i]);
|
|
|
|
br.Db.ModelSpace.Append(nails[i]);
|
|
|
|
nId = nails[i].Id;
|
|
|
|
nId = nails[i].Id;
|
|
|
|
br.AppendNails([nId]);
|
|
|
|
br.AppendNails([nId]);
|
|
|
|
let otherBoard = brNailMap.get(nails[i]);
|
|
|
|
|
|
|
|
nails[i].MId = br.Id;
|
|
|
|
nails[i].MId = br.Id;
|
|
|
|
nails[i].FId = otherBoard.Id;
|
|
|
|
nails[i].FId = otherBoard.Id;
|
|
|
|
otherBoard.AppendNails([nId]);
|
|
|
|
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();
|
|
|
|
export const activityLayerBoardTool = new ActivityLayerBoardTool();
|
|
|
|