@lucablockltd/ultimate-packaging 1.0.3 → 1.2.0
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/dist/AGENTS_README.md +570 -119
- package/dist/index.d.mts +129 -23
- package/dist/index.d.ts +129 -23
- package/dist/index.js +2142 -654
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2139 -655
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -411,6 +411,7 @@ var AUTO_LAYOUT_THEME_CONFIG = {
|
|
|
411
411
|
};
|
|
412
412
|
|
|
413
413
|
// src/config.ts
|
|
414
|
+
var DEFAULT_FONT_DIMENSION_SIZE = 4.2;
|
|
414
415
|
var globalConfig = {};
|
|
415
416
|
function configurePackaging(config) {
|
|
416
417
|
globalConfig = config;
|
|
@@ -418,6 +419,9 @@ function configurePackaging(config) {
|
|
|
418
419
|
function getModelTheme() {
|
|
419
420
|
return { ...MODEL_THEME_CONFIG, ...globalConfig.modelTheme };
|
|
420
421
|
}
|
|
422
|
+
function getFontDimensionSize() {
|
|
423
|
+
return globalConfig.fontDimensionSize ?? DEFAULT_FONT_DIMENSION_SIZE;
|
|
424
|
+
}
|
|
421
425
|
function getAutoLayoutTheme() {
|
|
422
426
|
return { ...AUTO_LAYOUT_THEME_CONFIG, ...globalConfig.autoLayoutTheme };
|
|
423
427
|
}
|
|
@@ -1009,7 +1013,7 @@ var UNIT_FACTOR = {
|
|
|
1009
1013
|
in: 1 / 25.4
|
|
1010
1014
|
};
|
|
1011
1015
|
var PX_PER_MM = 96 / 25.4;
|
|
1012
|
-
function renderDimension(dim, i) {
|
|
1016
|
+
function renderDimension(dim, i, fs) {
|
|
1013
1017
|
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
1014
1018
|
const tick = 1.5;
|
|
1015
1019
|
if (orientation === "horizontal") {
|
|
@@ -1025,7 +1029,7 @@ function renderDimension(dim, i) {
|
|
|
1025
1029
|
x: midX,
|
|
1026
1030
|
y: y - 1.5,
|
|
1027
1031
|
textAnchor: "middle",
|
|
1028
|
-
fontSize:
|
|
1032
|
+
fontSize: fs,
|
|
1029
1033
|
fontFamily: "sans-serif",
|
|
1030
1034
|
fill: "#000",
|
|
1031
1035
|
children: label
|
|
@@ -1046,7 +1050,7 @@ function renderDimension(dim, i) {
|
|
|
1046
1050
|
y: midY - 1,
|
|
1047
1051
|
textAnchor: "middle",
|
|
1048
1052
|
dominantBaseline: "central",
|
|
1049
|
-
fontSize:
|
|
1053
|
+
fontSize: fs,
|
|
1050
1054
|
fontFamily: "sans-serif",
|
|
1051
1055
|
fill: "#000",
|
|
1052
1056
|
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
@@ -1155,7 +1159,7 @@ var DIE_LINE_BECF_1010A = forwardRef(
|
|
|
1155
1159
|
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1156
1160
|
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
1157
1161
|
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
1158
|
-
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map(renderDimension) })
|
|
1162
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension(d, i, getFontDimensionSize())) })
|
|
1159
1163
|
] });
|
|
1160
1164
|
if (renderAs === "group") {
|
|
1161
1165
|
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
@@ -1657,7 +1661,7 @@ var UNIT_FACTOR2 = {
|
|
|
1657
1661
|
in: 1 / 25.4
|
|
1658
1662
|
};
|
|
1659
1663
|
var PX_PER_MM2 = 96 / 25.4;
|
|
1660
|
-
function renderDimension2(dim, i) {
|
|
1664
|
+
function renderDimension2(dim, i, fs) {
|
|
1661
1665
|
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
1662
1666
|
const tick = 1.5;
|
|
1663
1667
|
if (orientation === "horizontal") {
|
|
@@ -1673,7 +1677,7 @@ function renderDimension2(dim, i) {
|
|
|
1673
1677
|
x: midX,
|
|
1674
1678
|
y: y - 1.5,
|
|
1675
1679
|
textAnchor: "middle",
|
|
1676
|
-
fontSize:
|
|
1680
|
+
fontSize: fs,
|
|
1677
1681
|
fontFamily: "sans-serif",
|
|
1678
1682
|
fill: "#000",
|
|
1679
1683
|
children: label
|
|
@@ -1694,7 +1698,7 @@ function renderDimension2(dim, i) {
|
|
|
1694
1698
|
y: midY - 1,
|
|
1695
1699
|
textAnchor: "middle",
|
|
1696
1700
|
dominantBaseline: "central",
|
|
1697
|
-
fontSize:
|
|
1701
|
+
fontSize: fs,
|
|
1698
1702
|
fontFamily: "sans-serif",
|
|
1699
1703
|
fill: "#000",
|
|
1700
1704
|
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
@@ -1803,7 +1807,7 @@ var DIE_LINE_BECF_1030A = forwardRef(
|
|
|
1803
1807
|
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1804
1808
|
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
1805
1809
|
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
1806
|
-
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map(renderDimension2) })
|
|
1810
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension2(d, i, getFontDimensionSize())) })
|
|
1807
1811
|
] });
|
|
1808
1812
|
if (renderAs === "group") {
|
|
1809
1813
|
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
@@ -2308,7 +2312,7 @@ var UNIT_FACTOR3 = {
|
|
|
2308
2312
|
in: 1 / 25.4
|
|
2309
2313
|
};
|
|
2310
2314
|
var PX_PER_MM3 = 96 / 25.4;
|
|
2311
|
-
function renderDimension3(dim, i) {
|
|
2315
|
+
function renderDimension3(dim, i, fs) {
|
|
2312
2316
|
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
2313
2317
|
const tick = 1.5;
|
|
2314
2318
|
if (orientation === "horizontal") {
|
|
@@ -2324,7 +2328,7 @@ function renderDimension3(dim, i) {
|
|
|
2324
2328
|
x: midX,
|
|
2325
2329
|
y: y - 1.5,
|
|
2326
2330
|
textAnchor: "middle",
|
|
2327
|
-
fontSize:
|
|
2331
|
+
fontSize: fs,
|
|
2328
2332
|
fontFamily: "sans-serif",
|
|
2329
2333
|
fill: "#000",
|
|
2330
2334
|
children: label
|
|
@@ -2345,7 +2349,7 @@ function renderDimension3(dim, i) {
|
|
|
2345
2349
|
y: midY - 1,
|
|
2346
2350
|
textAnchor: "middle",
|
|
2347
2351
|
dominantBaseline: "central",
|
|
2348
|
-
fontSize:
|
|
2352
|
+
fontSize: fs,
|
|
2349
2353
|
fontFamily: "sans-serif",
|
|
2350
2354
|
fill: "#000",
|
|
2351
2355
|
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
@@ -2454,7 +2458,7 @@ var DIE_LINE_BECF_1040A = forwardRef(
|
|
|
2454
2458
|
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2455
2459
|
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
2456
2460
|
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
2457
|
-
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map(renderDimension3) })
|
|
2461
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension3(d, i, getFontDimensionSize())) })
|
|
2458
2462
|
] });
|
|
2459
2463
|
if (renderAs === "group") {
|
|
2460
2464
|
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
@@ -2871,7 +2875,7 @@ var UNIT_FACTOR4 = {
|
|
|
2871
2875
|
in: 1 / 25.4
|
|
2872
2876
|
};
|
|
2873
2877
|
var PX_PER_MM4 = 96 / 25.4;
|
|
2874
|
-
function renderDimension4(dim, i) {
|
|
2878
|
+
function renderDimension4(dim, i, fs) {
|
|
2875
2879
|
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
2876
2880
|
const tick = 1.5;
|
|
2877
2881
|
if (orientation === "horizontal") {
|
|
@@ -2887,7 +2891,7 @@ function renderDimension4(dim, i) {
|
|
|
2887
2891
|
x: midX,
|
|
2888
2892
|
y: y - 1.5,
|
|
2889
2893
|
textAnchor: "middle",
|
|
2890
|
-
fontSize:
|
|
2894
|
+
fontSize: fs,
|
|
2891
2895
|
fontFamily: "sans-serif",
|
|
2892
2896
|
fill: "#000",
|
|
2893
2897
|
children: label
|
|
@@ -2908,7 +2912,7 @@ function renderDimension4(dim, i) {
|
|
|
2908
2912
|
y: midY - 1,
|
|
2909
2913
|
textAnchor: "middle",
|
|
2910
2914
|
dominantBaseline: "central",
|
|
2911
|
-
fontSize:
|
|
2915
|
+
fontSize: fs,
|
|
2912
2916
|
fontFamily: "sans-serif",
|
|
2913
2917
|
fill: "#000",
|
|
2914
2918
|
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
@@ -3016,7 +3020,7 @@ var DIE_LINE_BECF_11D01 = forwardRef(
|
|
|
3016
3020
|
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3017
3021
|
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
3018
3022
|
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
3019
|
-
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map(renderDimension4) })
|
|
3023
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension4(d, i, getFontDimensionSize())) })
|
|
3020
3024
|
] });
|
|
3021
3025
|
if (renderAs === "group") {
|
|
3022
3026
|
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
@@ -3130,369 +3134,1761 @@ var MODEL_BECF_11D01 = forwardRef(
|
|
|
3130
3134
|
}
|
|
3131
3135
|
);
|
|
3132
3136
|
|
|
3133
|
-
// src/
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
|
|
3161
|
-
for (let gx = startGx; gx <= endGx; gx++) {
|
|
3162
|
-
data[gy * w + gx] = 1;
|
|
3163
|
-
}
|
|
3164
|
-
}
|
|
3165
|
-
}
|
|
3166
|
-
return { data, width: w, height: h, offsetX, offsetY };
|
|
3137
|
+
// src/components/dieline/bags-pillows/becf-12101/generate.ts
|
|
3138
|
+
var DIP = 15;
|
|
3139
|
+
var ROPE_R = 3;
|
|
3140
|
+
var ROPE_Y = 20;
|
|
3141
|
+
var D_MAX = 40;
|
|
3142
|
+
function calcD(c, b) {
|
|
3143
|
+
return Math.min(c - 2 - b / 2, D_MAX);
|
|
3144
|
+
}
|
|
3145
|
+
function calcKulak(b) {
|
|
3146
|
+
if (b <= 13) return b - 1;
|
|
3147
|
+
if (b <= 99) return 13;
|
|
3148
|
+
if (b <= 249) return 20;
|
|
3149
|
+
if (b <= 499) return 25;
|
|
3150
|
+
return 30;
|
|
3151
|
+
}
|
|
3152
|
+
function calcX(a) {
|
|
3153
|
+
return Math.min(a / 2, 110);
|
|
3154
|
+
}
|
|
3155
|
+
function getAutoCalcValues(attr) {
|
|
3156
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3157
|
+
const D = calcD(C, B);
|
|
3158
|
+
const kulak = glueArea ?? calcKulak(B);
|
|
3159
|
+
const X = calcX(A);
|
|
3160
|
+
return { d: D, kulak, dip: DIP, ropeR: ROPE_R, ropeY: ROPE_Y, ropeX: X };
|
|
3161
|
+
}
|
|
3162
|
+
function line5(x1, y1, x2, y2) {
|
|
3163
|
+
return `M${x1} ${y1} L${x2} ${y2}`;
|
|
3167
3164
|
}
|
|
3168
|
-
function
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3165
|
+
function circlePath(cx, cy, r) {
|
|
3166
|
+
return `M${cx - r} ${cy} A${r} ${r} 0 0 1 ${cx + r} ${cy} A${r} ${r} 0 0 1 ${cx - r} ${cy}`;
|
|
3167
|
+
}
|
|
3168
|
+
function generateBecf12101(attr) {
|
|
3169
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3170
|
+
const D = calcD(C, B);
|
|
3171
|
+
const kulak = glueArea ?? calcKulak(B);
|
|
3172
|
+
const X = calcX(A);
|
|
3173
|
+
const xFront = kulak;
|
|
3174
|
+
const xSide1 = kulak + A;
|
|
3175
|
+
const xSide1Mid = kulak + A + B / 2;
|
|
3176
|
+
const xBack = kulak + A + B;
|
|
3177
|
+
const xSide2 = kulak + 2 * A + B;
|
|
3178
|
+
const xSide2Mid = kulak + 2 * A + B + B / 2;
|
|
3179
|
+
const xEnd = kulak + 2 * A + 2 * B - 2;
|
|
3180
|
+
const yFoldTop = D;
|
|
3181
|
+
const yFoldBottomStart = D + C - B / 2;
|
|
3182
|
+
const yFoldBottom = D + C;
|
|
3183
|
+
const yBottomFlap = D + C + B / 2;
|
|
3184
|
+
const yEnd = D + C + B / 2 + DIP;
|
|
3185
|
+
const totalWidth = xEnd;
|
|
3186
|
+
const totalHeight = yEnd;
|
|
3187
|
+
const cut = [];
|
|
3188
|
+
const crease = [];
|
|
3189
|
+
cut.push(line5(0, 0, totalWidth, 0));
|
|
3190
|
+
cut.push(line5(totalWidth, 0, totalWidth, totalHeight));
|
|
3191
|
+
cut.push(line5(totalWidth, totalHeight, 0, totalHeight));
|
|
3192
|
+
cut.push(line5(0, totalHeight, 0, 0));
|
|
3193
|
+
cut.push(line5(kulak + B / 2, yBottomFlap, kulak + B / 2, yEnd));
|
|
3194
|
+
cut.push(line5(kulak + A - B / 2, yBottomFlap, kulak + A - B / 2, yEnd));
|
|
3195
|
+
cut.push(line5(kulak + A + B + B / 2, yBottomFlap, kulak + A + B + B / 2, yEnd));
|
|
3196
|
+
cut.push(line5(kulak + 2 * A + B - B / 2, yBottomFlap, kulak + 2 * A + B - B / 2, yEnd));
|
|
3197
|
+
const frontCx = kulak + A / 2;
|
|
3198
|
+
const backCx = kulak + A + B + A / 2;
|
|
3199
|
+
const ropeTopY = yFoldTop - ROPE_Y;
|
|
3200
|
+
const ropeBotY = yFoldTop + ROPE_Y;
|
|
3201
|
+
cut.push(circlePath(frontCx - X / 2, ropeTopY, ROPE_R));
|
|
3202
|
+
cut.push(circlePath(frontCx - X / 2, ropeBotY, ROPE_R));
|
|
3203
|
+
cut.push(circlePath(frontCx + X / 2, ropeTopY, ROPE_R));
|
|
3204
|
+
cut.push(circlePath(frontCx + X / 2, ropeBotY, ROPE_R));
|
|
3205
|
+
cut.push(circlePath(backCx - X / 2, ropeTopY, ROPE_R));
|
|
3206
|
+
cut.push(circlePath(backCx - X / 2, ropeBotY, ROPE_R));
|
|
3207
|
+
cut.push(circlePath(backCx + X / 2, ropeTopY, ROPE_R));
|
|
3208
|
+
cut.push(circlePath(backCx + X / 2, ropeBotY, ROPE_R));
|
|
3209
|
+
crease.push(line5(0, yFoldTop, totalWidth, yFoldTop));
|
|
3210
|
+
crease.push(line5(0, yFoldBottomStart, totalWidth, yFoldBottomStart));
|
|
3211
|
+
crease.push(line5(0, yFoldBottom, totalWidth, yFoldBottom));
|
|
3212
|
+
crease.push(line5(xFront, 0, xFront, totalHeight));
|
|
3213
|
+
crease.push(line5(xSide1, 0, xSide1, totalHeight));
|
|
3214
|
+
crease.push(line5(xSide1Mid, 0, xSide1Mid, totalHeight));
|
|
3215
|
+
crease.push(line5(xBack, 0, xBack, totalHeight));
|
|
3216
|
+
crease.push(line5(xSide2, 0, xSide2, totalHeight));
|
|
3217
|
+
crease.push(line5(xSide2Mid, 0, xSide2Mid, totalHeight));
|
|
3218
|
+
crease.push(line5(0, yFoldBottom - kulak, kulak + B / 2, yBottomFlap));
|
|
3219
|
+
crease.push(line5(kulak + A - B / 2, yBottomFlap, xSide1Mid, yFoldBottomStart));
|
|
3220
|
+
crease.push(line5(xSide1Mid, yFoldBottomStart, kulak + A + B + B / 2, yBottomFlap));
|
|
3221
|
+
crease.push(line5(kulak + 2 * A + B - B / 2, yBottomFlap, xSide2Mid, yFoldBottomStart));
|
|
3222
|
+
crease.push(line5(xSide2Mid, yFoldBottomStart, xEnd, D + C - 2));
|
|
3223
|
+
return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
|
|
3224
|
+
}
|
|
3225
|
+
function generateOuterContour5(attr) {
|
|
3226
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3227
|
+
const D = calcD(C, B);
|
|
3228
|
+
const kulak = glueArea ?? calcKulak(B);
|
|
3229
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
3230
|
+
const totalHeight = D + C + B / 2 + DIP;
|
|
3231
|
+
return [
|
|
3232
|
+
{ x: 0, y: 0 },
|
|
3233
|
+
{ x: totalWidth, y: 0 },
|
|
3234
|
+
{ x: totalWidth, y: totalHeight },
|
|
3235
|
+
{ x: 0, y: totalHeight }
|
|
3236
|
+
];
|
|
3237
|
+
}
|
|
3238
|
+
function offsetContour5(points, distance) {
|
|
3239
|
+
const n = points.length;
|
|
3240
|
+
const result = [];
|
|
3241
|
+
for (let i = 0; i < n; i++) {
|
|
3242
|
+
const prev = points[(i - 1 + n) % n];
|
|
3243
|
+
const curr = points[i];
|
|
3244
|
+
const next = points[(i + 1) % n];
|
|
3245
|
+
const e1x = curr.x - prev.x;
|
|
3246
|
+
const e1y = curr.y - prev.y;
|
|
3247
|
+
const e2x = next.x - curr.x;
|
|
3248
|
+
const e2y = next.y - curr.y;
|
|
3249
|
+
const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
|
|
3250
|
+
const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
|
|
3251
|
+
if (len1 === 0 || len2 === 0) {
|
|
3252
|
+
result.push(curr);
|
|
3175
3253
|
continue;
|
|
3176
3254
|
}
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3255
|
+
const n1x = e1y / len1;
|
|
3256
|
+
const n1y = -e1x / len1;
|
|
3257
|
+
const n2x = e2y / len2;
|
|
3258
|
+
const n2y = -e2x / len2;
|
|
3259
|
+
const ax = n1x + n2x;
|
|
3260
|
+
const ay = n1y + n2y;
|
|
3261
|
+
const aLen = Math.sqrt(ax * ax + ay * ay);
|
|
3262
|
+
if (aLen < 1e-3) {
|
|
3263
|
+
result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
|
|
3264
|
+
continue;
|
|
3182
3265
|
}
|
|
3266
|
+
const nx = ax / aLen;
|
|
3267
|
+
const ny = ay / aLen;
|
|
3268
|
+
const dot = n1x * nx + n1y * ny;
|
|
3269
|
+
const d = distance / Math.max(dot, 0.1);
|
|
3270
|
+
result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
|
|
3183
3271
|
}
|
|
3184
|
-
return
|
|
3272
|
+
return result;
|
|
3185
3273
|
}
|
|
3186
|
-
function
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
}
|
|
3192
|
-
}
|
|
3274
|
+
function contourToPath5(points) {
|
|
3275
|
+
if (points.length === 0) return "";
|
|
3276
|
+
let d = `M${points[0].x} ${points[0].y}`;
|
|
3277
|
+
for (let i = 1; i < points.length; i++) {
|
|
3278
|
+
d += ` L${points[i].x} ${points[i].y}`;
|
|
3193
3279
|
}
|
|
3280
|
+
d += " Z";
|
|
3281
|
+
return d;
|
|
3194
3282
|
}
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
}
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3283
|
+
function generateDimensions5(attr, unit) {
|
|
3284
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3285
|
+
const D = calcD(C, B);
|
|
3286
|
+
const kulak = glueArea ?? calcKulak(B);
|
|
3287
|
+
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
3288
|
+
const suffix = unit;
|
|
3289
|
+
const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
|
|
3290
|
+
const xFront = kulak;
|
|
3291
|
+
const xSide1 = kulak + A;
|
|
3292
|
+
const xBack = kulak + A + B;
|
|
3293
|
+
const yFoldTop = D;
|
|
3294
|
+
const yFoldBottom = D + C;
|
|
3295
|
+
const yEnd = D + C + B / 2 + DIP;
|
|
3296
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
3297
|
+
const totalHeight = yEnd;
|
|
3298
|
+
const bottomSection = B / 2 + DIP;
|
|
3299
|
+
return [
|
|
3300
|
+
// Overall dimensions (outside)
|
|
3301
|
+
{
|
|
3302
|
+
x1: 0,
|
|
3303
|
+
y1: 0,
|
|
3304
|
+
x2: totalWidth,
|
|
3305
|
+
y2: 0,
|
|
3306
|
+
label: `Overall Width : ${fmt(totalWidth)}`,
|
|
3307
|
+
orientation: "horizontal",
|
|
3308
|
+
offset: -12
|
|
3309
|
+
},
|
|
3310
|
+
{
|
|
3311
|
+
x1: 0,
|
|
3312
|
+
y1: 0,
|
|
3313
|
+
x2: 0,
|
|
3314
|
+
y2: totalHeight,
|
|
3315
|
+
label: `Overall Height : ${fmt(totalHeight)}`,
|
|
3316
|
+
orientation: "vertical",
|
|
3317
|
+
offset: -12
|
|
3318
|
+
},
|
|
3319
|
+
// Height (C) — body area (centered on back panel)
|
|
3320
|
+
{
|
|
3321
|
+
x1: xBack + A * 0.6,
|
|
3322
|
+
y1: yFoldTop,
|
|
3323
|
+
x2: xBack + A * 0.6,
|
|
3324
|
+
y2: yFoldBottom,
|
|
3325
|
+
label: fmt(C),
|
|
3326
|
+
orientation: "vertical",
|
|
3327
|
+
offset: -10
|
|
3328
|
+
},
|
|
3329
|
+
// Top flap (D) (centered on back panel)
|
|
3330
|
+
{
|
|
3331
|
+
x1: xBack + A * 0.6,
|
|
3332
|
+
y1: 0,
|
|
3333
|
+
x2: xBack + A * 0.6,
|
|
3334
|
+
y2: yFoldTop,
|
|
3335
|
+
label: fmt(D),
|
|
3336
|
+
orientation: "vertical",
|
|
3337
|
+
offset: -10
|
|
3338
|
+
},
|
|
3339
|
+
// Bottom section (B/2 + _dip) (centered on back panel)
|
|
3340
|
+
{
|
|
3341
|
+
x1: xBack + A * 0.6,
|
|
3342
|
+
y1: yFoldBottom,
|
|
3343
|
+
x2: xBack + A * 0.6,
|
|
3344
|
+
y2: yEnd,
|
|
3345
|
+
label: fmt(bottomSection),
|
|
3346
|
+
orientation: "vertical",
|
|
3347
|
+
offset: -10
|
|
3348
|
+
},
|
|
3349
|
+
// Length (A) — front panel (centered vertically on body)
|
|
3350
|
+
{
|
|
3351
|
+
x1: xFront,
|
|
3352
|
+
y1: yFoldTop + C * 0.65,
|
|
3353
|
+
x2: xSide1,
|
|
3354
|
+
y2: yFoldTop + C * 0.65,
|
|
3355
|
+
label: fmt(A),
|
|
3356
|
+
orientation: "horizontal",
|
|
3357
|
+
offset: -20
|
|
3358
|
+
},
|
|
3359
|
+
// Width (B) — side panel (centered vertically on body)
|
|
3360
|
+
{
|
|
3361
|
+
x1: xSide1,
|
|
3362
|
+
y1: yFoldTop + C * 0.65,
|
|
3363
|
+
x2: xBack,
|
|
3364
|
+
y2: yFoldTop + C * 0.65,
|
|
3365
|
+
label: fmt(B),
|
|
3366
|
+
orientation: "horizontal",
|
|
3367
|
+
offset: -20
|
|
3368
|
+
},
|
|
3369
|
+
// Glue Area (kulak) — left glue flap width
|
|
3370
|
+
{
|
|
3371
|
+
x1: 0,
|
|
3372
|
+
y1: yFoldTop + C * 0.65,
|
|
3373
|
+
x2: xFront,
|
|
3374
|
+
y2: yFoldTop + C * 0.65,
|
|
3375
|
+
label: fmt(kulak),
|
|
3376
|
+
orientation: "horizontal",
|
|
3377
|
+
offset: -20
|
|
3378
|
+
}
|
|
3379
|
+
];
|
|
3233
3380
|
}
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3381
|
+
var MODEL_ID5 = "BECF-12101";
|
|
3382
|
+
var UNIT_FACTOR5 = {
|
|
3383
|
+
mm: 1,
|
|
3384
|
+
cm: 0.1,
|
|
3385
|
+
in: 1 / 25.4
|
|
3386
|
+
};
|
|
3387
|
+
var PX_PER_MM5 = 96 / 25.4;
|
|
3388
|
+
function renderDimension5(dim, i, fs) {
|
|
3389
|
+
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
3390
|
+
const tick = 1.5;
|
|
3391
|
+
if (orientation === "horizontal") {
|
|
3392
|
+
const y = y1 + offset;
|
|
3393
|
+
const midX = (x1 + x2) / 2;
|
|
3394
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3395
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
|
|
3396
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
3397
|
+
/* @__PURE__ */ jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
3398
|
+
/* @__PURE__ */ jsx(
|
|
3399
|
+
"text",
|
|
3400
|
+
{
|
|
3401
|
+
x: midX,
|
|
3402
|
+
y: y - 1.5,
|
|
3403
|
+
textAnchor: "middle",
|
|
3404
|
+
fontSize: fs,
|
|
3405
|
+
fontFamily: "sans-serif",
|
|
3406
|
+
fill: "#000",
|
|
3407
|
+
children: label
|
|
3408
|
+
}
|
|
3409
|
+
)
|
|
3410
|
+
] }, `dim-${i}`);
|
|
3246
3411
|
}
|
|
3247
|
-
|
|
3412
|
+
const x = x1 + offset;
|
|
3413
|
+
const midY = (y1 + y2) / 2;
|
|
3414
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3415
|
+
/* @__PURE__ */ jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
|
|
3416
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
|
|
3417
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
|
|
3418
|
+
/* @__PURE__ */ jsx(
|
|
3419
|
+
"text",
|
|
3420
|
+
{
|
|
3421
|
+
x: x - 1.5,
|
|
3422
|
+
y: midY - 1,
|
|
3423
|
+
textAnchor: "middle",
|
|
3424
|
+
dominantBaseline: "central",
|
|
3425
|
+
fontSize: fs,
|
|
3426
|
+
fontFamily: "sans-serif",
|
|
3427
|
+
fill: "#000",
|
|
3428
|
+
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
3429
|
+
children: label
|
|
3430
|
+
}
|
|
3431
|
+
)
|
|
3432
|
+
] }, `dim-${i}`);
|
|
3248
3433
|
}
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3434
|
+
var DIE_LINE_BECF_12101 = forwardRef(
|
|
3435
|
+
({
|
|
3436
|
+
attributes,
|
|
3437
|
+
unit = "mm",
|
|
3438
|
+
isShowDimensions = false,
|
|
3439
|
+
renderAs = "svg"
|
|
3440
|
+
}, ref) => {
|
|
3441
|
+
const theme = useMemo(
|
|
3442
|
+
() => getModelTheme(),
|
|
3443
|
+
[]
|
|
3444
|
+
);
|
|
3445
|
+
const svgRef = useRef(null);
|
|
3446
|
+
const dieline = useMemo(() => generateBecf12101(attributes), [attributes]);
|
|
3447
|
+
const dimensions = useMemo(
|
|
3448
|
+
() => generateDimensions5(attributes, unit),
|
|
3449
|
+
[attributes, unit]
|
|
3450
|
+
);
|
|
3451
|
+
const factor = UNIT_FACTOR5[unit] ?? 1;
|
|
3452
|
+
const serializeSvg = useCallback(
|
|
3453
|
+
(showDimensions) => {
|
|
3454
|
+
const svg = svgRef.current;
|
|
3455
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
3456
|
+
const clone = svg.cloneNode(true);
|
|
3457
|
+
if (!showDimensions) {
|
|
3458
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
3459
|
+
dimGroup?.remove();
|
|
3460
|
+
}
|
|
3461
|
+
return new XMLSerializer().serializeToString(clone);
|
|
3462
|
+
},
|
|
3463
|
+
[]
|
|
3464
|
+
);
|
|
3465
|
+
useImperativeHandle(
|
|
3466
|
+
ref,
|
|
3467
|
+
() => {
|
|
3468
|
+
const auto = getAutoCalcValues(attributes);
|
|
3469
|
+
return {
|
|
3470
|
+
getAttributes: () => ({
|
|
3471
|
+
modelId: MODEL_ID5,
|
|
3472
|
+
overallWidth: dieline.viewBox.width * factor,
|
|
3473
|
+
overallHeight: dieline.viewBox.height * factor,
|
|
3474
|
+
length: attributes.length * factor,
|
|
3475
|
+
width: attributes.width * factor,
|
|
3476
|
+
height: attributes.height * factor,
|
|
3477
|
+
glueArea: auto.kulak * factor,
|
|
3478
|
+
d: auto.d * factor,
|
|
3479
|
+
kulak: auto.kulak * factor,
|
|
3480
|
+
dip: auto.dip * factor,
|
|
3481
|
+
ropeR: auto.ropeR * factor,
|
|
3482
|
+
ropeY: auto.ropeY * factor,
|
|
3483
|
+
ropeX: auto.ropeX * factor
|
|
3484
|
+
}),
|
|
3485
|
+
exportImage: async (options) => {
|
|
3486
|
+
const svgStr = serializeSvg(options.isShowDimension);
|
|
3487
|
+
const blob = new Blob([svgStr], {
|
|
3488
|
+
type: "image/svg+xml;charset=utf-8"
|
|
3489
|
+
});
|
|
3490
|
+
const url = URL.createObjectURL(blob);
|
|
3491
|
+
const img = new Image();
|
|
3492
|
+
await new Promise((resolve, reject) => {
|
|
3493
|
+
img.onload = () => resolve();
|
|
3494
|
+
img.onerror = reject;
|
|
3495
|
+
img.src = url;
|
|
3496
|
+
});
|
|
3497
|
+
const canvas = document.createElement("canvas");
|
|
3498
|
+
if (options.originalSize) {
|
|
3499
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM5);
|
|
3500
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM5);
|
|
3501
|
+
} else {
|
|
3502
|
+
canvas.width = 1920;
|
|
3503
|
+
canvas.height = 1080;
|
|
3504
|
+
}
|
|
3505
|
+
const ctx = canvas.getContext("2d");
|
|
3506
|
+
ctx.fillStyle = "#ffffff";
|
|
3507
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
3508
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
3509
|
+
URL.revokeObjectURL(url);
|
|
3510
|
+
return new Promise((resolve, reject) => {
|
|
3511
|
+
canvas.toBlob(
|
|
3512
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
3513
|
+
"image/png"
|
|
3514
|
+
);
|
|
3515
|
+
});
|
|
3516
|
+
},
|
|
3517
|
+
exportDimension: async () => {
|
|
3518
|
+
const dimData = generateDimensions5(attributes, unit);
|
|
3519
|
+
return exportDimensionPdf({
|
|
3520
|
+
modelId: MODEL_ID5,
|
|
3521
|
+
dieline,
|
|
3522
|
+
dimensions: dimData,
|
|
3523
|
+
attributes,
|
|
3524
|
+
unit,
|
|
3525
|
+
factor,
|
|
3526
|
+
theme
|
|
3527
|
+
});
|
|
3528
|
+
}
|
|
3529
|
+
};
|
|
3530
|
+
},
|
|
3531
|
+
[attributes, dieline, factor, unit, serializeSvg, theme]
|
|
3532
|
+
);
|
|
3533
|
+
const padding = isShowDimensions ? 15 : 0;
|
|
3534
|
+
const vbX = -padding;
|
|
3535
|
+
const vbY = -padding;
|
|
3536
|
+
const vbW = dieline.viewBox.width + padding * 2;
|
|
3537
|
+
const vbH = dieline.viewBox.height + padding * 2;
|
|
3538
|
+
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3539
|
+
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
3540
|
+
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
3541
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension5(d, i, getFontDimensionSize())) })
|
|
3542
|
+
] });
|
|
3543
|
+
if (renderAs === "group") {
|
|
3544
|
+
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
3545
|
+
}
|
|
3546
|
+
return /* @__PURE__ */ jsx(
|
|
3547
|
+
"svg",
|
|
3548
|
+
{
|
|
3549
|
+
ref: svgRef,
|
|
3550
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3551
|
+
viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`,
|
|
3552
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
3553
|
+
style: { backgroundColor: theme.colorBackground },
|
|
3554
|
+
children: svgChildren
|
|
3555
|
+
}
|
|
3556
|
+
);
|
|
3557
|
+
}
|
|
3558
|
+
);
|
|
3559
|
+
var CANVAS_BECF_12101 = forwardRef(
|
|
3560
|
+
(props, ref) => {
|
|
3561
|
+
const dieLineRef = useRef(null);
|
|
3562
|
+
const canvasRef = useRef(null);
|
|
3563
|
+
const {
|
|
3564
|
+
attributes
|
|
3565
|
+
} = props;
|
|
3566
|
+
const theme = useMemo(
|
|
3567
|
+
() => getModelTheme(),
|
|
3568
|
+
[]
|
|
3569
|
+
);
|
|
3570
|
+
const dieline = useMemo(() => generateBecf12101(attributes), [attributes]);
|
|
3571
|
+
const stablePadding = 15;
|
|
3572
|
+
const viewBox = useMemo(
|
|
3573
|
+
() => ({
|
|
3574
|
+
x: -stablePadding,
|
|
3575
|
+
y: -stablePadding,
|
|
3576
|
+
width: dieline.viewBox.width + stablePadding * 2,
|
|
3577
|
+
height: dieline.viewBox.height + stablePadding * 2
|
|
3578
|
+
}),
|
|
3579
|
+
[dieline.viewBox.width, dieline.viewBox.height]
|
|
3580
|
+
);
|
|
3581
|
+
const serializeCanvasSvg = useCallback((showDimensions) => {
|
|
3582
|
+
const svg = canvasRef.current?.getSvgElement();
|
|
3583
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
3584
|
+
const clone = svg.cloneNode(true);
|
|
3585
|
+
if (!showDimensions) {
|
|
3586
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
3587
|
+
dimGroup?.remove();
|
|
3588
|
+
}
|
|
3589
|
+
return new XMLSerializer().serializeToString(clone);
|
|
3590
|
+
}, []);
|
|
3591
|
+
useImperativeHandle(ref, () => ({
|
|
3592
|
+
getAttributes: () => dieLineRef.current.getAttributes(),
|
|
3593
|
+
exportImage: async (options) => {
|
|
3594
|
+
const svgStr = serializeCanvasSvg(options.isShowDimension);
|
|
3595
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
3596
|
+
const url = URL.createObjectURL(blob);
|
|
3597
|
+
const img = new Image();
|
|
3598
|
+
await new Promise((resolve, reject) => {
|
|
3599
|
+
img.onload = () => resolve();
|
|
3600
|
+
img.onerror = reject;
|
|
3601
|
+
img.src = url;
|
|
3602
|
+
});
|
|
3603
|
+
const canvas = document.createElement("canvas");
|
|
3604
|
+
if (options.originalSize) {
|
|
3605
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM5);
|
|
3606
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM5);
|
|
3607
|
+
} else {
|
|
3608
|
+
canvas.width = 1920;
|
|
3609
|
+
canvas.height = 1080;
|
|
3610
|
+
}
|
|
3611
|
+
const ctx = canvas.getContext("2d");
|
|
3612
|
+
ctx.fillStyle = "#ffffff";
|
|
3613
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
3614
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
3615
|
+
URL.revokeObjectURL(url);
|
|
3616
|
+
return new Promise((resolve, reject) => {
|
|
3617
|
+
canvas.toBlob(
|
|
3618
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
3619
|
+
"image/png"
|
|
3620
|
+
);
|
|
3621
|
+
});
|
|
3622
|
+
},
|
|
3623
|
+
exportDimension: () => dieLineRef.current.exportDimension(),
|
|
3624
|
+
resetView: () => canvasRef.current?.resetView(),
|
|
3625
|
+
fitView: () => canvasRef.current?.fitView()
|
|
3626
|
+
}), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
|
|
3627
|
+
return /* @__PURE__ */ jsx(
|
|
3628
|
+
BaseCanvas,
|
|
3629
|
+
{
|
|
3630
|
+
ref: canvasRef,
|
|
3631
|
+
viewBox,
|
|
3632
|
+
backgroundColor: theme.colorBackground,
|
|
3633
|
+
children: /* @__PURE__ */ jsx(DIE_LINE_BECF_12101, { ref: dieLineRef, ...props, renderAs: "group" })
|
|
3634
|
+
}
|
|
3635
|
+
);
|
|
3636
|
+
}
|
|
3637
|
+
);
|
|
3638
|
+
var MODEL_BECF_12101 = forwardRef(
|
|
3639
|
+
({ mode = "DIE_LINE", ...props }, ref) => {
|
|
3640
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (() => {
|
|
3641
|
+
switch (mode) {
|
|
3642
|
+
case "DIE_LINE":
|
|
3643
|
+
return /* @__PURE__ */ jsx(CANVAS_BECF_12101, { ref, ...props });
|
|
3644
|
+
case "3D":
|
|
3645
|
+
return null;
|
|
3646
|
+
case "AUTO_LAYOUT":
|
|
3647
|
+
return /* @__PURE__ */ jsx(DIE_LINE_BECF_12101, { ref, ...props });
|
|
3648
|
+
default:
|
|
3649
|
+
return null;
|
|
3650
|
+
}
|
|
3651
|
+
})() });
|
|
3652
|
+
}
|
|
3653
|
+
);
|
|
3654
|
+
|
|
3655
|
+
// src/components/dieline/bags-pillows/becf-12109/generate.ts
|
|
3656
|
+
var DIP2 = 13;
|
|
3657
|
+
var ROPE_R2 = 3;
|
|
3658
|
+
var ROPE_Y2 = 20;
|
|
3659
|
+
var D_MAX2 = 40;
|
|
3660
|
+
var NOTCH_X = 3;
|
|
3661
|
+
var NOTCH_Y = 5;
|
|
3662
|
+
function calcD2(c, b) {
|
|
3663
|
+
return Math.min(c - 2 - b / 2, D_MAX2);
|
|
3664
|
+
}
|
|
3665
|
+
function calcKulak2(b) {
|
|
3666
|
+
if (b <= 13) return b - 1;
|
|
3667
|
+
if (b <= 99) return 13;
|
|
3668
|
+
if (b <= 249) return 20;
|
|
3669
|
+
if (b <= 499) return 25;
|
|
3670
|
+
return 30;
|
|
3671
|
+
}
|
|
3672
|
+
function calcX2(a) {
|
|
3673
|
+
return a / 2;
|
|
3674
|
+
}
|
|
3675
|
+
function getAutoCalcValues2(attr) {
|
|
3676
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3677
|
+
const D = calcD2(C, B);
|
|
3678
|
+
const kulak = glueArea ?? calcKulak2(B);
|
|
3679
|
+
const X = calcX2(A);
|
|
3680
|
+
return { d: D, kulak, dip: DIP2, ropeR: ROPE_R2, ropeY: ROPE_Y2, ropeX: X };
|
|
3681
|
+
}
|
|
3682
|
+
function line6(x1, y1, x2, y2) {
|
|
3683
|
+
return `M${x1} ${y1} L${x2} ${y2}`;
|
|
3684
|
+
}
|
|
3685
|
+
function circlePath2(cx, cy, r) {
|
|
3686
|
+
return `M${cx - r} ${cy} A${r} ${r} 0 0 1 ${cx + r} ${cy} A${r} ${r} 0 0 1 ${cx - r} ${cy}`;
|
|
3687
|
+
}
|
|
3688
|
+
function generateBecf12109(attr) {
|
|
3689
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3690
|
+
const D = calcD2(C, B);
|
|
3691
|
+
const kulak = glueArea ?? calcKulak2(B);
|
|
3692
|
+
const X = calcX2(A);
|
|
3693
|
+
const xFront = kulak;
|
|
3694
|
+
const xSide1 = kulak + A;
|
|
3695
|
+
const xSide1Mid = kulak + A + B / 2;
|
|
3696
|
+
const xBack = kulak + A + B;
|
|
3697
|
+
const xSide2 = kulak + 2 * A + B;
|
|
3698
|
+
const xSide2Mid = kulak + 2 * A + B + B / 2;
|
|
3699
|
+
const xEnd = kulak + 2 * A + 2 * B - 2;
|
|
3700
|
+
const yFoldTop = D;
|
|
3701
|
+
const yFoldBottomStart = D + C - B / 2;
|
|
3702
|
+
const yFoldBottom = D + C;
|
|
3703
|
+
const yNotchStart = yFoldBottom + NOTCH_Y;
|
|
3704
|
+
const yEnd = D + C + B / 2 + DIP2;
|
|
3705
|
+
const totalWidth = xEnd;
|
|
3706
|
+
const totalHeight = yEnd;
|
|
3707
|
+
const cut = [];
|
|
3708
|
+
const crease = [];
|
|
3709
|
+
cut.push(line6(0, 0, 0, yFoldBottom - kulak));
|
|
3710
|
+
cut.push(line6(0, 0, totalWidth, 0));
|
|
3711
|
+
cut.push(line6(totalWidth, 0, totalWidth, yFoldBottom));
|
|
3712
|
+
cut.push(line6(0, yFoldBottom - kulak, kulak, yFoldBottom));
|
|
3713
|
+
const boundaries = [xFront, xSide1, xBack, xSide2, xEnd];
|
|
3714
|
+
for (let i = 0; i < boundaries.length; i++) {
|
|
3715
|
+
const xb = boundaries[i];
|
|
3716
|
+
const isFirst = i === 0;
|
|
3717
|
+
const isLast = i === boundaries.length - 1;
|
|
3718
|
+
if (!isFirst) {
|
|
3719
|
+
cut.push(line6(xb - NOTCH_X, yNotchStart, xb - NOTCH_X, totalHeight));
|
|
3720
|
+
cut.push(line6(xb - NOTCH_X, yNotchStart, xb, yFoldBottom));
|
|
3721
|
+
}
|
|
3722
|
+
if (!isLast) {
|
|
3723
|
+
cut.push(line6(xb + NOTCH_X, yNotchStart, xb + NOTCH_X, totalHeight));
|
|
3724
|
+
cut.push(line6(xb + NOTCH_X, yNotchStart, xb, yFoldBottom));
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
cut.push(line6(xFront + NOTCH_X, totalHeight, xSide1 - NOTCH_X, totalHeight));
|
|
3728
|
+
cut.push(line6(xSide1 + NOTCH_X, totalHeight, xBack - NOTCH_X, totalHeight));
|
|
3729
|
+
cut.push(line6(xBack + NOTCH_X, totalHeight, xSide2 - NOTCH_X, totalHeight));
|
|
3730
|
+
cut.push(line6(xSide2 + NOTCH_X, totalHeight, xEnd - NOTCH_X, totalHeight));
|
|
3731
|
+
const frontCx = kulak + A / 2;
|
|
3732
|
+
const backCx = kulak + A + B + A / 2;
|
|
3733
|
+
const ropeTopY = yFoldTop - ROPE_Y2;
|
|
3734
|
+
const ropeBotY = yFoldTop + ROPE_Y2;
|
|
3735
|
+
cut.push(circlePath2(frontCx - X / 2, ropeTopY, ROPE_R2));
|
|
3736
|
+
cut.push(circlePath2(frontCx - X / 2, ropeBotY, ROPE_R2));
|
|
3737
|
+
cut.push(circlePath2(frontCx + X / 2, ropeTopY, ROPE_R2));
|
|
3738
|
+
cut.push(circlePath2(frontCx + X / 2, ropeBotY, ROPE_R2));
|
|
3739
|
+
cut.push(circlePath2(backCx - X / 2, ropeTopY, ROPE_R2));
|
|
3740
|
+
cut.push(circlePath2(backCx - X / 2, ropeBotY, ROPE_R2));
|
|
3741
|
+
cut.push(circlePath2(backCx + X / 2, ropeTopY, ROPE_R2));
|
|
3742
|
+
cut.push(circlePath2(backCx + X / 2, ropeBotY, ROPE_R2));
|
|
3743
|
+
crease.push(line6(0, yFoldTop, totalWidth, yFoldTop));
|
|
3744
|
+
crease.push(line6(0, yFoldBottomStart, totalWidth, yFoldBottomStart));
|
|
3745
|
+
crease.push(line6(kulak, yFoldBottom, xEnd, yFoldBottom));
|
|
3746
|
+
crease.push(line6(xFront, 0, xFront, yFoldBottom));
|
|
3747
|
+
crease.push(line6(xSide1, 0, xSide1, yFoldBottom));
|
|
3748
|
+
crease.push(line6(xBack, 0, xBack, yFoldBottom));
|
|
3749
|
+
crease.push(line6(xSide2, 0, xSide2, yFoldBottom));
|
|
3750
|
+
crease.push(line6(xSide1Mid, 0, xSide1Mid, totalHeight));
|
|
3751
|
+
crease.push(line6(xSide2Mid, 0, xSide2Mid, totalHeight));
|
|
3752
|
+
crease.push(line6(xBack, yFoldBottom, xSide1Mid, yFoldBottomStart));
|
|
3753
|
+
crease.push(line6(xSide1Mid, yFoldBottomStart, xSide1, yFoldBottom));
|
|
3754
|
+
crease.push(line6(xSide2Mid, yFoldBottomStart, xSide2, yFoldBottom));
|
|
3755
|
+
crease.push(line6(xSide2Mid, yFoldBottomStart, xEnd, D + C - 2));
|
|
3756
|
+
return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
|
|
3757
|
+
}
|
|
3758
|
+
function generateOuterContour6(attr) {
|
|
3759
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3760
|
+
const D = calcD2(C, B);
|
|
3761
|
+
const kulak = glueArea ?? calcKulak2(B);
|
|
3762
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
3763
|
+
const totalHeight = D + C + B / 2 + DIP2;
|
|
3764
|
+
return [
|
|
3765
|
+
{ x: 0, y: 0 },
|
|
3766
|
+
{ x: totalWidth, y: 0 },
|
|
3767
|
+
{ x: totalWidth, y: totalHeight },
|
|
3768
|
+
{ x: 0, y: totalHeight }
|
|
3769
|
+
];
|
|
3770
|
+
}
|
|
3771
|
+
function offsetContour6(points, distance) {
|
|
3772
|
+
const n = points.length;
|
|
3773
|
+
const result = [];
|
|
3774
|
+
for (let i = 0; i < n; i++) {
|
|
3775
|
+
const prev = points[(i - 1 + n) % n];
|
|
3776
|
+
const curr = points[i];
|
|
3777
|
+
const next = points[(i + 1) % n];
|
|
3778
|
+
const e1x = curr.x - prev.x;
|
|
3779
|
+
const e1y = curr.y - prev.y;
|
|
3780
|
+
const e2x = next.x - curr.x;
|
|
3781
|
+
const e2y = next.y - curr.y;
|
|
3782
|
+
const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
|
|
3783
|
+
const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
|
|
3784
|
+
if (len1 === 0 || len2 === 0) {
|
|
3785
|
+
result.push(curr);
|
|
3786
|
+
continue;
|
|
3787
|
+
}
|
|
3788
|
+
const n1x = e1y / len1;
|
|
3789
|
+
const n1y = -e1x / len1;
|
|
3790
|
+
const n2x = e2y / len2;
|
|
3791
|
+
const n2y = -e2x / len2;
|
|
3792
|
+
const ax = n1x + n2x;
|
|
3793
|
+
const ay = n1y + n2y;
|
|
3794
|
+
const aLen = Math.sqrt(ax * ax + ay * ay);
|
|
3795
|
+
if (aLen < 1e-3) {
|
|
3796
|
+
result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
|
|
3797
|
+
continue;
|
|
3798
|
+
}
|
|
3799
|
+
const nx = ax / aLen;
|
|
3800
|
+
const ny = ay / aLen;
|
|
3801
|
+
const dot = n1x * nx + n1y * ny;
|
|
3802
|
+
const d = distance / Math.max(dot, 0.1);
|
|
3803
|
+
result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
|
|
3804
|
+
}
|
|
3805
|
+
return result;
|
|
3806
|
+
}
|
|
3807
|
+
function contourToPath6(points) {
|
|
3808
|
+
if (points.length === 0) return "";
|
|
3809
|
+
let d = `M${points[0].x} ${points[0].y}`;
|
|
3810
|
+
for (let i = 1; i < points.length; i++) {
|
|
3811
|
+
d += ` L${points[i].x} ${points[i].y}`;
|
|
3812
|
+
}
|
|
3813
|
+
d += " Z";
|
|
3814
|
+
return d;
|
|
3815
|
+
}
|
|
3816
|
+
function generateDimensions6(attr, unit) {
|
|
3817
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3818
|
+
const D = calcD2(C, B);
|
|
3819
|
+
const kulak = glueArea ?? calcKulak2(B);
|
|
3820
|
+
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
3821
|
+
const suffix = unit;
|
|
3822
|
+
const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
|
|
3823
|
+
const xFront = kulak;
|
|
3824
|
+
const xSide1 = kulak + A;
|
|
3825
|
+
const xBack = kulak + A + B;
|
|
3826
|
+
const yFoldTop = D;
|
|
3827
|
+
const yFoldBottom = D + C;
|
|
3828
|
+
const yEnd = D + C + B / 2 + DIP2;
|
|
3829
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
3830
|
+
const totalHeight = yEnd;
|
|
3831
|
+
const bottomSection = B / 2 + DIP2;
|
|
3832
|
+
return [
|
|
3833
|
+
// Overall dimensions (outside)
|
|
3834
|
+
{
|
|
3835
|
+
x1: 0,
|
|
3836
|
+
y1: 0,
|
|
3837
|
+
x2: totalWidth,
|
|
3838
|
+
y2: 0,
|
|
3839
|
+
label: `Overall Width : ${fmt(totalWidth)}`,
|
|
3840
|
+
orientation: "horizontal",
|
|
3841
|
+
offset: -12
|
|
3842
|
+
},
|
|
3843
|
+
{
|
|
3844
|
+
x1: 0,
|
|
3845
|
+
y1: 0,
|
|
3846
|
+
x2: 0,
|
|
3847
|
+
y2: totalHeight,
|
|
3848
|
+
label: `Overall Height : ${fmt(totalHeight)}`,
|
|
3849
|
+
orientation: "vertical",
|
|
3850
|
+
offset: -12
|
|
3851
|
+
},
|
|
3852
|
+
// Height (C) — body area (centered on back panel)
|
|
3853
|
+
{
|
|
3854
|
+
x1: xBack + A * 0.6,
|
|
3855
|
+
y1: yFoldTop,
|
|
3856
|
+
x2: xBack + A * 0.6,
|
|
3857
|
+
y2: yFoldBottom,
|
|
3858
|
+
label: fmt(C),
|
|
3859
|
+
orientation: "vertical",
|
|
3860
|
+
offset: -10
|
|
3861
|
+
},
|
|
3862
|
+
// Top flap (D) (centered on back panel)
|
|
3863
|
+
{
|
|
3864
|
+
x1: xBack + A * 0.6,
|
|
3865
|
+
y1: 0,
|
|
3866
|
+
x2: xBack + A * 0.6,
|
|
3867
|
+
y2: yFoldTop,
|
|
3868
|
+
label: fmt(D),
|
|
3869
|
+
orientation: "vertical",
|
|
3870
|
+
offset: -10
|
|
3871
|
+
},
|
|
3872
|
+
// Bottom section (B/2 + _dip) (centered on back panel)
|
|
3873
|
+
{
|
|
3874
|
+
x1: xBack + A * 0.6,
|
|
3875
|
+
y1: yFoldBottom,
|
|
3876
|
+
x2: xBack + A * 0.6,
|
|
3877
|
+
y2: yEnd,
|
|
3878
|
+
label: fmt(bottomSection),
|
|
3879
|
+
orientation: "vertical",
|
|
3880
|
+
offset: -10
|
|
3881
|
+
},
|
|
3882
|
+
// Length (A) — front panel (centered vertically on body)
|
|
3883
|
+
{
|
|
3884
|
+
x1: xFront,
|
|
3885
|
+
y1: yFoldTop + C * 0.65,
|
|
3886
|
+
x2: xSide1,
|
|
3887
|
+
y2: yFoldTop + C * 0.65,
|
|
3888
|
+
label: fmt(A),
|
|
3889
|
+
orientation: "horizontal",
|
|
3890
|
+
offset: -20
|
|
3891
|
+
},
|
|
3892
|
+
// Width (B) — side panel (centered vertically on body)
|
|
3893
|
+
{
|
|
3894
|
+
x1: xSide1,
|
|
3895
|
+
y1: yFoldTop + C * 0.65,
|
|
3896
|
+
x2: xBack,
|
|
3897
|
+
y2: yFoldTop + C * 0.65,
|
|
3898
|
+
label: fmt(B),
|
|
3899
|
+
orientation: "horizontal",
|
|
3900
|
+
offset: -20
|
|
3901
|
+
},
|
|
3902
|
+
// Glue Area (kulak) — left glue flap width
|
|
3903
|
+
{
|
|
3904
|
+
x1: 0,
|
|
3905
|
+
y1: yFoldTop + C * 0.65,
|
|
3906
|
+
x2: xFront,
|
|
3907
|
+
y2: yFoldTop + C * 0.65,
|
|
3908
|
+
label: fmt(kulak),
|
|
3909
|
+
orientation: "horizontal",
|
|
3910
|
+
offset: -20
|
|
3911
|
+
}
|
|
3912
|
+
];
|
|
3913
|
+
}
|
|
3914
|
+
var MODEL_ID6 = "BECF-12109";
|
|
3915
|
+
var UNIT_FACTOR6 = {
|
|
3916
|
+
mm: 1,
|
|
3917
|
+
cm: 0.1,
|
|
3918
|
+
in: 1 / 25.4
|
|
3919
|
+
};
|
|
3920
|
+
var PX_PER_MM6 = 96 / 25.4;
|
|
3921
|
+
function renderDimension6(dim, i, fs) {
|
|
3922
|
+
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
3923
|
+
const tick = 1.5;
|
|
3924
|
+
if (orientation === "horizontal") {
|
|
3925
|
+
const y = y1 + offset;
|
|
3926
|
+
const midX = (x1 + x2) / 2;
|
|
3927
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3928
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
|
|
3929
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
3930
|
+
/* @__PURE__ */ jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
3931
|
+
/* @__PURE__ */ jsx(
|
|
3932
|
+
"text",
|
|
3933
|
+
{
|
|
3934
|
+
x: midX,
|
|
3935
|
+
y: y - 1.5,
|
|
3936
|
+
textAnchor: "middle",
|
|
3937
|
+
fontSize: fs,
|
|
3938
|
+
fontFamily: "sans-serif",
|
|
3939
|
+
fill: "#000",
|
|
3940
|
+
children: label
|
|
3941
|
+
}
|
|
3942
|
+
)
|
|
3943
|
+
] }, `dim-${i}`);
|
|
3944
|
+
}
|
|
3945
|
+
const x = x1 + offset;
|
|
3946
|
+
const midY = (y1 + y2) / 2;
|
|
3947
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3948
|
+
/* @__PURE__ */ jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
|
|
3949
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
|
|
3950
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
|
|
3951
|
+
/* @__PURE__ */ jsx(
|
|
3952
|
+
"text",
|
|
3953
|
+
{
|
|
3954
|
+
x: x - 1.5,
|
|
3955
|
+
y: midY - 1,
|
|
3956
|
+
textAnchor: "middle",
|
|
3957
|
+
dominantBaseline: "central",
|
|
3958
|
+
fontSize: fs,
|
|
3959
|
+
fontFamily: "sans-serif",
|
|
3960
|
+
fill: "#000",
|
|
3961
|
+
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
3962
|
+
children: label
|
|
3963
|
+
}
|
|
3964
|
+
)
|
|
3965
|
+
] }, `dim-${i}`);
|
|
3966
|
+
}
|
|
3967
|
+
var DIE_LINE_BECF_12109 = forwardRef(
|
|
3968
|
+
({
|
|
3969
|
+
attributes,
|
|
3970
|
+
unit = "mm",
|
|
3971
|
+
isShowDimensions = false,
|
|
3972
|
+
renderAs = "svg"
|
|
3973
|
+
}, ref) => {
|
|
3974
|
+
const theme = useMemo(
|
|
3975
|
+
() => getModelTheme(),
|
|
3976
|
+
[]
|
|
3977
|
+
);
|
|
3978
|
+
const svgRef = useRef(null);
|
|
3979
|
+
const dieline = useMemo(() => generateBecf12109(attributes), [attributes]);
|
|
3980
|
+
const dimensions = useMemo(
|
|
3981
|
+
() => generateDimensions6(attributes, unit),
|
|
3982
|
+
[attributes, unit]
|
|
3983
|
+
);
|
|
3984
|
+
const factor = UNIT_FACTOR6[unit] ?? 1;
|
|
3985
|
+
const serializeSvg = useCallback(
|
|
3986
|
+
(showDimensions) => {
|
|
3987
|
+
const svg = svgRef.current;
|
|
3988
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
3989
|
+
const clone = svg.cloneNode(true);
|
|
3990
|
+
if (!showDimensions) {
|
|
3991
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
3992
|
+
dimGroup?.remove();
|
|
3993
|
+
}
|
|
3994
|
+
return new XMLSerializer().serializeToString(clone);
|
|
3995
|
+
},
|
|
3996
|
+
[]
|
|
3997
|
+
);
|
|
3998
|
+
useImperativeHandle(
|
|
3999
|
+
ref,
|
|
4000
|
+
() => {
|
|
4001
|
+
const auto = getAutoCalcValues2(attributes);
|
|
4002
|
+
return {
|
|
4003
|
+
getAttributes: () => ({
|
|
4004
|
+
modelId: MODEL_ID6,
|
|
4005
|
+
overallWidth: dieline.viewBox.width * factor,
|
|
4006
|
+
overallHeight: dieline.viewBox.height * factor,
|
|
4007
|
+
length: attributes.length * factor,
|
|
4008
|
+
width: attributes.width * factor,
|
|
4009
|
+
height: attributes.height * factor,
|
|
4010
|
+
glueArea: auto.kulak * factor,
|
|
4011
|
+
d: auto.d * factor,
|
|
4012
|
+
kulak: auto.kulak * factor,
|
|
4013
|
+
dip: auto.dip * factor,
|
|
4014
|
+
ropeR: auto.ropeR * factor,
|
|
4015
|
+
ropeY: auto.ropeY * factor,
|
|
4016
|
+
ropeX: auto.ropeX * factor
|
|
4017
|
+
}),
|
|
4018
|
+
exportImage: async (options) => {
|
|
4019
|
+
const svgStr = serializeSvg(options.isShowDimension);
|
|
4020
|
+
const blob = new Blob([svgStr], {
|
|
4021
|
+
type: "image/svg+xml;charset=utf-8"
|
|
4022
|
+
});
|
|
4023
|
+
const url = URL.createObjectURL(blob);
|
|
4024
|
+
const img = new Image();
|
|
4025
|
+
await new Promise((resolve, reject) => {
|
|
4026
|
+
img.onload = () => resolve();
|
|
4027
|
+
img.onerror = reject;
|
|
4028
|
+
img.src = url;
|
|
4029
|
+
});
|
|
4030
|
+
const canvas = document.createElement("canvas");
|
|
4031
|
+
if (options.originalSize) {
|
|
4032
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM6);
|
|
4033
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM6);
|
|
4034
|
+
} else {
|
|
4035
|
+
canvas.width = 1920;
|
|
4036
|
+
canvas.height = 1080;
|
|
4037
|
+
}
|
|
4038
|
+
const ctx = canvas.getContext("2d");
|
|
4039
|
+
ctx.fillStyle = "#ffffff";
|
|
4040
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
4041
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
4042
|
+
URL.revokeObjectURL(url);
|
|
4043
|
+
return new Promise((resolve, reject) => {
|
|
4044
|
+
canvas.toBlob(
|
|
4045
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
4046
|
+
"image/png"
|
|
4047
|
+
);
|
|
4048
|
+
});
|
|
4049
|
+
},
|
|
4050
|
+
exportDimension: async () => {
|
|
4051
|
+
const dimData = generateDimensions6(attributes, unit);
|
|
4052
|
+
return exportDimensionPdf({
|
|
4053
|
+
modelId: MODEL_ID6,
|
|
4054
|
+
dieline,
|
|
4055
|
+
dimensions: dimData,
|
|
4056
|
+
attributes,
|
|
4057
|
+
unit,
|
|
4058
|
+
factor,
|
|
4059
|
+
theme
|
|
4060
|
+
});
|
|
4061
|
+
}
|
|
4062
|
+
};
|
|
4063
|
+
},
|
|
4064
|
+
[attributes, dieline, factor, unit, serializeSvg, theme]
|
|
4065
|
+
);
|
|
4066
|
+
const padding = isShowDimensions ? 15 : 0;
|
|
4067
|
+
const vbX = -padding;
|
|
4068
|
+
const vbY = -padding;
|
|
4069
|
+
const vbW = dieline.viewBox.width + padding * 2;
|
|
4070
|
+
const vbH = dieline.viewBox.height + padding * 2;
|
|
4071
|
+
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4072
|
+
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
4073
|
+
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
4074
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension6(d, i, getFontDimensionSize())) })
|
|
4075
|
+
] });
|
|
4076
|
+
if (renderAs === "group") {
|
|
4077
|
+
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
4078
|
+
}
|
|
4079
|
+
return /* @__PURE__ */ jsx(
|
|
4080
|
+
"svg",
|
|
4081
|
+
{
|
|
4082
|
+
ref: svgRef,
|
|
4083
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4084
|
+
viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`,
|
|
4085
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
4086
|
+
style: { backgroundColor: theme.colorBackground },
|
|
4087
|
+
children: svgChildren
|
|
4088
|
+
}
|
|
4089
|
+
);
|
|
4090
|
+
}
|
|
4091
|
+
);
|
|
4092
|
+
var CANVAS_BECF_12109 = forwardRef(
|
|
4093
|
+
(props, ref) => {
|
|
4094
|
+
const dieLineRef = useRef(null);
|
|
4095
|
+
const canvasRef = useRef(null);
|
|
4096
|
+
const {
|
|
4097
|
+
attributes
|
|
4098
|
+
} = props;
|
|
4099
|
+
const theme = useMemo(
|
|
4100
|
+
() => getModelTheme(),
|
|
4101
|
+
[]
|
|
4102
|
+
);
|
|
4103
|
+
const dieline = useMemo(() => generateBecf12109(attributes), [attributes]);
|
|
4104
|
+
const stablePadding = 15;
|
|
4105
|
+
const viewBox = useMemo(
|
|
4106
|
+
() => ({
|
|
4107
|
+
x: -stablePadding,
|
|
4108
|
+
y: -stablePadding,
|
|
4109
|
+
width: dieline.viewBox.width + stablePadding * 2,
|
|
4110
|
+
height: dieline.viewBox.height + stablePadding * 2
|
|
4111
|
+
}),
|
|
4112
|
+
[dieline.viewBox.width, dieline.viewBox.height]
|
|
4113
|
+
);
|
|
4114
|
+
const serializeCanvasSvg = useCallback((showDimensions) => {
|
|
4115
|
+
const svg = canvasRef.current?.getSvgElement();
|
|
4116
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
4117
|
+
const clone = svg.cloneNode(true);
|
|
4118
|
+
if (!showDimensions) {
|
|
4119
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
4120
|
+
dimGroup?.remove();
|
|
4121
|
+
}
|
|
4122
|
+
return new XMLSerializer().serializeToString(clone);
|
|
4123
|
+
}, []);
|
|
4124
|
+
useImperativeHandle(ref, () => ({
|
|
4125
|
+
getAttributes: () => dieLineRef.current.getAttributes(),
|
|
4126
|
+
exportImage: async (options) => {
|
|
4127
|
+
const svgStr = serializeCanvasSvg(options.isShowDimension);
|
|
4128
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
4129
|
+
const url = URL.createObjectURL(blob);
|
|
4130
|
+
const img = new Image();
|
|
4131
|
+
await new Promise((resolve, reject) => {
|
|
4132
|
+
img.onload = () => resolve();
|
|
4133
|
+
img.onerror = reject;
|
|
4134
|
+
img.src = url;
|
|
4135
|
+
});
|
|
4136
|
+
const canvas = document.createElement("canvas");
|
|
4137
|
+
if (options.originalSize) {
|
|
4138
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM6);
|
|
4139
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM6);
|
|
4140
|
+
} else {
|
|
4141
|
+
canvas.width = 1920;
|
|
4142
|
+
canvas.height = 1080;
|
|
4143
|
+
}
|
|
4144
|
+
const ctx = canvas.getContext("2d");
|
|
4145
|
+
ctx.fillStyle = "#ffffff";
|
|
4146
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
4147
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
4148
|
+
URL.revokeObjectURL(url);
|
|
4149
|
+
return new Promise((resolve, reject) => {
|
|
4150
|
+
canvas.toBlob(
|
|
4151
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
4152
|
+
"image/png"
|
|
4153
|
+
);
|
|
4154
|
+
});
|
|
4155
|
+
},
|
|
4156
|
+
exportDimension: () => dieLineRef.current.exportDimension(),
|
|
4157
|
+
resetView: () => canvasRef.current?.resetView(),
|
|
4158
|
+
fitView: () => canvasRef.current?.fitView()
|
|
4159
|
+
}), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
|
|
4160
|
+
return /* @__PURE__ */ jsx(
|
|
4161
|
+
BaseCanvas,
|
|
4162
|
+
{
|
|
4163
|
+
ref: canvasRef,
|
|
4164
|
+
viewBox,
|
|
4165
|
+
backgroundColor: theme.colorBackground,
|
|
4166
|
+
children: /* @__PURE__ */ jsx(DIE_LINE_BECF_12109, { ref: dieLineRef, ...props, renderAs: "group" })
|
|
4167
|
+
}
|
|
4168
|
+
);
|
|
4169
|
+
}
|
|
4170
|
+
);
|
|
4171
|
+
var MODEL_BECF_12109 = forwardRef(
|
|
4172
|
+
({ mode = "DIE_LINE", ...props }, ref) => {
|
|
4173
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (() => {
|
|
4174
|
+
switch (mode) {
|
|
4175
|
+
case "DIE_LINE":
|
|
4176
|
+
return /* @__PURE__ */ jsx(CANVAS_BECF_12109, { ref, ...props });
|
|
4177
|
+
case "3D":
|
|
4178
|
+
return null;
|
|
4179
|
+
case "AUTO_LAYOUT":
|
|
4180
|
+
return /* @__PURE__ */ jsx(DIE_LINE_BECF_12109, { ref, ...props });
|
|
4181
|
+
default:
|
|
4182
|
+
return null;
|
|
4183
|
+
}
|
|
4184
|
+
})() });
|
|
4185
|
+
}
|
|
4186
|
+
);
|
|
4187
|
+
|
|
4188
|
+
// src/utils/autoLayout/rasterize.ts
|
|
4189
|
+
function rasterizePolygon(points, resolution) {
|
|
4190
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4191
|
+
for (const p of points) {
|
|
4192
|
+
if (p.x < minX) minX = p.x;
|
|
4193
|
+
if (p.y < minY) minY = p.y;
|
|
4194
|
+
if (p.x > maxX) maxX = p.x;
|
|
4195
|
+
if (p.y > maxY) maxY = p.y;
|
|
4196
|
+
}
|
|
4197
|
+
const offsetX = Math.floor(minX / resolution);
|
|
4198
|
+
const offsetY = Math.floor(minY / resolution);
|
|
4199
|
+
const w = Math.ceil((maxX - offsetX * resolution) / resolution) + 1;
|
|
4200
|
+
const h = Math.ceil((maxY - offsetY * resolution) / resolution) + 1;
|
|
4201
|
+
const data = new Uint8Array(w * h);
|
|
4202
|
+
for (let gy = 0; gy < h; gy++) {
|
|
4203
|
+
const worldY = (offsetY + gy) * resolution + resolution / 2;
|
|
4204
|
+
const crossings = [];
|
|
4205
|
+
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
|
|
4206
|
+
const yi = points[i].y, yj = points[j].y;
|
|
4207
|
+
if (yi <= worldY && yj > worldY || yj <= worldY && yi > worldY) {
|
|
4208
|
+
const t = (worldY - yi) / (yj - yi);
|
|
4209
|
+
crossings.push(points[i].x + t * (points[j].x - points[i].x));
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
crossings.sort((a, b) => a - b);
|
|
4213
|
+
for (let c = 0; c < crossings.length - 1; c += 2) {
|
|
4214
|
+
const startGx = Math.max(0, Math.floor((crossings[c] - offsetX * resolution) / resolution));
|
|
4215
|
+
const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
|
|
4216
|
+
for (let gx = startGx; gx <= endGx; gx++) {
|
|
4217
|
+
data[gy * w + gx] = 1;
|
|
4218
|
+
}
|
|
4219
|
+
}
|
|
4220
|
+
}
|
|
4221
|
+
return { data, width: w, height: h, offsetX, offsetY };
|
|
4222
|
+
}
|
|
4223
|
+
function canPlace(paperGrid, paperW, paperH, piece, px, py) {
|
|
4224
|
+
for (let y = 0; y < piece.height; y++) {
|
|
4225
|
+
const paperY = py + y;
|
|
4226
|
+
if (paperY < 0 || paperY >= paperH) {
|
|
4227
|
+
for (let x = 0; x < piece.width; x++) {
|
|
4228
|
+
if (piece.data[y * piece.width + x]) return false;
|
|
4229
|
+
}
|
|
4230
|
+
continue;
|
|
4231
|
+
}
|
|
4232
|
+
for (let x = 0; x < piece.width; x++) {
|
|
4233
|
+
if (!piece.data[y * piece.width + x]) continue;
|
|
4234
|
+
const paperX = px + x;
|
|
4235
|
+
if (paperX < 0 || paperX >= paperW) return false;
|
|
4236
|
+
if (paperGrid[paperY * paperW + paperX]) return false;
|
|
4237
|
+
}
|
|
4238
|
+
}
|
|
4239
|
+
return true;
|
|
4240
|
+
}
|
|
4241
|
+
function placePiece(paperGrid, paperW, piece, px, py) {
|
|
4242
|
+
for (let y = 0; y < piece.height; y++) {
|
|
4243
|
+
for (let x = 0; x < piece.width; x++) {
|
|
4244
|
+
if (piece.data[y * piece.width + x]) {
|
|
4245
|
+
paperGrid[(py + y) * paperW + (px + x)] = 1;
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
}
|
|
4250
|
+
|
|
4251
|
+
// src/utils/autoLayout/calculate/shared.ts
|
|
4252
|
+
var RESOLUTION = 1;
|
|
4253
|
+
function resolveGripperSide(paperWidth, paperHeight) {
|
|
4254
|
+
if (paperWidth >= paperHeight) return "bottom";
|
|
4255
|
+
return "left";
|
|
4256
|
+
}
|
|
4257
|
+
function computeUsableBounds(paperWidth, paperHeight, gripperSide, spacing, griper, colorbarDepth) {
|
|
4258
|
+
switch (gripperSide) {
|
|
4259
|
+
case "bottom":
|
|
4260
|
+
return {
|
|
4261
|
+
top: colorbarDepth + spacing,
|
|
4262
|
+
bottom: paperHeight - griper,
|
|
4263
|
+
left: spacing,
|
|
4264
|
+
right: paperWidth - spacing
|
|
4265
|
+
};
|
|
4266
|
+
case "top":
|
|
4267
|
+
return {
|
|
4268
|
+
top: griper,
|
|
4269
|
+
bottom: paperHeight - colorbarDepth - spacing,
|
|
4270
|
+
left: spacing,
|
|
4271
|
+
right: paperWidth - spacing
|
|
4272
|
+
};
|
|
4273
|
+
case "left":
|
|
4274
|
+
return {
|
|
4275
|
+
top: spacing,
|
|
4276
|
+
bottom: paperHeight - spacing,
|
|
4277
|
+
left: griper,
|
|
4278
|
+
right: paperWidth - colorbarDepth - spacing
|
|
4279
|
+
};
|
|
4280
|
+
case "right":
|
|
4281
|
+
return {
|
|
4282
|
+
top: spacing,
|
|
4283
|
+
bottom: paperHeight - spacing,
|
|
4284
|
+
left: colorbarDepth + spacing,
|
|
4285
|
+
right: paperWidth - griper
|
|
4286
|
+
};
|
|
4287
|
+
}
|
|
4288
|
+
}
|
|
4289
|
+
function normalizePoints(points, degrees) {
|
|
4290
|
+
const rad = degrees * Math.PI / 180;
|
|
4291
|
+
const cos = Math.cos(rad);
|
|
4292
|
+
const sin = Math.sin(rad);
|
|
4293
|
+
const rotated = points.map((p) => ({
|
|
4294
|
+
x: p.x * cos - p.y * sin,
|
|
4295
|
+
y: p.x * sin + p.y * cos
|
|
4296
|
+
}));
|
|
4297
|
+
let minX = Infinity, minY = Infinity;
|
|
4298
|
+
for (const p of rotated) {
|
|
4299
|
+
if (p.x < minX) minX = p.x;
|
|
4300
|
+
if (p.y < minY) minY = p.y;
|
|
4301
|
+
}
|
|
4302
|
+
return rotated.map((p) => ({ x: p.x - minX, y: p.y - minY }));
|
|
4303
|
+
}
|
|
4304
|
+
function computeDielineBBOffset(offsetContourPoints, dielineW, dielineH, degrees) {
|
|
4305
|
+
const rad = degrees * Math.PI / 180;
|
|
4306
|
+
const cos = Math.cos(rad);
|
|
4307
|
+
const sin = Math.sin(rad);
|
|
4308
|
+
let ocMinX = Infinity, ocMinY = Infinity;
|
|
4309
|
+
for (const p of offsetContourPoints) {
|
|
4310
|
+
const rx = p.x * cos - p.y * sin;
|
|
3256
4311
|
const ry = p.x * sin + p.y * cos;
|
|
3257
4312
|
if (rx < ocMinX) ocMinX = rx;
|
|
3258
4313
|
if (ry < ocMinY) ocMinY = ry;
|
|
3259
4314
|
}
|
|
3260
|
-
const corners = [[0, 0], [dielineW, 0], [0, dielineH], [dielineW, dielineH]];
|
|
3261
|
-
let dlMinX = Infinity, dlMinY = Infinity;
|
|
3262
|
-
for (const [cx, cy] of corners) {
|
|
3263
|
-
const rx = cx * cos - cy * sin;
|
|
3264
|
-
const ry = cx * sin + cy * cos;
|
|
3265
|
-
if (rx < dlMinX) dlMinX = rx;
|
|
3266
|
-
if (ry < dlMinY) dlMinY = ry;
|
|
4315
|
+
const corners = [[0, 0], [dielineW, 0], [0, dielineH], [dielineW, dielineH]];
|
|
4316
|
+
let dlMinX = Infinity, dlMinY = Infinity;
|
|
4317
|
+
for (const [cx, cy] of corners) {
|
|
4318
|
+
const rx = cx * cos - cy * sin;
|
|
4319
|
+
const ry = cx * sin + cy * cos;
|
|
4320
|
+
if (rx < dlMinX) dlMinX = rx;
|
|
4321
|
+
if (ry < dlMinY) dlMinY = ry;
|
|
4322
|
+
}
|
|
4323
|
+
return { dx: dlMinX - ocMinX, dy: dlMinY - ocMinY };
|
|
4324
|
+
}
|
|
4325
|
+
function computeLayoutForPaperDefault(contourPoints, dielineW, dielineH, paperWidth, paperHeight, bounds) {
|
|
4326
|
+
const usableLeft = Math.ceil(bounds.left / RESOLUTION);
|
|
4327
|
+
const usableTop = Math.ceil(bounds.top / RESOLUTION);
|
|
4328
|
+
const usableRight = Math.floor(bounds.right / RESOLUTION);
|
|
4329
|
+
const usableBottom = Math.floor(bounds.bottom / RESOLUTION);
|
|
4330
|
+
const paperW = Math.floor(paperWidth / RESOLUTION);
|
|
4331
|
+
const paperH = Math.floor(paperHeight / RESOLUTION);
|
|
4332
|
+
let bestCandidate = { rotation: 0, placements: [], producedPerSheet: 0 };
|
|
4333
|
+
let bestGridPositions = [];
|
|
4334
|
+
let bestBitmapW = 0;
|
|
4335
|
+
let bestBitmapH = 0;
|
|
4336
|
+
for (const deg of [0, 90, 180, 270]) {
|
|
4337
|
+
const rotatedContour = normalizePoints(contourPoints, deg);
|
|
4338
|
+
const pieceBitmap = rasterizePolygon(rotatedContour, RESOLUTION);
|
|
4339
|
+
const bbOffset = computeDielineBBOffset(contourPoints, dielineW, dielineH, deg);
|
|
4340
|
+
const paperGrid = new Uint8Array(paperW * paperH);
|
|
4341
|
+
const placements = [];
|
|
4342
|
+
const gridPositions = [];
|
|
4343
|
+
for (let py = usableTop; py <= usableBottom - pieceBitmap.height; py++) {
|
|
4344
|
+
for (let px = usableLeft; px <= usableRight - pieceBitmap.width; px++) {
|
|
4345
|
+
if (canPlace(paperGrid, paperW, paperH, pieceBitmap, px, py)) {
|
|
4346
|
+
placePiece(paperGrid, paperW, pieceBitmap, px, py);
|
|
4347
|
+
gridPositions.push({ px, py });
|
|
4348
|
+
placements.push({
|
|
4349
|
+
x: px * RESOLUTION + bbOffset.dx,
|
|
4350
|
+
y: py * RESOLUTION + bbOffset.dy,
|
|
4351
|
+
rotation: deg
|
|
4352
|
+
});
|
|
4353
|
+
}
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
4356
|
+
if (placements.length > bestCandidate.producedPerSheet) {
|
|
4357
|
+
bestCandidate = { rotation: deg, placements, producedPerSheet: placements.length };
|
|
4358
|
+
bestGridPositions = gridPositions;
|
|
4359
|
+
bestBitmapW = pieceBitmap.width;
|
|
4360
|
+
bestBitmapH = pieceBitmap.height;
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
if (bestCandidate.placements.length > 0) {
|
|
4364
|
+
let gridMinX = Infinity;
|
|
4365
|
+
let gridMinY = Infinity;
|
|
4366
|
+
let gridMaxX = -Infinity;
|
|
4367
|
+
let gridMaxY = -Infinity;
|
|
4368
|
+
for (const { px, py } of bestGridPositions) {
|
|
4369
|
+
if (px < gridMinX) gridMinX = px;
|
|
4370
|
+
if (py < gridMinY) gridMinY = py;
|
|
4371
|
+
if (px + bestBitmapW > gridMaxX) gridMaxX = px + bestBitmapW;
|
|
4372
|
+
if (py + bestBitmapH > gridMaxY) gridMaxY = py + bestBitmapH;
|
|
4373
|
+
}
|
|
4374
|
+
const groupW = gridMaxX - gridMinX;
|
|
4375
|
+
const groupH = gridMaxY - gridMinY;
|
|
4376
|
+
const usableW = usableRight - usableLeft;
|
|
4377
|
+
const usableH = usableBottom - usableTop;
|
|
4378
|
+
const offsetX = ((usableW - groupW) / 2 - (gridMinX - usableLeft)) * RESOLUTION;
|
|
4379
|
+
const offsetY = ((usableH - groupH) / 2 - (gridMinY - usableTop)) * RESOLUTION;
|
|
4380
|
+
for (const p of bestCandidate.placements) {
|
|
4381
|
+
p.x += offsetX;
|
|
4382
|
+
p.y += offsetY;
|
|
4383
|
+
}
|
|
4384
|
+
}
|
|
4385
|
+
return bestCandidate;
|
|
4386
|
+
}
|
|
4387
|
+
|
|
4388
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1010a/index.ts
|
|
4389
|
+
var SAMPLE_STEP = 0.1;
|
|
4390
|
+
function buildProfile(points) {
|
|
4391
|
+
let maxX = 0, maxY = 0;
|
|
4392
|
+
for (const p of points) {
|
|
4393
|
+
if (p.x > maxX) maxX = p.x;
|
|
4394
|
+
if (p.y > maxY) maxY = p.y;
|
|
4395
|
+
}
|
|
4396
|
+
const width = maxX, height = maxY;
|
|
4397
|
+
const nY = Math.ceil(height / SAMPLE_STEP) + 1;
|
|
4398
|
+
const nX = Math.ceil(width / SAMPLE_STEP) + 1;
|
|
4399
|
+
const rightX = new Float64Array(nY).fill(-Infinity);
|
|
4400
|
+
const leftX = new Float64Array(nY).fill(Infinity);
|
|
4401
|
+
const bottomY = new Float64Array(nX).fill(-Infinity);
|
|
4402
|
+
const topY = new Float64Array(nX).fill(Infinity);
|
|
4403
|
+
const nPts = points.length;
|
|
4404
|
+
for (let iy = 0; iy < nY; iy++) {
|
|
4405
|
+
const y = iy * SAMPLE_STEP;
|
|
4406
|
+
for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
|
|
4407
|
+
const yj = points[j].y, yk = points[k].y;
|
|
4408
|
+
if (yj <= y && yk > y || yk <= y && yj > y) {
|
|
4409
|
+
const t = (y - yj) / (yk - yj);
|
|
4410
|
+
const x = points[j].x + t * (points[k].x - points[j].x);
|
|
4411
|
+
if (x > rightX[iy]) rightX[iy] = x;
|
|
4412
|
+
if (x < leftX[iy]) leftX[iy] = x;
|
|
4413
|
+
}
|
|
4414
|
+
}
|
|
4415
|
+
}
|
|
4416
|
+
for (let ix = 0; ix < nX; ix++) {
|
|
4417
|
+
const x = ix * SAMPLE_STEP;
|
|
4418
|
+
for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
|
|
4419
|
+
const xj = points[j].x, xk = points[k].x;
|
|
4420
|
+
if (xj <= x && xk > x || xk <= x && xj > x) {
|
|
4421
|
+
const t = (x - xj) / (xk - xj);
|
|
4422
|
+
const y = points[j].y + t * (points[k].y - points[j].y);
|
|
4423
|
+
if (y > bottomY[ix]) bottomY[ix] = y;
|
|
4424
|
+
if (y < topY[ix]) topY[ix] = y;
|
|
4425
|
+
}
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
return { width, height, nY, nX, rightX, leftX, bottomY, topY };
|
|
4429
|
+
}
|
|
4430
|
+
function prepareRotation(contourPoints, dielineW, dielineH, deg) {
|
|
4431
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
4432
|
+
return {
|
|
4433
|
+
profile: buildProfile(rotated),
|
|
4434
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
4435
|
+
deg
|
|
4436
|
+
};
|
|
4437
|
+
}
|
|
4438
|
+
function findMinStepX(a, b, dyMm) {
|
|
4439
|
+
const dySamples = Math.round(dyMm / SAMPLE_STEP);
|
|
4440
|
+
let maxOverlap = -Infinity;
|
|
4441
|
+
for (let ia = 0; ia < a.nY; ia++) {
|
|
4442
|
+
const ib = ia - dySamples;
|
|
4443
|
+
if (ib < 0 || ib >= b.nY) continue;
|
|
4444
|
+
if (a.rightX[ia] === -Infinity || b.leftX[ib] === Infinity) continue;
|
|
4445
|
+
const overlap = a.rightX[ia] - b.leftX[ib];
|
|
4446
|
+
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
4447
|
+
}
|
|
4448
|
+
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
4449
|
+
}
|
|
4450
|
+
function findMinStepY(a, b, dxMm) {
|
|
4451
|
+
const dxSamples = Math.round(dxMm / SAMPLE_STEP);
|
|
4452
|
+
let maxOverlap = -Infinity;
|
|
4453
|
+
for (let ia = 0; ia < a.nX; ia++) {
|
|
4454
|
+
const ib = ia - dxSamples;
|
|
4455
|
+
if (ib < 0 || ib >= b.nX) continue;
|
|
4456
|
+
if (a.bottomY[ia] === -Infinity || b.topY[ib] === Infinity) continue;
|
|
4457
|
+
const overlap = a.bottomY[ia] - b.topY[ib];
|
|
4458
|
+
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
4459
|
+
}
|
|
4460
|
+
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
4461
|
+
}
|
|
4462
|
+
function findMinStepY_multi(profA, stepX_A, profB, offsetX) {
|
|
4463
|
+
const reach = Math.max(profA.width, profB.width);
|
|
4464
|
+
let maxStep = 0;
|
|
4465
|
+
const nMin = Math.floor((offsetX - reach) / stepX_A);
|
|
4466
|
+
const nMax = Math.ceil((offsetX + reach) / stepX_A);
|
|
4467
|
+
for (let n = nMin; n <= nMax; n++) {
|
|
4468
|
+
const s = findMinStepY(profA, profB, offsetX - n * stepX_A);
|
|
4469
|
+
if (s > maxStep) maxStep = s;
|
|
4470
|
+
}
|
|
4471
|
+
return maxStep;
|
|
4472
|
+
}
|
|
4473
|
+
function emptyResult() {
|
|
4474
|
+
return { placements: [], count: 0, minX: 0, minY: 0, maxX: 0, maxY: 0 };
|
|
4475
|
+
}
|
|
4476
|
+
function singleRotGrid(rd, bounds) {
|
|
4477
|
+
const p = rd.profile;
|
|
4478
|
+
const stepX = findMinStepX(p, p, 0);
|
|
4479
|
+
const stepY = findMinStepY(p, p, 0);
|
|
4480
|
+
if (stepX <= 0 || stepY <= 0) return emptyResult();
|
|
4481
|
+
const cols = Math.max(0, Math.floor((bounds.right - bounds.left - p.width) / stepX) + 1);
|
|
4482
|
+
const rows = Math.max(0, Math.floor((bounds.bottom - bounds.top - p.height) / stepY) + 1);
|
|
4483
|
+
if (cols === 0 || rows === 0) return emptyResult();
|
|
4484
|
+
const placements = [];
|
|
4485
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4486
|
+
for (let r = 0; r < rows; r++) {
|
|
4487
|
+
for (let c = 0; c < cols; c++) {
|
|
4488
|
+
const ox = bounds.left + c * stepX;
|
|
4489
|
+
const oy = bounds.top + r * stepY;
|
|
4490
|
+
placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
|
|
4491
|
+
if (ox < minX) minX = ox;
|
|
4492
|
+
if (oy < minY) minY = oy;
|
|
4493
|
+
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
4494
|
+
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
4495
|
+
}
|
|
4496
|
+
}
|
|
4497
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4498
|
+
}
|
|
4499
|
+
function dualRotGrid(rdA, rdB, offsetX, bounds) {
|
|
4500
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
4501
|
+
const stepX_A = findMinStepX(pA, pA, 0);
|
|
4502
|
+
const stepX_B = findMinStepX(pB, pB, 0);
|
|
4503
|
+
if (stepX_A <= 0 || stepX_B <= 0) return emptyResult();
|
|
4504
|
+
const stepY_AB = findMinStepY_multi(pA, stepX_A, pB, offsetX);
|
|
4505
|
+
const stepY_BA = findMinStepY_multi(pB, stepX_B, pA, -offsetX);
|
|
4506
|
+
if (stepY_AB + stepY_BA <= 0) return emptyResult();
|
|
4507
|
+
const placements = [];
|
|
4508
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4509
|
+
let oy = bounds.top;
|
|
4510
|
+
let isRowA = true;
|
|
4511
|
+
while (true) {
|
|
4512
|
+
const rd = isRowA ? rdA : rdB;
|
|
4513
|
+
const p = rd.profile;
|
|
4514
|
+
const stepX = isRowA ? stepX_A : stepX_B;
|
|
4515
|
+
if (oy + p.height > bounds.bottom) break;
|
|
4516
|
+
let sx = isRowA ? bounds.left : bounds.left + offsetX;
|
|
4517
|
+
if (sx < bounds.left) sx += stepX * Math.ceil((bounds.left - sx) / stepX);
|
|
4518
|
+
for (let ox = sx; ox + p.width <= bounds.right; ox += stepX) {
|
|
4519
|
+
placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
|
|
4520
|
+
if (ox < minX) minX = ox;
|
|
4521
|
+
if (oy < minY) minY = oy;
|
|
4522
|
+
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
4523
|
+
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
4524
|
+
}
|
|
4525
|
+
oy += isRowA ? stepY_AB : stepY_BA;
|
|
4526
|
+
isRowA = !isRowA;
|
|
4527
|
+
}
|
|
4528
|
+
if (placements.length === 0) return emptyResult();
|
|
4529
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4530
|
+
}
|
|
4531
|
+
function centerLayout(result, bounds) {
|
|
4532
|
+
if (result.count === 0) return;
|
|
4533
|
+
const offX = (bounds.right - bounds.left - (result.maxX - result.minX)) / 2 - (result.minX - bounds.left);
|
|
4534
|
+
const offY = (bounds.bottom - bounds.top - (result.maxY - result.minY)) / 2 - (result.minY - bounds.top);
|
|
4535
|
+
for (const p of result.placements) {
|
|
4536
|
+
p.x += offX;
|
|
4537
|
+
p.y += offY;
|
|
4538
|
+
}
|
|
4539
|
+
}
|
|
4540
|
+
function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4541
|
+
const rots = [0, 90, 180, 270];
|
|
4542
|
+
const rd = /* @__PURE__ */ new Map();
|
|
4543
|
+
for (const deg of rots) {
|
|
4544
|
+
rd.set(deg, prepareRotation(contourPoints, dielineW, dielineH, deg));
|
|
4545
|
+
}
|
|
4546
|
+
const results = [];
|
|
4547
|
+
for (const deg of rots) {
|
|
4548
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
4549
|
+
}
|
|
4550
|
+
const pairs = [
|
|
4551
|
+
[0, 180],
|
|
4552
|
+
[90, 270],
|
|
4553
|
+
[0, 90],
|
|
4554
|
+
[0, 270],
|
|
4555
|
+
[90, 180],
|
|
4556
|
+
[180, 270]
|
|
4557
|
+
];
|
|
4558
|
+
for (const [a, b] of pairs) {
|
|
4559
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
4560
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
4561
|
+
if (stepA <= 0) continue;
|
|
4562
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
4563
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
4564
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
4565
|
+
}
|
|
4566
|
+
}
|
|
4567
|
+
let best = results[0];
|
|
4568
|
+
for (const r of results) {
|
|
4569
|
+
if (r.count > best.count) best = r;
|
|
4570
|
+
}
|
|
4571
|
+
centerLayout(best, bounds);
|
|
4572
|
+
return {
|
|
4573
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
4574
|
+
placements: best.placements,
|
|
4575
|
+
producedPerSheet: best.count
|
|
4576
|
+
};
|
|
4577
|
+
}
|
|
4578
|
+
|
|
4579
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1030a/index.ts
|
|
4580
|
+
function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
|
|
4581
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
4582
|
+
return {
|
|
4583
|
+
profile: buildProfile(rotated),
|
|
4584
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
4585
|
+
deg
|
|
4586
|
+
};
|
|
4587
|
+
}
|
|
4588
|
+
function pairGrid(rdA, rdB, bounds) {
|
|
4589
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
4590
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
4591
|
+
if (gapAB <= 0) return emptyResult();
|
|
4592
|
+
const pairW = gapAB + pB.width;
|
|
4593
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
4594
|
+
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
4595
|
+
const pairStepY = Math.max(
|
|
4596
|
+
findMinStepY(pA, pA, 0),
|
|
4597
|
+
findMinStepY(pA, pB, gapAB),
|
|
4598
|
+
findMinStepY(pB, pA, -gapAB),
|
|
4599
|
+
findMinStepY(pB, pB, 0)
|
|
4600
|
+
);
|
|
4601
|
+
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
4602
|
+
const usableW = bounds.right - bounds.left;
|
|
4603
|
+
const usableH = bounds.bottom - bounds.top;
|
|
4604
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
4605
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
4606
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
4607
|
+
const placements = [];
|
|
4608
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4609
|
+
for (let r = 0; r < pairRows; r++) {
|
|
4610
|
+
for (let c = 0; c < pairCols; c++) {
|
|
4611
|
+
const baseX = bounds.left + c * pairStepX;
|
|
4612
|
+
const baseY = bounds.top + r * pairStepY;
|
|
4613
|
+
const oxA = baseX;
|
|
4614
|
+
const oyA = baseY;
|
|
4615
|
+
placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
4616
|
+
if (oxA < minX) minX = oxA;
|
|
4617
|
+
if (oyA < minY) minY = oyA;
|
|
4618
|
+
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
4619
|
+
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
4620
|
+
const oxB = baseX + gapAB;
|
|
4621
|
+
const oyB = baseY;
|
|
4622
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
4623
|
+
if (oxB < minX) minX = oxB;
|
|
4624
|
+
if (oyB < minY) minY = oyB;
|
|
4625
|
+
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
4626
|
+
if (oyB + pB.height > maxY) maxY = oyB + pB.height;
|
|
4627
|
+
}
|
|
3267
4628
|
}
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
const
|
|
3272
|
-
const
|
|
3273
|
-
const
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
const rotatedContour = normalizePoints(contourPoints, deg);
|
|
3283
|
-
const pieceBitmap = rasterizePolygon(rotatedContour, RESOLUTION);
|
|
3284
|
-
const bbOffset = computeDielineBBOffset(contourPoints, dielineW, dielineH, deg);
|
|
3285
|
-
const paperGrid = new Uint8Array(paperW * paperH);
|
|
3286
|
-
const placements = [];
|
|
3287
|
-
const gridPositions = [];
|
|
3288
|
-
for (let py = usableTop; py <= usableBottom - pieceBitmap.height; py++) {
|
|
3289
|
-
for (let px = usableLeft; px <= usableRight - pieceBitmap.width; px++) {
|
|
3290
|
-
if (canPlace(paperGrid, paperW, paperH, pieceBitmap, px, py)) {
|
|
3291
|
-
placePiece(paperGrid, paperW, pieceBitmap, px, py);
|
|
3292
|
-
gridPositions.push({ px, py });
|
|
3293
|
-
placements.push({
|
|
3294
|
-
x: px * RESOLUTION + bbOffset.dx,
|
|
3295
|
-
y: py * RESOLUTION + bbOffset.dy,
|
|
3296
|
-
rotation: deg
|
|
3297
|
-
});
|
|
4629
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
4630
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
4631
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
4632
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
4633
|
+
const extraRotations = [rdA, rdB];
|
|
4634
|
+
for (const rdExtra of extraRotations) {
|
|
4635
|
+
const pe = rdExtra.profile;
|
|
4636
|
+
if (pe.width <= gapRight) {
|
|
4637
|
+
for (let r = 0; r < pairRows; r++) {
|
|
4638
|
+
const ox = pairsRightEdge;
|
|
4639
|
+
const oy = bounds.top + r * pairStepY;
|
|
4640
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4641
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4642
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
3298
4643
|
}
|
|
3299
4644
|
}
|
|
4645
|
+
break;
|
|
3300
4646
|
}
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
4647
|
+
}
|
|
4648
|
+
for (const rdExtra of extraRotations) {
|
|
4649
|
+
const pe = rdExtra.profile;
|
|
4650
|
+
if (pe.height <= gapBottom) {
|
|
4651
|
+
for (let c = 0; c < pairCols; c++) {
|
|
4652
|
+
const oxA = bounds.left + c * pairStepX;
|
|
4653
|
+
const oy = pairsBottomEdge;
|
|
4654
|
+
if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4655
|
+
placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4656
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
4657
|
+
}
|
|
4658
|
+
}
|
|
4659
|
+
break;
|
|
3306
4660
|
}
|
|
3307
4661
|
}
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
4662
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4663
|
+
}
|
|
4664
|
+
function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4665
|
+
const rots = [0, 90, 180, 270];
|
|
4666
|
+
const rd = /* @__PURE__ */ new Map();
|
|
4667
|
+
for (const deg of rots) {
|
|
4668
|
+
rd.set(deg, prepareRotation2(contourPoints, dielineW, dielineH, deg));
|
|
4669
|
+
}
|
|
4670
|
+
const results = [];
|
|
4671
|
+
for (const deg of rots) {
|
|
4672
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
4673
|
+
}
|
|
4674
|
+
const allPairs = [
|
|
4675
|
+
[0, 180],
|
|
4676
|
+
[90, 270],
|
|
4677
|
+
[0, 90],
|
|
4678
|
+
[0, 270],
|
|
4679
|
+
[90, 180],
|
|
4680
|
+
[180, 270]
|
|
4681
|
+
];
|
|
4682
|
+
for (const [a, b] of allPairs) {
|
|
4683
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
4684
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
4685
|
+
if (stepA <= 0) continue;
|
|
4686
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
4687
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
4688
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
3318
4689
|
}
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
4690
|
+
}
|
|
4691
|
+
for (const [a, b] of allPairs) {
|
|
4692
|
+
results.push(pairGrid(rd.get(a), rd.get(b), bounds));
|
|
4693
|
+
results.push(pairGrid(rd.get(b), rd.get(a), bounds));
|
|
4694
|
+
}
|
|
4695
|
+
const singleResults = [];
|
|
4696
|
+
const multiResults = [];
|
|
4697
|
+
for (const r of results) {
|
|
4698
|
+
if (r.count === 0) continue;
|
|
4699
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
4700
|
+
if (rotations.size > 1) {
|
|
4701
|
+
multiResults.push(r);
|
|
4702
|
+
} else {
|
|
4703
|
+
singleResults.push(r);
|
|
3328
4704
|
}
|
|
3329
4705
|
}
|
|
3330
|
-
|
|
4706
|
+
function pickBest(arr) {
|
|
4707
|
+
let b = arr[0] ?? emptyResult();
|
|
4708
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
4709
|
+
for (const r of arr) {
|
|
4710
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
4711
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
4712
|
+
b = r;
|
|
4713
|
+
bArea = area;
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
return b;
|
|
4717
|
+
}
|
|
4718
|
+
const bestSingle = pickBest(singleResults);
|
|
4719
|
+
const bestMulti = pickBest(multiResults);
|
|
4720
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
4721
|
+
centerLayout(best, bounds);
|
|
4722
|
+
return {
|
|
4723
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
4724
|
+
placements: best.placements,
|
|
4725
|
+
producedPerSheet: best.count
|
|
4726
|
+
};
|
|
3331
4727
|
}
|
|
3332
4728
|
|
|
3333
|
-
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
4729
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1040a/index.ts
|
|
4730
|
+
function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
|
|
4731
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
4732
|
+
return {
|
|
4733
|
+
profile: buildProfile(rotated),
|
|
4734
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
4735
|
+
deg
|
|
4736
|
+
};
|
|
4737
|
+
}
|
|
4738
|
+
function findPairRowStepY(pA, pB, gapAB, pairStepX) {
|
|
4739
|
+
const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
|
|
4740
|
+
const nMin = Math.floor(-reach / pairStepX) - 1;
|
|
4741
|
+
const nMax = Math.ceil(reach / pairStepX) + 1;
|
|
4742
|
+
let maxStep = 0;
|
|
4743
|
+
for (let n = nMin; n <= nMax; n++) {
|
|
4744
|
+
const dx = n * pairStepX;
|
|
4745
|
+
const s1 = findMinStepY(pA, pA, dx);
|
|
4746
|
+
if (s1 > maxStep) maxStep = s1;
|
|
4747
|
+
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
4748
|
+
if (s2 > maxStep) maxStep = s2;
|
|
4749
|
+
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
4750
|
+
if (s3 > maxStep) maxStep = s3;
|
|
4751
|
+
const s4 = findMinStepY(pB, pB, dx);
|
|
4752
|
+
if (s4 > maxStep) maxStep = s4;
|
|
3340
4753
|
}
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
const
|
|
3345
|
-
const
|
|
3346
|
-
|
|
3347
|
-
const
|
|
3348
|
-
const
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
4754
|
+
return maxStep;
|
|
4755
|
+
}
|
|
4756
|
+
function pairGrid2(rdA, rdB, bounds) {
|
|
4757
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
4758
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
4759
|
+
if (gapAB <= 0) return emptyResult();
|
|
4760
|
+
const pairW = gapAB + pB.width;
|
|
4761
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
4762
|
+
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
4763
|
+
if (pairStepX <= 0) return emptyResult();
|
|
4764
|
+
const pairStepY = findPairRowStepY(pA, pB, gapAB, pairStepX);
|
|
4765
|
+
if (pairStepY <= 0) return emptyResult();
|
|
4766
|
+
const usableW = bounds.right - bounds.left;
|
|
4767
|
+
const usableH = bounds.bottom - bounds.top;
|
|
4768
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
4769
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
4770
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
4771
|
+
const placements = [];
|
|
4772
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4773
|
+
for (let r = 0; r < pairRows; r++) {
|
|
4774
|
+
for (let c = 0; c < pairCols; c++) {
|
|
4775
|
+
const baseX = bounds.left + c * pairStepX;
|
|
4776
|
+
const baseY = bounds.top + r * pairStepY;
|
|
4777
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
4778
|
+
if (baseX < minX) minX = baseX;
|
|
4779
|
+
if (baseY < minY) minY = baseY;
|
|
4780
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
4781
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
4782
|
+
const bx = baseX + gapAB;
|
|
4783
|
+
placements.push({ x: bx + rdB.bbOffset.dx, y: baseY + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
4784
|
+
if (bx < minX) minX = bx;
|
|
4785
|
+
if (bx + pB.width > maxX) maxX = bx + pB.width;
|
|
4786
|
+
if (baseY + pB.height > maxY) maxY = baseY + pB.height;
|
|
3359
4787
|
}
|
|
3360
4788
|
}
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
4789
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
4790
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
4791
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
4792
|
+
const pe = rdExtra.profile;
|
|
4793
|
+
if (pe.width > gapRight) continue;
|
|
4794
|
+
const dxFromB = pairsRightEdge - (bounds.left + (pairCols - 1) * pairStepX + gapAB);
|
|
4795
|
+
const dxFromA = pairsRightEdge - bounds.left - (pairCols - 1) * pairStepX;
|
|
4796
|
+
const extraStepY = Math.max(
|
|
4797
|
+
findMinStepY(pA, pe, dxFromA),
|
|
4798
|
+
findMinStepY(pB, pe, dxFromB),
|
|
4799
|
+
findMinStepY(pe, pe, 0)
|
|
4800
|
+
);
|
|
4801
|
+
if (extraStepY <= 0) continue;
|
|
4802
|
+
const effectiveStepY = Math.max(pairStepY, extraStepY);
|
|
4803
|
+
const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
|
|
4804
|
+
for (let r = 0; r < extraRows; r++) {
|
|
4805
|
+
const ox = pairsRightEdge;
|
|
4806
|
+
const oy = bounds.top + r * effectiveStepY;
|
|
4807
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4808
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4809
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
4810
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
3370
4811
|
}
|
|
3371
4812
|
}
|
|
4813
|
+
break;
|
|
3372
4814
|
}
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
function findMinStepY(a, b, dxMm) {
|
|
3396
|
-
const dxSamples = Math.round(dxMm / SAMPLE_STEP);
|
|
3397
|
-
let maxOverlap = -Infinity;
|
|
3398
|
-
for (let ia = 0; ia < a.nX; ia++) {
|
|
3399
|
-
const ib = ia - dxSamples;
|
|
3400
|
-
if (ib < 0 || ib >= b.nX) continue;
|
|
3401
|
-
if (a.bottomY[ia] === -Infinity || b.topY[ib] === Infinity) continue;
|
|
3402
|
-
const overlap = a.bottomY[ia] - b.topY[ib];
|
|
3403
|
-
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
4815
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
4816
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
4817
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
4818
|
+
const pe = rdExtra.profile;
|
|
4819
|
+
if (pe.height > gapBottom) continue;
|
|
4820
|
+
const extraStepX = findMinStepX(pe, pe, 0);
|
|
4821
|
+
if (extraStepX <= 0) continue;
|
|
4822
|
+
const dyFromPairRow = pairsBottomEdge - (bounds.top + (pairRows - 1) * pairStepY);
|
|
4823
|
+
const stepFromA = findMinStepY(pA, pe, 0);
|
|
4824
|
+
const stepFromB = findMinStepY(pB, pe, gapAB);
|
|
4825
|
+
if (dyFromPairRow < stepFromA || dyFromPairRow < stepFromB) continue;
|
|
4826
|
+
const extraCols = Math.max(0, Math.floor((usableW - pe.width) / extraStepX) + 1);
|
|
4827
|
+
for (let c = 0; c < extraCols; c++) {
|
|
4828
|
+
const ox = bounds.left + c * extraStepX;
|
|
4829
|
+
const oy = pairsBottomEdge;
|
|
4830
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4831
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4832
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
4833
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
break;
|
|
3404
4837
|
}
|
|
3405
|
-
return
|
|
4838
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3406
4839
|
}
|
|
3407
|
-
function
|
|
3408
|
-
const
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
const
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
4840
|
+
function verticalPairGrid(rdA, rdB, bounds) {
|
|
4841
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
4842
|
+
const gapAB_Y = findMinStepY(pA, pB, 0);
|
|
4843
|
+
if (gapAB_Y <= 0) return emptyResult();
|
|
4844
|
+
const vpairH = gapAB_Y + pB.height;
|
|
4845
|
+
const vpairW = Math.max(pA.width, pB.width);
|
|
4846
|
+
Math.max(pA.height, pB.height) + Math.abs(gapAB_Y);
|
|
4847
|
+
let vpairStepX = 0;
|
|
4848
|
+
{
|
|
4849
|
+
const stepXAA = findMinStepX(pA, pA, 0);
|
|
4850
|
+
const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
|
|
4851
|
+
const stepXBA = findMinStepX(pB, pA, gapAB_Y);
|
|
4852
|
+
const stepXBB = findMinStepX(pB, pB, 0);
|
|
4853
|
+
vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
|
|
3415
4854
|
}
|
|
3416
|
-
return
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
const
|
|
3423
|
-
const stepX = findMinStepX(p, p, 0);
|
|
3424
|
-
const stepY = findMinStepY(p, p, 0);
|
|
3425
|
-
if (stepX <= 0 || stepY <= 0) return emptyResult();
|
|
3426
|
-
const cols = Math.max(0, Math.floor((bounds.right - bounds.left - p.width) / stepX) + 1);
|
|
3427
|
-
const rows = Math.max(0, Math.floor((bounds.bottom - bounds.top - p.height) / stepY) + 1);
|
|
4855
|
+
if (vpairStepX <= 0) return emptyResult();
|
|
4856
|
+
const vpairStepY = gapAB_Y + findMinStepY(pB, pA, 0);
|
|
4857
|
+
if (vpairStepY <= 0) return emptyResult();
|
|
4858
|
+
const usableW = bounds.right - bounds.left;
|
|
4859
|
+
const usableH = bounds.bottom - bounds.top;
|
|
4860
|
+
const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
|
|
4861
|
+
const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
|
|
3428
4862
|
if (cols === 0 || rows === 0) return emptyResult();
|
|
3429
4863
|
const placements = [];
|
|
3430
4864
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
3431
4865
|
for (let r = 0; r < rows; r++) {
|
|
3432
4866
|
for (let c = 0; c < cols; c++) {
|
|
3433
|
-
const
|
|
3434
|
-
const
|
|
3435
|
-
placements.push({ x:
|
|
3436
|
-
if (
|
|
3437
|
-
if (
|
|
3438
|
-
if (
|
|
3439
|
-
if (
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
}
|
|
3444
|
-
function dualRotGrid(rdA, rdB, offsetX, bounds) {
|
|
3445
|
-
const pA = rdA.profile, pB = rdB.profile;
|
|
3446
|
-
const stepX_A = findMinStepX(pA, pA, 0);
|
|
3447
|
-
const stepX_B = findMinStepX(pB, pB, 0);
|
|
3448
|
-
if (stepX_A <= 0 || stepX_B <= 0) return emptyResult();
|
|
3449
|
-
const stepY_AB = findMinStepY_multi(pA, stepX_A, pB, offsetX);
|
|
3450
|
-
const stepY_BA = findMinStepY_multi(pB, stepX_B, pA, -offsetX);
|
|
3451
|
-
if (stepY_AB + stepY_BA <= 0) return emptyResult();
|
|
3452
|
-
const placements = [];
|
|
3453
|
-
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
3454
|
-
let oy = bounds.top;
|
|
3455
|
-
let isRowA = true;
|
|
3456
|
-
while (true) {
|
|
3457
|
-
const rd = isRowA ? rdA : rdB;
|
|
3458
|
-
const p = rd.profile;
|
|
3459
|
-
const stepX = isRowA ? stepX_A : stepX_B;
|
|
3460
|
-
if (oy + p.height > bounds.bottom) break;
|
|
3461
|
-
let sx = isRowA ? bounds.left : bounds.left + offsetX;
|
|
3462
|
-
if (sx < bounds.left) sx += stepX * Math.ceil((bounds.left - sx) / stepX);
|
|
3463
|
-
for (let ox = sx; ox + p.width <= bounds.right; ox += stepX) {
|
|
3464
|
-
placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
|
|
3465
|
-
if (ox < minX) minX = ox;
|
|
3466
|
-
if (oy < minY) minY = oy;
|
|
3467
|
-
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
3468
|
-
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
4867
|
+
const baseX = bounds.left + c * vpairStepX;
|
|
4868
|
+
const baseY = bounds.top + r * vpairStepY;
|
|
4869
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
4870
|
+
if (baseX < minX) minX = baseX;
|
|
4871
|
+
if (baseY < minY) minY = baseY;
|
|
4872
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
4873
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
4874
|
+
const by = baseY + gapAB_Y;
|
|
4875
|
+
placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
4876
|
+
if (by + pB.height > maxY) maxY = by + pB.height;
|
|
3469
4877
|
}
|
|
3470
|
-
oy += isRowA ? stepY_AB : stepY_BA;
|
|
3471
|
-
isRowA = !isRowA;
|
|
3472
4878
|
}
|
|
3473
|
-
if (placements.length === 0) return emptyResult();
|
|
3474
4879
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3475
4880
|
}
|
|
3476
|
-
function
|
|
3477
|
-
if (result.count === 0) return;
|
|
3478
|
-
const offX = (bounds.right - bounds.left - (result.maxX - result.minX)) / 2 - (result.minX - bounds.left);
|
|
3479
|
-
const offY = (bounds.bottom - bounds.top - (result.maxY - result.minY)) / 2 - (result.minY - bounds.top);
|
|
3480
|
-
for (const p of result.placements) {
|
|
3481
|
-
p.x += offX;
|
|
3482
|
-
p.y += offY;
|
|
3483
|
-
}
|
|
3484
|
-
}
|
|
3485
|
-
function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4881
|
+
function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
3486
4882
|
const rots = [0, 90, 180, 270];
|
|
3487
4883
|
const rd = /* @__PURE__ */ new Map();
|
|
3488
4884
|
for (const deg of rots) {
|
|
3489
|
-
rd.set(deg,
|
|
4885
|
+
rd.set(deg, prepareRotation3(contourPoints, dielineW, dielineH, deg));
|
|
3490
4886
|
}
|
|
3491
4887
|
const results = [];
|
|
3492
4888
|
for (const deg of rots) {
|
|
3493
4889
|
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
3494
4890
|
}
|
|
3495
|
-
const
|
|
4891
|
+
const allPairs = [
|
|
3496
4892
|
[0, 180],
|
|
3497
4893
|
[90, 270],
|
|
3498
4894
|
[0, 90],
|
|
@@ -3500,7 +4896,7 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
3500
4896
|
[90, 180],
|
|
3501
4897
|
[180, 270]
|
|
3502
4898
|
];
|
|
3503
|
-
for (const [a, b] of
|
|
4899
|
+
for (const [a, b] of allPairs) {
|
|
3504
4900
|
const rdA = rd.get(a), rdB = rd.get(b);
|
|
3505
4901
|
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
3506
4902
|
if (stepA <= 0) continue;
|
|
@@ -3509,10 +4905,40 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
3509
4905
|
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
3510
4906
|
}
|
|
3511
4907
|
}
|
|
3512
|
-
|
|
4908
|
+
for (const [a, b] of allPairs) {
|
|
4909
|
+
results.push(pairGrid2(rd.get(a), rd.get(b), bounds));
|
|
4910
|
+
results.push(pairGrid2(rd.get(b), rd.get(a), bounds));
|
|
4911
|
+
}
|
|
4912
|
+
for (const [a, b] of allPairs) {
|
|
4913
|
+
results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
|
|
4914
|
+
results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
|
|
4915
|
+
}
|
|
4916
|
+
const singleResults = [];
|
|
4917
|
+
const multiResults = [];
|
|
3513
4918
|
for (const r of results) {
|
|
3514
|
-
if (r.count
|
|
4919
|
+
if (r.count === 0) continue;
|
|
4920
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
4921
|
+
if (rotations.size > 1) {
|
|
4922
|
+
multiResults.push(r);
|
|
4923
|
+
} else {
|
|
4924
|
+
singleResults.push(r);
|
|
4925
|
+
}
|
|
4926
|
+
}
|
|
4927
|
+
function pickBest(arr) {
|
|
4928
|
+
let b = arr[0] ?? emptyResult();
|
|
4929
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
4930
|
+
for (const r of arr) {
|
|
4931
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
4932
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
4933
|
+
b = r;
|
|
4934
|
+
bArea = area;
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
return b;
|
|
3515
4938
|
}
|
|
4939
|
+
const bestSingle = pickBest(singleResults);
|
|
4940
|
+
const bestMulti = pickBest(multiResults);
|
|
4941
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
3516
4942
|
centerLayout(best, bounds);
|
|
3517
4943
|
return {
|
|
3518
4944
|
rotation: best.placements[0]?.rotation ?? 0,
|
|
@@ -3521,8 +4947,8 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
3521
4947
|
};
|
|
3522
4948
|
}
|
|
3523
4949
|
|
|
3524
|
-
// src/utils/autoLayout/calculate/
|
|
3525
|
-
function
|
|
4950
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-12101/index.ts
|
|
4951
|
+
function prepareRotation4(contourPoints, dielineW, dielineH, deg) {
|
|
3526
4952
|
const rotated = normalizePoints(contourPoints, deg);
|
|
3527
4953
|
return {
|
|
3528
4954
|
profile: buildProfile(rotated),
|
|
@@ -3530,7 +4956,7 @@ function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
|
|
|
3530
4956
|
deg
|
|
3531
4957
|
};
|
|
3532
4958
|
}
|
|
3533
|
-
function
|
|
4959
|
+
function pairGrid3(rdA, rdB, bounds) {
|
|
3534
4960
|
const pA = rdA.profile, pB = rdB.profile;
|
|
3535
4961
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
3536
4962
|
if (gapAB <= 0) return emptyResult();
|
|
@@ -3606,11 +5032,11 @@ function pairGrid(rdA, rdB, bounds) {
|
|
|
3606
5032
|
}
|
|
3607
5033
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3608
5034
|
}
|
|
3609
|
-
function
|
|
5035
|
+
function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
3610
5036
|
const rots = [0, 90, 180, 270];
|
|
3611
5037
|
const rd = /* @__PURE__ */ new Map();
|
|
3612
5038
|
for (const deg of rots) {
|
|
3613
|
-
rd.set(deg,
|
|
5039
|
+
rd.set(deg, prepareRotation4(contourPoints, dielineW, dielineH, deg));
|
|
3614
5040
|
}
|
|
3615
5041
|
const results = [];
|
|
3616
5042
|
for (const deg of rots) {
|
|
@@ -3634,8 +5060,8 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
3634
5060
|
}
|
|
3635
5061
|
}
|
|
3636
5062
|
for (const [a, b] of allPairs) {
|
|
3637
|
-
results.push(
|
|
3638
|
-
results.push(
|
|
5063
|
+
results.push(pairGrid3(rd.get(a), rd.get(b), bounds));
|
|
5064
|
+
results.push(pairGrid3(rd.get(b), rd.get(a), bounds));
|
|
3639
5065
|
}
|
|
3640
5066
|
const singleResults = [];
|
|
3641
5067
|
const multiResults = [];
|
|
@@ -3671,8 +5097,8 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
3671
5097
|
};
|
|
3672
5098
|
}
|
|
3673
5099
|
|
|
3674
|
-
// src/utils/autoLayout/calculate/
|
|
3675
|
-
function
|
|
5100
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-12109/index.ts
|
|
5101
|
+
function prepareRotation5(contourPoints, dielineW, dielineH, deg) {
|
|
3676
5102
|
const rotated = normalizePoints(contourPoints, deg);
|
|
3677
5103
|
return {
|
|
3678
5104
|
profile: buildProfile(rotated),
|
|
@@ -3680,34 +5106,20 @@ function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
|
|
|
3680
5106
|
deg
|
|
3681
5107
|
};
|
|
3682
5108
|
}
|
|
3683
|
-
function
|
|
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) {
|
|
5109
|
+
function pairGrid4(rdA, rdB, bounds) {
|
|
3702
5110
|
const pA = rdA.profile, pB = rdB.profile;
|
|
3703
5111
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
3704
5112
|
if (gapAB <= 0) return emptyResult();
|
|
3705
5113
|
const pairW = gapAB + pB.width;
|
|
3706
5114
|
const pairH = Math.max(pA.height, pB.height);
|
|
3707
5115
|
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
5116
|
+
const pairStepY = Math.max(
|
|
5117
|
+
findMinStepY(pA, pA, 0),
|
|
5118
|
+
findMinStepY(pA, pB, gapAB),
|
|
5119
|
+
findMinStepY(pB, pA, -gapAB),
|
|
5120
|
+
findMinStepY(pB, pB, 0)
|
|
5121
|
+
);
|
|
5122
|
+
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
3711
5123
|
const usableW = bounds.right - bounds.left;
|
|
3712
5124
|
const usableH = bounds.bottom - bounds.top;
|
|
3713
5125
|
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
@@ -3719,115 +5131,62 @@ function pairGrid2(rdA, rdB, bounds) {
|
|
|
3719
5131
|
for (let c = 0; c < pairCols; c++) {
|
|
3720
5132
|
const baseX = bounds.left + c * pairStepX;
|
|
3721
5133
|
const baseY = bounds.top + r * pairStepY;
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
if (
|
|
3726
|
-
if (
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
5134
|
+
const oxA = baseX;
|
|
5135
|
+
const oyA = baseY;
|
|
5136
|
+
placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
5137
|
+
if (oxA < minX) minX = oxA;
|
|
5138
|
+
if (oyA < minY) minY = oyA;
|
|
5139
|
+
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
5140
|
+
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
5141
|
+
const oxB = baseX + gapAB;
|
|
5142
|
+
const oyB = baseY;
|
|
5143
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
5144
|
+
if (oxB < minX) minX = oxB;
|
|
5145
|
+
if (oyB < minY) minY = oyB;
|
|
5146
|
+
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
5147
|
+
if (oyB + pB.height > maxY) maxY = oyB + pB.height;
|
|
3732
5148
|
}
|
|
3733
5149
|
}
|
|
3734
5150
|
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
5151
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
3735
5152
|
const gapRight = bounds.right - pairsRightEdge;
|
|
3736
|
-
|
|
5153
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
5154
|
+
const extraRotations = [rdA, rdB];
|
|
5155
|
+
for (const rdExtra of extraRotations) {
|
|
3737
5156
|
const pe = rdExtra.profile;
|
|
3738
|
-
if (pe.width
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
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;
|
|
5157
|
+
if (pe.width <= gapRight) {
|
|
5158
|
+
for (let r = 0; r < pairRows; r++) {
|
|
5159
|
+
const ox = pairsRightEdge;
|
|
5160
|
+
const oy = bounds.top + r * pairStepY;
|
|
5161
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
5162
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
5163
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
5164
|
+
}
|
|
3756
5165
|
}
|
|
5166
|
+
break;
|
|
3757
5167
|
}
|
|
3758
|
-
break;
|
|
3759
5168
|
}
|
|
3760
|
-
const
|
|
3761
|
-
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
3762
|
-
for (const rdExtra of [rdA, rdB]) {
|
|
5169
|
+
for (const rdExtra of extraRotations) {
|
|
3763
5170
|
const pe = rdExtra.profile;
|
|
3764
|
-
if (pe.height
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
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;
|
|
5171
|
+
if (pe.height <= gapBottom) {
|
|
5172
|
+
for (let c = 0; c < pairCols; c++) {
|
|
5173
|
+
const oxA = bounds.left + c * pairStepX;
|
|
5174
|
+
const oy = pairsBottomEdge;
|
|
5175
|
+
if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
5176
|
+
placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
5177
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
5178
|
+
}
|
|
3779
5179
|
}
|
|
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;
|
|
5180
|
+
break;
|
|
3822
5181
|
}
|
|
3823
5182
|
}
|
|
3824
5183
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3825
5184
|
}
|
|
3826
|
-
function
|
|
5185
|
+
function computeLayoutForPaper5(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
3827
5186
|
const rots = [0, 90, 180, 270];
|
|
3828
5187
|
const rd = /* @__PURE__ */ new Map();
|
|
3829
5188
|
for (const deg of rots) {
|
|
3830
|
-
rd.set(deg,
|
|
5189
|
+
rd.set(deg, prepareRotation5(contourPoints, dielineW, dielineH, deg));
|
|
3831
5190
|
}
|
|
3832
5191
|
const results = [];
|
|
3833
5192
|
for (const deg of rots) {
|
|
@@ -3851,12 +5210,8 @@ function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
3851
5210
|
}
|
|
3852
5211
|
}
|
|
3853
5212
|
for (const [a, b] of allPairs) {
|
|
3854
|
-
results.push(
|
|
3855
|
-
results.push(
|
|
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));
|
|
5213
|
+
results.push(pairGrid4(rd.get(a), rd.get(b), bounds));
|
|
5214
|
+
results.push(pairGrid4(rd.get(b), rd.get(a), bounds));
|
|
3860
5215
|
}
|
|
3861
5216
|
const singleResults = [];
|
|
3862
5217
|
const multiResults = [];
|
|
@@ -3919,6 +5274,22 @@ function resolveModelFunctions(modelId, attrs) {
|
|
|
3919
5274
|
offsetContour: offsetContour4
|
|
3920
5275
|
};
|
|
3921
5276
|
}
|
|
5277
|
+
case "BECF-12101": {
|
|
5278
|
+
const a = attrs;
|
|
5279
|
+
return {
|
|
5280
|
+
contour: generateOuterContour5(a),
|
|
5281
|
+
dieline: generateBecf12101(a),
|
|
5282
|
+
offsetContour: offsetContour5
|
|
5283
|
+
};
|
|
5284
|
+
}
|
|
5285
|
+
case "BECF-12109": {
|
|
5286
|
+
const a = attrs;
|
|
5287
|
+
return {
|
|
5288
|
+
contour: generateOuterContour6(a),
|
|
5289
|
+
dieline: generateBecf12109(a),
|
|
5290
|
+
offsetContour: offsetContour6
|
|
5291
|
+
};
|
|
5292
|
+
}
|
|
3922
5293
|
case "BECF-1010A":
|
|
3923
5294
|
default: {
|
|
3924
5295
|
const a = attrs;
|
|
@@ -3938,16 +5309,28 @@ function resolveLayoutCalculator(modelId) {
|
|
|
3938
5309
|
return computeLayoutForPaper2;
|
|
3939
5310
|
case "BECF-1040A":
|
|
3940
5311
|
return computeLayoutForPaper3;
|
|
5312
|
+
case "BECF-12101":
|
|
5313
|
+
return computeLayoutForPaper4;
|
|
5314
|
+
case "BECF-12109":
|
|
5315
|
+
return computeLayoutForPaper5;
|
|
3941
5316
|
default:
|
|
3942
5317
|
return computeLayoutForPaperDefault;
|
|
3943
5318
|
}
|
|
3944
5319
|
}
|
|
3945
|
-
function calculateAutoLayout(
|
|
3946
|
-
const
|
|
5320
|
+
function calculateAutoLayout(rawConfig) {
|
|
5321
|
+
const config = {
|
|
5322
|
+
...rawConfig,
|
|
5323
|
+
layoutDistance: rawConfig.layoutDistance ?? 3,
|
|
5324
|
+
spacing: rawConfig.spacing ?? 5,
|
|
5325
|
+
griper: rawConfig.griper ?? 10,
|
|
5326
|
+
colorbarHeight: rawConfig.colorbarHeight ?? 5,
|
|
5327
|
+
isShowColorbar: rawConfig.isShowColorbar ?? true
|
|
5328
|
+
};
|
|
5329
|
+
const { contour, dieline, offsetContour: offsetContour7 } = resolveModelFunctions(
|
|
3947
5330
|
config.model.modelId,
|
|
3948
5331
|
config.model.attributes
|
|
3949
5332
|
);
|
|
3950
|
-
const offsetContourPoints = config.layoutDistance > 0 ?
|
|
5333
|
+
const offsetContourPoints = config.layoutDistance > 0 ? offsetContour7(contour, config.layoutDistance / 2) : contour;
|
|
3951
5334
|
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
3952
5335
|
const computeLayout = resolveLayoutCalculator(config.model.modelId);
|
|
3953
5336
|
const paperResults = [];
|
|
@@ -4292,6 +5675,22 @@ function renderDieLine(modelId, attrs) {
|
|
|
4292
5675
|
renderAs: "group"
|
|
4293
5676
|
}
|
|
4294
5677
|
);
|
|
5678
|
+
case "BECF-11D01":
|
|
5679
|
+
return /* @__PURE__ */ jsx(
|
|
5680
|
+
DIE_LINE_BECF_11D01,
|
|
5681
|
+
{
|
|
5682
|
+
attributes: attrs,
|
|
5683
|
+
renderAs: "group"
|
|
5684
|
+
}
|
|
5685
|
+
);
|
|
5686
|
+
case "BECF-12101":
|
|
5687
|
+
return /* @__PURE__ */ jsx(
|
|
5688
|
+
DIE_LINE_BECF_12101,
|
|
5689
|
+
{
|
|
5690
|
+
attributes: attrs,
|
|
5691
|
+
renderAs: "group"
|
|
5692
|
+
}
|
|
5693
|
+
);
|
|
4295
5694
|
case "BECF-1010A":
|
|
4296
5695
|
default:
|
|
4297
5696
|
return /* @__PURE__ */ jsx(
|
|
@@ -4341,9 +5740,9 @@ function getTransformedContour(normalizedPoints, x, y, rotation) {
|
|
|
4341
5740
|
}
|
|
4342
5741
|
return translatePolygon(rotated, x - rMinX, y - rMinY);
|
|
4343
5742
|
}
|
|
4344
|
-
function checkCollisions(items,
|
|
5743
|
+
function checkCollisions(items, shrunkContour, paperWidth, paperHeight) {
|
|
4345
5744
|
const polys = items.map(
|
|
4346
|
-
(item) => getTransformedContour(
|
|
5745
|
+
(item) => getTransformedContour(shrunkContour, item.x, item.y, item.rotation)
|
|
4347
5746
|
);
|
|
4348
5747
|
return items.map((item, i) => {
|
|
4349
5748
|
let colliding = false;
|
|
@@ -4401,7 +5800,10 @@ function ModifyLayout({
|
|
|
4401
5800
|
const [panX, setPanX] = useState(0);
|
|
4402
5801
|
const [panY, setPanY] = useState(0);
|
|
4403
5802
|
const theme = useMemo(() => getAutoLayoutTheme(), []);
|
|
4404
|
-
const
|
|
5803
|
+
const shrunkContour = useMemo(
|
|
5804
|
+
() => normalizeContour(offsetContour(offsetContourPoints, -0.15)),
|
|
5805
|
+
[offsetContourPoints]
|
|
5806
|
+
);
|
|
4405
5807
|
const pw = paperResult.paperWidth;
|
|
4406
5808
|
const ph = paperResult.paperHeight;
|
|
4407
5809
|
const padding = 20;
|
|
@@ -4414,7 +5816,7 @@ function ModifyLayout({
|
|
|
4414
5816
|
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
4415
5817
|
const layoutDistance = config.layoutDistance;
|
|
4416
5818
|
useEffect(() => {
|
|
4417
|
-
setItems((prev) => checkCollisions(prev,
|
|
5819
|
+
setItems((prev) => checkCollisions(prev, shrunkContour, pw, ph));
|
|
4418
5820
|
}, []);
|
|
4419
5821
|
const itemsRef = useRef(items);
|
|
4420
5822
|
itemsRef.current = items;
|
|
@@ -4431,7 +5833,7 @@ function ModifyLayout({
|
|
|
4431
5833
|
const updated = prev.map(
|
|
4432
5834
|
(it) => it.id === dragItemId ? { ...it, x: newX, y: newY } : it
|
|
4433
5835
|
);
|
|
4434
|
-
return checkCollisions(updated,
|
|
5836
|
+
return checkCollisions(updated, shrunkContour, pw, ph);
|
|
4435
5837
|
});
|
|
4436
5838
|
return;
|
|
4437
5839
|
}
|
|
@@ -4465,7 +5867,7 @@ function ModifyLayout({
|
|
|
4465
5867
|
window.removeEventListener("pointerup", handleMouseUp);
|
|
4466
5868
|
window.removeEventListener("pointercancel", handleMouseUp);
|
|
4467
5869
|
};
|
|
4468
|
-
}, [
|
|
5870
|
+
}, [shrunkContour, pw, ph, zoom, padding]);
|
|
4469
5871
|
const handleItemMouseDown = useCallback((e, itemId) => {
|
|
4470
5872
|
e.stopPropagation();
|
|
4471
5873
|
e.preventDefault();
|
|
@@ -4504,9 +5906,9 @@ function ModifyLayout({
|
|
|
4504
5906
|
const updated = prev.map(
|
|
4505
5907
|
(it) => it.id === selectedId ? { ...it, rotation: degrees } : it
|
|
4506
5908
|
);
|
|
4507
|
-
return checkCollisions(updated,
|
|
5909
|
+
return checkCollisions(updated, shrunkContour, pw, ph);
|
|
4508
5910
|
});
|
|
4509
|
-
}, [selectedId,
|
|
5911
|
+
}, [selectedId, shrunkContour, pw, ph]);
|
|
4510
5912
|
const handleAdd = useCallback(() => {
|
|
4511
5913
|
const newItem = {
|
|
4512
5914
|
id: `item-${nextItemId++}`,
|
|
@@ -4517,17 +5919,17 @@ function ModifyLayout({
|
|
|
4517
5919
|
};
|
|
4518
5920
|
setItems((prev) => {
|
|
4519
5921
|
const updated = [...prev, newItem];
|
|
4520
|
-
return checkCollisions(updated,
|
|
5922
|
+
return checkCollisions(updated, shrunkContour, pw, ph);
|
|
4521
5923
|
});
|
|
4522
5924
|
setSelectedId(newItem.id);
|
|
4523
|
-
}, [pw, ph, dielineViewBox,
|
|
5925
|
+
}, [pw, ph, dielineViewBox, shrunkContour]);
|
|
4524
5926
|
const handleRemove = useCallback((itemId) => {
|
|
4525
5927
|
setItems((prev) => {
|
|
4526
5928
|
const filtered = prev.filter((it) => it.id !== itemId);
|
|
4527
|
-
return checkCollisions(filtered,
|
|
5929
|
+
return checkCollisions(filtered, shrunkContour, pw, ph);
|
|
4528
5930
|
});
|
|
4529
5931
|
if (selectedId === itemId) setSelectedId(null);
|
|
4530
|
-
}, [selectedId,
|
|
5932
|
+
}, [selectedId, shrunkContour, pw, ph]);
|
|
4531
5933
|
const handleSubmit = useCallback(() => {
|
|
4532
5934
|
const validItems = items.filter((it) => !it.isColliding);
|
|
4533
5935
|
const placements = validItems.map((it) => ({
|
|
@@ -4857,6 +6259,28 @@ function resolveModel(modelId, attrs, layoutDistance) {
|
|
|
4857
6259
|
generateContour: (a) => generateOuterContour4(a)
|
|
4858
6260
|
};
|
|
4859
6261
|
}
|
|
6262
|
+
case "BECF-12101": {
|
|
6263
|
+
const typedAttrs = attrs;
|
|
6264
|
+
const contour = generateOuterContour5(typedAttrs);
|
|
6265
|
+
return {
|
|
6266
|
+
dieline: generateBecf12101(typedAttrs),
|
|
6267
|
+
contourPath: contourToPath5(contour),
|
|
6268
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour5(contour, layoutDistance / 2) : contour,
|
|
6269
|
+
generate: (a) => generateBecf12101(a),
|
|
6270
|
+
generateContour: (a) => generateOuterContour5(a)
|
|
6271
|
+
};
|
|
6272
|
+
}
|
|
6273
|
+
case "BECF-12109": {
|
|
6274
|
+
const typedAttrs = attrs;
|
|
6275
|
+
const contour = generateOuterContour6(typedAttrs);
|
|
6276
|
+
return {
|
|
6277
|
+
dieline: generateBecf12109(typedAttrs),
|
|
6278
|
+
contourPath: contourToPath6(contour),
|
|
6279
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour6(contour, layoutDistance / 2) : contour,
|
|
6280
|
+
generate: (a) => generateBecf12109(a),
|
|
6281
|
+
generateContour: (a) => generateOuterContour6(a)
|
|
6282
|
+
};
|
|
6283
|
+
}
|
|
4860
6284
|
case "BECF-1010A":
|
|
4861
6285
|
default: {
|
|
4862
6286
|
const typedAttrs = attrs;
|
|
@@ -4898,6 +6322,22 @@ function renderDieLine2(modelId, attrs) {
|
|
|
4898
6322
|
renderAs: "group"
|
|
4899
6323
|
}
|
|
4900
6324
|
);
|
|
6325
|
+
case "BECF-12101":
|
|
6326
|
+
return /* @__PURE__ */ jsx(
|
|
6327
|
+
DIE_LINE_BECF_12101,
|
|
6328
|
+
{
|
|
6329
|
+
attributes: attrs,
|
|
6330
|
+
renderAs: "group"
|
|
6331
|
+
}
|
|
6332
|
+
);
|
|
6333
|
+
case "BECF-12109":
|
|
6334
|
+
return /* @__PURE__ */ jsx(
|
|
6335
|
+
DIE_LINE_BECF_12109,
|
|
6336
|
+
{
|
|
6337
|
+
attributes: attrs,
|
|
6338
|
+
renderAs: "group"
|
|
6339
|
+
}
|
|
6340
|
+
);
|
|
4901
6341
|
case "BECF-1010A":
|
|
4902
6342
|
default:
|
|
4903
6343
|
return /* @__PURE__ */ jsx(
|
|
@@ -4911,7 +6351,7 @@ function renderDieLine2(modelId, attrs) {
|
|
|
4911
6351
|
})();
|
|
4912
6352
|
}
|
|
4913
6353
|
var PAPER_GAP = 20;
|
|
4914
|
-
var
|
|
6354
|
+
var PX_PER_MM7 = 96 / 25.4;
|
|
4915
6355
|
var RESULT_PANEL_HEIGHT = 55;
|
|
4916
6356
|
var RESULT_GAP = 5;
|
|
4917
6357
|
function getOpposite2(side) {
|
|
@@ -5038,7 +6478,7 @@ function getDielineTransform2(x, y, rotation, w, h) {
|
|
|
5038
6478
|
}
|
|
5039
6479
|
}
|
|
5040
6480
|
var AUTO_LAYOUT = forwardRef(
|
|
5041
|
-
({ config, onResult, onModifiedPapers }, ref) => {
|
|
6481
|
+
({ config, onResult, onModifiedPapers, isShowSummary = true, isShowAction }, ref) => {
|
|
5042
6482
|
const canvasRef = useRef(null);
|
|
5043
6483
|
const [result, setResult] = useState(null);
|
|
5044
6484
|
const [modifiedPapers, setModifiedPapers] = useState([]);
|
|
@@ -5061,7 +6501,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5061
6501
|
);
|
|
5062
6502
|
const modelId = config?.model.modelId ?? "";
|
|
5063
6503
|
const attrs = config?.model.attributes;
|
|
5064
|
-
const layoutDistance = config?.layoutDistance ??
|
|
6504
|
+
const layoutDistance = config?.layoutDistance ?? 3;
|
|
5065
6505
|
const resolved = useMemo(
|
|
5066
6506
|
() => modelId && attrs ? resolveModel(modelId, attrs, layoutDistance) : null,
|
|
5067
6507
|
[modelId, attrs, layoutDistance]
|
|
@@ -5088,8 +6528,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5088
6528
|
const svg = document.createElementNS(svgNs, "svg");
|
|
5089
6529
|
svg.setAttribute("xmlns", svgNs);
|
|
5090
6530
|
svg.setAttribute("viewBox", `0 0 ${vw} ${vh}`);
|
|
5091
|
-
svg.setAttribute("width", String(Math.round(vw *
|
|
5092
|
-
svg.setAttribute("height", String(Math.round(vh *
|
|
6531
|
+
svg.setAttribute("width", String(Math.round(vw * PX_PER_MM7)));
|
|
6532
|
+
svg.setAttribute("height", String(Math.round(vh * PX_PER_MM7)));
|
|
5093
6533
|
const bg = document.createElementNS(svgNs, "rect");
|
|
5094
6534
|
bg.setAttribute("width", String(vw));
|
|
5095
6535
|
bg.setAttribute("height", String(vh));
|
|
@@ -5122,8 +6562,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5122
6562
|
img.src = url;
|
|
5123
6563
|
});
|
|
5124
6564
|
const canvas = document.createElement("canvas");
|
|
5125
|
-
canvas.width = Math.round(vw *
|
|
5126
|
-
canvas.height = Math.round(vh *
|
|
6565
|
+
canvas.width = Math.round(vw * PX_PER_MM7);
|
|
6566
|
+
canvas.height = Math.round(vh * PX_PER_MM7);
|
|
5127
6567
|
const ctx = canvas.getContext("2d");
|
|
5128
6568
|
ctx.fillStyle = "#ffffff";
|
|
5129
6569
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -5142,13 +6582,13 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5142
6582
|
if (!paperResult) throw new Error("Invalid paper index");
|
|
5143
6583
|
const dl = resolved.generate(attrs);
|
|
5144
6584
|
const cPath = contourToPath(resolved.generateContour(attrs));
|
|
5145
|
-
const dist = config.layoutDistance;
|
|
6585
|
+
const dist = config.layoutDistance ?? 3;
|
|
5146
6586
|
const svgNs = "http://www.w3.org/2000/svg";
|
|
5147
6587
|
const svg = document.createElementNS(svgNs, "svg");
|
|
5148
6588
|
svg.setAttribute("xmlns", svgNs);
|
|
5149
6589
|
svg.setAttribute("viewBox", `0 0 ${paperResult.paperWidth} ${paperResult.paperHeight}`);
|
|
5150
|
-
svg.setAttribute("width", String(Math.round(paperResult.paperWidth *
|
|
5151
|
-
svg.setAttribute("height", String(Math.round(paperResult.paperHeight *
|
|
6590
|
+
svg.setAttribute("width", String(Math.round(paperResult.paperWidth * PX_PER_MM7)));
|
|
6591
|
+
svg.setAttribute("height", String(Math.round(paperResult.paperHeight * PX_PER_MM7)));
|
|
5152
6592
|
const bg = document.createElementNS(svgNs, "rect");
|
|
5153
6593
|
bg.setAttribute("width", String(paperResult.paperWidth));
|
|
5154
6594
|
bg.setAttribute("height", String(paperResult.paperHeight));
|
|
@@ -5158,12 +6598,16 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5158
6598
|
svg.appendChild(bg);
|
|
5159
6599
|
const gripperSide = paperResult.gripperSide;
|
|
5160
6600
|
const colorbarSide = getOpposite2(gripperSide);
|
|
5161
|
-
const
|
|
5162
|
-
|
|
5163
|
-
|
|
6601
|
+
const colorbarHeight = config.colorbarHeight ?? 5;
|
|
6602
|
+
const isShowColorbar = config.isShowColorbar ?? true;
|
|
6603
|
+
const spacing = config.spacing ?? 5;
|
|
6604
|
+
const griper = config.griper ?? 10;
|
|
6605
|
+
const cbDepth = isShowColorbar ? colorbarHeight : 0;
|
|
6606
|
+
if (isShowColorbar) {
|
|
6607
|
+
appendColorbarToSvg(svg, svgNs, colorbarSide, colorbarHeight, paperResult.paperWidth, paperResult.paperHeight);
|
|
5164
6608
|
}
|
|
5165
|
-
if (
|
|
5166
|
-
const rects = getSpacingRects2(gripperSide, paperResult.paperWidth, paperResult.paperHeight,
|
|
6609
|
+
if (spacing > 0) {
|
|
6610
|
+
const rects = getSpacingRects2(gripperSide, paperResult.paperWidth, paperResult.paperHeight, spacing, griper, cbDepth);
|
|
5167
6611
|
for (const sr of rects) {
|
|
5168
6612
|
const r = document.createElementNS(svgNs, "rect");
|
|
5169
6613
|
r.setAttribute("x", String(sr.x));
|
|
@@ -5174,8 +6618,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5174
6618
|
svg.appendChild(r);
|
|
5175
6619
|
}
|
|
5176
6620
|
}
|
|
5177
|
-
if (
|
|
5178
|
-
appendGripperToSvg(svg, svgNs, gripperSide, paperResult.paperWidth, paperResult.paperHeight,
|
|
6621
|
+
if (griper > 0) {
|
|
6622
|
+
appendGripperToSvg(svg, svgNs, gripperSide, paperResult.paperWidth, paperResult.paperHeight, griper, theme.colorGriper);
|
|
5179
6623
|
}
|
|
5180
6624
|
if (dist > 0) {
|
|
5181
6625
|
const defs = document.createElementNS(svgNs, "defs");
|
|
@@ -5248,8 +6692,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5248
6692
|
img.src = url;
|
|
5249
6693
|
});
|
|
5250
6694
|
const canvas = document.createElement("canvas");
|
|
5251
|
-
canvas.width = Math.round(paperResult.paperWidth *
|
|
5252
|
-
canvas.height = Math.round(paperResult.paperHeight *
|
|
6695
|
+
canvas.width = Math.round(paperResult.paperWidth * PX_PER_MM7);
|
|
6696
|
+
canvas.height = Math.round(paperResult.paperHeight * PX_PER_MM7);
|
|
5253
6697
|
const ctx = canvas.getContext("2d");
|
|
5254
6698
|
ctx.fillStyle = theme.colorPaperFill;
|
|
5255
6699
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -5277,7 +6721,10 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5277
6721
|
unit: "mm",
|
|
5278
6722
|
format: [pw, ph]
|
|
5279
6723
|
});
|
|
5280
|
-
|
|
6724
|
+
const pdfColorbarHeight = config.colorbarHeight ?? 5;
|
|
6725
|
+
const pdfIsShowColorbar = config.isShowColorbar ?? true;
|
|
6726
|
+
const pdfGriper = config.griper ?? 10;
|
|
6727
|
+
if (pdfIsShowColorbar) {
|
|
5281
6728
|
const BASE_COLORS2 = ["#02FFFF", "#FF00FF", "#FFFF00", "#000000"];
|
|
5282
6729
|
const FADE_LEVELS2 = [1, 0.8, 0.6, 0.4, 0.2];
|
|
5283
6730
|
const fadeToWhite2 = (hex, opacity) => {
|
|
@@ -5295,7 +6742,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5295
6742
|
);
|
|
5296
6743
|
const count = colors.length;
|
|
5297
6744
|
const isHoriz = colorbarSide === "top" || colorbarSide === "bottom";
|
|
5298
|
-
const cbH =
|
|
6745
|
+
const cbH = pdfColorbarHeight;
|
|
5299
6746
|
colors.forEach((c, i) => {
|
|
5300
6747
|
doc.setFillColor(c.r, c.g, c.b);
|
|
5301
6748
|
if (isHoriz) {
|
|
@@ -5309,7 +6756,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5309
6756
|
}
|
|
5310
6757
|
});
|
|
5311
6758
|
}
|
|
5312
|
-
if (
|
|
6759
|
+
if (pdfGriper > 0) {
|
|
5313
6760
|
const hexToRgb2 = (hex) => ({
|
|
5314
6761
|
r: parseInt(hex.slice(1, 3), 16),
|
|
5315
6762
|
g: parseInt(hex.slice(3, 5), 16),
|
|
@@ -5317,7 +6764,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5317
6764
|
});
|
|
5318
6765
|
const gc = hexToRgb2(theme.colorGriper);
|
|
5319
6766
|
doc.setFillColor(gc.r, gc.g, gc.b);
|
|
5320
|
-
const depth =
|
|
6767
|
+
const depth = pdfGriper;
|
|
5321
6768
|
switch (gripperSide) {
|
|
5322
6769
|
case "bottom":
|
|
5323
6770
|
doc.rect(0, ph - depth, pw, depth, "F");
|
|
@@ -5442,7 +6889,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5442
6889
|
exportImage,
|
|
5443
6890
|
exportPdf
|
|
5444
6891
|
}), [result, getPackedResult, exportDielineImage, exportImage, exportPdf]);
|
|
5445
|
-
const
|
|
6892
|
+
const showAction = (action) => !isShowAction || isShowAction.includes(action);
|
|
6893
|
+
const paperOriginY = isShowSummary ? RESULT_PANEL_HEIGHT + RESULT_GAP : 0;
|
|
5446
6894
|
const viewBox = useMemo(() => {
|
|
5447
6895
|
if (allPapers.length === 0) {
|
|
5448
6896
|
return { x: 0, y: 0, width: 400, height: 300 };
|
|
@@ -5486,7 +6934,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5486
6934
|
}
|
|
5487
6935
|
const gripperSide = paperResult.gripperSide;
|
|
5488
6936
|
const colorbarSide = getOpposite2(gripperSide);
|
|
5489
|
-
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
6937
|
+
const cbDepth = config.isShowColorbar ?? true ? config.colorbarHeight ?? 5 : 0;
|
|
5490
6938
|
const panelW = paperResult.paperWidth;
|
|
5491
6939
|
const fontSize = Math.min(4, panelW / 30);
|
|
5492
6940
|
const padX = fontSize * 1.2;
|
|
@@ -5510,148 +6958,150 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5510
6958
|
curY += gap;
|
|
5511
6959
|
const exportBtnY = curY;
|
|
5512
6960
|
return /* @__PURE__ */ jsxs("g", { transform: `translate(${offsetX}, 0)`, children: [
|
|
5513
|
-
/* @__PURE__ */
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
"
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
"
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
"
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
"
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
"
|
|
5550
|
-
|
|
5551
|
-
|
|
6961
|
+
isShowSummary && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6962
|
+
/* @__PURE__ */ jsx(
|
|
6963
|
+
"rect",
|
|
6964
|
+
{
|
|
6965
|
+
x: 0,
|
|
6966
|
+
y: 0,
|
|
6967
|
+
width: panelW,
|
|
6968
|
+
height: RESULT_PANEL_HEIGHT,
|
|
6969
|
+
rx: 2,
|
|
6970
|
+
ry: 2,
|
|
6971
|
+
fill: "#f8fafc",
|
|
6972
|
+
stroke: "#d4dce7",
|
|
6973
|
+
strokeWidth: 0.3
|
|
6974
|
+
}
|
|
6975
|
+
),
|
|
6976
|
+
/* @__PURE__ */ jsx("text", { x: padX, y: titleY, fontSize: fontSize + 1, fontWeight: "bold", fill: "#0f172a", children: paperResult.paperName }),
|
|
6977
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: recY, fontSize, fontWeight: "bold", fill: rank === 1 ? "#10b981" : "#475569", children: [
|
|
6978
|
+
"Recommended: #",
|
|
6979
|
+
rank
|
|
6980
|
+
] }),
|
|
6981
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: perSheetY, fontSize, fill: "#475569", children: [
|
|
6982
|
+
"Produced per sheet: ",
|
|
6983
|
+
paperResult.producedPerSheet,
|
|
6984
|
+
" pcs"
|
|
6985
|
+
] }),
|
|
6986
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: sheetsY, fontSize, fill: "#475569", children: [
|
|
6987
|
+
"Sheets needed: ",
|
|
6988
|
+
paperResult.independentSheets
|
|
6989
|
+
] }),
|
|
6990
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: producedY, fontSize, fill: "#475569", children: [
|
|
6991
|
+
"Produced: ",
|
|
6992
|
+
paperResult.independentSheets * paperResult.producedPerSheet,
|
|
6993
|
+
" pcs (excess ",
|
|
6994
|
+
paperResult.independentSheets * paperResult.producedPerSheet - (config?.quantity ?? 0),
|
|
6995
|
+
")"
|
|
6996
|
+
] }),
|
|
6997
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: wasteY, fontSize, fill: "#475569", children: [
|
|
6998
|
+
"Waste per sheet: ",
|
|
6999
|
+
paperResult.wastePercent,
|
|
7000
|
+
"%"
|
|
7001
|
+
] }),
|
|
7002
|
+
showAction("EXPORT_SHEET") && /* @__PURE__ */ jsxs(
|
|
7003
|
+
"g",
|
|
7004
|
+
{
|
|
7005
|
+
style: { cursor: "pointer" },
|
|
7006
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
7007
|
+
onClick: () => handleExportImage(paperIdx),
|
|
7008
|
+
children: [
|
|
7009
|
+
/* @__PURE__ */ jsx(
|
|
7010
|
+
"rect",
|
|
7011
|
+
{
|
|
7012
|
+
x: padX,
|
|
7013
|
+
y: exportBtnY,
|
|
7014
|
+
width: exportBtnW,
|
|
7015
|
+
height: exportBtnH,
|
|
7016
|
+
rx: 1.5,
|
|
7017
|
+
ry: 1.5,
|
|
7018
|
+
fill: "#0f172a"
|
|
7019
|
+
}
|
|
7020
|
+
),
|
|
7021
|
+
/* @__PURE__ */ jsx(
|
|
7022
|
+
"text",
|
|
7023
|
+
{
|
|
7024
|
+
x: padX + exportBtnW / 2,
|
|
7025
|
+
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
7026
|
+
textAnchor: "middle",
|
|
7027
|
+
fontSize,
|
|
7028
|
+
fill: "#fff",
|
|
7029
|
+
style: { pointerEvents: "none" },
|
|
7030
|
+
children: "Export Sheet"
|
|
7031
|
+
}
|
|
7032
|
+
)
|
|
7033
|
+
]
|
|
7034
|
+
}
|
|
7035
|
+
),
|
|
7036
|
+
showAction("EXPORT_PDF") && /* @__PURE__ */ jsxs(
|
|
7037
|
+
"g",
|
|
7038
|
+
{
|
|
7039
|
+
style: { cursor: "pointer" },
|
|
7040
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
7041
|
+
onClick: () => handleExportPdf(paperIdx),
|
|
7042
|
+
children: [
|
|
7043
|
+
/* @__PURE__ */ jsx(
|
|
7044
|
+
"rect",
|
|
7045
|
+
{
|
|
7046
|
+
x: padX + exportBtnW + fontSize * 2,
|
|
7047
|
+
y: exportBtnY,
|
|
7048
|
+
width: exportBtnW,
|
|
7049
|
+
height: exportBtnH,
|
|
7050
|
+
rx: 1.5,
|
|
7051
|
+
ry: 1.5,
|
|
7052
|
+
fill: "#1e40af"
|
|
7053
|
+
}
|
|
7054
|
+
),
|
|
7055
|
+
/* @__PURE__ */ jsx(
|
|
7056
|
+
"text",
|
|
7057
|
+
{
|
|
7058
|
+
x: padX + exportBtnW + fontSize * 2 + exportBtnW / 2,
|
|
7059
|
+
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
7060
|
+
textAnchor: "middle",
|
|
7061
|
+
fontSize,
|
|
7062
|
+
fill: "#fff",
|
|
7063
|
+
style: { pointerEvents: "none" },
|
|
7064
|
+
children: "Export PDF"
|
|
7065
|
+
}
|
|
7066
|
+
)
|
|
7067
|
+
]
|
|
7068
|
+
}
|
|
7069
|
+
),
|
|
7070
|
+
showAction("MODIFY_LAYOUT") && paperResult.producedPerSheet > 0 && /* @__PURE__ */ jsxs(
|
|
7071
|
+
"g",
|
|
7072
|
+
{
|
|
7073
|
+
style: { cursor: "pointer" },
|
|
7074
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
7075
|
+
onClick: () => setModifyingPaper(paperResult),
|
|
7076
|
+
children: [
|
|
7077
|
+
/* @__PURE__ */ jsx(
|
|
7078
|
+
"rect",
|
|
7079
|
+
{
|
|
7080
|
+
x: padX + (exportBtnW + fontSize * 2) * 2,
|
|
7081
|
+
y: exportBtnY,
|
|
7082
|
+
width: exportBtnW,
|
|
7083
|
+
height: exportBtnH,
|
|
7084
|
+
rx: 1.5,
|
|
7085
|
+
ry: 1.5,
|
|
7086
|
+
fill: "#7c3aed"
|
|
7087
|
+
}
|
|
7088
|
+
),
|
|
7089
|
+
/* @__PURE__ */ jsx(
|
|
7090
|
+
"text",
|
|
7091
|
+
{
|
|
7092
|
+
x: padX + (exportBtnW + fontSize * 2) * 2 + exportBtnW / 2,
|
|
7093
|
+
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
7094
|
+
textAnchor: "middle",
|
|
7095
|
+
fontSize,
|
|
7096
|
+
fill: "#fff",
|
|
7097
|
+
style: { pointerEvents: "none" },
|
|
7098
|
+
children: "Modify Layout"
|
|
7099
|
+
}
|
|
7100
|
+
)
|
|
7101
|
+
]
|
|
7102
|
+
}
|
|
7103
|
+
)
|
|
5552
7104
|
] }),
|
|
5553
|
-
/* @__PURE__ */ jsxs(
|
|
5554
|
-
"g",
|
|
5555
|
-
{
|
|
5556
|
-
style: { cursor: "pointer" },
|
|
5557
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
5558
|
-
onClick: () => handleExportImage(paperIdx),
|
|
5559
|
-
children: [
|
|
5560
|
-
/* @__PURE__ */ jsx(
|
|
5561
|
-
"rect",
|
|
5562
|
-
{
|
|
5563
|
-
x: padX,
|
|
5564
|
-
y: exportBtnY,
|
|
5565
|
-
width: exportBtnW,
|
|
5566
|
-
height: exportBtnH,
|
|
5567
|
-
rx: 1.5,
|
|
5568
|
-
ry: 1.5,
|
|
5569
|
-
fill: "#0f172a"
|
|
5570
|
-
}
|
|
5571
|
-
),
|
|
5572
|
-
/* @__PURE__ */ jsx(
|
|
5573
|
-
"text",
|
|
5574
|
-
{
|
|
5575
|
-
x: padX + exportBtnW / 2,
|
|
5576
|
-
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
5577
|
-
textAnchor: "middle",
|
|
5578
|
-
fontSize,
|
|
5579
|
-
fill: "#fff",
|
|
5580
|
-
style: { pointerEvents: "none" },
|
|
5581
|
-
children: "Export Sheet"
|
|
5582
|
-
}
|
|
5583
|
-
)
|
|
5584
|
-
]
|
|
5585
|
-
}
|
|
5586
|
-
),
|
|
5587
|
-
/* @__PURE__ */ jsxs(
|
|
5588
|
-
"g",
|
|
5589
|
-
{
|
|
5590
|
-
style: { cursor: "pointer" },
|
|
5591
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
5592
|
-
onClick: () => handleExportPdf(paperIdx),
|
|
5593
|
-
children: [
|
|
5594
|
-
/* @__PURE__ */ jsx(
|
|
5595
|
-
"rect",
|
|
5596
|
-
{
|
|
5597
|
-
x: padX + exportBtnW + fontSize * 2,
|
|
5598
|
-
y: exportBtnY,
|
|
5599
|
-
width: exportBtnW,
|
|
5600
|
-
height: exportBtnH,
|
|
5601
|
-
rx: 1.5,
|
|
5602
|
-
ry: 1.5,
|
|
5603
|
-
fill: "#1e40af"
|
|
5604
|
-
}
|
|
5605
|
-
),
|
|
5606
|
-
/* @__PURE__ */ jsx(
|
|
5607
|
-
"text",
|
|
5608
|
-
{
|
|
5609
|
-
x: padX + exportBtnW + fontSize * 2 + exportBtnW / 2,
|
|
5610
|
-
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
5611
|
-
textAnchor: "middle",
|
|
5612
|
-
fontSize,
|
|
5613
|
-
fill: "#fff",
|
|
5614
|
-
style: { pointerEvents: "none" },
|
|
5615
|
-
children: "Export PDF"
|
|
5616
|
-
}
|
|
5617
|
-
)
|
|
5618
|
-
]
|
|
5619
|
-
}
|
|
5620
|
-
),
|
|
5621
|
-
paperResult.producedPerSheet > 0 && /* @__PURE__ */ jsxs(
|
|
5622
|
-
"g",
|
|
5623
|
-
{
|
|
5624
|
-
style: { cursor: "pointer" },
|
|
5625
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
5626
|
-
onClick: () => setModifyingPaper(paperResult),
|
|
5627
|
-
children: [
|
|
5628
|
-
/* @__PURE__ */ jsx(
|
|
5629
|
-
"rect",
|
|
5630
|
-
{
|
|
5631
|
-
x: padX + (exportBtnW + fontSize * 2) * 2,
|
|
5632
|
-
y: exportBtnY,
|
|
5633
|
-
width: exportBtnW,
|
|
5634
|
-
height: exportBtnH,
|
|
5635
|
-
rx: 1.5,
|
|
5636
|
-
ry: 1.5,
|
|
5637
|
-
fill: "#7c3aed"
|
|
5638
|
-
}
|
|
5639
|
-
),
|
|
5640
|
-
/* @__PURE__ */ jsx(
|
|
5641
|
-
"text",
|
|
5642
|
-
{
|
|
5643
|
-
x: padX + (exportBtnW + fontSize * 2) * 2 + exportBtnW / 2,
|
|
5644
|
-
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
5645
|
-
textAnchor: "middle",
|
|
5646
|
-
fontSize,
|
|
5647
|
-
fill: "#fff",
|
|
5648
|
-
style: { pointerEvents: "none" },
|
|
5649
|
-
children: "Modify Layout"
|
|
5650
|
-
}
|
|
5651
|
-
)
|
|
5652
|
-
]
|
|
5653
|
-
}
|
|
5654
|
-
),
|
|
5655
7105
|
/* @__PURE__ */ jsxs("g", { transform: `translate(0, ${paperOriginY})`, children: [
|
|
5656
7106
|
/* @__PURE__ */ jsx(
|
|
5657
7107
|
"rect",
|
|
@@ -5663,30 +7113,30 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5663
7113
|
strokeWidth: 0.5
|
|
5664
7114
|
}
|
|
5665
7115
|
),
|
|
5666
|
-
config.isShowColorbar && /* @__PURE__ */ jsx(
|
|
7116
|
+
(config.isShowColorbar ?? true) && /* @__PURE__ */ jsx(
|
|
5667
7117
|
Colorbar,
|
|
5668
7118
|
{
|
|
5669
7119
|
side: colorbarSide,
|
|
5670
|
-
colorbarHeight: config.colorbarHeight,
|
|
7120
|
+
colorbarHeight: config.colorbarHeight ?? 5,
|
|
5671
7121
|
paperWidth: paperResult.paperWidth,
|
|
5672
7122
|
paperHeight: paperResult.paperHeight
|
|
5673
7123
|
}
|
|
5674
7124
|
),
|
|
5675
|
-
config.spacing > 0 && getSpacingRects2(
|
|
7125
|
+
(config.spacing ?? 5) > 0 && getSpacingRects2(
|
|
5676
7126
|
gripperSide,
|
|
5677
7127
|
paperResult.paperWidth,
|
|
5678
7128
|
paperResult.paperHeight,
|
|
5679
|
-
config.spacing,
|
|
5680
|
-
config.griper,
|
|
7129
|
+
config.spacing ?? 5,
|
|
7130
|
+
config.griper ?? 10,
|
|
5681
7131
|
cbDepth
|
|
5682
7132
|
).map((r, i) => /* @__PURE__ */ jsx("rect", { x: r.x, y: r.y, width: r.w, height: r.h, fill: theme.colorSpacing }, `sp-${i}`)),
|
|
5683
|
-
config.griper > 0 && /* @__PURE__ */ jsx(
|
|
7133
|
+
(config.griper ?? 10) > 0 && /* @__PURE__ */ jsx(
|
|
5684
7134
|
Gripper,
|
|
5685
7135
|
{
|
|
5686
7136
|
side: gripperSide,
|
|
5687
7137
|
paperWidth: paperResult.paperWidth,
|
|
5688
7138
|
paperHeight: paperResult.paperHeight,
|
|
5689
|
-
depth: config.griper,
|
|
7139
|
+
depth: config.griper ?? 10,
|
|
5690
7140
|
fillColor: theme.colorGriper
|
|
5691
7141
|
}
|
|
5692
7142
|
),
|
|
@@ -5748,6 +7198,10 @@ var DIE_LINE_LAYOUT = forwardRef(
|
|
|
5748
7198
|
return /* @__PURE__ */ jsx(MODEL_BECF_1040A, { ref, ...props });
|
|
5749
7199
|
case "BECF-11D01":
|
|
5750
7200
|
return /* @__PURE__ */ jsx(MODEL_BECF_11D01, { ref, ...props });
|
|
7201
|
+
case "BECF-12101":
|
|
7202
|
+
return /* @__PURE__ */ jsx(MODEL_BECF_12101, { ref, ...props });
|
|
7203
|
+
case "BECF-12109":
|
|
7204
|
+
return /* @__PURE__ */ jsx(MODEL_BECF_12109, { ref, ...props });
|
|
5751
7205
|
default:
|
|
5752
7206
|
return null;
|
|
5753
7207
|
}
|
|
@@ -5784,12 +7238,19 @@ var BECF_1040A_DEFAULT_ATTRIBUTES = {
|
|
|
5784
7238
|
tuckFlap: 14
|
|
5785
7239
|
};
|
|
5786
7240
|
|
|
5787
|
-
// src/statics/
|
|
5788
|
-
var
|
|
7241
|
+
// src/statics/bags-pillows/becf-12101/DEFAULT_ATTRIBUTES.ts
|
|
7242
|
+
var BECF_12101_DEFAULT_ATTRIBUTES = {
|
|
7243
|
+
length: 100,
|
|
7244
|
+
width: 50,
|
|
7245
|
+
height: 150,
|
|
7246
|
+
glueArea: 13
|
|
7247
|
+
};
|
|
7248
|
+
|
|
7249
|
+
// src/statics/bags-pillows/becf-12109/DEFAULT_ATTRIBUTES.ts
|
|
7250
|
+
var BECF_12109_DEFAULT_ATTRIBUTES = {
|
|
5789
7251
|
length: 100,
|
|
5790
7252
|
width: 50,
|
|
5791
7253
|
height: 150,
|
|
5792
|
-
flapHeight: 50,
|
|
5793
7254
|
glueArea: 13
|
|
5794
7255
|
};
|
|
5795
7256
|
|
|
@@ -5816,15 +7277,38 @@ var modelList = [
|
|
|
5816
7277
|
dimension: ["DIE_LINE"],
|
|
5817
7278
|
attributes: { ...BECF_1030A_DEFAULT_ATTRIBUTES }
|
|
5818
7279
|
},
|
|
7280
|
+
// {
|
|
7281
|
+
// id: "BECF-11D01",
|
|
7282
|
+
// nameEN: "Standard Box BECF-11D01",
|
|
7283
|
+
// nameTH: "กล่องทั่วไป BECF-11D01",
|
|
7284
|
+
// dimension: ["DIE_LINE"],
|
|
7285
|
+
// attributes: { ...BECF_11D01_DEFAULT_ATTRIBUTES },
|
|
7286
|
+
// },
|
|
5819
7287
|
{
|
|
5820
|
-
id: "BECF-
|
|
5821
|
-
nameEN: "
|
|
5822
|
-
nameTH: "\
|
|
7288
|
+
id: "BECF-12101",
|
|
7289
|
+
nameEN: "SHOPPING BAGS TYPE A",
|
|
7290
|
+
nameTH: "\u0E16\u0E38\u0E07\u0E23\u0E49\u0E2D\u0E22\u0E40\u0E0A\u0E37\u0E2D\u0E01\u0E40\u0E1B\u0E35\u0E22 \u0E21\u0E31\u0E14\u0E1B\u0E21 A",
|
|
5823
7291
|
dimension: ["DIE_LINE"],
|
|
5824
|
-
attributes: { ...
|
|
7292
|
+
attributes: { ...BECF_12101_DEFAULT_ATTRIBUTES }
|
|
7293
|
+
},
|
|
7294
|
+
{
|
|
7295
|
+
id: "BECF-12109",
|
|
7296
|
+
nameEN: "SHOPPING BAGS TYPE B",
|
|
7297
|
+
nameTH: "\u0E16\u0E38\u0E07\u0E23\u0E49\u0E2D\u0E22\u0E40\u0E0A\u0E37\u0E2D\u0E01\u0E40\u0E1B\u0E35\u0E22 \u0E21\u0E31\u0E14\u0E1B\u0E21 B",
|
|
7298
|
+
dimension: ["DIE_LINE"],
|
|
7299
|
+
attributes: { ...BECF_12109_DEFAULT_ATTRIBUTES }
|
|
5825
7300
|
}
|
|
5826
7301
|
];
|
|
5827
7302
|
|
|
5828
|
-
|
|
7303
|
+
// src/statics/standard-boxes/becf-11d01/DEFAULT_ATTRIBUTES.ts
|
|
7304
|
+
var BECF_11D01_DEFAULT_ATTRIBUTES = {
|
|
7305
|
+
length: 100,
|
|
7306
|
+
width: 50,
|
|
7307
|
+
height: 150,
|
|
7308
|
+
flapHeight: 50,
|
|
7309
|
+
glueArea: 13
|
|
7310
|
+
};
|
|
7311
|
+
|
|
7312
|
+
export { AUTO_LAYOUT, AUTO_LAYOUT_THEME_CONFIG, BECF_1010A_DEFAULT_ATTRIBUTES, BECF_1030A_DEFAULT_ATTRIBUTES, BECF_1040A_DEFAULT_ATTRIBUTES, BECF_11D01_DEFAULT_ATTRIBUTES, BECF_12101_DEFAULT_ATTRIBUTES, BECF_12109_DEFAULT_ATTRIBUTES, Colorbar, DIE_LINE_LAYOUT, Gripper, MODEL_BECF_1010A, MODEL_BECF_1030A, MODEL_BECF_1040A, MODEL_BECF_11D01, MODEL_BECF_12101, MODEL_BECF_12109, MODEL_THEME_CONFIG, appendColorbarToSvg, appendGripperToSvg, calculateAutoLayout, configurePackaging, modelList };
|
|
5829
7313
|
//# sourceMappingURL=index.mjs.map
|
|
5830
7314
|
//# sourceMappingURL=index.mjs.map
|