|
|
|
@ -174,6 +174,10 @@ export namespace Production
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SPLITBUL = Math.tan(Math.PI / 8);
|
|
|
|
|
function GetSpliteCount(allAngle: number)
|
|
|
|
|
{
|
|
|
|
|
return Math.ceil(Math.abs(allAngle) / Math.PI * 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 打断多段线超过1/4圆的圆弧*/
|
|
|
|
|
export function SplitePolylineAtArc(cu: Polyline): { pts: Vector2[], buls: number[]; }
|
|
|
|
@ -192,7 +196,7 @@ export namespace Production
|
|
|
|
|
if (Math.abs(bul) > SPLITBUL + 1e-8)
|
|
|
|
|
{
|
|
|
|
|
let allAngle = Math.atan(bul) * 4;
|
|
|
|
|
let splitCount = Math.floor(Math.abs(allAngle) / (Math.PI / 2)) + 1;
|
|
|
|
|
let splitCount = GetSpliteCount(allAngle);
|
|
|
|
|
let arc = cu.GetCurveAtIndex(i) as Arc;
|
|
|
|
|
let paramDiv = 1 / splitCount;
|
|
|
|
|
let newBul = Math.tan((allAngle / splitCount) / 4);
|
|
|
|
@ -243,15 +247,22 @@ export namespace Production
|
|
|
|
|
}
|
|
|
|
|
else if (cu instanceof Arc)
|
|
|
|
|
{
|
|
|
|
|
let allAngle = cu.AllAngle;
|
|
|
|
|
let splitCount = GetSpliteCount(cu.AllAngle);
|
|
|
|
|
let len = 2 * Math.PI * cu.Radius / 4;
|
|
|
|
|
let splitCount = Math.ceil(allAngle / Math.PI * 2);
|
|
|
|
|
for (let i = 0; i < splitCount; i++)
|
|
|
|
|
{
|
|
|
|
|
let arcLen = i !== splitCount - 1 ? len : cu.Length - (splitCount - 1) * len;
|
|
|
|
|
sealData.push(Object.assign({}, data, { length: arcLen }));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (cu instanceof Circle)
|
|
|
|
|
{
|
|
|
|
|
let length = 2 * Math.PI * cu.Radius / 4;
|
|
|
|
|
sealData.push(...Array.from({ length: 4 }, () =>
|
|
|
|
|
{
|
|
|
|
|
return { ...data, length };
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|