mirror of https://gitee.com/cf-fz/WebCAD.git
!2003 功能:酷家乐使用名称可切换和酷家乐封边值映射
parent
5265f5094d
commit
9a879e0b32
@ -0,0 +1,61 @@
|
|||||||
|
import { arrayLast } from "../../../Common/ArrayExt";
|
||||||
|
import { KJLImportConfigOption } from "../../../UI/Store/BoardInterface";
|
||||||
|
import { KJL_Parameter, KJL_ParamModel } from "./KJLInterface";
|
||||||
|
|
||||||
|
export class KJLEdgeParse
|
||||||
|
{
|
||||||
|
//(酷家乐封边值) -> 导入实际值
|
||||||
|
KjlEdgeValueMap = new Map<number, number>();
|
||||||
|
|
||||||
|
async LoadKJLEdgeValueMap(config: { [key: string]: KJLImportConfigOption; })
|
||||||
|
{
|
||||||
|
if (!config?.option?.edgeValueMap) return;
|
||||||
|
for (const [key, value] of config.option.edgeValueMap)
|
||||||
|
{
|
||||||
|
if (key === 0 && value === 0) continue;
|
||||||
|
this.KjlEdgeValueMap.set(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//解析封边
|
||||||
|
ParseSeals(model: KJL_ParamModel): number[] | undefined
|
||||||
|
{
|
||||||
|
let seals: number[] = [];
|
||||||
|
let maxIndex = 0;//避免漏掉,我们保存了最大的索引
|
||||||
|
const Parse = (params: KJL_Parameter[]) =>
|
||||||
|
{
|
||||||
|
if (!params) return;
|
||||||
|
for (let param of params)
|
||||||
|
{
|
||||||
|
if (param.name === "ET")
|
||||||
|
{
|
||||||
|
seals.push(parseFloat(param.value));
|
||||||
|
for (let i = 0; i < maxIndex - 1; i++)
|
||||||
|
seals[i] = arrayLast(seals);
|
||||||
|
maxIndex++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (param.name.startsWith("ET"))
|
||||||
|
{
|
||||||
|
let index = parseInt(param.name.substring(2)) - 1;
|
||||||
|
seals[index] = parseFloat(param.value);
|
||||||
|
maxIndex = Math.max(index, maxIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Parse(model.constParameters);
|
||||||
|
Parse(model.ignoreParameters);
|
||||||
|
Parse(model.parameters);
|
||||||
|
|
||||||
|
for (let i = 0; i < maxIndex; i++)
|
||||||
|
{
|
||||||
|
if (seals[i] === undefined)
|
||||||
|
seals[i] = seals[maxIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seals.length > 0)
|
||||||
|
return seals.map(e => this.KjlEdgeValueMap.get(e) ?? e);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue