!2829 优化:组合模块功能组合模块时,模块顶层的板厚数值相同,则模块顶层板厚参数BH的表达式使用'_BH'

pull/2939/MERGE
林三 2 months ago committed by ChenX
parent d5f18a99cf
commit 2790ab6a9f

@ -545,6 +545,47 @@ function BoxSplitType(box1: Box3Ext, box2: Box3Ext): SplitType
return SplitType.Y;
}
function GetGroupTempRoot(temp1: TemplateRecord, temp2: TemplateRecord, spaceType: TemplateSplitType, midBox: Box3Ext, newCreateTemp: Set<TemplateRecord>): TemplateRecord
{
let rootTemp: TemplateRecord;
if (temp1.SplitType === spaceType && newCreateTemp.has(temp1))
{
rootTemp = temp1;
AddSpaceBoxes([midBox], rootTemp);
rootTemp.Children.push(temp2.Id);
const temp1BHParam = temp1.Params.find((p) => p.name === "BH");
const temp2BHParam = temp2.Params.find((p) => p.name === "BH");
if (temp1BHParam.value == temp2BHParam.value)
temp2BHParam.expr = "_BH";
}
else
{
//组合后的顶层节点
rootTemp = new TemplateVisualSpace();
rootTemp.Name = "组合模板";
rootTemp.InitBaseParams();
app.Database.TemplateTable.Append(rootTemp);
rootTemp.Children.push(temp1.Id);
AddSpaceBoxes([midBox], rootTemp);
rootTemp.Children.push(temp2.Id);
newCreateTemp.add(rootTemp);
const temp1BHParam = temp1.Params.find((p) => p.name === "BH");
const temp2BHParam = temp2.Params.find((p) => p.name === "BH");
if (temp1BHParam.value == temp2BHParam.value)
{
temp1BHParam.expr = "_BH";
temp2BHParam.expr = "_BH";
const rootTempBHParam = rootTemp.Params.find((p) => p.name === "BH");
rootTempBHParam.value = temp1BHParam.value;
}
}
return rootTemp;
}
async function SplitBoxOfX(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: TemplateRecord, secondTemp: TemplateRecord, newCreateTemp: Set<TemplateRecord>): Promise<TemplateRecord>
{
let box1: Box3Ext = boxes[0].clone();
@ -553,9 +594,6 @@ async function SplitBoxOfX(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
let temp2: TemplateRecord = secondTemp;
const Reverse = box1.min.x > box2.max.x;
//组合后的顶层节点
let rootTemp: TemplateRecord;
if (Reverse)
{
box1 = boxes[1].clone();
@ -671,24 +709,8 @@ async function SplitBoxOfX(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
temp2 = AddTopBottomBox(box2, temp2);
temp2 = AddFrontBackBox(box2, temp2);
if (temp1.SplitType === TemplateSplitType.X && newCreateTemp.has(temp1))
{
rootTemp = temp1;
AddSpaceBoxes([midBox], rootTemp);
rootTemp.Children.push(temp2.Id);
}
else
{
//组合后的顶层节点
rootTemp = new TemplateVisualSpace();
rootTemp.Name = "组合模板";
rootTemp.InitBaseParams();
app.Database.TemplateTable.Append(rootTemp);
rootTemp.Children.push(temp1.Id);
AddSpaceBoxes([midBox], rootTemp);
rootTemp.Children.push(temp2.Id);
newCreateTemp.add(rootTemp);
}
//获取组合后的顶层节点
let rootTemp = GetGroupTempRoot(temp1, temp2, TemplateSplitType.X, midBox, newCreateTemp);
await temp1.UpdateTemplateTree();
if (!(temp1.SplitType === TemplateSplitType.X && newCreateTemp.has(temp1)))
@ -708,9 +730,6 @@ async function SplitBoxOfY(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
let temp2: TemplateRecord = secondTemp;
const Reverse = box1.min.y > box2.max.y;
//组合后的顶层节点
let rootTemp: TemplateRecord;
if (Reverse)
{
box1 = boxes[1].clone();
@ -828,24 +847,8 @@ async function SplitBoxOfY(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
temp2 = AddLeftRightBox(box2, temp2);
temp2 = AddTopBottomBox(box2, temp2);
if (temp1.SplitType === TemplateSplitType.Y && newCreateTemp.has(temp1))
{
rootTemp = temp1;
AddSpaceBoxes([midBox], rootTemp);
rootTemp.Children.push(temp2.Id);
}
else
{
//组合后的顶层节点
rootTemp = new TemplateVisualSpace();
rootTemp.Name = "组合模板";
rootTemp.InitBaseParams();
app.Database.TemplateTable.Append(rootTemp);
rootTemp.Children.push(temp1.Id);
AddSpaceBoxes([midBox], rootTemp);
rootTemp.Children.push(temp2.Id);
newCreateTemp.add(rootTemp);
}
//获取组合后的顶层节点
let rootTemp = GetGroupTempRoot(temp1, temp2, TemplateSplitType.Y, midBox, newCreateTemp);
await temp1.UpdateTemplateTree();
if (!(temp1.SplitType === TemplateSplitType.Y && newCreateTemp.has(temp1)))
@ -865,9 +868,6 @@ async function SplitBoxOfZ(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
let temp2: TemplateRecord = secondTemp;
const Reverse = box1.min.z > box2.max.z;
//组合后的顶层节点
let rootTemp: TemplateRecord;
if (Reverse)
{
box1 = boxes[1].clone();
@ -984,24 +984,8 @@ async function SplitBoxOfZ(spaceBox: Box3Ext, boxes: Box3Ext[], firstTemp: Templ
temp2 = AddLeftRightBox(box2, temp2);
temp2 = AddFrontBackBox(box2, temp2);
if (temp1.SplitType === TemplateSplitType.Z && newCreateTemp.has(temp1))
{
rootTemp = temp1;
AddSpaceBoxes([midBox], rootTemp);
rootTemp.Children.push(temp2.Id);
}
else
{
//组合后的顶层节点
rootTemp = new TemplateVisualSpace();
rootTemp.Name = "组合模板";
rootTemp.InitBaseParams();
app.Database.TemplateTable.Append(rootTemp);
rootTemp.Children.push(temp1.Id);
AddSpaceBoxes([midBox], rootTemp);
rootTemp.Children.push(temp2.Id);
newCreateTemp.add(rootTemp);
}
//获取组合后的顶层节点
let rootTemp = GetGroupTempRoot(temp1, temp2, TemplateSplitType.Z, midBox, newCreateTemp);
await temp1.UpdateTemplateTree();
if (!(temp1.SplitType === TemplateSplitType.Z && newCreateTemp.has(temp1)))

Loading…
Cancel
Save