feat: 提交

This commit is contained in:
2025-07-22 18:38:25 +08:00
parent 87e2804d1f
commit b7399fd6e7
23 changed files with 36662 additions and 58 deletions

View File

@@ -0,0 +1,42 @@
import type { Big_bang, xbang } from './bang'
import { RectOptimizeMachine } from './RectOptimizeMachine'
// import {Worker} from "worker_threads"
import { Worker as NodeWorker } from 'worker_threads';
const ctx: NodeWorker | Worker = self as any
debugger
if (typeof window !== 'undefined' && 'Worker' in window) {
ctx.addEventListener('message', async (event) => {
let m = new RectOptimizeMachine()
m.CallBack = async (best, fit, arg, info) => {
ctx.postMessage([best, fit, arg, info])
}
if (event.data.type == 'start') {
/**
* blockList 小板列表
* boardList 大板(N个元素前N-1个元素表示余料板且余料板须为矩形第N个元素表示大板)
* boardCount 余料板数量(bigBang中前N-1个元素对应的数量如果bigBang中只有一个元素即只有大板没有余料板则为空数组)
* optimizeTimes 新优化次数
* isDoubleFaceBlockFirst 双面加工的小板是否优先排入
* gap 排版缝隙 = 开料刀直径 + 缝隙
* gzpb 规则排版
* isDoubleFaceBlockInRemain 余料板是否排入双面加工的小板
*/
let [blockList, boardList, boardCount, optimizeTimes, isDoubleFaceBlockFirst, gap, gzpb, isDoubleFaceBlockInRemain] = (event.data.data) as [xbang[], Big_bang[], number[], number, boolean, number, boolean, boolean]
m.Start(blockList, boardList, boardCount, optimizeTimes, isDoubleFaceBlockFirst, gap, gzpb, isDoubleFaceBlockInRemain)
} else {
const info = {
type: 'isStop',
}
await m.Stop(info)
ctx.postMessage([[], null, null, info])
ctx?.terminate()
}
})
} else {
}
export default {} as typeof Worker & (new () => Worker)