!2949 优化:组合模块时防止原模块参数被修改

pull/3011/MERGE
林三 1 month ago committed by ChenX
parent 592448ce59
commit 5b8abe1e35

@ -175,7 +175,10 @@ export class Command_TemplateGroup implements Command
//挨个组合
let rootTemp: TemplateRecord;
//每个原始模块和占位空间的组合模块 因为在生成这个最顶层时已经分析了内部位置关系
let newCreateTemp = new Set<TemplateRecord>();
//需要设置DIV参数的节点每个组合模块
let needSetDivTemp = new Set<TemplateRecord>();
let masterTemp = NewTempArray.shift();
while (NewTempArray.length)
@ -193,19 +196,19 @@ export class Command_TemplateGroup implements Command
if (spaceType === SplitType.X)
{
//X轴切割并补充BOX
rootTemp = await SplitBoxOfX(SpaceBox, [box1, box2], masterTemp, secondTemp, newCreateTemp);
rootTemp = await SplitBoxOfX(SpaceBox, [box1, box2], masterTemp, secondTemp, newCreateTemp, needSetDivTemp);
rootTemp.SplitType = TemplateSplitType.X;
}
else if (spaceType === SplitType.Z)
{
//Z轴切割并补充BOX
rootTemp = await SplitBoxOfZ(SpaceBox, [box1, box2], masterTemp, secondTemp, newCreateTemp);
rootTemp = await SplitBoxOfZ(SpaceBox, [box1, box2], masterTemp, secondTemp, newCreateTemp, needSetDivTemp);
rootTemp.SplitType = TemplateSplitType.Z;
}
else if (spaceType === SplitType.Y)
{
//Y轴切割并补充BOX
rootTemp = await SplitBoxOfY(SpaceBox, [box1, box2], masterTemp, secondTemp, newCreateTemp);
rootTemp = await SplitBoxOfY(SpaceBox, [box1, box2], masterTemp, secondTemp, newCreateTemp, needSetDivTemp);
rootTemp.SplitType = TemplateSplitType.Y;
}
@ -225,10 +228,14 @@ export class Command_TemplateGroup implements Command
rootTemp.PYParam.expr = 0;
rootTemp.PZParam.expr = 0;
SetSplitTypeDiv(rootTemp);
//每个组合模块设置内部DIV 不修改原模块内部DIV关系
for (let temp of Array.from(needSetDivTemp))
SetSplitTypeDiv(temp);
for (let children of rootTemp.Children)
SetSplitTypeParam(rootTemp.SplitType, children.Object as TemplateRecord);
//只分析原始模块和占位空间生成的组合模块之间关系 因为已经分析了原模块和占位空间的定位关系
for (let temp of Array.from(newCreateTemp))
for (let children of temp.Children)
SetSplitTypeParam(temp.SplitType, children.Object as TemplateRecord);
let minPt = new Vector3().applyMatrix4(rootTemp.Positioning.SpaceCS);
minPt.applyMatrix4(BackOCS);
@ -537,7 +544,7 @@ function BoxSplitType(box1: Box3Ext, box2: Box3Ext): SplitType
return SplitType.Y;
}
function GetGroupTempRoot(temp1: TemplateRecord, temp2: TemplateRecord, spaceType: TemplateSplitType, midBox: Box3Ext, newCreateTemp: Set<TemplateRecord>): TemplateRecord
function GetGroupTempRoot(temp1: TemplateRecord, temp2: TemplateRecord, spaceType: TemplateSplitType, midBox: Box3Ext, newCreateTemp: Set<TemplateRecord>, needSetDivTemp: Set<TemplateRecord>): TemplateRecord
{
let rootTemp: TemplateRecord;
if (temp1.SplitType === spaceType && newCreateTemp.has(temp1))
@ -562,6 +569,7 @@ function GetGroupTempRoot(temp1: TemplateRecord, temp2: TemplateRecord, spaceTyp
AddSpaceBoxes([midBox], rootTemp);
rootTemp.Children.push(temp2.Id);
newCreateTemp.add(rootTemp);
needSetDivTemp.add(rootTemp);
const temp1BHParam = temp1.Params.find((p) => p.name === "BH");
const temp2BHParam = temp2.Params.find((p) => p.name === "BH");
@ -578,7 +586,7 @@ function GetGroupTempRoot(temp1: TemplateRecord, temp2: TemplateRecord, spaceTyp
return rootTemp;
}
async function SplitBoxOfX(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: TemplateRecord, secondTemp: TemplateRecord, newCreateTemp: Set<TemplateRecord>): Promise<TemplateRecord>
async function SplitBoxOfX(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: TemplateRecord, secondTemp: TemplateRecord, newCreateTemp: Set<TemplateRecord>, needSetDivTemp: Set<TemplateRecord>): Promise<TemplateRecord>
{
let box1: Box3Ext = boxes[0].clone();
let box2: Box3Ext = boxes[1].clone();
@ -622,6 +630,7 @@ async function SplitBoxOfX(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
newTemp.Name = "组合模板";
newTemp.InitBaseParams();
app.Database.TemplateTable.Append(newTemp);
needSetDivTemp.add(newTemp);
//组合模块的Box和Size
const NewTempSpaceBox = box.clone();
@ -668,6 +677,7 @@ async function SplitBoxOfX(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
newTemp.Name = "组合模板";
newTemp.InitBaseParams();
app.Database.TemplateTable.Append(newTemp);
needSetDivTemp.add(newTemp);
//组合模块的Box和Size
const NewTempSpaceBox = box.clone();
@ -702,7 +712,7 @@ async function SplitBoxOfX(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
temp2 = AddFrontBackBox(box2, temp2);
//获取组合后的顶层节点
let rootTemp = GetGroupTempRoot(temp1, temp2, TemplateSplitType.X, midBox, newCreateTemp);
let rootTemp = GetGroupTempRoot(temp1, temp2, TemplateSplitType.X, midBox, newCreateTemp, needSetDivTemp);
await temp1.UpdateTemplateTree();
if (!(temp1.SplitType === TemplateSplitType.X && newCreateTemp.has(temp1)))
@ -714,7 +724,7 @@ async function SplitBoxOfX(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
return rootTemp;
}
async function SplitBoxOfY(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: TemplateRecord, secondTemp: TemplateRecord, newCreateTemp: Set<TemplateRecord>): Promise<TemplateRecord>
async function SplitBoxOfY(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: TemplateRecord, secondTemp: TemplateRecord, newCreateTemp: Set<TemplateRecord>, needSetDivTemp: Set<TemplateRecord>): Promise<TemplateRecord>
{
let box1: Box3Ext = boxes[0].clone();
let box2: Box3Ext = boxes[1].clone();
@ -759,6 +769,7 @@ async function SplitBoxOfY(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
newTemp.Name = "组合模板";
newTemp.InitBaseParams();
app.Database.TemplateTable.Append(newTemp);
needSetDivTemp.add(newTemp);
//组合模块的Box和Size
const NewTempSpaceBox = box.clone();
@ -805,6 +816,7 @@ async function SplitBoxOfY(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
newTemp.Name = "组合模板";
newTemp.InitBaseParams();
app.Database.TemplateTable.Append(newTemp);
needSetDivTemp.add(newTemp);
//组合模块的Box和Size
const NewTempSpaceBox = box.clone();
@ -840,7 +852,7 @@ async function SplitBoxOfY(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
temp2 = AddTopBottomBox(box2, temp2);
//获取组合后的顶层节点
let rootTemp = GetGroupTempRoot(temp1, temp2, TemplateSplitType.Y, midBox, newCreateTemp);
let rootTemp = GetGroupTempRoot(temp1, temp2, TemplateSplitType.Y, midBox, newCreateTemp, needSetDivTemp);
await temp1.UpdateTemplateTree();
if (!(temp1.SplitType === TemplateSplitType.Y && newCreateTemp.has(temp1)))
@ -852,7 +864,7 @@ async function SplitBoxOfY(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
return rootTemp;
}
async function SplitBoxOfZ(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: TemplateRecord, secondTemp: TemplateRecord, newCreateTemp: Set<TemplateRecord>): Promise<TemplateRecord>
async function SplitBoxOfZ(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: TemplateRecord, secondTemp: TemplateRecord, newCreateTemp: Set<TemplateRecord>, needSetDivTemp: Set<TemplateRecord>): Promise<TemplateRecord>
{
let box1: Box3Ext = boxes[0].clone();
let box2: Box3Ext = boxes[1].clone();
@ -896,6 +908,7 @@ async function SplitBoxOfZ(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
newTemp.Name = "组合模板";
newTemp.InitBaseParams();
app.Database.TemplateTable.Append(newTemp);
needSetDivTemp.add(newTemp);
//组合模块的Box和Size
const NewTempSpaceBox = box.clone();
@ -942,6 +955,7 @@ async function SplitBoxOfZ(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
newTemp.Name = "组合模板";
newTemp.InitBaseParams();
app.Database.TemplateTable.Append(newTemp);
needSetDivTemp.add(newTemp);
//组合模块的Box和Size
const NewTempSpaceBox = box.clone();
@ -977,7 +991,7 @@ async function SplitBoxOfZ(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
temp2 = AddFrontBackBox(box2, temp2);
//获取组合后的顶层节点
let rootTemp = GetGroupTempRoot(temp1, temp2, TemplateSplitType.Z, midBox, newCreateTemp);
let rootTemp = GetGroupTempRoot(temp1, temp2, TemplateSplitType.Z, midBox, newCreateTemp, needSetDivTemp);
await temp1.UpdateTemplateTree();
if (!(temp1.SplitType === TemplateSplitType.Z && newCreateTemp.has(temp1)))

@ -2916,6 +2916,16 @@ export const CommandList: ICommand[] = [
chName: "切割空间",
chDes: "切割空间",
},
{
icon: IconEnum.TemplateGroup,
typeId: "temp",
link: `#`,
defaultCustom: CommandNames.TemplateGroup,
command: CommandNames.TemplateGroup,
type: "模板",
chName: "组合模块",
chDes: "组合模块",
},
// 模块命令
{

Loading…
Cancel
Save