Files
cut-abstractions/tests/dev1/dataHandle/common/BlockSealEdge.ts

67 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-07-22 18:22:31 +08:00
import { Arc2d,Point2d } from "./base/CAD"
import type { PlaceMaterial } from "../confClass"
export function getMaterialSealEdge(pm: PlaceMaterial)
{
let ext = 30 // 每条边 浪费的长度
let fbs = []
for (let block of pm.blockList)
{
if (!block.isUnRegular)
{
pushLength(block.sealLeft, block.length)
pushLength(block.sealRight, block.length)
pushLength(block.sealBottom, block.width)
pushLength(block.sealTop, block.width)
}
else
{
for (let i = 0; i < block.orgPoints.length; i++)
{
let p1 = block.orgPoints[i]
if (Math.abs(p1.sealSize) < 0.001)
continue
let j = i + 1
if (j == block.orgPoints.length)
j = 0
let p2 = block.orgPoints[j]
let len = 0
if (p1.curve == 0)
{
len = Math.sqrt((p1.pointX - p2.pointX) * (p1.pointX - p2.pointX) + (p1.pointY - p2.pointY) * (p1.pointY - p2.pointY))
}
else
{
let arc = new Arc2d(new Point2d(p1.pointX, p1.pointY), new Point2d(p2.pointX, p2.pointY), p1.curve)
len = Math.abs(arc.m_Radius * arc.m_AllAngle)
}
pushLength(p1.sealSize, len)
}
}
}
let rlfbs = []
// 转换成米
for (let key in fbs)
{
let rt = fbs[key]
rt.l = Math.ceil(rt.l / 100) / 10
rlfbs.push(rt)
}
return rlfbs
function pushLength(fb: number, len: number)
{
if (Math.abs(fb) < 0.001)
return//
let str = fb.toFixed(2)
let sul = fbs[str]
if (sul == null)
{
sul = { t: fb, l: 0 }
fbs[str] = sul
}
sul.l += len + ext
}
}