84 lines
2.6 KiB
TypeScript
84 lines
2.6 KiB
TypeScript
import { Processor, ProcessorModule } from "../../src/device";
|
||
|
||
import { ErrorInfo } from "../../src/device";
|
||
import { FaceType, PlaceBlockDetail } from "../confClass";
|
||
// import { PolylineHelper } from "../handleAbility/common/LayoutEngine/PolylineHelper";
|
||
// import {PolylineHelper} from "../handleAbility/common/LayoutEngine/PolylineHelper.js"
|
||
/** 模块 造型轮廓(含封边),扣除封边, 变成开料坐标
|
||
* !!!!!! 有异常 要调整
|
||
* input 入参
|
||
|
||
*/
|
||
|
||
export const Init2VModel: ProcessorModule<any, any> = {
|
||
moduleName: "Init2VModel",
|
||
moduleVersion: '20250714',
|
||
config: {
|
||
|
||
},
|
||
setConfig(config) {
|
||
this.config = { ...this.config, ...config };
|
||
},
|
||
|
||
// 会在处理器自动执行
|
||
/**
|
||
*
|
||
* @param input 输入数据
|
||
* @param next 下一个流程的函数
|
||
* @param context 上下文
|
||
* @returns
|
||
*/
|
||
|
||
process(input, next, context) {
|
||
const { blockDetailList } = input
|
||
for (const bd of blockDetailList) {
|
||
init2VModel(bd);
|
||
}
|
||
|
||
function init2VModel(blockDetail: PlaceBlockDetail, isCNC = false) {
|
||
for (let model of blockDetail.models) {
|
||
if (!model.isVKnifeModel)
|
||
continue
|
||
let vModels: any = []
|
||
model.VLines = vModels
|
||
let isFaceB = model.face == FaceType.BACK
|
||
if (model.pointList.length < 1)
|
||
continue
|
||
let ps = model.pointList.map((t) => { return { x: t.pointX, y: t.pointY, bul: t.curve } })
|
||
let pl = PolylineHelper.create(ps)
|
||
if (model.VLines?.length > 0)
|
||
return // 已经分析了
|
||
model.VLines = []
|
||
for (let os of model.offsetList) {
|
||
let knife1 = isCNC ? null : this.getModelKnifeByName(os.name)
|
||
let knifeR = os.radius
|
||
let knifeId = knife1 ? knife1.knifeId : -1
|
||
try {
|
||
let vps_1 = PolylineHelper.getVModelPoints_offset(pl, os.offset, os.depth, os.angle)
|
||
let vLine = { isFaceB, name: os.name, value: os.offset, knife: knife1, knifeId, knifeRadius: knifeR, depth: os.depth, points: vps_1, offset: os }
|
||
vModels.push(vLine) // 偏移路径
|
||
model.VLines.push(vLine)
|
||
}
|
||
catch (err) {
|
||
console.log('v型刀走刀路径算法出错。' + err)
|
||
}
|
||
}
|
||
model.VLines = vModels
|
||
}
|
||
}
|
||
|
||
return next ? next(input) : input;
|
||
},
|
||
|
||
|
||
|
||
|
||
|
||
onError(error) {
|
||
|
||
console.error('出错了哦', error);
|
||
|
||
}
|
||
};
|
||
|