|
|
|
@ -19,6 +19,8 @@ import { Entity } from "../../DatabaseServices/Entity/Entity";
|
|
|
|
|
import { Polyline } from "../../DatabaseServices/Entity/Polyline";
|
|
|
|
|
import { FileServer } from "../../DatabaseServices/FileServer";
|
|
|
|
|
import { GroupRecord } from "../../DatabaseServices/GroupTableRecord";
|
|
|
|
|
import { HardwareCompositeEntity } from "../../DatabaseServices/Hardware/HardwareCompositeEntity";
|
|
|
|
|
import { HardwareTopline } from "../../DatabaseServices/Hardware/HardwareTopline";
|
|
|
|
|
import { Text } from "../../DatabaseServices/Text/Text";
|
|
|
|
|
import { ViewportEntity } from "../../DatabaseServices/ViewportEntity";
|
|
|
|
|
import { Command } from "../../Editor/CommandMachine";
|
|
|
|
@ -291,9 +293,118 @@ export class OneKeyLayout implements Command
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//板、复合实体、模型
|
|
|
|
|
let box2EntMap = GroupEntitysByBox(ents);
|
|
|
|
|
let box2EntMap: Map<Box3Ext, Entity[]> = new Map();
|
|
|
|
|
let othersBox2EntMap: Map<Box3Ext, Entity[]> = new Map();
|
|
|
|
|
|
|
|
|
|
//按房名出图
|
|
|
|
|
if (groupType === GroupByType.roomName)
|
|
|
|
|
{
|
|
|
|
|
let roomNameEntsMap: Map<string, Set<Entity>> = new Map();
|
|
|
|
|
let alreadyAllocated: Set<Entity> = new Set(); //提前加入组织的实体
|
|
|
|
|
|
|
|
|
|
//按房名分类
|
|
|
|
|
while (ents.length)
|
|
|
|
|
{
|
|
|
|
|
let ent = ents.pop();
|
|
|
|
|
let roomName = "";
|
|
|
|
|
|
|
|
|
|
if (ent instanceof Board)
|
|
|
|
|
roomName = ent.BoardProcessOption.roomName;
|
|
|
|
|
else if (ent instanceof HardwareCompositeEntity || ent instanceof HardwareTopline)
|
|
|
|
|
roomName = ent.HardwareOption.roomName;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
others.push(ent);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//加入组织
|
|
|
|
|
let group = roomNameEntsMap.get(roomName);
|
|
|
|
|
if (group)
|
|
|
|
|
group.add(ent);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
group = new Set([ent]);
|
|
|
|
|
roomNameEntsMap.set(roomName, group);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查看编组
|
|
|
|
|
let groupId = ent.GroupId?.Object as GroupRecord;
|
|
|
|
|
if (groupId)
|
|
|
|
|
{
|
|
|
|
|
for (let obj of groupId.Entitys)
|
|
|
|
|
{
|
|
|
|
|
let groupEn = obj.Object as Entity;
|
|
|
|
|
|
|
|
|
|
if (groupEn instanceof Board)
|
|
|
|
|
{
|
|
|
|
|
if (roomName !== groupEn.BoardProcessOption.roomName)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else if (groupEn instanceof HardwareCompositeEntity || groupEn instanceof HardwareTopline)
|
|
|
|
|
{
|
|
|
|
|
if (roomName !== groupEn.HardwareOption.roomName)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
arrayRemoveIf(ents, (en) =>
|
|
|
|
|
{
|
|
|
|
|
if (en === groupEn)
|
|
|
|
|
{
|
|
|
|
|
group.add(en);
|
|
|
|
|
alreadyAllocated.add(en);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
arrayRemoveIf(others, (en) =>
|
|
|
|
|
{
|
|
|
|
|
if (en === groupEn)
|
|
|
|
|
{
|
|
|
|
|
group.add(en);
|
|
|
|
|
alreadyAllocated.add(en);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//计算包围盒
|
|
|
|
|
for (let [str, ents] of roomNameEntsMap)
|
|
|
|
|
{
|
|
|
|
|
let box = new Box3Ext();
|
|
|
|
|
for (let ent of ents)
|
|
|
|
|
box.union(ent.BoundingBox);
|
|
|
|
|
|
|
|
|
|
box2EntMap.set(box, Array.from(ents));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//分配剩余others实体
|
|
|
|
|
if (others.length)
|
|
|
|
|
{
|
|
|
|
|
box2EntMap = new Map(Array.from(box2EntMap).sort((b1, b2) => { return b1[0].Volume - b2[0].Volume; }));
|
|
|
|
|
//将标注 文字 模型 SweepSolid 对象加入编组
|
|
|
|
|
for (let [box, entitys] of box2EntMap)
|
|
|
|
|
{
|
|
|
|
|
arrayRemoveIf(others, (ent) =>
|
|
|
|
|
{
|
|
|
|
|
let box3 = ent.BoundingBox as Box3Ext;
|
|
|
|
|
//容差100 考虑到标注离得较远
|
|
|
|
|
if (box3.intersectsBox(box, 100))
|
|
|
|
|
{
|
|
|
|
|
entitys.push(ent);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
box2EntMap = GroupEntitysByBox(ents);
|
|
|
|
|
//文字 标注 曲线
|
|
|
|
|
let othersBox2EntMap = GroupEntitysByBox(others);
|
|
|
|
|
othersBox2EntMap = GroupEntitysByBox(others);
|
|
|
|
|
|
|
|
|
|
//将标注 文字对象加入编组
|
|
|
|
|
for (let [box, entitys] of box2EntMap)
|
|
|
|
@ -324,16 +435,6 @@ export class OneKeyLayout implements Command
|
|
|
|
|
arrayRemoveIf(boxs, (box) => this.checkBoxOnY(firstBox, box, box2EntMap));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (groupType === GroupByType.roomName) //默认一个块里面都是同一个房名(不会有人会做房名不一样的吧)
|
|
|
|
|
{
|
|
|
|
|
let boxs = Array.from(box2EntMap.keys());
|
|
|
|
|
boxs.sort((box1, box2) => box1.min.x - box2.min.x);
|
|
|
|
|
while (boxs.length > 1)
|
|
|
|
|
{
|
|
|
|
|
let firstBox = boxs[0];
|
|
|
|
|
boxs.shift();
|
|
|
|
|
arrayRemoveIf(boxs, (box) => this.checkBoxbyRoomName(firstBox, box, box2EntMap));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据图框生成视口
|
|
|
|
|