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