diff --git a/src/Add-on/testEntity/test.ts b/src/Add-on/testEntity/test.ts index 2a67f1004..9d1c1263f 100644 --- a/src/Add-on/testEntity/test.ts +++ b/src/Add-on/testEntity/test.ts @@ -20,12 +20,11 @@ export class Test implements Command if (enRes.Status === PromptStatus.OK) { let en = enRes.SelectSet.SelectEntityList as Board[]; - let highSeals: IHighSealedItem[] = [{ size: 1 }, { size: 1 }, { size: 1 }, { size: 2 }, { size: 3 }, { size: 4 }, { size: 5 }, { size: 6 }, { size: 7 }]; for (let e of en) { // if (e.IsClockWise) e.ColorIndex = 1; - console.log(ParagraphSealinglist(highSeals, e.ContourCurve.Explode() as Curve[])); + console.log(Production.GetBoardSplitOrderData(e as Board)); } } } diff --git a/src/Production/Product.ts b/src/Production/Product.ts index 036dd809a..e5bc020e7 100644 --- a/src/Production/Product.ts +++ b/src/Production/Product.ts @@ -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 }; + })); + } } }