|
|
|
@ -42,7 +42,20 @@ export class Command_TemplateGroup implements Command
|
|
|
|
|
for (let ent of ents)
|
|
|
|
|
{
|
|
|
|
|
let temp = GetRootTemp(ent.Template?.Object as TemplateRecord);
|
|
|
|
|
if (temp) temps.add(temp);
|
|
|
|
|
if (temp)
|
|
|
|
|
{
|
|
|
|
|
if (temp.Positioning.SpaceSize)
|
|
|
|
|
temps.add(temp);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: `模块:${temp.Name} 空间信息丢失,请检查!`,
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
intent: Intent.DANGER,
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (temps.size < 2)
|
|
|
|
@ -94,6 +107,7 @@ export class Command_TemplateGroup implements Command
|
|
|
|
|
//组合模块的Box和Size
|
|
|
|
|
const NewTempArray = [];
|
|
|
|
|
const NewTempSpaceBox = new Box3Ext();
|
|
|
|
|
let NewTempSpaceSize;
|
|
|
|
|
|
|
|
|
|
for (let temp of tempArray)
|
|
|
|
|
{
|
|
|
|
@ -111,8 +125,6 @@ export class Command_TemplateGroup implements Command
|
|
|
|
|
newPositioning.SpaceSize = positioning.SpaceSize;
|
|
|
|
|
newPositioning.SpaceCS = positioning.SpaceCS.setPosition(tempPt).multiply(new Matrix4().getInverse(RMtx));
|
|
|
|
|
|
|
|
|
|
temp.Positioning = newPositioning;
|
|
|
|
|
|
|
|
|
|
let box = new Box3Ext(new Vector3(), newPositioning.SpaceSize.clone());
|
|
|
|
|
box.applyMatrix4(newPositioning.SpaceCS);
|
|
|
|
|
temp.__CacheBox__ = box;
|
|
|
|
@ -124,22 +136,31 @@ export class Command_TemplateGroup implements Command
|
|
|
|
|
NewTempSpaceBox.union(box);
|
|
|
|
|
NewTempArray.push(temp);
|
|
|
|
|
}
|
|
|
|
|
const NewTempSpaceSize = NewTempSpaceBox.getSize(new Vector3);
|
|
|
|
|
|
|
|
|
|
NewTempSpaceSize = NewTempSpaceBox.getSize(new Vector3);
|
|
|
|
|
|
|
|
|
|
//验证所选模块空间关系及排序
|
|
|
|
|
{
|
|
|
|
|
let spaceType;
|
|
|
|
|
//判断两个模块空间关系
|
|
|
|
|
let spaceType = BoxSplitType(NewTempArray[0].__CacheBox__, NewTempArray[1].__CacheBox__);
|
|
|
|
|
|
|
|
|
|
if (spaceType > 2)
|
|
|
|
|
for (let i = 0; i < NewTempArray.length - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: "存在模块相交,无法组合!",
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
intent: Intent.DANGER,
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
for (let j = i + 1; j < NewTempArray.length; j++)
|
|
|
|
|
{
|
|
|
|
|
spaceType = BoxSplitType(NewTempArray[i].__CacheBox__, NewTempArray[j].__CacheBox__);
|
|
|
|
|
|
|
|
|
|
if (spaceType > 2)
|
|
|
|
|
{
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: "存在模块相交,无法组合!",
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
intent: Intent.DANGER,
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NewTempArray.sort((a, b) =>
|
|
|
|
|
{
|
|
|
|
|
let b1 = a.__CacheBox__;
|
|
|
|
@ -302,6 +323,7 @@ function SetSplitTypeDiv(temp: TemplateRecord)
|
|
|
|
|
if (temp.SplitType === TemplateSplitType.X)
|
|
|
|
|
{
|
|
|
|
|
let SameX: ObjectId<CADObject>[][] = [];
|
|
|
|
|
|
|
|
|
|
while (childrens.length)
|
|
|
|
|
{
|
|
|
|
|
let childrenTemp = childrens.pop();
|
|
|
|
@ -316,6 +338,9 @@ function SetSplitTypeDiv(temp: TemplateRecord)
|
|
|
|
|
});
|
|
|
|
|
SameX.push(same);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!SameX.length) return;
|
|
|
|
|
|
|
|
|
|
SameX.sort((a, b) => b.length - a.length);
|
|
|
|
|
//柜体X轴都相等 或者相等的有最大值 [3,2,2,1,1]
|
|
|
|
|
if (SameX.length === 1 || (SameX.length > 1 && SameX[0].length > SameX[1].length))
|
|
|
|
@ -368,6 +393,9 @@ function SetSplitTypeDiv(temp: TemplateRecord)
|
|
|
|
|
});
|
|
|
|
|
SameY.push(same);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!SameY.length) return;
|
|
|
|
|
|
|
|
|
|
SameY.sort((a, b) => b.length - a.length);
|
|
|
|
|
if (SameY.length === 1 || (SameY.length > 1 && SameY[0].length > SameY[1].length))
|
|
|
|
|
{
|
|
|
|
@ -419,6 +447,9 @@ function SetSplitTypeDiv(temp: TemplateRecord)
|
|
|
|
|
});
|
|
|
|
|
SameZ.push(same);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!SameZ.length) return;
|
|
|
|
|
|
|
|
|
|
SameZ.sort((a, b) => b.length - a.length);
|
|
|
|
|
if (SameZ.length === 1 || (SameZ.length > 1 && SameZ[0].length > SameZ[1].length))
|
|
|
|
|
{
|
|
|
|
|