@lucablockltd/ultimate-packaging 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -0
- package/README.md +1 -1019
- package/dist/index.js +404 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +404 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -15
package/dist/index.mjs
CHANGED
|
@@ -2065,6 +2065,142 @@ function bottomDustFlaps3(xSide1, xFront, xSide2, xEnd, yBody2, dustFlap, dfCorn
|
|
|
2065
2065
|
dustFlapPath3(xSide2, xEnd, yBody2, 1, dustFlap, dfCorner, dfInset, dfVertical, "none", "edge")
|
|
2066
2066
|
];
|
|
2067
2067
|
}
|
|
2068
|
+
function generateOuterContour3(attr) {
|
|
2069
|
+
const { length, width, height, glueArea, dustFlap, tuckFlap } = attr;
|
|
2070
|
+
const glueTaper = glueArea * GLUE_TAPER_RATIO3;
|
|
2071
|
+
const dfInset = Math.min(dustFlap / 6, width * 0.2);
|
|
2072
|
+
const dfCorner = Math.min(dustFlap * 0.1, dfInset * 0.6);
|
|
2073
|
+
const dfVertical = Math.min(dustFlap / 6, dustFlap - dfCorner);
|
|
2074
|
+
const xRear = glueArea;
|
|
2075
|
+
const xSide1 = glueArea + length;
|
|
2076
|
+
const xFront = glueArea + length + width;
|
|
2077
|
+
const xSide2 = glueArea + length + width + length;
|
|
2078
|
+
const xEnd = glueArea + 2 * length + 2 * width;
|
|
2079
|
+
const yTop = 0;
|
|
2080
|
+
const yFold1 = tuckFlap;
|
|
2081
|
+
const yBody1 = tuckFlap + width;
|
|
2082
|
+
const yBody2 = tuckFlap + width + height;
|
|
2083
|
+
const yFold2 = tuckFlap + width + height + width;
|
|
2084
|
+
const yBot = tuckFlap + 2 * width + height + tuckFlap;
|
|
2085
|
+
const arcSteps = 8;
|
|
2086
|
+
const points = [];
|
|
2087
|
+
points.push({ x: 0, y: yBody2 - glueTaper });
|
|
2088
|
+
points.push({ x: 0, y: yBody1 + glueTaper });
|
|
2089
|
+
points.push({ x: xRear, y: yBody1 });
|
|
2090
|
+
points.push({ x: xSide1, y: yBody1 });
|
|
2091
|
+
points.push({ x: xSide1 + MT3, y: yBody1 });
|
|
2092
|
+
points.push({ x: xSide1 + MT3, y: yBody1 - dfVertical });
|
|
2093
|
+
points.push({ x: xSide1 + MT3 + dfCorner, y: yBody1 - dfVertical - dfCorner });
|
|
2094
|
+
points.push({ x: xSide1 + dfInset, y: yBody1 - dustFlap });
|
|
2095
|
+
points.push({ x: xFront - dfInset, y: yBody1 - dustFlap });
|
|
2096
|
+
points.push({ x: xFront - dfCorner, y: yBody1 - dfCorner });
|
|
2097
|
+
points.push({ x: xFront, y: yBody1 });
|
|
2098
|
+
points.push({ x: xFront, y: yFold1 });
|
|
2099
|
+
points.push({ x: xFront + MT3, y: yFold1 });
|
|
2100
|
+
for (let i = 0; i <= arcSteps; i++) {
|
|
2101
|
+
const a = Math.PI + Math.PI / 2 * (i / arcSteps);
|
|
2102
|
+
points.push({
|
|
2103
|
+
x: xFront + MT3 + ARC_R3 + ARC_R3 * Math.cos(a),
|
|
2104
|
+
y: yTop + ARC_R3 + ARC_R3 * Math.sin(a)
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2107
|
+
for (let i = 0; i <= arcSteps; i++) {
|
|
2108
|
+
const a = -Math.PI / 2 + Math.PI / 2 * (i / arcSteps);
|
|
2109
|
+
points.push({
|
|
2110
|
+
x: xSide2 - MT3 - ARC_R3 + ARC_R3 * Math.cos(a),
|
|
2111
|
+
y: yTop + ARC_R3 + ARC_R3 * Math.sin(a)
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
points.push({ x: xSide2 - MT3, y: yFold1 });
|
|
2115
|
+
points.push({ x: xSide2, y: yFold1 });
|
|
2116
|
+
points.push({ x: xSide2, y: yBody1 });
|
|
2117
|
+
points.push({ x: xSide2 + dfCorner, y: yBody1 - dfCorner });
|
|
2118
|
+
points.push({ x: xSide2 + dfInset, y: yBody1 - dustFlap });
|
|
2119
|
+
points.push({ x: xEnd - dfInset, y: yBody1 - dustFlap });
|
|
2120
|
+
points.push({ x: xEnd - dfCorner, y: yBody1 - dfVertical - dfCorner });
|
|
2121
|
+
points.push({ x: xEnd, y: yBody1 - dfVertical });
|
|
2122
|
+
points.push({ x: xEnd, y: yBody1 });
|
|
2123
|
+
points.push({ x: xEnd, y: yBody2 });
|
|
2124
|
+
points.push({ x: xEnd, y: yBody2 + dfVertical });
|
|
2125
|
+
points.push({ x: xEnd - dfCorner, y: yBody2 + dfVertical + dfCorner });
|
|
2126
|
+
points.push({ x: xEnd - dfInset, y: yBody2 + dustFlap });
|
|
2127
|
+
points.push({ x: xSide2 + dfInset, y: yBody2 + dustFlap });
|
|
2128
|
+
points.push({ x: xSide2 + dfCorner, y: yBody2 + dfCorner });
|
|
2129
|
+
points.push({ x: xSide2, y: yBody2 });
|
|
2130
|
+
points.push({ x: xSide2, y: yFold2 });
|
|
2131
|
+
points.push({ x: xSide2 - MT3, y: yFold2 });
|
|
2132
|
+
for (let i = 0; i <= arcSteps; i++) {
|
|
2133
|
+
const a = Math.PI / 2 * (i / arcSteps);
|
|
2134
|
+
points.push({
|
|
2135
|
+
x: xSide2 - MT3 - ARC_R3 + ARC_R3 * Math.cos(a),
|
|
2136
|
+
y: yBot - ARC_R3 + ARC_R3 * Math.sin(a)
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
for (let i = 0; i <= arcSteps; i++) {
|
|
2140
|
+
const a = Math.PI / 2 + Math.PI / 2 * (i / arcSteps);
|
|
2141
|
+
points.push({
|
|
2142
|
+
x: xFront + MT3 + ARC_R3 + ARC_R3 * Math.cos(a),
|
|
2143
|
+
y: yBot - ARC_R3 + ARC_R3 * Math.sin(a)
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
points.push({ x: xFront + MT3, y: yFold2 });
|
|
2147
|
+
points.push({ x: xFront, y: yFold2 });
|
|
2148
|
+
points.push({ x: xFront, y: yBody2 });
|
|
2149
|
+
points.push({ x: xFront - dfCorner, y: yBody2 + dfCorner });
|
|
2150
|
+
points.push({ x: xFront - dfInset, y: yBody2 + dustFlap });
|
|
2151
|
+
points.push({ x: xSide1 + dfInset, y: yBody2 + dustFlap });
|
|
2152
|
+
points.push({ x: xSide1 + MT3 + dfCorner, y: yBody2 + dfVertical + dfCorner });
|
|
2153
|
+
points.push({ x: xSide1 + MT3, y: yBody2 + dfVertical });
|
|
2154
|
+
points.push({ x: xSide1 + MT3, y: yBody2 });
|
|
2155
|
+
points.push({ x: xSide1, y: yBody2 });
|
|
2156
|
+
points.push({ x: xRear, y: yBody2 });
|
|
2157
|
+
return points;
|
|
2158
|
+
}
|
|
2159
|
+
function offsetContour3(points, distance) {
|
|
2160
|
+
const n = points.length;
|
|
2161
|
+
const result = [];
|
|
2162
|
+
for (let i = 0; i < n; i++) {
|
|
2163
|
+
const prev = points[(i - 1 + n) % n];
|
|
2164
|
+
const curr = points[i];
|
|
2165
|
+
const next = points[(i + 1) % n];
|
|
2166
|
+
const e1x = curr.x - prev.x;
|
|
2167
|
+
const e1y = curr.y - prev.y;
|
|
2168
|
+
const e2x = next.x - curr.x;
|
|
2169
|
+
const e2y = next.y - curr.y;
|
|
2170
|
+
const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
|
|
2171
|
+
const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
|
|
2172
|
+
if (len1 === 0 || len2 === 0) {
|
|
2173
|
+
result.push(curr);
|
|
2174
|
+
continue;
|
|
2175
|
+
}
|
|
2176
|
+
const n1x = e1y / len1;
|
|
2177
|
+
const n1y = -e1x / len1;
|
|
2178
|
+
const n2x = e2y / len2;
|
|
2179
|
+
const n2y = -e2x / len2;
|
|
2180
|
+
const ax = n1x + n2x;
|
|
2181
|
+
const ay = n1y + n2y;
|
|
2182
|
+
const aLen = Math.sqrt(ax * ax + ay * ay);
|
|
2183
|
+
if (aLen < 1e-3) {
|
|
2184
|
+
result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
|
|
2185
|
+
continue;
|
|
2186
|
+
}
|
|
2187
|
+
const nx = ax / aLen;
|
|
2188
|
+
const ny = ay / aLen;
|
|
2189
|
+
const dot = n1x * nx + n1y * ny;
|
|
2190
|
+
const d = distance / Math.max(dot, 0.1);
|
|
2191
|
+
result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
|
|
2192
|
+
}
|
|
2193
|
+
return result;
|
|
2194
|
+
}
|
|
2195
|
+
function contourToPath3(points) {
|
|
2196
|
+
if (points.length === 0) return "";
|
|
2197
|
+
let d = `M${points[0].x} ${points[0].y}`;
|
|
2198
|
+
for (let i = 1; i < points.length; i++) {
|
|
2199
|
+
d += ` L${points[i].x} ${points[i].y}`;
|
|
2200
|
+
}
|
|
2201
|
+
d += " Z";
|
|
2202
|
+
return d;
|
|
2203
|
+
}
|
|
2068
2204
|
function generateDimensions3(attr, unit) {
|
|
2069
2205
|
const { length, width, height, glueArea, dustFlap, tuckFlap } = attr;
|
|
2070
2206
|
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
@@ -2551,7 +2687,7 @@ function bottomFlaps(xRear, xSide1, xFront, xSide2, xEnd, yBody2, yBot) {
|
|
|
2551
2687
|
);
|
|
2552
2688
|
return paths;
|
|
2553
2689
|
}
|
|
2554
|
-
function
|
|
2690
|
+
function generateOuterContour4(attr) {
|
|
2555
2691
|
const { length, width, height, flapHeight, glueArea } = attr;
|
|
2556
2692
|
const glueTaper = glueArea * GLUE_TAPER_RATIO4;
|
|
2557
2693
|
const xRear = glueArea;
|
|
@@ -2602,7 +2738,7 @@ function generateOuterContour3(attr) {
|
|
|
2602
2738
|
points.push({ x: xRear, y: yBody2 });
|
|
2603
2739
|
return points;
|
|
2604
2740
|
}
|
|
2605
|
-
function
|
|
2741
|
+
function offsetContour4(points, distance) {
|
|
2606
2742
|
const n = points.length;
|
|
2607
2743
|
const result = [];
|
|
2608
2744
|
for (let i = 0; i < n; i++) {
|
|
@@ -2638,7 +2774,7 @@ function offsetContour3(points, distance) {
|
|
|
2638
2774
|
}
|
|
2639
2775
|
return result;
|
|
2640
2776
|
}
|
|
2641
|
-
function
|
|
2777
|
+
function contourToPath4(points) {
|
|
2642
2778
|
if (points.length === 0) return "";
|
|
2643
2779
|
let d = `M${points[0].x} ${points[0].y}`;
|
|
2644
2780
|
for (let i = 1; i < points.length; i++) {
|
|
@@ -3535,9 +3671,238 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
3535
3671
|
};
|
|
3536
3672
|
}
|
|
3537
3673
|
|
|
3674
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1040a/index.ts
|
|
3675
|
+
function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
|
|
3676
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
3677
|
+
return {
|
|
3678
|
+
profile: buildProfile(rotated),
|
|
3679
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
3680
|
+
deg
|
|
3681
|
+
};
|
|
3682
|
+
}
|
|
3683
|
+
function findPairRowStepY(pA, pB, gapAB, pairStepX) {
|
|
3684
|
+
const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
|
|
3685
|
+
const nMin = Math.floor(-reach / pairStepX) - 1;
|
|
3686
|
+
const nMax = Math.ceil(reach / pairStepX) + 1;
|
|
3687
|
+
let maxStep = 0;
|
|
3688
|
+
for (let n = nMin; n <= nMax; n++) {
|
|
3689
|
+
const dx = n * pairStepX;
|
|
3690
|
+
const s1 = findMinStepY(pA, pA, dx);
|
|
3691
|
+
if (s1 > maxStep) maxStep = s1;
|
|
3692
|
+
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
3693
|
+
if (s2 > maxStep) maxStep = s2;
|
|
3694
|
+
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
3695
|
+
if (s3 > maxStep) maxStep = s3;
|
|
3696
|
+
const s4 = findMinStepY(pB, pB, dx);
|
|
3697
|
+
if (s4 > maxStep) maxStep = s4;
|
|
3698
|
+
}
|
|
3699
|
+
return maxStep;
|
|
3700
|
+
}
|
|
3701
|
+
function pairGrid2(rdA, rdB, bounds) {
|
|
3702
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
3703
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
3704
|
+
if (gapAB <= 0) return emptyResult();
|
|
3705
|
+
const pairW = gapAB + pB.width;
|
|
3706
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
3707
|
+
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
3708
|
+
if (pairStepX <= 0) return emptyResult();
|
|
3709
|
+
const pairStepY = findPairRowStepY(pA, pB, gapAB, pairStepX);
|
|
3710
|
+
if (pairStepY <= 0) return emptyResult();
|
|
3711
|
+
const usableW = bounds.right - bounds.left;
|
|
3712
|
+
const usableH = bounds.bottom - bounds.top;
|
|
3713
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
3714
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
3715
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
3716
|
+
const placements = [];
|
|
3717
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
3718
|
+
for (let r = 0; r < pairRows; r++) {
|
|
3719
|
+
for (let c = 0; c < pairCols; c++) {
|
|
3720
|
+
const baseX = bounds.left + c * pairStepX;
|
|
3721
|
+
const baseY = bounds.top + r * pairStepY;
|
|
3722
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
3723
|
+
if (baseX < minX) minX = baseX;
|
|
3724
|
+
if (baseY < minY) minY = baseY;
|
|
3725
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
3726
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
3727
|
+
const bx = baseX + gapAB;
|
|
3728
|
+
placements.push({ x: bx + rdB.bbOffset.dx, y: baseY + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
3729
|
+
if (bx < minX) minX = bx;
|
|
3730
|
+
if (bx + pB.width > maxX) maxX = bx + pB.width;
|
|
3731
|
+
if (baseY + pB.height > maxY) maxY = baseY + pB.height;
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
3735
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
3736
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
3737
|
+
const pe = rdExtra.profile;
|
|
3738
|
+
if (pe.width > gapRight) continue;
|
|
3739
|
+
const dxFromB = pairsRightEdge - (bounds.left + (pairCols - 1) * pairStepX + gapAB);
|
|
3740
|
+
const dxFromA = pairsRightEdge - bounds.left - (pairCols - 1) * pairStepX;
|
|
3741
|
+
const extraStepY = Math.max(
|
|
3742
|
+
findMinStepY(pA, pe, dxFromA),
|
|
3743
|
+
findMinStepY(pB, pe, dxFromB),
|
|
3744
|
+
findMinStepY(pe, pe, 0)
|
|
3745
|
+
);
|
|
3746
|
+
if (extraStepY <= 0) continue;
|
|
3747
|
+
const effectiveStepY = Math.max(pairStepY, extraStepY);
|
|
3748
|
+
const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
|
|
3749
|
+
for (let r = 0; r < extraRows; r++) {
|
|
3750
|
+
const ox = pairsRightEdge;
|
|
3751
|
+
const oy = bounds.top + r * effectiveStepY;
|
|
3752
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
3753
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
3754
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
3755
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
break;
|
|
3759
|
+
}
|
|
3760
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
3761
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
3762
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
3763
|
+
const pe = rdExtra.profile;
|
|
3764
|
+
if (pe.height > gapBottom) continue;
|
|
3765
|
+
const extraStepX = findMinStepX(pe, pe, 0);
|
|
3766
|
+
if (extraStepX <= 0) continue;
|
|
3767
|
+
const dyFromPairRow = pairsBottomEdge - (bounds.top + (pairRows - 1) * pairStepY);
|
|
3768
|
+
const stepFromA = findMinStepY(pA, pe, 0);
|
|
3769
|
+
const stepFromB = findMinStepY(pB, pe, gapAB);
|
|
3770
|
+
if (dyFromPairRow < stepFromA || dyFromPairRow < stepFromB) continue;
|
|
3771
|
+
const extraCols = Math.max(0, Math.floor((usableW - pe.width) / extraStepX) + 1);
|
|
3772
|
+
for (let c = 0; c < extraCols; c++) {
|
|
3773
|
+
const ox = bounds.left + c * extraStepX;
|
|
3774
|
+
const oy = pairsBottomEdge;
|
|
3775
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
3776
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
3777
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
3778
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3781
|
+
break;
|
|
3782
|
+
}
|
|
3783
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3784
|
+
}
|
|
3785
|
+
function verticalPairGrid(rdA, rdB, bounds) {
|
|
3786
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
3787
|
+
const gapAB_Y = findMinStepY(pA, pB, 0);
|
|
3788
|
+
if (gapAB_Y <= 0) return emptyResult();
|
|
3789
|
+
const vpairH = gapAB_Y + pB.height;
|
|
3790
|
+
const vpairW = Math.max(pA.width, pB.width);
|
|
3791
|
+
Math.max(pA.height, pB.height) + Math.abs(gapAB_Y);
|
|
3792
|
+
let vpairStepX = 0;
|
|
3793
|
+
{
|
|
3794
|
+
const stepXAA = findMinStepX(pA, pA, 0);
|
|
3795
|
+
const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
|
|
3796
|
+
const stepXBA = findMinStepX(pB, pA, gapAB_Y);
|
|
3797
|
+
const stepXBB = findMinStepX(pB, pB, 0);
|
|
3798
|
+
vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
|
|
3799
|
+
}
|
|
3800
|
+
if (vpairStepX <= 0) return emptyResult();
|
|
3801
|
+
const vpairStepY = gapAB_Y + findMinStepY(pB, pA, 0);
|
|
3802
|
+
if (vpairStepY <= 0) return emptyResult();
|
|
3803
|
+
const usableW = bounds.right - bounds.left;
|
|
3804
|
+
const usableH = bounds.bottom - bounds.top;
|
|
3805
|
+
const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
|
|
3806
|
+
const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
|
|
3807
|
+
if (cols === 0 || rows === 0) return emptyResult();
|
|
3808
|
+
const placements = [];
|
|
3809
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
3810
|
+
for (let r = 0; r < rows; r++) {
|
|
3811
|
+
for (let c = 0; c < cols; c++) {
|
|
3812
|
+
const baseX = bounds.left + c * vpairStepX;
|
|
3813
|
+
const baseY = bounds.top + r * vpairStepY;
|
|
3814
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
3815
|
+
if (baseX < minX) minX = baseX;
|
|
3816
|
+
if (baseY < minY) minY = baseY;
|
|
3817
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
3818
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
3819
|
+
const by = baseY + gapAB_Y;
|
|
3820
|
+
placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
3821
|
+
if (by + pB.height > maxY) maxY = by + pB.height;
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3825
|
+
}
|
|
3826
|
+
function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
3827
|
+
const rots = [0, 90, 180, 270];
|
|
3828
|
+
const rd = /* @__PURE__ */ new Map();
|
|
3829
|
+
for (const deg of rots) {
|
|
3830
|
+
rd.set(deg, prepareRotation3(contourPoints, dielineW, dielineH, deg));
|
|
3831
|
+
}
|
|
3832
|
+
const results = [];
|
|
3833
|
+
for (const deg of rots) {
|
|
3834
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
3835
|
+
}
|
|
3836
|
+
const allPairs = [
|
|
3837
|
+
[0, 180],
|
|
3838
|
+
[90, 270],
|
|
3839
|
+
[0, 90],
|
|
3840
|
+
[0, 270],
|
|
3841
|
+
[90, 180],
|
|
3842
|
+
[180, 270]
|
|
3843
|
+
];
|
|
3844
|
+
for (const [a, b] of allPairs) {
|
|
3845
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
3846
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
3847
|
+
if (stepA <= 0) continue;
|
|
3848
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
3849
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
3850
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
for (const [a, b] of allPairs) {
|
|
3854
|
+
results.push(pairGrid2(rd.get(a), rd.get(b), bounds));
|
|
3855
|
+
results.push(pairGrid2(rd.get(b), rd.get(a), bounds));
|
|
3856
|
+
}
|
|
3857
|
+
for (const [a, b] of allPairs) {
|
|
3858
|
+
results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
|
|
3859
|
+
results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
|
|
3860
|
+
}
|
|
3861
|
+
const singleResults = [];
|
|
3862
|
+
const multiResults = [];
|
|
3863
|
+
for (const r of results) {
|
|
3864
|
+
if (r.count === 0) continue;
|
|
3865
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
3866
|
+
if (rotations.size > 1) {
|
|
3867
|
+
multiResults.push(r);
|
|
3868
|
+
} else {
|
|
3869
|
+
singleResults.push(r);
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
function pickBest(arr) {
|
|
3873
|
+
let b = arr[0] ?? emptyResult();
|
|
3874
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
3875
|
+
for (const r of arr) {
|
|
3876
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
3877
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
3878
|
+
b = r;
|
|
3879
|
+
bArea = area;
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
return b;
|
|
3883
|
+
}
|
|
3884
|
+
const bestSingle = pickBest(singleResults);
|
|
3885
|
+
const bestMulti = pickBest(multiResults);
|
|
3886
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
3887
|
+
centerLayout(best, bounds);
|
|
3888
|
+
return {
|
|
3889
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
3890
|
+
placements: best.placements,
|
|
3891
|
+
producedPerSheet: best.count
|
|
3892
|
+
};
|
|
3893
|
+
}
|
|
3894
|
+
|
|
3538
3895
|
// src/utils/autoLayout/calculate/index.ts
|
|
3539
3896
|
function resolveModelFunctions(modelId, attrs) {
|
|
3540
3897
|
switch (modelId) {
|
|
3898
|
+
case "BECF-1040A": {
|
|
3899
|
+
const a = attrs;
|
|
3900
|
+
return {
|
|
3901
|
+
contour: generateOuterContour3(a),
|
|
3902
|
+
dieline: generateBecf1040a(a),
|
|
3903
|
+
offsetContour: offsetContour3
|
|
3904
|
+
};
|
|
3905
|
+
}
|
|
3541
3906
|
case "BECF-1030A": {
|
|
3542
3907
|
const a = attrs;
|
|
3543
3908
|
return {
|
|
@@ -3549,9 +3914,9 @@ function resolveModelFunctions(modelId, attrs) {
|
|
|
3549
3914
|
case "BECF-11D01": {
|
|
3550
3915
|
const a = attrs;
|
|
3551
3916
|
return {
|
|
3552
|
-
contour:
|
|
3917
|
+
contour: generateOuterContour4(a),
|
|
3553
3918
|
dieline: generateBecf11d01(a),
|
|
3554
|
-
offsetContour:
|
|
3919
|
+
offsetContour: offsetContour4
|
|
3555
3920
|
};
|
|
3556
3921
|
}
|
|
3557
3922
|
case "BECF-1010A":
|
|
@@ -3571,16 +3936,18 @@ function resolveLayoutCalculator(modelId) {
|
|
|
3571
3936
|
return computeLayoutForPaper;
|
|
3572
3937
|
case "BECF-1030A":
|
|
3573
3938
|
return computeLayoutForPaper2;
|
|
3939
|
+
case "BECF-1040A":
|
|
3940
|
+
return computeLayoutForPaper3;
|
|
3574
3941
|
default:
|
|
3575
3942
|
return computeLayoutForPaperDefault;
|
|
3576
3943
|
}
|
|
3577
3944
|
}
|
|
3578
3945
|
function calculateAutoLayout(config) {
|
|
3579
|
-
const { contour, dieline, offsetContour:
|
|
3946
|
+
const { contour, dieline, offsetContour: offsetContour5 } = resolveModelFunctions(
|
|
3580
3947
|
config.model.modelId,
|
|
3581
3948
|
config.model.attributes
|
|
3582
3949
|
);
|
|
3583
|
-
const offsetContourPoints = config.layoutDistance > 0 ?
|
|
3950
|
+
const offsetContourPoints = config.layoutDistance > 0 ? offsetContour5(contour, config.layoutDistance / 2) : contour;
|
|
3584
3951
|
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
3585
3952
|
const computeLayout = resolveLayoutCalculator(config.model.modelId);
|
|
3586
3953
|
const paperResults = [];
|
|
@@ -3917,6 +4284,14 @@ function renderDieLine(modelId, attrs) {
|
|
|
3917
4284
|
renderAs: "group"
|
|
3918
4285
|
}
|
|
3919
4286
|
);
|
|
4287
|
+
case "BECF-1040A":
|
|
4288
|
+
return /* @__PURE__ */ jsx(
|
|
4289
|
+
DIE_LINE_BECF_1040A,
|
|
4290
|
+
{
|
|
4291
|
+
attributes: attrs,
|
|
4292
|
+
renderAs: "group"
|
|
4293
|
+
}
|
|
4294
|
+
);
|
|
3920
4295
|
case "BECF-1010A":
|
|
3921
4296
|
default:
|
|
3922
4297
|
return /* @__PURE__ */ jsx(
|
|
@@ -4460,17 +4835,28 @@ function resolveModel(modelId, attrs, layoutDistance) {
|
|
|
4460
4835
|
generateContour: (a) => generateOuterContour2(a)
|
|
4461
4836
|
};
|
|
4462
4837
|
}
|
|
4463
|
-
case "BECF-
|
|
4838
|
+
case "BECF-1040A": {
|
|
4464
4839
|
const typedAttrs = attrs;
|
|
4465
4840
|
const contour = generateOuterContour3(typedAttrs);
|
|
4466
4841
|
return {
|
|
4467
|
-
dieline:
|
|
4842
|
+
dieline: generateBecf1040a(typedAttrs),
|
|
4468
4843
|
contourPath: contourToPath3(contour),
|
|
4469
4844
|
offsetContourPoints: layoutDistance > 0 ? offsetContour3(contour, layoutDistance / 2) : contour,
|
|
4470
|
-
generate: (a) =>
|
|
4845
|
+
generate: (a) => generateBecf1040a(a),
|
|
4471
4846
|
generateContour: (a) => generateOuterContour3(a)
|
|
4472
4847
|
};
|
|
4473
4848
|
}
|
|
4849
|
+
case "BECF-11D01": {
|
|
4850
|
+
const typedAttrs = attrs;
|
|
4851
|
+
const contour = generateOuterContour4(typedAttrs);
|
|
4852
|
+
return {
|
|
4853
|
+
dieline: generateBecf11d01(typedAttrs),
|
|
4854
|
+
contourPath: contourToPath4(contour),
|
|
4855
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour4(contour, layoutDistance / 2) : contour,
|
|
4856
|
+
generate: (a) => generateBecf11d01(a),
|
|
4857
|
+
generateContour: (a) => generateOuterContour4(a)
|
|
4858
|
+
};
|
|
4859
|
+
}
|
|
4474
4860
|
case "BECF-1010A":
|
|
4475
4861
|
default: {
|
|
4476
4862
|
const typedAttrs = attrs;
|
|
@@ -4496,6 +4882,14 @@ function renderDieLine2(modelId, attrs) {
|
|
|
4496
4882
|
renderAs: "group"
|
|
4497
4883
|
}
|
|
4498
4884
|
);
|
|
4885
|
+
case "BECF-1040A":
|
|
4886
|
+
return /* @__PURE__ */ jsx(
|
|
4887
|
+
DIE_LINE_BECF_1040A,
|
|
4888
|
+
{
|
|
4889
|
+
attributes: attrs,
|
|
4890
|
+
renderAs: "group"
|
|
4891
|
+
}
|
|
4892
|
+
);
|
|
4499
4893
|
case "BECF-11D01":
|
|
4500
4894
|
return /* @__PURE__ */ jsx(
|
|
4501
4895
|
DIE_LINE_BECF_11D01,
|