640 lines
26 KiB
TypeScript
640 lines
26 KiB
TypeScript
|
import { Processor, ProcessorModule } from "../../src/device";
|
|||
|
|
|||
|
import { ErrorInfo } from "../../src/device";
|
|||
|
import { BoardPosition, PlaceBlock, PlaceBoard, PlaceMaterial, PlaceStyle } from "../confClass";
|
|||
|
import { ArrayExt } from "../handleAbility/common/ArrayExt";
|
|||
|
|
|||
|
/** 模块 检查是否 板材尺寸大于机台尺寸
|
|||
|
*
|
|||
|
* input 入参
|
|||
|
|
|||
|
*/
|
|||
|
class Point {
|
|||
|
/** 坐标x */
|
|||
|
x: number
|
|||
|
/** 坐标y */
|
|||
|
y: number
|
|||
|
|
|||
|
constructor(x: number, y: number) {
|
|||
|
this.x = x
|
|||
|
this.y = y
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/** 检查是否 板材尺寸大于机台尺寸 */
|
|||
|
export const handlePlaceResultToPlaceMaterial: ProcessorModule<any, any> = {
|
|||
|
moduleName: "handlePlaceResultToPlaceMaterial",
|
|||
|
moduleVersion: '20250714',
|
|||
|
config: {
|
|||
|
boardWidth: 0,
|
|||
|
boardLength: 0,
|
|||
|
placeStyle: 1,
|
|||
|
},
|
|||
|
setConfig(config) {
|
|||
|
this.config = { ...this.config, ...config };
|
|||
|
},
|
|||
|
|
|||
|
// 会在处理器自动执行
|
|||
|
/**
|
|||
|
*
|
|||
|
* @param input 输入数据
|
|||
|
* @param next 下一个流程的函数
|
|||
|
* @param context 上下文
|
|||
|
* @returns
|
|||
|
*/
|
|||
|
|
|||
|
process(input, next, context) {
|
|||
|
// const { placeResult,pm } = input
|
|||
|
|
|||
|
let pm: PlaceMaterial = context.MaterialPlaceResult.pm
|
|||
|
pm.tempBestPlaceResult = context.MaterialPlaceResult.placeResult
|
|||
|
// 没发现优化结果
|
|||
|
if (!pm.tempBestPlaceResult) {
|
|||
|
let errInfo: ErrorInfo = {
|
|||
|
moduleName: this.moduleName,
|
|||
|
info: '没有优化数据'
|
|||
|
}
|
|||
|
return errInfo
|
|||
|
}
|
|||
|
|
|||
|
let placeResult = pm.tempBestPlaceResult
|
|||
|
|
|||
|
let orgBoardList = pm.boardList
|
|||
|
|
|||
|
let dic: any = [] // 存放当前 优化的小板
|
|||
|
|
|||
|
pm.boardList = []
|
|||
|
let boardId = 1
|
|||
|
// 第一次 false
|
|||
|
if (pm.tempPlaceResultOnyUnlockedBoard) {
|
|||
|
for (let pb of orgBoardList) {
|
|||
|
if (pb.isLocked == false && pb.cutedType == 0) // 未锁定
|
|||
|
{
|
|||
|
pb.blockList.forEach(i => dic[i.blockNo] = i)
|
|||
|
}
|
|||
|
else // 锁定
|
|||
|
{
|
|||
|
if (pb.isAdnormal) {
|
|||
|
let sb = pm.remainBoardList.find(t => t.id == Number(pb.boardNo))
|
|||
|
if (sb)
|
|||
|
sb.isUsed = true
|
|||
|
}
|
|||
|
pb.boardId = boardId
|
|||
|
pm.boardList.push(pb)
|
|||
|
boardId++
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else {
|
|||
|
pm.blockList.forEach(i => dic[i.blockNo] = i)
|
|||
|
}
|
|||
|
|
|||
|
// 0904 修复 需求改造后 导致 这里的dic 最终为空
|
|||
|
if (Object.keys(dic).length == 0) {
|
|||
|
pm.blockList.forEach(i => dic[i.blockNo] = i)
|
|||
|
}
|
|||
|
|
|||
|
let locator = this.boardLocation
|
|||
|
// 大板优化结果
|
|||
|
|
|||
|
for (let bpr of placeResult.boards) {
|
|||
|
boardId++
|
|||
|
// bpr.isRemainBoard false
|
|||
|
let bW = bpr.isRemainBoard ? bpr.width : pm.width
|
|||
|
let bL = bpr.isRemainBoard ? bpr.length : pm.length
|
|||
|
let pb = new PlaceBoard(boardId, bW, bL, bpr.remainId, bpr.remainNo)
|
|||
|
pb.isCreateRemainSpace = true
|
|||
|
|
|||
|
for (let bInfo of bpr.blocks) {
|
|||
|
let block: PlaceBlock = dic[bInfo.blockId]
|
|||
|
|
|||
|
if (block) {
|
|||
|
block.isPlaced = true
|
|||
|
block.boardId = boardId
|
|||
|
block.placeId = bInfo.placeId
|
|||
|
block.placeX = bInfo.placeX
|
|||
|
block.placeY = bInfo.placeY
|
|||
|
// console.log('重置 开料面 开料信息 after', block.boardId, block.blockNo, block, block.placeStyle, bInfo.placeStyle)
|
|||
|
|
|||
|
/**
|
|||
|
* 雕刻机(钻孔、拉槽、开料)优化排版,开料排版面(开料正面)选择顺序:排版面>>造型>>排钻>>设计正面
|
|||
|
1. 排版面
|
|||
|
小板设计排版面为正面或反面,设置对应面为开料排版面,
|
|||
|
小板设计排版面为随意面,则继续;
|
|||
|
2. 造型
|
|||
|
小板只有单面造型,设置对应面为开料排版面,
|
|||
|
小板双面无造型或双面有造型,则继续;
|
|||
|
3. 排钻
|
|||
|
小板有大孔(偏心轮锁孔),设置对应面为开料排版面,
|
|||
|
小板无大孔(偏心轮锁孔),则设置孔多的面为开料排版面,
|
|||
|
小板无孔,则继续;
|
|||
|
4. 设计正面
|
|||
|
默认设置设计正面为开料排版面。
|
|||
|
*/
|
|||
|
|
|||
|
block.placeStyle = bInfo.placeStyle
|
|||
|
|
|||
|
let posOff = this.getOffDis(block)
|
|||
|
|
|||
|
block.placeOffX = posOff.x
|
|||
|
block.placeOffY = posOff.y
|
|||
|
block.placeX = bInfo.placeX + posOff.x
|
|||
|
block.placeY = bInfo.placeY + posOff.y
|
|||
|
|
|||
|
if (bInfo.placeStyle == PlaceStyle.FRONT || bInfo.placeStyle == PlaceStyle.FRONT_TURN_BACK
|
|||
|
|| bInfo.placeStyle == PlaceStyle.BACK || bInfo.placeStyle == PlaceStyle.BACK_TURN_BACK) {
|
|||
|
block.placeWidth = block.cutWidth
|
|||
|
block.placeLength = block.cutLength
|
|||
|
}
|
|||
|
else {
|
|||
|
block.placeWidth = block.cutLength
|
|||
|
block.placeLength = block.cutWidth
|
|||
|
}
|
|||
|
|
|||
|
block.isAutoPlaced = true
|
|||
|
block.isOverlap = false
|
|||
|
block.cutOrder = 0
|
|||
|
pb.blockList.push(block)
|
|||
|
pb.blockCount++
|
|||
|
pb.blockArea += block.area
|
|||
|
delete dic[bInfo.blockId] // 移除block;
|
|||
|
} else {
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
if (bpr.isScrap) {
|
|||
|
// 设置前余料板的使用状态,将不需要的释放.
|
|||
|
console.log('设置前余料板的使用状态,将不需要的释放.')
|
|||
|
let sb = pm.remainBoardList.find(t => t.id == bpr.remainId)
|
|||
|
if (sb) {
|
|||
|
sb.isUsed = true
|
|||
|
|
|||
|
if (sb.placeStyle % 2 != 0) {
|
|||
|
pb.width = sb.length
|
|||
|
pb.length = sb.width
|
|||
|
}
|
|||
|
let pl = sb.placePolyline
|
|||
|
pb.points = sb?.placePolyline?.LineData.map((t) => { return { x: t.pt.x, y: t.pt.y, bul: t.bul } }) || []
|
|||
|
// pb.StoreNo = sb.StoreHouse;
|
|||
|
}
|
|||
|
}
|
|||
|
pb.usageRate = Math.round(10000 * pb.blockArea / pb.area) / 100
|
|||
|
pm.boardList.push(pb)
|
|||
|
console.log('大板靠板翻转', pb.boardId, locator)
|
|||
|
|
|||
|
// 大板靠板翻转
|
|||
|
this.turnPlacePosition(pb, locator)
|
|||
|
for (let block of pb.blockList) {
|
|||
|
// 重置 开料面 开料信息
|
|||
|
// console.log('重置 开料面 开料信息', block.boardId, block.blockNo, block, block.placeStyle)
|
|||
|
if (block.placeStyle == null || block.placeStyle == undefined) {
|
|||
|
console.log('handleTempPlaceResultToPlaceMaterial error !block.placeStyle is null or undefined')
|
|||
|
} else {
|
|||
|
this.resetPlaceStyle(block, block.placeStyle)
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//【功能】 大板长边两侧 width 范围内 避免出现造型 DisPoseModelInBoardBorderWidth > 0 生效
|
|||
|
// this.DisPoseModelInBoardBorder(
|
|||
|
// pm,
|
|||
|
// this.boardBorderModelRange,
|
|||
|
// this.boardBorderModelModeToFace,
|
|||
|
// this.boardBorderModelByMachine,
|
|||
|
// this.modelNearBoardBorder,
|
|||
|
// )
|
|||
|
|
|||
|
// for (let pb of pm.boardList) {
|
|||
|
// // 重设大板汇总 重设 大板开料 顺序,下刀点
|
|||
|
// this.resetPlaceBoard(pm, pb)
|
|||
|
// // 检查干涉
|
|||
|
// if (pb.isLocked == false && pb.cutedType == 0)
|
|||
|
// this.checkOverlapInBoard(pm, pb)
|
|||
|
// }
|
|||
|
|
|||
|
let rBoardCount = placeResult.boardCount
|
|||
|
let rUseSize_avg = placeResult.avgUsageRateAll
|
|||
|
let rUseSize_noLast = placeResult.avgUsageRateExcludeLastBoard
|
|||
|
let rUseSize_last = placeResult.usageRateLastBoard
|
|||
|
|
|||
|
pm.avgUsageRateAll = rUseSize_avg
|
|||
|
pm.avgUsageRateExcludeLastBoard = rUseSize_noLast
|
|||
|
pm.usageRateLastBoard = rUseSize_last
|
|||
|
pm.boardCount = pm.boardList.length
|
|||
|
pm.remainBoardCount = placeResult.remainBoardCount
|
|||
|
pm.minBoardId = 1
|
|||
|
pm.maxBoardId = pm.boardCount
|
|||
|
//【功能】 获取封边长度
|
|||
|
// pm.edgeSealLengthList = this.getMaterialSealEdge(pm.blockList)
|
|||
|
|
|||
|
pm.boardCountFlipFace = ArrayExt.count(pm.boardList, t => t.isTwoFaceProcessing)
|
|||
|
|
|||
|
pm.isOptimized = true
|
|||
|
pm.tempBestPlaceResult = null
|
|||
|
pm.tempPlaceResultError = ''
|
|||
|
|
|||
|
let mesg = ''
|
|||
|
let c = 0
|
|||
|
for (let v in dic) {
|
|||
|
mesg += `${v} `
|
|||
|
c++
|
|||
|
}
|
|||
|
|
|||
|
mesg = `有${c}片小板未能排入大板,有可能是尖角导致优化失败.${mesg}`
|
|||
|
|
|||
|
if (c > 0) {
|
|||
|
console.log(pm)
|
|||
|
// createMessage.error(mesg)
|
|||
|
|
|||
|
throw new Error(mesg)
|
|||
|
}
|
|||
|
|
|||
|
// return pm
|
|||
|
let res = { module:this.moduleName, pm }
|
|||
|
Reflect.set(context,this.moduleName,res)
|
|||
|
|
|||
|
return next ? next(input) : input;
|
|||
|
},
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
onError(error) {
|
|||
|
|
|||
|
console.error('出错了哦', error);
|
|||
|
|
|||
|
},
|
|||
|
/** 获得板件偏移值 */
|
|||
|
getOffDis(block: PlaceBlock, placeStyle?: PlaceStyle): any {
|
|||
|
// console.log('获得板件偏移值')
|
|||
|
if (placeStyle == null || placeStyle == undefined) {
|
|||
|
placeStyle = block.placeStyle
|
|||
|
}
|
|||
|
|
|||
|
let expandSize: any = block.sizeExpand
|
|||
|
let posOff = { x: 0, y: 0, left: 0, right: 0, top: 0, bottom: 0 }
|
|||
|
if (expandSize) {
|
|||
|
switch (placeStyle) {
|
|||
|
case PlaceStyle.FRONT: // 正面
|
|||
|
posOff.x = expandSize.left
|
|||
|
posOff.y = expandSize.bottom
|
|||
|
posOff.left = expandSize.left
|
|||
|
posOff.right = expandSize.right
|
|||
|
posOff.bottom = expandSize.bottom
|
|||
|
posOff.top = expandSize.top
|
|||
|
break
|
|||
|
case PlaceStyle.FRONT_TURN_RIGHT: // 正面右转
|
|||
|
posOff.x = expandSize.bottom
|
|||
|
posOff.y = expandSize.right
|
|||
|
posOff.left = expandSize.bottom
|
|||
|
posOff.right = expandSize.top
|
|||
|
posOff.bottom = expandSize.right
|
|||
|
posOff.top = expandSize.left
|
|||
|
break
|
|||
|
case PlaceStyle.FRONT_TURN_BACK: // 正面后转
|
|||
|
posOff.x = expandSize.right
|
|||
|
posOff.y = expandSize.top
|
|||
|
posOff.left = expandSize.right
|
|||
|
posOff.right = expandSize.left
|
|||
|
posOff.bottom = expandSize.top
|
|||
|
posOff.top = expandSize.bottom
|
|||
|
break
|
|||
|
case PlaceStyle.FRONT_TURN_LEFT: // 正面左转
|
|||
|
posOff.x = expandSize.top
|
|||
|
posOff.y = expandSize.left
|
|||
|
posOff.left = expandSize.top
|
|||
|
posOff.right = expandSize.bottom
|
|||
|
posOff.bottom = expandSize.left
|
|||
|
posOff.top = expandSize.right
|
|||
|
break
|
|||
|
case PlaceStyle.BACK: // 反面
|
|||
|
posOff.x = expandSize.right
|
|||
|
posOff.y = expandSize.bottom
|
|||
|
posOff.left = expandSize.right
|
|||
|
posOff.right = expandSize.left
|
|||
|
posOff.bottom = expandSize.bottom
|
|||
|
posOff.top = expandSize.top
|
|||
|
break
|
|||
|
case PlaceStyle.BACK_TURN_RIGHT: // 反面右转
|
|||
|
posOff.x = expandSize.bottom
|
|||
|
posOff.y = expandSize.left
|
|||
|
posOff.left = expandSize.bottom
|
|||
|
posOff.right = expandSize.top
|
|||
|
posOff.bottom = expandSize.left
|
|||
|
posOff.top = expandSize.right
|
|||
|
break
|
|||
|
case PlaceStyle.BACK_TURN_BACK: // 反面后转
|
|||
|
posOff.x = expandSize.left
|
|||
|
posOff.y = expandSize.top
|
|||
|
posOff.left = expandSize.left
|
|||
|
posOff.right = expandSize.right
|
|||
|
posOff.bottom = expandSize.top
|
|||
|
posOff.top = expandSize.bottom
|
|||
|
break
|
|||
|
case PlaceStyle.BACK_TURN_LEFT: // 反面左转
|
|||
|
posOff.x = expandSize.top
|
|||
|
posOff.y = expandSize.right
|
|||
|
posOff.left = expandSize.bottom
|
|||
|
posOff.right = expandSize.bottom
|
|||
|
posOff.bottom = expandSize.right
|
|||
|
posOff.top = expandSize.left
|
|||
|
break
|
|||
|
default:
|
|||
|
break
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return posOff
|
|||
|
},
|
|||
|
/**翻转 */
|
|||
|
turnPlacePosition(pb: PlaceBoard, newlocator: BoardPosition) {
|
|||
|
if (this.placeOriginByBoardLocation == false)
|
|||
|
return
|
|||
|
if (pb.isAdnormal())
|
|||
|
return // 余料板是余料板,不参与翻转
|
|||
|
let width = pb.width
|
|||
|
let length = pb.length
|
|||
|
// RIGHT_BOTTOM, 靠板
|
|||
|
if (newlocator == BoardPosition.RIGHT_BOTTOM) {
|
|||
|
for (let block of pb.blockList) {
|
|||
|
let x = width - block.placeX - block.placeWidth
|
|||
|
let y = block.placeY
|
|||
|
let placeStyle = this.getPlaceStyle_zy(block)
|
|||
|
block.placeX = x
|
|||
|
block.placeY = y
|
|||
|
block.placeStyle = placeStyle
|
|||
|
}
|
|||
|
}
|
|||
|
// RIGHT_TOP, 靠板
|
|||
|
if (newlocator == BoardPosition.RIGHT_TOP) {
|
|||
|
console.log('BoardPosition=BoardPosition.RIGHT_TOP')
|
|||
|
for (let block of pb.blockList) {
|
|||
|
let x = width - block.placeX - block.placeWidth
|
|||
|
let y = length - block.placeLength - block.placeY
|
|||
|
let placeStyle = this.getPlaceStyle_dj(block)
|
|||
|
block.placeX = x
|
|||
|
block.placeY = y
|
|||
|
block.placeStyle = placeStyle
|
|||
|
}
|
|||
|
}
|
|||
|
// 左上角, 靠板
|
|||
|
if (newlocator == BoardPosition.LEFT_TOP) {
|
|||
|
console.log('BoardPosition=BoardPosition.左上角')
|
|||
|
for (let block of pb.blockList) {
|
|||
|
let x = block.placeX
|
|||
|
let y = length - block.placeLength - block.placeY
|
|||
|
let placeStyle = this.getPlaceStyle_sx(block)
|
|||
|
block.placeX = x
|
|||
|
block.placeY = y
|
|||
|
block.placeStyle = placeStyle
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
/** 板放置后,重置placeWidth, placeLength, 封边, 正反面, 面孔, 造型等 */
|
|||
|
resetPlaceStyle(_block: PlaceBlock, newStyle: PlaceStyle) {
|
|||
|
let block = new PlaceBlock(_block)
|
|||
|
block = { ..._block }
|
|||
|
// console.debug('resetPlaceStyle test!!!',newStyle)
|
|||
|
block.placeStyle = newStyle
|
|||
|
|
|||
|
// tryFix
|
|||
|
let _width = block.cutWidth
|
|||
|
let _lenth = block.cutLength
|
|||
|
if (block.width > block.length) {
|
|||
|
block.cutWidth = Math.max(_width, _lenth)
|
|||
|
block.cutLength = Math.min(_width, _lenth)
|
|||
|
} else {
|
|||
|
block.cutWidth = Math.min(_width, _lenth)
|
|||
|
block.cutLength = Math.max(_width, _lenth)
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
switch (newStyle) {
|
|||
|
case PlaceStyle.FRONT: // 正面
|
|||
|
block.placeWidth = block.cutWidth
|
|||
|
block.placeLength = block.cutLength
|
|||
|
block.placeSealLeft = block.sealLeft
|
|||
|
block.placeSealRight = block.sealRight
|
|||
|
block.placeSealTop = block.sealTop
|
|||
|
block.placeSealBottom = block.sealBottom
|
|||
|
block.holeCountSideLeft = block?.blockDetail?.holeCountLeft || 0
|
|||
|
block.holeCountSideRight = block?.blockDetail?.holeCountRight || 0
|
|||
|
block.holeCountSideTop = block?.blockDetail?.holeCountTop || 0
|
|||
|
block.holeCountSideBottom = block?.blockDetail?.holeCountBottom || 0
|
|||
|
block.placeDirection = '→'
|
|||
|
block.placeDirection_Length = block.length > block.width - 0.001 ? '→' : '↓'
|
|||
|
break
|
|||
|
case PlaceStyle.FRONT_TURN_RIGHT: // 正面右转
|
|||
|
block.placeWidth = block.cutLength
|
|||
|
block.placeLength = block.cutWidth
|
|||
|
block.placeSealLeft = block.sealBottom
|
|||
|
block.placeSealRight = block.sealTop
|
|||
|
block.placeSealTop = block.sealLeft
|
|||
|
block.placeSealBottom = block.sealRight
|
|||
|
block.holeCountSideLeft = block?.blockDetail?.holeCountBottom || 0
|
|||
|
block.holeCountSideRight = block?.blockDetail?.holeCountTop || 0
|
|||
|
block.holeCountSideTop = block?.blockDetail?.holeCountLeft || 0
|
|||
|
block.holeCountSideBottom = block?.blockDetail?.holeCountRight || 0
|
|||
|
block.placeDirection = '↓'
|
|||
|
block.placeDirection_Length = block.length > block.width - 0.001 ? '↓' : '←'
|
|||
|
break
|
|||
|
case PlaceStyle.FRONT_TURN_BACK: // 正面后转
|
|||
|
block.placeWidth = block.cutWidth
|
|||
|
block.placeLength = block.cutLength
|
|||
|
block.placeSealLeft = block.sealRight
|
|||
|
block.placeSealRight = block.sealLeft
|
|||
|
block.placeSealTop = block.sealBottom
|
|||
|
block.placeSealBottom = block.sealTop
|
|||
|
block.holeCountSideLeft = block?.blockDetail?.holeCountRight || 0
|
|||
|
block.holeCountSideRight = block?.blockDetail?.holeCountLeft || 0
|
|||
|
block.holeCountSideTop = block?.blockDetail?.holeCountBottom || 0
|
|||
|
block.holeCountSideBottom = block?.blockDetail?.holeCountTop || 0
|
|||
|
block.placeDirection = '←'
|
|||
|
block.placeDirection_Length = block.length > block.width - 0.001 ? '←' : '↑'
|
|||
|
break
|
|||
|
case PlaceStyle.FRONT_TURN_LEFT: // 正面左转
|
|||
|
block.placeWidth = block.cutLength
|
|||
|
block.placeLength = block.cutWidth
|
|||
|
block.placeSealLeft = block.sealTop
|
|||
|
block.placeSealRight = block.sealBottom
|
|||
|
block.placeSealTop = block.sealRight
|
|||
|
block.placeSealBottom = block.sealLeft
|
|||
|
block.holeCountSideLeft = block?.blockDetail?.holeCountTop || 0
|
|||
|
block.holeCountSideRight = block?.blockDetail?.holeCountBottom || 0
|
|||
|
block.holeCountSideTop = block?.blockDetail?.holeCountRight || 0
|
|||
|
block.holeCountSideBottom = block?.blockDetail?.holeCountLeft || 0
|
|||
|
block.placeDirection = '↑'
|
|||
|
block.placeDirection_Length = block.length > block.width - 0.001 ? '↑' : '→'
|
|||
|
break
|
|||
|
case PlaceStyle.BACK: // 反面
|
|||
|
block.placeWidth = block.cutWidth
|
|||
|
block.placeLength = block.cutLength
|
|||
|
block.placeSealLeft = block.sealRight
|
|||
|
block.placeSealRight = block.sealLeft
|
|||
|
block.placeSealTop = block.sealTop
|
|||
|
block.placeSealBottom = block.sealBottom
|
|||
|
block.holeCountSideLeft = block?.blockDetail?.holeCountRight || 0
|
|||
|
block.holeCountSideRight = block?.blockDetail?.holeCountLeft || 0
|
|||
|
block.holeCountSideTop = block?.blockDetail?.holeCountTop || 0
|
|||
|
block.holeCountSideBottom = block?.blockDetail?.holeCountBottom || 0
|
|||
|
block.placeDirection = '→'
|
|||
|
block.placeDirection_Length = block.length > block.width - 0.001 ? '→' : '↑'
|
|||
|
break
|
|||
|
case PlaceStyle.BACK_TURN_RIGHT: // 反面右转
|
|||
|
block.placeWidth = block.cutLength
|
|||
|
block.placeLength = block.cutWidth
|
|||
|
block.placeSealLeft = block.sealBottom
|
|||
|
block.placeSealRight = block.sealTop
|
|||
|
block.placeSealTop = block.sealRight
|
|||
|
block.placeSealBottom = block.sealLeft
|
|||
|
block.holeCountSideLeft = block?.blockDetail?.holeCountBottom || 0
|
|||
|
block.holeCountSideRight = block?.blockDetail?.holeCountTop || 0
|
|||
|
block.holeCountSideTop = block?.blockDetail?.holeCountRight || 0
|
|||
|
block.holeCountSideBottom = block?.blockDetail?.holeCountLeft || 0
|
|||
|
block.placeDirection = '↓'
|
|||
|
block.placeDirection_Length = block.length > block.width - 0.001 ? '↓' : '→'
|
|||
|
break
|
|||
|
case PlaceStyle.BACK_TURN_BACK: // 反面后转
|
|||
|
block.placeWidth = block.cutWidth
|
|||
|
block.placeLength = block.cutLength
|
|||
|
block.placeSealLeft = block.sealLeft
|
|||
|
block.placeSealRight = block.sealRight
|
|||
|
block.placeSealTop = block.sealTop
|
|||
|
block.placeSealBottom = block.sealBottom
|
|||
|
block.holeCountSideLeft = block?.blockDetail?.holeCountLeft || 0
|
|||
|
block.holeCountSideRight = block?.blockDetail?.holeCountRight || 0
|
|||
|
block.holeCountSideTop = block?.blockDetail?.holeCountTop || 0
|
|||
|
block.holeCountSideBottom = block?.blockDetail?.holeCountBottom || 0
|
|||
|
block.placeDirection = '←'
|
|||
|
block.placeDirection_Length = block.length > block.width - 0.001 ? '←' : '↓'
|
|||
|
break
|
|||
|
case PlaceStyle.BACK_TURN_LEFT: // 反面左转
|
|||
|
block.placeWidth = block.cutLength
|
|||
|
block.placeLength = block.cutWidth
|
|||
|
block.placeSealLeft = block.sealTop
|
|||
|
block.placeSealRight = block.sealBottom
|
|||
|
block.placeSealTop = block.sealLeft
|
|||
|
block.placeSealBottom = block.sealRight
|
|||
|
block.holeCountSideLeft = block?.blockDetail?.holeCountTop || 0
|
|||
|
block.holeCountSideRight = block?.blockDetail?.holeCountBottom || 0
|
|||
|
block.holeCountSideTop = block?.blockDetail?.holeCountLeft || 0
|
|||
|
block.holeCountSideBottom = block?.blockDetail?.holeCountRight || 0
|
|||
|
block.placeDirection = '↑'
|
|||
|
block.placeDirection_Length = block.length > block.width - 0.001 ? '↑' : '←'
|
|||
|
break
|
|||
|
default:
|
|||
|
break
|
|||
|
}
|
|||
|
this.resetDoFace_HoleModel(block)
|
|||
|
},
|
|||
|
resetDoFace_HoleModel(block: PlaceBlock) {
|
|||
|
|
|||
|
let isTurnOver = block.isTurnOver
|
|||
|
if (block.blockDetail == null) {
|
|||
|
console.error('resetDoFace_HoleModel error,with out blockDetail');
|
|||
|
return
|
|||
|
}
|
|||
|
let orgMA = block.blockDetail.modelListFaceA
|
|||
|
let orgMB = block.blockDetail.modelListFaceB
|
|||
|
let orgMT = block.blockDetail.modelListThrough
|
|||
|
let orgHA = block.blockDetail.holeListFaceA
|
|||
|
let orgHB = block.blockDetail.holeListFaceB
|
|||
|
let orgHT = block.blockDetail.holeListThrough
|
|||
|
|
|||
|
if (isTurnOver) {
|
|||
|
block.modelListFaceA = orgMB.concat(orgMT);
|
|||
|
block.modelListFaceB = orgMA;
|
|||
|
block.holeListFaceA = orgHB.concat(orgHT);
|
|||
|
block.holeListFaceB = orgHA;
|
|||
|
}
|
|||
|
else {
|
|||
|
block.modelListFaceA = orgMA.concat(orgMT);
|
|||
|
block.modelListFaceB = orgMB;
|
|||
|
block.holeListFaceA = orgHA.concat(orgHT);;
|
|||
|
block.holeListFaceB = orgHB;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//获取贴标位置
|
|||
|
let p = this.getPlaceXYInBlock(block, block.blockDetail.labelPosX, block.blockDetail.labelPosY, false, false);
|
|||
|
block.labelPosX = p.x;
|
|||
|
block.labelPosY = p.y;
|
|||
|
},
|
|||
|
getPlaceXYInBlock(block: PlaceBlock, x: number, y: number, isSealed: boolean, isFaceB = false, preCutValueOff = null): Point {
|
|||
|
let bwidth = block.cutWidth
|
|||
|
let blength = block.cutLength
|
|||
|
let x0: any = x
|
|||
|
let y0: any = y
|
|||
|
if (isSealed) // 已封边
|
|||
|
{
|
|||
|
bwidth = block.width
|
|||
|
blength = block.length
|
|||
|
x0 += block.offsetX
|
|||
|
y0 += block.offsetY
|
|||
|
}
|
|||
|
if (!isSealed && preCutValueOff) // 没封边,且有封边
|
|||
|
{
|
|||
|
bwidth += preCutValueOff.w
|
|||
|
blength += preCutValueOff.l
|
|||
|
x0 += preCutValueOff.x
|
|||
|
y0 += preCutValueOff.y
|
|||
|
}
|
|||
|
|
|||
|
let _point: any = this.getPlacedPostionInBlock(block.placeStyle, bwidth, blength, x0, y0, isFaceB)
|
|||
|
|
|||
|
return _point
|
|||
|
},
|
|||
|
/** 获得翻转后的新坐标 */
|
|||
|
getPlacedPostionInBlock(placeStyle: PlaceStyle, bwidth: number, blength: number, x0: number, y0: number, isFaceB: boolean): Point {
|
|||
|
let posX = x0
|
|||
|
let posY = y0
|
|||
|
let placeWidth = bwidth
|
|||
|
switch (placeStyle) {
|
|||
|
case PlaceStyle.FRONT:
|
|||
|
break
|
|||
|
case PlaceStyle.FRONT_TURN_RIGHT:
|
|||
|
posX = y0
|
|||
|
posY = bwidth - x0
|
|||
|
placeWidth = blength
|
|||
|
break
|
|||
|
case PlaceStyle.FRONT_TURN_BACK:
|
|||
|
posX = bwidth - x0
|
|||
|
posY = blength - y0
|
|||
|
break
|
|||
|
case PlaceStyle.FRONT_TURN_LEFT:
|
|||
|
posX = blength - y0
|
|||
|
posY = x0
|
|||
|
placeWidth = blength
|
|||
|
break
|
|||
|
case PlaceStyle.BACK:
|
|||
|
posX = bwidth - x0
|
|||
|
posY = y0
|
|||
|
break
|
|||
|
case PlaceStyle.BACK_TURN_RIGHT:
|
|||
|
posX = y0
|
|||
|
posY = x0
|
|||
|
placeWidth = blength
|
|||
|
break
|
|||
|
case PlaceStyle.BACK_TURN_BACK:
|
|||
|
posX = x0
|
|||
|
posY = blength - y0
|
|||
|
break
|
|||
|
case PlaceStyle.BACK_TURN_LEFT:
|
|||
|
posX = blength - y0
|
|||
|
posY = bwidth - x0
|
|||
|
placeWidth = blength
|
|||
|
break
|
|||
|
default:
|
|||
|
break
|
|||
|
}
|
|||
|
if (isFaceB) {
|
|||
|
posX = placeWidth - posX
|
|||
|
}
|
|||
|
return new Point(posX, posY)
|
|||
|
}
|
|||
|
}
|
|||
|
|