From 2d3c09c0b23d747d305c43ae23fb53dcf5051582 Mon Sep 17 00:00:00 2001 From: "2817212736@qq.com" <2817212736@qq.com> Date: Tue, 29 Jul 2025 17:34:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=9F=A9=E5=BD=A2=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=A4=84=E7=90=86=E5=99=A8=E5=AD=97=E6=AE=B5=E5=90=8D?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BC=98=E5=8C=96=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 10 +- pnpm-lock.yaml | 144 ---------------- src/device.ts | 248 ---------------------------- src/models/processors/rectLayout.ts | 27 +-- 4 files changed, 16 insertions(+), 413 deletions(-) delete mode 100644 src/device.ts diff --git a/package.json b/package.json index 4370f46..1122a32 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cut-abstractions", - "version": "0.1.9", + "version": "0.1.12", "description": "", "files": [ "dist/**/*" @@ -28,15 +28,7 @@ "@types/jest": "^30.0.0", "cadapi": "http://gitea.cf/MES-FE/webcad-api/archive/0.0.60.tar.gz", "jest": "^30.0.2", - "jest-worker": "^30.0.2", - "js-angusj-clipper": "^1.0.4", "rimraf": "^6.0.1", - "ts-jest": "^29.4.0", "typescript": "^5.8.3" - }, - "dependencies": { - "jest-worker": "^30.0.2", - "three": "^0.178.0", - "webworker": "^0.8.4" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9fa47cb..53f0ae8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,16 +7,6 @@ settings: importers: .: - dependencies: - jest-worker: - specifier: ^30.0.2 - version: 30.0.2 - three: - specifier: ^0.178.0 - version: 0.178.0 - webworker: - specifier: ^0.8.4 - version: 0.8.4 devDependencies: '@jest/globals': specifier: ^30.0.2 @@ -36,15 +26,9 @@ importers: jest: specifier: ^30.0.2 version: 30.0.4(@types/node@24.0.12) - js-angusj-clipper: - specifier: ^1.0.4 - version: 1.3.1 rimraf: specifier: ^6.0.1 version: 6.0.1 - ts-jest: - specifier: ^29.4.0 - version: 29.4.0(@babel/core@7.28.0)(@jest/transform@30.0.4)(@jest/types@30.0.1)(babel-jest@30.0.4(@babel/core@7.28.0))(jest-util@30.0.2)(jest@30.0.4(@types/node@24.0.12))(typescript@5.8.3) typescript: specifier: ^5.8.3 version: 5.8.3 @@ -640,9 +624,6 @@ packages: argparse@1.0.10: resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} - async@3.2.6: - resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==} - babel-jest@30.0.4: resolution: {integrity: sha512-UjG2j7sAOqsp2Xua1mS/e+ekddkSu3wpf4nZUSvXNHuVWdaOUXQ77+uyjJLDE9i0atm5x4kds8K9yb5lRsRtcA==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -686,10 +667,6 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true - bs-logger@0.2.6: - resolution: {integrity: sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==} - engines: {node: '>= 6'} - bser@2.1.1: resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==} @@ -786,11 +763,6 @@ packages: eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} - ejs@3.1.10: - resolution: {integrity: sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==} - engines: {node: '>=0.10.0'} - hasBin: true - electron-to-chromium@1.5.180: resolution: {integrity: sha512-ED+GEyEh3kYMwt2faNmgMB0b8O5qtATGgR4RmRsIp4T6p7B8vdMbIedYndnvZfsaXvSzegtpfqRMDNCjjiSduA==} @@ -838,9 +810,6 @@ packages: fb-watchman@2.0.2: resolution: {integrity: sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==} - filelist@1.0.4: - resolution: {integrity: sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==} - fill-range@7.1.1: resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} engines: {node: '>=8'} @@ -969,11 +938,6 @@ packages: resolution: {integrity: sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==} engines: {node: 20 || >=22} - jake@10.9.2: - resolution: {integrity: sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==} - engines: {node: '>=10'} - hasBin: true - jest-changed-files@30.0.2: resolution: {integrity: sha512-Ius/iRST9FKfJI+I+kpiDh8JuUlAISnRszF9ixZDIqJF17FckH5sOzKC8a0wd0+D+8em5ADRHA5V5MnfeDk2WA==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -1102,9 +1066,6 @@ packages: node-notifier: optional: true - js-angusj-clipper@1.3.1: - resolution: {integrity: sha512-/qru4QXxN/gBbQjL4WaFl296YSM8kh5XKpNuNqfZhJ4t4Hw3KeLc5ERj3XHAeLi6pBrqeh6o9PFZUpS3QThEEQ==} - js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -1139,9 +1100,6 @@ packages: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} engines: {node: '>=8'} - lodash.memoize@4.1.2: - resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==} - lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} @@ -1156,9 +1114,6 @@ packages: resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==} engines: {node: '>=10'} - make-error@1.3.6: - resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} - makeerror@1.0.12: resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==} @@ -1180,10 +1135,6 @@ packages: minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} - minimatch@5.1.6: - resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} - engines: {node: '>=10'} - minimatch@9.0.5: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} @@ -1403,9 +1354,6 @@ packages: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} - three@0.178.0: - resolution: {integrity: sha512-ybFIB0+x8mz0wnZgSGy2MO/WCO6xZhQSZnmfytSPyNpM0sBafGRVhdaj+erYh5U+RhQOAg/eXqw5uVDiM2BjhQ==} - tmpl@1.0.5: resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==} @@ -1413,33 +1361,6 @@ packages: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} - ts-jest@29.4.0: - resolution: {integrity: sha512-d423TJMnJGu80/eSgfQ5w/R+0zFJvdtTxwtF9KzFFunOpSeD+79lHJQIiAhluJoyGRbvj9NZJsl9WjCUo0ND7Q==} - engines: {node: ^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@babel/core': '>=7.0.0-beta.0 <8' - '@jest/transform': ^29.0.0 || ^30.0.0 - '@jest/types': ^29.0.0 || ^30.0.0 - babel-jest: ^29.0.0 || ^30.0.0 - esbuild: '*' - jest: ^29.0.0 || ^30.0.0 - jest-util: ^29.0.0 || ^30.0.0 - typescript: '>=4.3 <6' - peerDependenciesMeta: - '@babel/core': - optional: true - '@jest/transform': - optional: true - '@jest/types': - optional: true - babel-jest: - optional: true - esbuild: - optional: true - jest-util: - optional: true - tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} @@ -1451,10 +1372,6 @@ packages: resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} engines: {node: '>=10'} - type-fest@4.41.0: - resolution: {integrity: sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==} - engines: {node: '>=16'} - typescript@5.8.3: resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==} engines: {node: '>=14.17'} @@ -1479,10 +1396,6 @@ packages: walker@1.0.8: resolution: {integrity: sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==} - webworker@0.8.4: - resolution: {integrity: sha512-zzsVxtHf+mCn0WuYLarSWfRGmX7JiYKkKvso5FYC7rJ9G8svwGQA5a51Sjq9D2c/rKVU6U/kyBcaI7gUTVlsJg==} - engines: {node: '>=0.4.3'} - which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} @@ -2191,8 +2104,6 @@ snapshots: dependencies: sprintf-js: 1.0.3 - async@3.2.6: {} - babel-jest@30.0.4(@babel/core@7.28.0): dependencies: '@babel/core': 7.28.0 @@ -2269,10 +2180,6 @@ snapshots: node-releases: 2.0.19 update-browserslist-db: 1.1.3(browserslist@4.25.1) - bs-logger@0.2.6: - dependencies: - fast-json-stable-stringify: 2.1.0 - bser@2.1.1: dependencies: node-int64: 0.4.0 @@ -2338,10 +2245,6 @@ snapshots: eastasianwidth@0.2.0: {} - ejs@3.1.10: - dependencies: - jake: 10.9.2 - electron-to-chromium@1.5.180: {} emittery@0.13.1: {} @@ -2389,10 +2292,6 @@ snapshots: dependencies: bser: 2.1.1 - filelist@1.0.4: - dependencies: - minimatch: 5.1.6 - fill-range@7.1.1: dependencies: to-regex-range: 5.0.1 @@ -2522,13 +2421,6 @@ snapshots: dependencies: '@isaacs/cliui': 8.0.2 - jake@10.9.2: - dependencies: - async: 3.2.6 - chalk: 4.1.2 - filelist: 1.0.4 - minimatch: 3.1.2 - jest-changed-files@30.0.2: dependencies: execa: 5.1.1 @@ -2840,8 +2732,6 @@ snapshots: - supports-color - ts-node - js-angusj-clipper@1.3.1: {} - js-tokens@4.0.0: {} js-yaml@3.14.1: @@ -2865,8 +2755,6 @@ snapshots: dependencies: p-locate: 4.1.0 - lodash.memoize@4.1.2: {} - lru-cache@10.4.3: {} lru-cache@11.1.0: {} @@ -2879,8 +2767,6 @@ snapshots: dependencies: semver: 7.7.2 - make-error@1.3.6: {} - makeerror@1.0.12: dependencies: tmpl: 1.0.5 @@ -2902,10 +2788,6 @@ snapshots: dependencies: brace-expansion: 1.1.12 - minimatch@5.1.6: - dependencies: - brace-expansion: 2.0.2 - minimatch@9.0.5: dependencies: brace-expansion: 2.0.2 @@ -3088,34 +2970,12 @@ snapshots: glob: 7.2.3 minimatch: 3.1.2 - three@0.178.0: {} - tmpl@1.0.5: {} to-regex-range@5.0.1: dependencies: is-number: 7.0.0 - ts-jest@29.4.0(@babel/core@7.28.0)(@jest/transform@30.0.4)(@jest/types@30.0.1)(babel-jest@30.0.4(@babel/core@7.28.0))(jest-util@30.0.2)(jest@30.0.4(@types/node@24.0.12))(typescript@5.8.3): - dependencies: - bs-logger: 0.2.6 - ejs: 3.1.10 - fast-json-stable-stringify: 2.1.0 - jest: 30.0.4(@types/node@24.0.12) - json5: 2.2.3 - lodash.memoize: 4.1.2 - make-error: 1.3.6 - semver: 7.7.2 - type-fest: 4.41.0 - typescript: 5.8.3 - yargs-parser: 21.1.1 - optionalDependencies: - '@babel/core': 7.28.0 - '@jest/transform': 30.0.4 - '@jest/types': 30.0.1 - babel-jest: 30.0.4(@babel/core@7.28.0) - jest-util: 30.0.2 - tslib@2.8.1: optional: true @@ -3123,8 +2983,6 @@ snapshots: type-fest@0.21.3: {} - type-fest@4.41.0: {} - typescript@5.8.3: {} undici-types@7.8.0: {} @@ -3169,8 +3027,6 @@ snapshots: dependencies: makeerror: 1.0.12 - webworker@0.8.4: {} - which@2.0.2: dependencies: isexe: 2.0.0 diff --git a/src/device.ts b/src/device.ts deleted file mode 100644 index 30b7967..0000000 --- a/src/device.ts +++ /dev/null @@ -1,248 +0,0 @@ - -// 回调函数类型定义 -type ProcessCallback = ( - input: T, - next: (input: T) => R | Promise, - context?: any -) => R | Promise; - - -// 模块配置类型 -type ModuleConfig = Record; - -// 回调函数类型 -type ModuleCallback = (result: R, input?: T) => void | Promise; - -// 扩展后的功能模块接口 -export interface ProcessorModule { - // 主处理函数(可回调) - process?: ProcessCallback; - - // 直接是处理函数(无回调) - handle?: (input: T, next?: (input: T) => R | Promise, context?: Record) => R | Promise; - - // 模块名称(用于标识和排序) - moduleName?: string; - - // 模块配置 - config?: ModuleConfig; - - getConfigList?: () => ModuleConfig - // 设置配置的方法 - setConfig?: (config: ModuleConfig) => void; - - // 前置回调(在模块处理前执行) - before?: ModuleCallback; - - // 后置回调(在模块处理后执行) - after?: ModuleCallback; - - // 错误处理回调 - onError?: (error: unknown, input?: T) => void | Promise; -} - -export interface Processor { - // 注册模块 - use(module: ProcessorModule | ProcessorModule[]): this; - - // 调整模块顺序 - reorderModules(moduleNames: string[]): this; - - // 执行处理流程 - process(input: T): Promise; - - // 获取当前模块列表 - getModules(): ProcessorModule[]; - - // 新增方法:更新模块配置 - updateModuleConfig(moduleName: string, config: ModuleConfig): this; -} - -// 处理器集合接口 -export interface ProcessorCollection { - // 注册处理器 - registerProcessor(name: string, processor: Processor): this; - - // 切换当前处理器 - useProcessor(name: string): Processor; - - // 获取处理器 - getProcessor(name: string): Processor | undefined; -} - -/** 流程管理器 处理器内组件的执行流程管理器 - * - * 负责管理 组件执行顺序 和执行模块 - */ - -export class StepControllerProcessor implements Processor { - private modules: ProcessorModule[] = []; - private modulesMap = new Map>(); - - use(module: ProcessorModule | ProcessorModule[]): this { - const modules = Array.isArray(module) ? module : [module]; - - modules.forEach(m => { - if (m.moduleName) { - this.modulesMap.set(m.moduleName, m); - } - this.modules.push(m); - }); - - return this; - } - - reorderModules(moduleNames: string[]): this { - const orderedModules = moduleNames - .map(name => this.modulesMap.get(name)) - .filter(Boolean) as ProcessorModule[]; - - const remainingModules = this.modules.filter( - m => !m.moduleName || !moduleNames.includes(m.moduleName) - ); - - this.modules = [...orderedModules, ...remainingModules]; - return this; - } - - updateModuleConfig(moduleName: string, config: ModuleConfig): this { - const module = this.modulesMap.get(moduleName); - if (module && module.setConfig) { - module.setConfig(config); - } else if (module) { - module.config = { ...module.config, ...config }; - } - return this; - } - - private async executeModule( - module: ProcessorModule, - input: T, - next: (input: T) => Promise, - context: Record - ): Promise { - try { - // 执行前置回调 - if (module.before) { - await module.before(input, input); - } - - // 执行主处理逻辑(支持两种风格) - let result: R; - - if (module.process) { - // 回调风格 - const processResult = module.process(input, next, context); - result = processResult instanceof Promise ? await processResult : processResult; - } else if (module.handle) { - // 传统风格 - const handleResult = module.handle(input, next, context); - result = handleResult instanceof Promise ? await handleResult : handleResult; - } else { - // 默认直接调用 next - result = await next(input); - } - - // 执行后置回调 - if (module.after) { - await module.after(result, input); - } - - return result; - } catch (error) { - // 执行错误处理 - if (module.onError) { - await module.onError(error, input); - // 即使出错也继续流程(除非抛出) - return await next(input); - } - throw error; - } - } - async process(input: T): Promise { - if (this.modules.length === 0) { - throw new Error("No modules registered"); - } - - let currentIndex = 0; - const modules = this.modules; - const context: Record = {}; - - const executeNext = async (currentInput: T): Promise => { - const currentModule = modules[currentIndex++]; - if (!currentModule) { - return currentInput as unknown as R; - } - - // 创建 next 函数 - const next = async (nextInput: T): Promise => { - return executeNext(nextInput); - }; - - return this.executeModule(currentModule, currentInput, next, context); - }; - - return executeNext(input); - } - - // async process(input: T): Promise { - // if (this.modules.length === 0) { - // throw new Error("No modules registered"); - // } - - // let currentIndex = 0; - // const modules = this.modules; - // const context: Record = {}; // 共享上下文 - - // const executeNext = async (currentInput: T): Promise => { - // const currentModule = modules[currentIndex++]; - // if (!currentModule) { - // return currentInput as unknown as R; - // } - - // try { - // // 执行前置回调 - // if (currentModule.before) { - // await currentModule.before(currentInput, currentInput); - // } - - // // 执行主处理函数 - // const next = async (nextInput: T): Promise => { - // return executeNext(nextInput); - // }; - - // let result: R; - // const processResult = currentModule.process(currentInput, next, context); - - // if (processResult instanceof Promise) { - // result = await processResult; - // } else { - // result = processResult; - // } - - // // 执行后置回调 - // if (currentModule.after) { - // await currentModule.after(result, currentInput); - // } - - // return result; - // } catch (error) { - // // 执行错误处理 - // if (currentModule.onError) { - // await currentModule.onError(error, currentInput); - // } else { - // throw error; // 如果没有错误处理,则向上抛出 - // } - - // // 根据错误处理结果决定是否继续 - // return currentInput as unknown as R; - // } - // }; - - // return executeNext(input); - // } - - getModules(): ProcessorModule[] { - return [...this.modules]; - } -} \ No newline at end of file diff --git a/src/models/processors/rectLayout.ts b/src/models/processors/rectLayout.ts index 084d6b3..4480ddd 100644 --- a/src/models/processors/rectLayout.ts +++ b/src/models/processors/rectLayout.ts @@ -9,11 +9,11 @@ import { ConfigBase } from "../config"; export interface RectLayoutProcInput { /** 小板列表 */ - blocks: LayoutBlock[]; + blocks: RectLayoutBlock[]; /** 余料大板列表,可选,余料大板将会被优先优化,当余料大板被用尽时,则会使用配置中的大板尺寸进行优化 */ scrapBoards?: Array<{ /** 余料大板 */ - board: LayoutBoard, + board: RectLayoutBoard, /** 大板张数 */ count: number; }>; @@ -30,14 +30,17 @@ export class RectLayoutProcConfig extends ConfigBase { doubleSidedFirst: boolean = false; /** 刀路间隙 */ gap: number = 0; - /** 运行标识 */ + /** 运行标识 (其实改成方法更合适*/ _runFlag: 'running' | 'stopped' | 'terminated' = 'running'; + /** 当出现优化结果时,进行回调 */ + _onMessage?: (e: LayoutResult) => void; } -export type RectLayoutProcOutput = LayoutResult; -/** 优化小板输入 */ -export interface LayoutBlock { +export type RectLayoutProcOutput = never; + +/** 矩形优化小板输入 */ +export interface RectLayoutBlock { /** 小板ID */ id: number; /** 长 */ @@ -56,8 +59,8 @@ export interface LayoutBlock { isdtwosided?: boolean; } -/** 优化大板输入 */ -export interface LayoutBoard { +/** 矩形优化大板输入 */ +export interface RectLayoutBoard { length: number; width: number; } @@ -95,10 +98,10 @@ export enum HoleType { /** 布局大板 */ export interface LayoutResultBoard { id: string; + /** 大板高度 */ + boardLength: number; /** 大板宽度 */ boardWidth: number; - /** 大板高度 */ - boardHeight: number; } /** 布局小板 */ @@ -108,10 +111,10 @@ export interface LayoutResultBlock { x: number; /** y坐标 */ y: number; + /** 高度 */ + length: number; /** 宽度 */ width: number; - /** 高度 */ - height: number; /** 纹路类型 */ waveType: WaveType; }