From c66a2555cb144f177c9ddc81d78188f927ce64ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=89?= <940119273@qq.com> Date: Mon, 19 Feb 2024 09:42:19 +0000 Subject: [PATCH] =?UTF-8?q?!2553=20=E4=BC=98=E5=8C=96:=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=BB=84=E5=90=88=E6=97=B6=E6=9C=89=E7=A9=BA=E9=97=B4=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=A2=E5=A4=B1=E7=9A=84=E6=A8=A1=E5=9D=97=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E8=AF=AF=20Merge=20pull=20request=20!2553=20?= =?UTF-8?q?from=20=E6=9E=97=E4=B8=89/fix=5FtempGroup=5Ftip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/Command_TemplateGroup.ts | 57 ++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/src/Add-on/Command_TemplateGroup.ts b/src/Add-on/Command_TemplateGroup.ts index b31e35d15..391f3847d 100644 --- a/src/Add-on/Command_TemplateGroup.ts +++ b/src/Add-on/Command_TemplateGroup.ts @@ -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[][] = []; + 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)) {