Files
cut-abstractions/src/models/processors/rectLayout.ts

127 lines
3.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file 矩形板件布局优化处理器使用的数据模型,包含优化输入、输出、大板、小板以及各类枚举
* @todo 目前仅适配了矩形优化,后续还需要对数据结构进行扩展
* @since 0.1.8
* @author CZY
*/
import { ConfigBase } from "../config";
export interface RectLayoutProcInput {
/** 小板列表 */
blocks: LayoutBlock[];
/** 余料大板列表,可选,余料大板将会被优先优化,当余料大板被用尽时,则会使用配置中的大板尺寸进行优化 */
scrapBoards?: Array<{
/** 余料大板 */
board: LayoutBoard,
/** 大板张数 */
count: number;
}>;
}
export class RectLayoutProcConfig extends ConfigBase {
/** 大板高度 */
boardHeight: number = 1220;
/** 大板宽度 */
boardWidth: number = 2440;
/** 优化迭代次数 */
iterations: number = 50;
/** 双面加工优先排版 */
doubleSidedFirst: boolean = false;
/** 刀路间隙 */
gap: number = 0;
/** 运行标识 */
_runFlag: 'running' | 'stopped' | 'terminated' = 'running';
}
export type RectLayoutProcOutput = LayoutResult;
/** 优化小板输入 */
export interface LayoutBlock {
/** 小板ID */
id: number;
/** 长 */
length: number;
/** 宽 */
width: number;
/** 纹路类型 */
waveType: WaveType;
/** 排版面类型 */
composingType: ComposingType;
/** 孔洞类型 */
holeType: HoleType;
/** 是否为矩形板 */
isRect?: boolean;
/** 是否需要双面加工 */
isdtwosided?: boolean;
}
/** 优化大板输入 */
export interface LayoutBoard {
length: number;
width: number;
}
/** 纹路类型 */
export enum WaveType {
/** 正纹 */
Positive = 0,
/** 反纹 */
Reverse = 1,
/** 可翻转 */
CanReversal = 2,
}
/** 排版面 */
export enum ComposingType {
/** 正面 */
Positive = 0,
Reverse = 1, //反面
Arbitrary = 2 //任意
}
/** 孔类型 */
export enum HoleType {
/** 没有孔 */
None = 0,
/** 正面 */
Positive = 1,
/** 反面 */
Reverse = 2,
/** 正反皆有 */
Two = 3
}
/** 布局大板 */
export interface LayoutResultBoard {
id: string;
/** 大板宽度 */
boardWidth: number;
/** 大板高度 */
boardHeight: number;
}
/** 布局小板 */
export interface LayoutResultBlock {
id: string;
/** x坐标 */
x: number;
/** y坐标 */
y: number;
/** 宽度 */
width: number;
/** 高度 */
height: number;
/** 纹路类型 */
waveType: WaveType;
}
/** 优化布局结果 */
export type LayoutResult = {
/** 大板列表 */
boards: LayoutResultBoard[],
/** 小板列表其一维与boards长度对应二维为小板列表 */
blocks: LayoutResultBlock[][],
/** 优化中被使用的余料大板,这个列表中的每一个元素代表使用了一片该规格的大板 */
usedScrapBoard: LayoutResultBoard[];
};