132 lines
5.0 KiB
TypeScript
132 lines
5.0 KiB
TypeScript
import { FaceType, PlaceBlock, PlaceBlockDetail, PlaceBorderContour, PlaceMaterial, PlaceStyle, SizeExpand } from "../confClass"
|
|
import { Arc2d, Curve2d, Line2d } from "./common/base/CAD"
|
|
import { PolylineHelper } from "./common/LayoutEngine/PolylineHelper"
|
|
import { KnifeHelper } from "./knifeHelper"
|
|
|
|
/** 小板明细 相关的计算 孔 造型 以及轮廓 */
|
|
export class BlockDetailHelperBase {
|
|
|
|
/** 造型轮廓(含封边),扣除封边, 变成开料坐标 */
|
|
resetModelContour(bd: PlaceBlockDetail) {
|
|
let ox = bd.offsetX
|
|
let oy = bd.offsetY
|
|
for (let m of bd.models) {
|
|
if (m.hasContour()) {
|
|
let ptsArr = m.originModeling.outline.map(e => e.pts)
|
|
for (let pt of ptsArr) {
|
|
// 23.8.5 发现矩形的挖穿轮廓坐标是不含封边的
|
|
pt.x -= ox
|
|
pt.y -= oy
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 原始轮廓,成品轮廓
|
|
createFinalBorder(bd: PlaceBlockDetail, block: PlaceBlock): Curve2d[] {
|
|
const orgPoints = bd.orgPoints
|
|
const orgBorderCurveList = new Array<Curve2d>()
|
|
if (orgPoints && orgPoints.length > 1) // 异形
|
|
{
|
|
|
|
const count = orgPoints.length
|
|
for (let i = 0; i < count; i++) {
|
|
const p0 = orgPoints[i]
|
|
const p1 = i == count - 1 ? orgPoints[0] : orgPoints[i + 1]
|
|
const sideHoleCount = bd.holeListSide.filter(t => t.faceId == i).length
|
|
if (p0.curve == 0) // 直线
|
|
{
|
|
const newLine = Line2d.New(p0.pointX, p0.pointY, p1.pointX, p1.pointY)
|
|
newLine.tagData = p0.sealSize
|
|
newLine.tagData2 = sideHoleCount
|
|
orgBorderCurveList.push(newLine)
|
|
p0.radius = 0
|
|
}
|
|
else // 曲线
|
|
{
|
|
const crc = Arc2d.New(p0.pointX, p0.pointY, p1.pointX, p1.pointY, p0.curve)
|
|
crc.tagData = p0.sealSize
|
|
crc.tagData2 = sideHoleCount
|
|
p0.radius = crc.m_Radius
|
|
orgBorderCurveList.push(crc)
|
|
}
|
|
}
|
|
}
|
|
else // 矩形板
|
|
{
|
|
const w = block.width
|
|
const l = block.length
|
|
|
|
const line0 = Line2d.New(0, 0, w, 0)
|
|
line0.tagData = block.sealBottom
|
|
line0.tagData2 = block.holeCountBottom() || 0
|
|
|
|
const line1 = Line2d.New(w, 0, w, l)
|
|
line1.tagData = block.sealRight
|
|
line1.tagData2 = block.holeCountRight() || 0
|
|
|
|
const line2 = Line2d.New(w, l, 0, l)
|
|
line2.tagData = block.sealTop
|
|
line2.tagData2 = block.holeCountTop() || 0
|
|
|
|
const line3 = Line2d.New(0, l, 0, 0)
|
|
line3.tagData = block.sealLeft
|
|
line3.tagData2 = block.holeCountLeft() || 0
|
|
|
|
orgBorderCurveList.push(line0)
|
|
orgBorderCurveList.push(line1)
|
|
orgBorderCurveList.push(line2)
|
|
orgBorderCurveList.push(line3)
|
|
}
|
|
return orgBorderCurveList
|
|
}
|
|
/** 创建 开料轮廓不含预铣 */
|
|
createOrgBorder(bd: PlaceBlockDetail): Curve2d[] {
|
|
const borders = new Array<Curve2d>()
|
|
if (bd.points && bd.points.length > 1) // 异形
|
|
{
|
|
const count = bd.points.length
|
|
for (let i = 0; i < count - 1; i++) // 异形点(无封边,起点终点 是重复的)
|
|
{
|
|
const p0 = bd.points[i]
|
|
const p1 = i == count - 1 ? bd.points[0] : bd.points[i + 1]
|
|
const sideHoleCount = bd.holeListSide.filter(t => t.faceId == i).length
|
|
if (p0.curve == 0) // 直线
|
|
{
|
|
const newLine = Line2d.New(p0.pointX, p0.pointY, p1.pointX, p1.pointY)
|
|
newLine.tagData = p0.sealSize
|
|
newLine.tagData2 = sideHoleCount
|
|
borders.push(newLine)
|
|
p0.radius = 0
|
|
}
|
|
else // 曲线
|
|
{
|
|
const crc = Arc2d.New(p0.pointX, p0.pointY, p1.pointX, p1.pointY, p0.curve)
|
|
crc.tagData = p0.sealSize
|
|
crc.tagData2 = sideHoleCount
|
|
p0.radius = crc.m_Radius
|
|
if (p0.radius < 2) {
|
|
p0.curve = 0
|
|
p0.radius = 0
|
|
}
|
|
borders.push(crc)
|
|
}
|
|
}
|
|
}
|
|
else // 矩形板
|
|
{
|
|
const w = bd.cutWidth
|
|
const l = bd.cutLength
|
|
const line0 = Line2d.New(0, 0, w, 0)
|
|
const line1 = Line2d.New(w, 0, w, l)
|
|
const line2 = Line2d.New(w, l, 0, l)
|
|
const line3 = Line2d.New(0, l, 0, 0)
|
|
|
|
borders.push(line0)
|
|
borders.push(line1)
|
|
borders.push(line2)
|
|
borders.push(line3)
|
|
}
|
|
|
|
return borders
|
|
}
|
|
}
|