|
|
|
@ -31,7 +31,7 @@ import { EZengZhiBaoId, userConfigStore } from "../../../UI/Store/UserConfigStor
|
|
|
|
|
import { CuttingBoardByBoard } from "../../BoardCutting/CuttingUtils2";
|
|
|
|
|
import { KJL_DrillData, KJL_JsonFile, KJL_ModelType, KJL_Parameter, KJL_ParamModel, KJL_ParamModel_Board, KJL_ParamModel_Hardware } from "./KJLInterface";
|
|
|
|
|
import { KJLMaterialLoader } from "./KJLMaterialLoader";
|
|
|
|
|
import { ParseBCBZ, ParseBT, ParseCabNameMap, ParseDrilling, ParseEdgeBanding, ParseEdges, ParseKMFX, ParsePathOutlineAndHole, ParseRoomNameMap } from "./KJLParse";
|
|
|
|
|
import { ParseBCBZ, ParseBT, ParseCabNameMap, ParseDrilling, ParseEdgeBanding, ParseEdges, ParseKMFX, ParsePathOutlineAndHole, ParseRoomNameMap, ParseTopline } from "./KJLParse";
|
|
|
|
|
import { ApplyMaterial, CreateHardware } from "./KJLUtils";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -100,25 +100,40 @@ export async function ImportKJLData(fileData: KJL_JsonFile)
|
|
|
|
|
|
|
|
|
|
let mtlLoader = new KJLMaterialLoader;
|
|
|
|
|
await mtlLoader.LoadKJLConfigMaterials(config);
|
|
|
|
|
let toplines: HardwareTopline[] = [];
|
|
|
|
|
|
|
|
|
|
for (let m of fileData.paramModel)
|
|
|
|
|
{
|
|
|
|
|
let roomName = roomNameMap.get(m.roomId);
|
|
|
|
|
let gName = cabNameMap.get(m.id) ?? m.modelBrandGoodName;
|
|
|
|
|
await ParseModel(m, roomName, gName, mtlLoader, config);
|
|
|
|
|
await ParseModel(m, roomName, gName, mtlLoader, config, toplines);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let ents = app.CommandReactor._createObejcts.filter(obj => obj instanceof Entity) as Entity[];
|
|
|
|
|
let brs = ents.filter(en => en instanceof Board) as Board[];
|
|
|
|
|
let hws = ents.filter(en => en instanceof HardwareCompositeEntity).filter(hw => (hw as HardwareCompositeEntity).HardwareOption.isHole) as HardwareCompositeEntity[];
|
|
|
|
|
|
|
|
|
|
if (ents.length === 0)
|
|
|
|
|
if (ents.length === 0 && toplines.length === 0)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
let box = new Box3;
|
|
|
|
|
for (let en of ents)
|
|
|
|
|
box.union(en.BoundingBox);
|
|
|
|
|
|
|
|
|
|
//合理的设置顶线的位置
|
|
|
|
|
let topLineStartP = box.isEmpty() ? new Vector3 : box.min.clone().setY(box.max.y + 1000);
|
|
|
|
|
for (let i = 0; i < toplines.length; i++)
|
|
|
|
|
{
|
|
|
|
|
let tl = toplines[i];
|
|
|
|
|
|
|
|
|
|
tl.Position = topLineStartP;
|
|
|
|
|
|
|
|
|
|
topLineStartP.x += 50;
|
|
|
|
|
|
|
|
|
|
app.Database.ModelSpace.Append(tl);
|
|
|
|
|
ents.push(tl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Editor.GetPointServices.snapServices.FilterEntitys = new Set(ents);
|
|
|
|
|
let ok = await JigMoveEntity(ents, box.isEmpty() ? undefined : box.min);
|
|
|
|
|
app.Editor.GetPointServices.snapServices.FilterEntitys = undefined;
|
|
|
|
@ -168,6 +183,7 @@ async function ParseModel(model: KJL_ParamModel,
|
|
|
|
|
gName: string,
|
|
|
|
|
mtlLoader: KJLMaterialLoader,
|
|
|
|
|
config: { [key: string]: KJLImportConfigOption; },
|
|
|
|
|
outToplines: HardwareTopline[],
|
|
|
|
|
parentMatrix?: Matrix4,
|
|
|
|
|
edgeBandingAll?: number[],
|
|
|
|
|
drillData?: KJL_DrillData): Promise<Board | TemplateRecord | HardwareCompositeEntity>
|
|
|
|
@ -181,6 +197,22 @@ async function ParseModel(model: KJL_ParamModel,
|
|
|
|
|
if (parentMatrix)
|
|
|
|
|
mtx.premultiply(parentMatrix);
|
|
|
|
|
|
|
|
|
|
if (model.profileSegments)
|
|
|
|
|
{
|
|
|
|
|
let toplines = await ParseTopline(model, mtlLoader);
|
|
|
|
|
if (toplines)
|
|
|
|
|
{
|
|
|
|
|
for (const topline of toplines)
|
|
|
|
|
{
|
|
|
|
|
if (parentMatrix)
|
|
|
|
|
mtx.premultiply(parentMatrix);
|
|
|
|
|
|
|
|
|
|
outToplines.push(topline);
|
|
|
|
|
}
|
|
|
|
|
return;//顶线是单独的模块,数据在第一层,不需要解析子模块
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let boardType = ParseBT(model.parameters) ?? ParseBT(model.ignoreParameters) ?? ParseBT(model.constParameters);
|
|
|
|
|
if (boardType === 4)
|
|
|
|
|
{
|
|
|
|
@ -475,7 +507,7 @@ async function ParseModel(model: KJL_ParamModel,
|
|
|
|
|
if (holeFaceData) drillData.bigHole = holeFaceData.bigHole;
|
|
|
|
|
|
|
|
|
|
let boardType = ParseBT(model.parameters) ?? ParseBT(model.ignoreParameters) ?? ParseBT(model.constParameters);
|
|
|
|
|
let obj = await ParseModel(m, roomName, gName, mtlLoader, config, mtx, edgeBandings, drillData);
|
|
|
|
|
let obj = await ParseModel(m, roomName, gName, mtlLoader, config, outToplines, mtx, edgeBandings, drillData);
|
|
|
|
|
if (obj)
|
|
|
|
|
{
|
|
|
|
|
if (obj instanceof Board)
|
|
|
|
|