@lucablockltd/ultimate-packaging 1.0.2 → 1.1.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 +288 -106
- package/dist/index.d.mts +129 -23
- package/dist/index.d.ts +129 -23
- package/dist/index.js +2167 -522
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2164 -523
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
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 });
|
|
@@ -2065,6 +2069,142 @@ function bottomDustFlaps3(xSide1, xFront, xSide2, xEnd, yBody2, dustFlap, dfCorn
|
|
|
2065
2069
|
dustFlapPath3(xSide2, xEnd, yBody2, 1, dustFlap, dfCorner, dfInset, dfVertical, "none", "edge")
|
|
2066
2070
|
];
|
|
2067
2071
|
}
|
|
2072
|
+
function generateOuterContour3(attr) {
|
|
2073
|
+
const { length, width, height, glueArea, dustFlap, tuckFlap } = attr;
|
|
2074
|
+
const glueTaper = glueArea * GLUE_TAPER_RATIO3;
|
|
2075
|
+
const dfInset = Math.min(dustFlap / 6, width * 0.2);
|
|
2076
|
+
const dfCorner = Math.min(dustFlap * 0.1, dfInset * 0.6);
|
|
2077
|
+
const dfVertical = Math.min(dustFlap / 6, dustFlap - dfCorner);
|
|
2078
|
+
const xRear = glueArea;
|
|
2079
|
+
const xSide1 = glueArea + length;
|
|
2080
|
+
const xFront = glueArea + length + width;
|
|
2081
|
+
const xSide2 = glueArea + length + width + length;
|
|
2082
|
+
const xEnd = glueArea + 2 * length + 2 * width;
|
|
2083
|
+
const yTop = 0;
|
|
2084
|
+
const yFold1 = tuckFlap;
|
|
2085
|
+
const yBody1 = tuckFlap + width;
|
|
2086
|
+
const yBody2 = tuckFlap + width + height;
|
|
2087
|
+
const yFold2 = tuckFlap + width + height + width;
|
|
2088
|
+
const yBot = tuckFlap + 2 * width + height + tuckFlap;
|
|
2089
|
+
const arcSteps = 8;
|
|
2090
|
+
const points = [];
|
|
2091
|
+
points.push({ x: 0, y: yBody2 - glueTaper });
|
|
2092
|
+
points.push({ x: 0, y: yBody1 + glueTaper });
|
|
2093
|
+
points.push({ x: xRear, y: yBody1 });
|
|
2094
|
+
points.push({ x: xSide1, y: yBody1 });
|
|
2095
|
+
points.push({ x: xSide1 + MT3, y: yBody1 });
|
|
2096
|
+
points.push({ x: xSide1 + MT3, y: yBody1 - dfVertical });
|
|
2097
|
+
points.push({ x: xSide1 + MT3 + dfCorner, y: yBody1 - dfVertical - dfCorner });
|
|
2098
|
+
points.push({ x: xSide1 + dfInset, y: yBody1 - dustFlap });
|
|
2099
|
+
points.push({ x: xFront - dfInset, y: yBody1 - dustFlap });
|
|
2100
|
+
points.push({ x: xFront - dfCorner, y: yBody1 - dfCorner });
|
|
2101
|
+
points.push({ x: xFront, y: yBody1 });
|
|
2102
|
+
points.push({ x: xFront, y: yFold1 });
|
|
2103
|
+
points.push({ x: xFront + MT3, y: yFold1 });
|
|
2104
|
+
for (let i = 0; i <= arcSteps; i++) {
|
|
2105
|
+
const a = Math.PI + Math.PI / 2 * (i / arcSteps);
|
|
2106
|
+
points.push({
|
|
2107
|
+
x: xFront + MT3 + ARC_R3 + ARC_R3 * Math.cos(a),
|
|
2108
|
+
y: yTop + ARC_R3 + ARC_R3 * Math.sin(a)
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
for (let i = 0; i <= arcSteps; i++) {
|
|
2112
|
+
const a = -Math.PI / 2 + Math.PI / 2 * (i / arcSteps);
|
|
2113
|
+
points.push({
|
|
2114
|
+
x: xSide2 - MT3 - ARC_R3 + ARC_R3 * Math.cos(a),
|
|
2115
|
+
y: yTop + ARC_R3 + ARC_R3 * Math.sin(a)
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
points.push({ x: xSide2 - MT3, y: yFold1 });
|
|
2119
|
+
points.push({ x: xSide2, y: yFold1 });
|
|
2120
|
+
points.push({ x: xSide2, y: yBody1 });
|
|
2121
|
+
points.push({ x: xSide2 + dfCorner, y: yBody1 - dfCorner });
|
|
2122
|
+
points.push({ x: xSide2 + dfInset, y: yBody1 - dustFlap });
|
|
2123
|
+
points.push({ x: xEnd - dfInset, y: yBody1 - dustFlap });
|
|
2124
|
+
points.push({ x: xEnd - dfCorner, y: yBody1 - dfVertical - dfCorner });
|
|
2125
|
+
points.push({ x: xEnd, y: yBody1 - dfVertical });
|
|
2126
|
+
points.push({ x: xEnd, y: yBody1 });
|
|
2127
|
+
points.push({ x: xEnd, y: yBody2 });
|
|
2128
|
+
points.push({ x: xEnd, y: yBody2 + dfVertical });
|
|
2129
|
+
points.push({ x: xEnd - dfCorner, y: yBody2 + dfVertical + dfCorner });
|
|
2130
|
+
points.push({ x: xEnd - dfInset, y: yBody2 + dustFlap });
|
|
2131
|
+
points.push({ x: xSide2 + dfInset, y: yBody2 + dustFlap });
|
|
2132
|
+
points.push({ x: xSide2 + dfCorner, y: yBody2 + dfCorner });
|
|
2133
|
+
points.push({ x: xSide2, y: yBody2 });
|
|
2134
|
+
points.push({ x: xSide2, y: yFold2 });
|
|
2135
|
+
points.push({ x: xSide2 - MT3, y: yFold2 });
|
|
2136
|
+
for (let i = 0; i <= arcSteps; i++) {
|
|
2137
|
+
const a = Math.PI / 2 * (i / arcSteps);
|
|
2138
|
+
points.push({
|
|
2139
|
+
x: xSide2 - MT3 - ARC_R3 + ARC_R3 * Math.cos(a),
|
|
2140
|
+
y: yBot - ARC_R3 + ARC_R3 * Math.sin(a)
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
for (let i = 0; i <= arcSteps; i++) {
|
|
2144
|
+
const a = Math.PI / 2 + Math.PI / 2 * (i / arcSteps);
|
|
2145
|
+
points.push({
|
|
2146
|
+
x: xFront + MT3 + ARC_R3 + ARC_R3 * Math.cos(a),
|
|
2147
|
+
y: yBot - ARC_R3 + ARC_R3 * Math.sin(a)
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
points.push({ x: xFront + MT3, y: yFold2 });
|
|
2151
|
+
points.push({ x: xFront, y: yFold2 });
|
|
2152
|
+
points.push({ x: xFront, y: yBody2 });
|
|
2153
|
+
points.push({ x: xFront - dfCorner, y: yBody2 + dfCorner });
|
|
2154
|
+
points.push({ x: xFront - dfInset, y: yBody2 + dustFlap });
|
|
2155
|
+
points.push({ x: xSide1 + dfInset, y: yBody2 + dustFlap });
|
|
2156
|
+
points.push({ x: xSide1 + MT3 + dfCorner, y: yBody2 + dfVertical + dfCorner });
|
|
2157
|
+
points.push({ x: xSide1 + MT3, y: yBody2 + dfVertical });
|
|
2158
|
+
points.push({ x: xSide1 + MT3, y: yBody2 });
|
|
2159
|
+
points.push({ x: xSide1, y: yBody2 });
|
|
2160
|
+
points.push({ x: xRear, y: yBody2 });
|
|
2161
|
+
return points;
|
|
2162
|
+
}
|
|
2163
|
+
function offsetContour3(points, distance) {
|
|
2164
|
+
const n = points.length;
|
|
2165
|
+
const result = [];
|
|
2166
|
+
for (let i = 0; i < n; i++) {
|
|
2167
|
+
const prev = points[(i - 1 + n) % n];
|
|
2168
|
+
const curr = points[i];
|
|
2169
|
+
const next = points[(i + 1) % n];
|
|
2170
|
+
const e1x = curr.x - prev.x;
|
|
2171
|
+
const e1y = curr.y - prev.y;
|
|
2172
|
+
const e2x = next.x - curr.x;
|
|
2173
|
+
const e2y = next.y - curr.y;
|
|
2174
|
+
const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
|
|
2175
|
+
const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
|
|
2176
|
+
if (len1 === 0 || len2 === 0) {
|
|
2177
|
+
result.push(curr);
|
|
2178
|
+
continue;
|
|
2179
|
+
}
|
|
2180
|
+
const n1x = e1y / len1;
|
|
2181
|
+
const n1y = -e1x / len1;
|
|
2182
|
+
const n2x = e2y / len2;
|
|
2183
|
+
const n2y = -e2x / len2;
|
|
2184
|
+
const ax = n1x + n2x;
|
|
2185
|
+
const ay = n1y + n2y;
|
|
2186
|
+
const aLen = Math.sqrt(ax * ax + ay * ay);
|
|
2187
|
+
if (aLen < 1e-3) {
|
|
2188
|
+
result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
|
|
2189
|
+
continue;
|
|
2190
|
+
}
|
|
2191
|
+
const nx = ax / aLen;
|
|
2192
|
+
const ny = ay / aLen;
|
|
2193
|
+
const dot = n1x * nx + n1y * ny;
|
|
2194
|
+
const d = distance / Math.max(dot, 0.1);
|
|
2195
|
+
result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
|
|
2196
|
+
}
|
|
2197
|
+
return result;
|
|
2198
|
+
}
|
|
2199
|
+
function contourToPath3(points) {
|
|
2200
|
+
if (points.length === 0) return "";
|
|
2201
|
+
let d = `M${points[0].x} ${points[0].y}`;
|
|
2202
|
+
for (let i = 1; i < points.length; i++) {
|
|
2203
|
+
d += ` L${points[i].x} ${points[i].y}`;
|
|
2204
|
+
}
|
|
2205
|
+
d += " Z";
|
|
2206
|
+
return d;
|
|
2207
|
+
}
|
|
2068
2208
|
function generateDimensions3(attr, unit) {
|
|
2069
2209
|
const { length, width, height, glueArea, dustFlap, tuckFlap } = attr;
|
|
2070
2210
|
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
@@ -2172,7 +2312,7 @@ var UNIT_FACTOR3 = {
|
|
|
2172
2312
|
in: 1 / 25.4
|
|
2173
2313
|
};
|
|
2174
2314
|
var PX_PER_MM3 = 96 / 25.4;
|
|
2175
|
-
function renderDimension3(dim, i) {
|
|
2315
|
+
function renderDimension3(dim, i, fs) {
|
|
2176
2316
|
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
2177
2317
|
const tick = 1.5;
|
|
2178
2318
|
if (orientation === "horizontal") {
|
|
@@ -2188,7 +2328,7 @@ function renderDimension3(dim, i) {
|
|
|
2188
2328
|
x: midX,
|
|
2189
2329
|
y: y - 1.5,
|
|
2190
2330
|
textAnchor: "middle",
|
|
2191
|
-
fontSize:
|
|
2331
|
+
fontSize: fs,
|
|
2192
2332
|
fontFamily: "sans-serif",
|
|
2193
2333
|
fill: "#000",
|
|
2194
2334
|
children: label
|
|
@@ -2209,7 +2349,7 @@ function renderDimension3(dim, i) {
|
|
|
2209
2349
|
y: midY - 1,
|
|
2210
2350
|
textAnchor: "middle",
|
|
2211
2351
|
dominantBaseline: "central",
|
|
2212
|
-
fontSize:
|
|
2352
|
+
fontSize: fs,
|
|
2213
2353
|
fontFamily: "sans-serif",
|
|
2214
2354
|
fill: "#000",
|
|
2215
2355
|
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
@@ -2318,7 +2458,7 @@ var DIE_LINE_BECF_1040A = forwardRef(
|
|
|
2318
2458
|
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2319
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}`)) }),
|
|
2320
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}`)) }),
|
|
2321
|
-
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())) })
|
|
2322
2462
|
] });
|
|
2323
2463
|
if (renderAs === "group") {
|
|
2324
2464
|
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
@@ -2551,7 +2691,7 @@ function bottomFlaps(xRear, xSide1, xFront, xSide2, xEnd, yBody2, yBot) {
|
|
|
2551
2691
|
);
|
|
2552
2692
|
return paths;
|
|
2553
2693
|
}
|
|
2554
|
-
function
|
|
2694
|
+
function generateOuterContour4(attr) {
|
|
2555
2695
|
const { length, width, height, flapHeight, glueArea } = attr;
|
|
2556
2696
|
const glueTaper = glueArea * GLUE_TAPER_RATIO4;
|
|
2557
2697
|
const xRear = glueArea;
|
|
@@ -2602,7 +2742,7 @@ function generateOuterContour3(attr) {
|
|
|
2602
2742
|
points.push({ x: xRear, y: yBody2 });
|
|
2603
2743
|
return points;
|
|
2604
2744
|
}
|
|
2605
|
-
function
|
|
2745
|
+
function offsetContour4(points, distance) {
|
|
2606
2746
|
const n = points.length;
|
|
2607
2747
|
const result = [];
|
|
2608
2748
|
for (let i = 0; i < n; i++) {
|
|
@@ -2638,7 +2778,7 @@ function offsetContour3(points, distance) {
|
|
|
2638
2778
|
}
|
|
2639
2779
|
return result;
|
|
2640
2780
|
}
|
|
2641
|
-
function
|
|
2781
|
+
function contourToPath4(points) {
|
|
2642
2782
|
if (points.length === 0) return "";
|
|
2643
2783
|
let d = `M${points[0].x} ${points[0].y}`;
|
|
2644
2784
|
for (let i = 1; i < points.length; i++) {
|
|
@@ -2735,7 +2875,7 @@ var UNIT_FACTOR4 = {
|
|
|
2735
2875
|
in: 1 / 25.4
|
|
2736
2876
|
};
|
|
2737
2877
|
var PX_PER_MM4 = 96 / 25.4;
|
|
2738
|
-
function renderDimension4(dim, i) {
|
|
2878
|
+
function renderDimension4(dim, i, fs) {
|
|
2739
2879
|
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
2740
2880
|
const tick = 1.5;
|
|
2741
2881
|
if (orientation === "horizontal") {
|
|
@@ -2751,7 +2891,7 @@ function renderDimension4(dim, i) {
|
|
|
2751
2891
|
x: midX,
|
|
2752
2892
|
y: y - 1.5,
|
|
2753
2893
|
textAnchor: "middle",
|
|
2754
|
-
fontSize:
|
|
2894
|
+
fontSize: fs,
|
|
2755
2895
|
fontFamily: "sans-serif",
|
|
2756
2896
|
fill: "#000",
|
|
2757
2897
|
children: label
|
|
@@ -2772,7 +2912,7 @@ function renderDimension4(dim, i) {
|
|
|
2772
2912
|
y: midY - 1,
|
|
2773
2913
|
textAnchor: "middle",
|
|
2774
2914
|
dominantBaseline: "central",
|
|
2775
|
-
fontSize:
|
|
2915
|
+
fontSize: fs,
|
|
2776
2916
|
fontFamily: "sans-serif",
|
|
2777
2917
|
fill: "#000",
|
|
2778
2918
|
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
@@ -2880,7 +3020,7 @@ var DIE_LINE_BECF_11D01 = forwardRef(
|
|
|
2880
3020
|
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2881
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}`)) }),
|
|
2882
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}`)) }),
|
|
2883
|
-
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())) })
|
|
2884
3024
|
] });
|
|
2885
3025
|
if (renderAs === "group") {
|
|
2886
3026
|
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
@@ -2994,108 +3134,1101 @@ var MODEL_BECF_11D01 = forwardRef(
|
|
|
2994
3134
|
}
|
|
2995
3135
|
);
|
|
2996
3136
|
|
|
2997
|
-
// src/
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
if (p.y > maxY) maxY = p.y;
|
|
3005
|
-
}
|
|
3006
|
-
const offsetX = Math.floor(minX / resolution);
|
|
3007
|
-
const offsetY = Math.floor(minY / resolution);
|
|
3008
|
-
const w = Math.ceil((maxX - offsetX * resolution) / resolution) + 1;
|
|
3009
|
-
const h = Math.ceil((maxY - offsetY * resolution) / resolution) + 1;
|
|
3010
|
-
const data = new Uint8Array(w * h);
|
|
3011
|
-
for (let gy = 0; gy < h; gy++) {
|
|
3012
|
-
const worldY = (offsetY + gy) * resolution + resolution / 2;
|
|
3013
|
-
const crossings = [];
|
|
3014
|
-
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
|
|
3015
|
-
const yi = points[i].y, yj = points[j].y;
|
|
3016
|
-
if (yi <= worldY && yj > worldY || yj <= worldY && yi > worldY) {
|
|
3017
|
-
const t = (worldY - yi) / (yj - yi);
|
|
3018
|
-
crossings.push(points[i].x + t * (points[j].x - points[i].x));
|
|
3019
|
-
}
|
|
3020
|
-
}
|
|
3021
|
-
crossings.sort((a, b) => a - b);
|
|
3022
|
-
for (let c = 0; c < crossings.length - 1; c += 2) {
|
|
3023
|
-
const startGx = Math.max(0, Math.floor((crossings[c] - offsetX * resolution) / resolution));
|
|
3024
|
-
const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
|
|
3025
|
-
for (let gx = startGx; gx <= endGx; gx++) {
|
|
3026
|
-
data[gy * w + gx] = 1;
|
|
3027
|
-
}
|
|
3028
|
-
}
|
|
3029
|
-
}
|
|
3030
|
-
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);
|
|
3031
3144
|
}
|
|
3032
|
-
function
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
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}`;
|
|
3164
|
+
}
|
|
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);
|
|
3039
3253
|
continue;
|
|
3040
3254
|
}
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
}
|
|
3050
|
-
|
|
3051
|
-
for (let y = 0; y < piece.height; y++) {
|
|
3052
|
-
for (let x = 0; x < piece.width; x++) {
|
|
3053
|
-
if (piece.data[y * piece.width + x]) {
|
|
3054
|
-
paperGrid[(py + y) * paperW + (px + x)] = 1;
|
|
3055
|
-
}
|
|
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;
|
|
3056
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 });
|
|
3057
3271
|
}
|
|
3272
|
+
return result;
|
|
3058
3273
|
}
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
return "left";
|
|
3065
|
-
}
|
|
3066
|
-
function computeUsableBounds(paperWidth, paperHeight, gripperSide, spacing, griper, colorbarDepth) {
|
|
3067
|
-
switch (gripperSide) {
|
|
3068
|
-
case "bottom":
|
|
3069
|
-
return {
|
|
3070
|
-
top: colorbarDepth + spacing,
|
|
3071
|
-
bottom: paperHeight - griper,
|
|
3072
|
-
left: spacing,
|
|
3073
|
-
right: paperWidth - spacing
|
|
3074
|
-
};
|
|
3075
|
-
case "top":
|
|
3076
|
-
return {
|
|
3077
|
-
top: griper,
|
|
3078
|
-
bottom: paperHeight - colorbarDepth - spacing,
|
|
3079
|
-
left: spacing,
|
|
3080
|
-
right: paperWidth - spacing
|
|
3081
|
-
};
|
|
3082
|
-
case "left":
|
|
3083
|
-
return {
|
|
3084
|
-
top: spacing,
|
|
3085
|
-
bottom: paperHeight - spacing,
|
|
3086
|
-
left: griper,
|
|
3087
|
-
right: paperWidth - colorbarDepth - spacing
|
|
3088
|
-
};
|
|
3089
|
-
case "right":
|
|
3090
|
-
return {
|
|
3091
|
-
top: spacing,
|
|
3092
|
-
bottom: paperHeight - spacing,
|
|
3093
|
-
left: colorbarDepth + spacing,
|
|
3094
|
-
right: paperWidth - griper
|
|
3095
|
-
};
|
|
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}`;
|
|
3096
3279
|
}
|
|
3280
|
+
d += " Z";
|
|
3281
|
+
return d;
|
|
3097
3282
|
}
|
|
3098
|
-
function
|
|
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
|
+
];
|
|
3380
|
+
}
|
|
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}`);
|
|
3411
|
+
}
|
|
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}`);
|
|
3433
|
+
}
|
|
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 generateDimensions6(attr, unit) {
|
|
3759
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3760
|
+
const D = calcD2(C, B);
|
|
3761
|
+
const kulak = glueArea ?? calcKulak2(B);
|
|
3762
|
+
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
3763
|
+
const suffix = unit;
|
|
3764
|
+
const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
|
|
3765
|
+
const xFront = kulak;
|
|
3766
|
+
const xSide1 = kulak + A;
|
|
3767
|
+
const xBack = kulak + A + B;
|
|
3768
|
+
const yFoldTop = D;
|
|
3769
|
+
const yFoldBottom = D + C;
|
|
3770
|
+
const yEnd = D + C + B / 2 + DIP2;
|
|
3771
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
3772
|
+
const totalHeight = yEnd;
|
|
3773
|
+
const bottomSection = B / 2 + DIP2;
|
|
3774
|
+
return [
|
|
3775
|
+
// Overall dimensions (outside)
|
|
3776
|
+
{
|
|
3777
|
+
x1: 0,
|
|
3778
|
+
y1: 0,
|
|
3779
|
+
x2: totalWidth,
|
|
3780
|
+
y2: 0,
|
|
3781
|
+
label: `Overall Width : ${fmt(totalWidth)}`,
|
|
3782
|
+
orientation: "horizontal",
|
|
3783
|
+
offset: -12
|
|
3784
|
+
},
|
|
3785
|
+
{
|
|
3786
|
+
x1: 0,
|
|
3787
|
+
y1: 0,
|
|
3788
|
+
x2: 0,
|
|
3789
|
+
y2: totalHeight,
|
|
3790
|
+
label: `Overall Height : ${fmt(totalHeight)}`,
|
|
3791
|
+
orientation: "vertical",
|
|
3792
|
+
offset: -12
|
|
3793
|
+
},
|
|
3794
|
+
// Height (C) — body area (centered on back panel)
|
|
3795
|
+
{
|
|
3796
|
+
x1: xBack + A * 0.6,
|
|
3797
|
+
y1: yFoldTop,
|
|
3798
|
+
x2: xBack + A * 0.6,
|
|
3799
|
+
y2: yFoldBottom,
|
|
3800
|
+
label: fmt(C),
|
|
3801
|
+
orientation: "vertical",
|
|
3802
|
+
offset: -10
|
|
3803
|
+
},
|
|
3804
|
+
// Top flap (D) (centered on back panel)
|
|
3805
|
+
{
|
|
3806
|
+
x1: xBack + A * 0.6,
|
|
3807
|
+
y1: 0,
|
|
3808
|
+
x2: xBack + A * 0.6,
|
|
3809
|
+
y2: yFoldTop,
|
|
3810
|
+
label: fmt(D),
|
|
3811
|
+
orientation: "vertical",
|
|
3812
|
+
offset: -10
|
|
3813
|
+
},
|
|
3814
|
+
// Bottom section (B/2 + _dip) (centered on back panel)
|
|
3815
|
+
{
|
|
3816
|
+
x1: xBack + A * 0.6,
|
|
3817
|
+
y1: yFoldBottom,
|
|
3818
|
+
x2: xBack + A * 0.6,
|
|
3819
|
+
y2: yEnd,
|
|
3820
|
+
label: fmt(bottomSection),
|
|
3821
|
+
orientation: "vertical",
|
|
3822
|
+
offset: -10
|
|
3823
|
+
},
|
|
3824
|
+
// Length (A) — front panel (centered vertically on body)
|
|
3825
|
+
{
|
|
3826
|
+
x1: xFront,
|
|
3827
|
+
y1: yFoldTop + C * 0.65,
|
|
3828
|
+
x2: xSide1,
|
|
3829
|
+
y2: yFoldTop + C * 0.65,
|
|
3830
|
+
label: fmt(A),
|
|
3831
|
+
orientation: "horizontal",
|
|
3832
|
+
offset: -20
|
|
3833
|
+
},
|
|
3834
|
+
// Width (B) — side panel (centered vertically on body)
|
|
3835
|
+
{
|
|
3836
|
+
x1: xSide1,
|
|
3837
|
+
y1: yFoldTop + C * 0.65,
|
|
3838
|
+
x2: xBack,
|
|
3839
|
+
y2: yFoldTop + C * 0.65,
|
|
3840
|
+
label: fmt(B),
|
|
3841
|
+
orientation: "horizontal",
|
|
3842
|
+
offset: -20
|
|
3843
|
+
},
|
|
3844
|
+
// Glue Area (kulak) — left glue flap width
|
|
3845
|
+
{
|
|
3846
|
+
x1: 0,
|
|
3847
|
+
y1: yFoldTop + C * 0.65,
|
|
3848
|
+
x2: xFront,
|
|
3849
|
+
y2: yFoldTop + C * 0.65,
|
|
3850
|
+
label: fmt(kulak),
|
|
3851
|
+
orientation: "horizontal",
|
|
3852
|
+
offset: -20
|
|
3853
|
+
}
|
|
3854
|
+
];
|
|
3855
|
+
}
|
|
3856
|
+
var MODEL_ID6 = "BECF-12109";
|
|
3857
|
+
var UNIT_FACTOR6 = {
|
|
3858
|
+
mm: 1,
|
|
3859
|
+
cm: 0.1,
|
|
3860
|
+
in: 1 / 25.4
|
|
3861
|
+
};
|
|
3862
|
+
var PX_PER_MM6 = 96 / 25.4;
|
|
3863
|
+
function renderDimension6(dim, i, fs) {
|
|
3864
|
+
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
3865
|
+
const tick = 1.5;
|
|
3866
|
+
if (orientation === "horizontal") {
|
|
3867
|
+
const y = y1 + offset;
|
|
3868
|
+
const midX = (x1 + x2) / 2;
|
|
3869
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3870
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
|
|
3871
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
3872
|
+
/* @__PURE__ */ jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
3873
|
+
/* @__PURE__ */ jsx(
|
|
3874
|
+
"text",
|
|
3875
|
+
{
|
|
3876
|
+
x: midX,
|
|
3877
|
+
y: y - 1.5,
|
|
3878
|
+
textAnchor: "middle",
|
|
3879
|
+
fontSize: fs,
|
|
3880
|
+
fontFamily: "sans-serif",
|
|
3881
|
+
fill: "#000",
|
|
3882
|
+
children: label
|
|
3883
|
+
}
|
|
3884
|
+
)
|
|
3885
|
+
] }, `dim-${i}`);
|
|
3886
|
+
}
|
|
3887
|
+
const x = x1 + offset;
|
|
3888
|
+
const midY = (y1 + y2) / 2;
|
|
3889
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3890
|
+
/* @__PURE__ */ jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
|
|
3891
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
|
|
3892
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
|
|
3893
|
+
/* @__PURE__ */ jsx(
|
|
3894
|
+
"text",
|
|
3895
|
+
{
|
|
3896
|
+
x: x - 1.5,
|
|
3897
|
+
y: midY - 1,
|
|
3898
|
+
textAnchor: "middle",
|
|
3899
|
+
dominantBaseline: "central",
|
|
3900
|
+
fontSize: fs,
|
|
3901
|
+
fontFamily: "sans-serif",
|
|
3902
|
+
fill: "#000",
|
|
3903
|
+
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
3904
|
+
children: label
|
|
3905
|
+
}
|
|
3906
|
+
)
|
|
3907
|
+
] }, `dim-${i}`);
|
|
3908
|
+
}
|
|
3909
|
+
var DIE_LINE_BECF_12109 = forwardRef(
|
|
3910
|
+
({
|
|
3911
|
+
attributes,
|
|
3912
|
+
unit = "mm",
|
|
3913
|
+
isShowDimensions = false,
|
|
3914
|
+
renderAs = "svg"
|
|
3915
|
+
}, ref) => {
|
|
3916
|
+
const theme = useMemo(
|
|
3917
|
+
() => getModelTheme(),
|
|
3918
|
+
[]
|
|
3919
|
+
);
|
|
3920
|
+
const svgRef = useRef(null);
|
|
3921
|
+
const dieline = useMemo(() => generateBecf12109(attributes), [attributes]);
|
|
3922
|
+
const dimensions = useMemo(
|
|
3923
|
+
() => generateDimensions6(attributes, unit),
|
|
3924
|
+
[attributes, unit]
|
|
3925
|
+
);
|
|
3926
|
+
const factor = UNIT_FACTOR6[unit] ?? 1;
|
|
3927
|
+
const serializeSvg = useCallback(
|
|
3928
|
+
(showDimensions) => {
|
|
3929
|
+
const svg = svgRef.current;
|
|
3930
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
3931
|
+
const clone = svg.cloneNode(true);
|
|
3932
|
+
if (!showDimensions) {
|
|
3933
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
3934
|
+
dimGroup?.remove();
|
|
3935
|
+
}
|
|
3936
|
+
return new XMLSerializer().serializeToString(clone);
|
|
3937
|
+
},
|
|
3938
|
+
[]
|
|
3939
|
+
);
|
|
3940
|
+
useImperativeHandle(
|
|
3941
|
+
ref,
|
|
3942
|
+
() => {
|
|
3943
|
+
const auto = getAutoCalcValues2(attributes);
|
|
3944
|
+
return {
|
|
3945
|
+
getAttributes: () => ({
|
|
3946
|
+
modelId: MODEL_ID6,
|
|
3947
|
+
overallWidth: dieline.viewBox.width * factor,
|
|
3948
|
+
overallHeight: dieline.viewBox.height * factor,
|
|
3949
|
+
length: attributes.length * factor,
|
|
3950
|
+
width: attributes.width * factor,
|
|
3951
|
+
height: attributes.height * factor,
|
|
3952
|
+
glueArea: auto.kulak * factor,
|
|
3953
|
+
d: auto.d * factor,
|
|
3954
|
+
kulak: auto.kulak * factor,
|
|
3955
|
+
dip: auto.dip * factor,
|
|
3956
|
+
ropeR: auto.ropeR * factor,
|
|
3957
|
+
ropeY: auto.ropeY * factor,
|
|
3958
|
+
ropeX: auto.ropeX * factor
|
|
3959
|
+
}),
|
|
3960
|
+
exportImage: async (options) => {
|
|
3961
|
+
const svgStr = serializeSvg(options.isShowDimension);
|
|
3962
|
+
const blob = new Blob([svgStr], {
|
|
3963
|
+
type: "image/svg+xml;charset=utf-8"
|
|
3964
|
+
});
|
|
3965
|
+
const url = URL.createObjectURL(blob);
|
|
3966
|
+
const img = new Image();
|
|
3967
|
+
await new Promise((resolve, reject) => {
|
|
3968
|
+
img.onload = () => resolve();
|
|
3969
|
+
img.onerror = reject;
|
|
3970
|
+
img.src = url;
|
|
3971
|
+
});
|
|
3972
|
+
const canvas = document.createElement("canvas");
|
|
3973
|
+
if (options.originalSize) {
|
|
3974
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM6);
|
|
3975
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM6);
|
|
3976
|
+
} else {
|
|
3977
|
+
canvas.width = 1920;
|
|
3978
|
+
canvas.height = 1080;
|
|
3979
|
+
}
|
|
3980
|
+
const ctx = canvas.getContext("2d");
|
|
3981
|
+
ctx.fillStyle = "#ffffff";
|
|
3982
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
3983
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
3984
|
+
URL.revokeObjectURL(url);
|
|
3985
|
+
return new Promise((resolve, reject) => {
|
|
3986
|
+
canvas.toBlob(
|
|
3987
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
3988
|
+
"image/png"
|
|
3989
|
+
);
|
|
3990
|
+
});
|
|
3991
|
+
},
|
|
3992
|
+
exportDimension: async () => {
|
|
3993
|
+
const dimData = generateDimensions6(attributes, unit);
|
|
3994
|
+
return exportDimensionPdf({
|
|
3995
|
+
modelId: MODEL_ID6,
|
|
3996
|
+
dieline,
|
|
3997
|
+
dimensions: dimData,
|
|
3998
|
+
attributes,
|
|
3999
|
+
unit,
|
|
4000
|
+
factor,
|
|
4001
|
+
theme
|
|
4002
|
+
});
|
|
4003
|
+
}
|
|
4004
|
+
};
|
|
4005
|
+
},
|
|
4006
|
+
[attributes, dieline, factor, unit, serializeSvg, theme]
|
|
4007
|
+
);
|
|
4008
|
+
const padding = isShowDimensions ? 15 : 0;
|
|
4009
|
+
const vbX = -padding;
|
|
4010
|
+
const vbY = -padding;
|
|
4011
|
+
const vbW = dieline.viewBox.width + padding * 2;
|
|
4012
|
+
const vbH = dieline.viewBox.height + padding * 2;
|
|
4013
|
+
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4014
|
+
/* @__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}`)) }),
|
|
4015
|
+
/* @__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}`)) }),
|
|
4016
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension6(d, i, getFontDimensionSize())) })
|
|
4017
|
+
] });
|
|
4018
|
+
if (renderAs === "group") {
|
|
4019
|
+
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
4020
|
+
}
|
|
4021
|
+
return /* @__PURE__ */ jsx(
|
|
4022
|
+
"svg",
|
|
4023
|
+
{
|
|
4024
|
+
ref: svgRef,
|
|
4025
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4026
|
+
viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`,
|
|
4027
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
4028
|
+
style: { backgroundColor: theme.colorBackground },
|
|
4029
|
+
children: svgChildren
|
|
4030
|
+
}
|
|
4031
|
+
);
|
|
4032
|
+
}
|
|
4033
|
+
);
|
|
4034
|
+
var CANVAS_BECF_12109 = forwardRef(
|
|
4035
|
+
(props, ref) => {
|
|
4036
|
+
const dieLineRef = useRef(null);
|
|
4037
|
+
const canvasRef = useRef(null);
|
|
4038
|
+
const {
|
|
4039
|
+
attributes
|
|
4040
|
+
} = props;
|
|
4041
|
+
const theme = useMemo(
|
|
4042
|
+
() => getModelTheme(),
|
|
4043
|
+
[]
|
|
4044
|
+
);
|
|
4045
|
+
const dieline = useMemo(() => generateBecf12109(attributes), [attributes]);
|
|
4046
|
+
const stablePadding = 15;
|
|
4047
|
+
const viewBox = useMemo(
|
|
4048
|
+
() => ({
|
|
4049
|
+
x: -stablePadding,
|
|
4050
|
+
y: -stablePadding,
|
|
4051
|
+
width: dieline.viewBox.width + stablePadding * 2,
|
|
4052
|
+
height: dieline.viewBox.height + stablePadding * 2
|
|
4053
|
+
}),
|
|
4054
|
+
[dieline.viewBox.width, dieline.viewBox.height]
|
|
4055
|
+
);
|
|
4056
|
+
const serializeCanvasSvg = useCallback((showDimensions) => {
|
|
4057
|
+
const svg = canvasRef.current?.getSvgElement();
|
|
4058
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
4059
|
+
const clone = svg.cloneNode(true);
|
|
4060
|
+
if (!showDimensions) {
|
|
4061
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
4062
|
+
dimGroup?.remove();
|
|
4063
|
+
}
|
|
4064
|
+
return new XMLSerializer().serializeToString(clone);
|
|
4065
|
+
}, []);
|
|
4066
|
+
useImperativeHandle(ref, () => ({
|
|
4067
|
+
getAttributes: () => dieLineRef.current.getAttributes(),
|
|
4068
|
+
exportImage: async (options) => {
|
|
4069
|
+
const svgStr = serializeCanvasSvg(options.isShowDimension);
|
|
4070
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
4071
|
+
const url = URL.createObjectURL(blob);
|
|
4072
|
+
const img = new Image();
|
|
4073
|
+
await new Promise((resolve, reject) => {
|
|
4074
|
+
img.onload = () => resolve();
|
|
4075
|
+
img.onerror = reject;
|
|
4076
|
+
img.src = url;
|
|
4077
|
+
});
|
|
4078
|
+
const canvas = document.createElement("canvas");
|
|
4079
|
+
if (options.originalSize) {
|
|
4080
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM6);
|
|
4081
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM6);
|
|
4082
|
+
} else {
|
|
4083
|
+
canvas.width = 1920;
|
|
4084
|
+
canvas.height = 1080;
|
|
4085
|
+
}
|
|
4086
|
+
const ctx = canvas.getContext("2d");
|
|
4087
|
+
ctx.fillStyle = "#ffffff";
|
|
4088
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
4089
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
4090
|
+
URL.revokeObjectURL(url);
|
|
4091
|
+
return new Promise((resolve, reject) => {
|
|
4092
|
+
canvas.toBlob(
|
|
4093
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
4094
|
+
"image/png"
|
|
4095
|
+
);
|
|
4096
|
+
});
|
|
4097
|
+
},
|
|
4098
|
+
exportDimension: () => dieLineRef.current.exportDimension(),
|
|
4099
|
+
resetView: () => canvasRef.current?.resetView(),
|
|
4100
|
+
fitView: () => canvasRef.current?.fitView()
|
|
4101
|
+
}), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
|
|
4102
|
+
return /* @__PURE__ */ jsx(
|
|
4103
|
+
BaseCanvas,
|
|
4104
|
+
{
|
|
4105
|
+
ref: canvasRef,
|
|
4106
|
+
viewBox,
|
|
4107
|
+
backgroundColor: theme.colorBackground,
|
|
4108
|
+
children: /* @__PURE__ */ jsx(DIE_LINE_BECF_12109, { ref: dieLineRef, ...props, renderAs: "group" })
|
|
4109
|
+
}
|
|
4110
|
+
);
|
|
4111
|
+
}
|
|
4112
|
+
);
|
|
4113
|
+
var MODEL_BECF_12109 = forwardRef(
|
|
4114
|
+
({ mode = "DIE_LINE", ...props }, ref) => {
|
|
4115
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (() => {
|
|
4116
|
+
switch (mode) {
|
|
4117
|
+
case "DIE_LINE":
|
|
4118
|
+
return /* @__PURE__ */ jsx(CANVAS_BECF_12109, { ref, ...props });
|
|
4119
|
+
case "3D":
|
|
4120
|
+
return null;
|
|
4121
|
+
case "AUTO_LAYOUT":
|
|
4122
|
+
return /* @__PURE__ */ jsx(DIE_LINE_BECF_12109, { ref, ...props });
|
|
4123
|
+
default:
|
|
4124
|
+
return null;
|
|
4125
|
+
}
|
|
4126
|
+
})() });
|
|
4127
|
+
}
|
|
4128
|
+
);
|
|
4129
|
+
|
|
4130
|
+
// src/utils/autoLayout/rasterize.ts
|
|
4131
|
+
function rasterizePolygon(points, resolution) {
|
|
4132
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4133
|
+
for (const p of points) {
|
|
4134
|
+
if (p.x < minX) minX = p.x;
|
|
4135
|
+
if (p.y < minY) minY = p.y;
|
|
4136
|
+
if (p.x > maxX) maxX = p.x;
|
|
4137
|
+
if (p.y > maxY) maxY = p.y;
|
|
4138
|
+
}
|
|
4139
|
+
const offsetX = Math.floor(minX / resolution);
|
|
4140
|
+
const offsetY = Math.floor(minY / resolution);
|
|
4141
|
+
const w = Math.ceil((maxX - offsetX * resolution) / resolution) + 1;
|
|
4142
|
+
const h = Math.ceil((maxY - offsetY * resolution) / resolution) + 1;
|
|
4143
|
+
const data = new Uint8Array(w * h);
|
|
4144
|
+
for (let gy = 0; gy < h; gy++) {
|
|
4145
|
+
const worldY = (offsetY + gy) * resolution + resolution / 2;
|
|
4146
|
+
const crossings = [];
|
|
4147
|
+
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
|
|
4148
|
+
const yi = points[i].y, yj = points[j].y;
|
|
4149
|
+
if (yi <= worldY && yj > worldY || yj <= worldY && yi > worldY) {
|
|
4150
|
+
const t = (worldY - yi) / (yj - yi);
|
|
4151
|
+
crossings.push(points[i].x + t * (points[j].x - points[i].x));
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
crossings.sort((a, b) => a - b);
|
|
4155
|
+
for (let c = 0; c < crossings.length - 1; c += 2) {
|
|
4156
|
+
const startGx = Math.max(0, Math.floor((crossings[c] - offsetX * resolution) / resolution));
|
|
4157
|
+
const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
|
|
4158
|
+
for (let gx = startGx; gx <= endGx; gx++) {
|
|
4159
|
+
data[gy * w + gx] = 1;
|
|
4160
|
+
}
|
|
4161
|
+
}
|
|
4162
|
+
}
|
|
4163
|
+
return { data, width: w, height: h, offsetX, offsetY };
|
|
4164
|
+
}
|
|
4165
|
+
function canPlace(paperGrid, paperW, paperH, piece, px, py) {
|
|
4166
|
+
for (let y = 0; y < piece.height; y++) {
|
|
4167
|
+
const paperY = py + y;
|
|
4168
|
+
if (paperY < 0 || paperY >= paperH) {
|
|
4169
|
+
for (let x = 0; x < piece.width; x++) {
|
|
4170
|
+
if (piece.data[y * piece.width + x]) return false;
|
|
4171
|
+
}
|
|
4172
|
+
continue;
|
|
4173
|
+
}
|
|
4174
|
+
for (let x = 0; x < piece.width; x++) {
|
|
4175
|
+
if (!piece.data[y * piece.width + x]) continue;
|
|
4176
|
+
const paperX = px + x;
|
|
4177
|
+
if (paperX < 0 || paperX >= paperW) return false;
|
|
4178
|
+
if (paperGrid[paperY * paperW + paperX]) return false;
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4181
|
+
return true;
|
|
4182
|
+
}
|
|
4183
|
+
function placePiece(paperGrid, paperW, piece, px, py) {
|
|
4184
|
+
for (let y = 0; y < piece.height; y++) {
|
|
4185
|
+
for (let x = 0; x < piece.width; x++) {
|
|
4186
|
+
if (piece.data[y * piece.width + x]) {
|
|
4187
|
+
paperGrid[(py + y) * paperW + (px + x)] = 1;
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
|
|
4193
|
+
// src/utils/autoLayout/calculate/shared.ts
|
|
4194
|
+
var RESOLUTION = 1;
|
|
4195
|
+
function resolveGripperSide(paperWidth, paperHeight) {
|
|
4196
|
+
if (paperWidth >= paperHeight) return "bottom";
|
|
4197
|
+
return "left";
|
|
4198
|
+
}
|
|
4199
|
+
function computeUsableBounds(paperWidth, paperHeight, gripperSide, spacing, griper, colorbarDepth) {
|
|
4200
|
+
switch (gripperSide) {
|
|
4201
|
+
case "bottom":
|
|
4202
|
+
return {
|
|
4203
|
+
top: colorbarDepth + spacing,
|
|
4204
|
+
bottom: paperHeight - griper,
|
|
4205
|
+
left: spacing,
|
|
4206
|
+
right: paperWidth - spacing
|
|
4207
|
+
};
|
|
4208
|
+
case "top":
|
|
4209
|
+
return {
|
|
4210
|
+
top: griper,
|
|
4211
|
+
bottom: paperHeight - colorbarDepth - spacing,
|
|
4212
|
+
left: spacing,
|
|
4213
|
+
right: paperWidth - spacing
|
|
4214
|
+
};
|
|
4215
|
+
case "left":
|
|
4216
|
+
return {
|
|
4217
|
+
top: spacing,
|
|
4218
|
+
bottom: paperHeight - spacing,
|
|
4219
|
+
left: griper,
|
|
4220
|
+
right: paperWidth - colorbarDepth - spacing
|
|
4221
|
+
};
|
|
4222
|
+
case "right":
|
|
4223
|
+
return {
|
|
4224
|
+
top: spacing,
|
|
4225
|
+
bottom: paperHeight - spacing,
|
|
4226
|
+
left: colorbarDepth + spacing,
|
|
4227
|
+
right: paperWidth - griper
|
|
4228
|
+
};
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
function normalizePoints(points, degrees) {
|
|
3099
4232
|
const rad = degrees * Math.PI / 180;
|
|
3100
4233
|
const cos = Math.cos(rad);
|
|
3101
4234
|
const sin = Math.sin(rad);
|
|
@@ -3108,135 +4241,435 @@ function normalizePoints(points, degrees) {
|
|
|
3108
4241
|
if (p.x < minX) minX = p.x;
|
|
3109
4242
|
if (p.y < minY) minY = p.y;
|
|
3110
4243
|
}
|
|
3111
|
-
return rotated.map((p) => ({ x: p.x - minX, y: p.y - minY }));
|
|
4244
|
+
return rotated.map((p) => ({ x: p.x - minX, y: p.y - minY }));
|
|
4245
|
+
}
|
|
4246
|
+
function computeDielineBBOffset(offsetContourPoints, dielineW, dielineH, degrees) {
|
|
4247
|
+
const rad = degrees * Math.PI / 180;
|
|
4248
|
+
const cos = Math.cos(rad);
|
|
4249
|
+
const sin = Math.sin(rad);
|
|
4250
|
+
let ocMinX = Infinity, ocMinY = Infinity;
|
|
4251
|
+
for (const p of offsetContourPoints) {
|
|
4252
|
+
const rx = p.x * cos - p.y * sin;
|
|
4253
|
+
const ry = p.x * sin + p.y * cos;
|
|
4254
|
+
if (rx < ocMinX) ocMinX = rx;
|
|
4255
|
+
if (ry < ocMinY) ocMinY = ry;
|
|
4256
|
+
}
|
|
4257
|
+
const corners = [[0, 0], [dielineW, 0], [0, dielineH], [dielineW, dielineH]];
|
|
4258
|
+
let dlMinX = Infinity, dlMinY = Infinity;
|
|
4259
|
+
for (const [cx, cy] of corners) {
|
|
4260
|
+
const rx = cx * cos - cy * sin;
|
|
4261
|
+
const ry = cx * sin + cy * cos;
|
|
4262
|
+
if (rx < dlMinX) dlMinX = rx;
|
|
4263
|
+
if (ry < dlMinY) dlMinY = ry;
|
|
4264
|
+
}
|
|
4265
|
+
return { dx: dlMinX - ocMinX, dy: dlMinY - ocMinY };
|
|
4266
|
+
}
|
|
4267
|
+
function computeLayoutForPaperDefault(contourPoints, dielineW, dielineH, paperWidth, paperHeight, bounds) {
|
|
4268
|
+
const usableLeft = Math.ceil(bounds.left / RESOLUTION);
|
|
4269
|
+
const usableTop = Math.ceil(bounds.top / RESOLUTION);
|
|
4270
|
+
const usableRight = Math.floor(bounds.right / RESOLUTION);
|
|
4271
|
+
const usableBottom = Math.floor(bounds.bottom / RESOLUTION);
|
|
4272
|
+
const paperW = Math.floor(paperWidth / RESOLUTION);
|
|
4273
|
+
const paperH = Math.floor(paperHeight / RESOLUTION);
|
|
4274
|
+
let bestCandidate = { rotation: 0, placements: [], producedPerSheet: 0 };
|
|
4275
|
+
let bestGridPositions = [];
|
|
4276
|
+
let bestBitmapW = 0;
|
|
4277
|
+
let bestBitmapH = 0;
|
|
4278
|
+
for (const deg of [0, 90, 180, 270]) {
|
|
4279
|
+
const rotatedContour = normalizePoints(contourPoints, deg);
|
|
4280
|
+
const pieceBitmap = rasterizePolygon(rotatedContour, RESOLUTION);
|
|
4281
|
+
const bbOffset = computeDielineBBOffset(contourPoints, dielineW, dielineH, deg);
|
|
4282
|
+
const paperGrid = new Uint8Array(paperW * paperH);
|
|
4283
|
+
const placements = [];
|
|
4284
|
+
const gridPositions = [];
|
|
4285
|
+
for (let py = usableTop; py <= usableBottom - pieceBitmap.height; py++) {
|
|
4286
|
+
for (let px = usableLeft; px <= usableRight - pieceBitmap.width; px++) {
|
|
4287
|
+
if (canPlace(paperGrid, paperW, paperH, pieceBitmap, px, py)) {
|
|
4288
|
+
placePiece(paperGrid, paperW, pieceBitmap, px, py);
|
|
4289
|
+
gridPositions.push({ px, py });
|
|
4290
|
+
placements.push({
|
|
4291
|
+
x: px * RESOLUTION + bbOffset.dx,
|
|
4292
|
+
y: py * RESOLUTION + bbOffset.dy,
|
|
4293
|
+
rotation: deg
|
|
4294
|
+
});
|
|
4295
|
+
}
|
|
4296
|
+
}
|
|
4297
|
+
}
|
|
4298
|
+
if (placements.length > bestCandidate.producedPerSheet) {
|
|
4299
|
+
bestCandidate = { rotation: deg, placements, producedPerSheet: placements.length };
|
|
4300
|
+
bestGridPositions = gridPositions;
|
|
4301
|
+
bestBitmapW = pieceBitmap.width;
|
|
4302
|
+
bestBitmapH = pieceBitmap.height;
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4305
|
+
if (bestCandidate.placements.length > 0) {
|
|
4306
|
+
let gridMinX = Infinity;
|
|
4307
|
+
let gridMinY = Infinity;
|
|
4308
|
+
let gridMaxX = -Infinity;
|
|
4309
|
+
let gridMaxY = -Infinity;
|
|
4310
|
+
for (const { px, py } of bestGridPositions) {
|
|
4311
|
+
if (px < gridMinX) gridMinX = px;
|
|
4312
|
+
if (py < gridMinY) gridMinY = py;
|
|
4313
|
+
if (px + bestBitmapW > gridMaxX) gridMaxX = px + bestBitmapW;
|
|
4314
|
+
if (py + bestBitmapH > gridMaxY) gridMaxY = py + bestBitmapH;
|
|
4315
|
+
}
|
|
4316
|
+
const groupW = gridMaxX - gridMinX;
|
|
4317
|
+
const groupH = gridMaxY - gridMinY;
|
|
4318
|
+
const usableW = usableRight - usableLeft;
|
|
4319
|
+
const usableH = usableBottom - usableTop;
|
|
4320
|
+
const offsetX = ((usableW - groupW) / 2 - (gridMinX - usableLeft)) * RESOLUTION;
|
|
4321
|
+
const offsetY = ((usableH - groupH) / 2 - (gridMinY - usableTop)) * RESOLUTION;
|
|
4322
|
+
for (const p of bestCandidate.placements) {
|
|
4323
|
+
p.x += offsetX;
|
|
4324
|
+
p.y += offsetY;
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
return bestCandidate;
|
|
3112
4328
|
}
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
let
|
|
3118
|
-
for (const p of
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
if (rx < ocMinX) ocMinX = rx;
|
|
3122
|
-
if (ry < ocMinY) ocMinY = ry;
|
|
4329
|
+
|
|
4330
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1010a/index.ts
|
|
4331
|
+
var SAMPLE_STEP = 0.1;
|
|
4332
|
+
function buildProfile(points) {
|
|
4333
|
+
let maxX = 0, maxY = 0;
|
|
4334
|
+
for (const p of points) {
|
|
4335
|
+
if (p.x > maxX) maxX = p.x;
|
|
4336
|
+
if (p.y > maxY) maxY = p.y;
|
|
3123
4337
|
}
|
|
3124
|
-
const
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
4338
|
+
const width = maxX, height = maxY;
|
|
4339
|
+
const nY = Math.ceil(height / SAMPLE_STEP) + 1;
|
|
4340
|
+
const nX = Math.ceil(width / SAMPLE_STEP) + 1;
|
|
4341
|
+
const rightX = new Float64Array(nY).fill(-Infinity);
|
|
4342
|
+
const leftX = new Float64Array(nY).fill(Infinity);
|
|
4343
|
+
const bottomY = new Float64Array(nX).fill(-Infinity);
|
|
4344
|
+
const topY = new Float64Array(nX).fill(Infinity);
|
|
4345
|
+
const nPts = points.length;
|
|
4346
|
+
for (let iy = 0; iy < nY; iy++) {
|
|
4347
|
+
const y = iy * SAMPLE_STEP;
|
|
4348
|
+
for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
|
|
4349
|
+
const yj = points[j].y, yk = points[k].y;
|
|
4350
|
+
if (yj <= y && yk > y || yk <= y && yj > y) {
|
|
4351
|
+
const t = (y - yj) / (yk - yj);
|
|
4352
|
+
const x = points[j].x + t * (points[k].x - points[j].x);
|
|
4353
|
+
if (x > rightX[iy]) rightX[iy] = x;
|
|
4354
|
+
if (x < leftX[iy]) leftX[iy] = x;
|
|
4355
|
+
}
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
4358
|
+
for (let ix = 0; ix < nX; ix++) {
|
|
4359
|
+
const x = ix * SAMPLE_STEP;
|
|
4360
|
+
for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
|
|
4361
|
+
const xj = points[j].x, xk = points[k].x;
|
|
4362
|
+
if (xj <= x && xk > x || xk <= x && xj > x) {
|
|
4363
|
+
const t = (x - xj) / (xk - xj);
|
|
4364
|
+
const y = points[j].y + t * (points[k].y - points[j].y);
|
|
4365
|
+
if (y > bottomY[ix]) bottomY[ix] = y;
|
|
4366
|
+
if (y < topY[ix]) topY[ix] = y;
|
|
4367
|
+
}
|
|
4368
|
+
}
|
|
4369
|
+
}
|
|
4370
|
+
return { width, height, nY, nX, rightX, leftX, bottomY, topY };
|
|
4371
|
+
}
|
|
4372
|
+
function prepareRotation(contourPoints, dielineW, dielineH, deg) {
|
|
4373
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
4374
|
+
return {
|
|
4375
|
+
profile: buildProfile(rotated),
|
|
4376
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
4377
|
+
deg
|
|
4378
|
+
};
|
|
4379
|
+
}
|
|
4380
|
+
function findMinStepX(a, b, dyMm) {
|
|
4381
|
+
const dySamples = Math.round(dyMm / SAMPLE_STEP);
|
|
4382
|
+
let maxOverlap = -Infinity;
|
|
4383
|
+
for (let ia = 0; ia < a.nY; ia++) {
|
|
4384
|
+
const ib = ia - dySamples;
|
|
4385
|
+
if (ib < 0 || ib >= b.nY) continue;
|
|
4386
|
+
if (a.rightX[ia] === -Infinity || b.leftX[ib] === Infinity) continue;
|
|
4387
|
+
const overlap = a.rightX[ia] - b.leftX[ib];
|
|
4388
|
+
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
4389
|
+
}
|
|
4390
|
+
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
4391
|
+
}
|
|
4392
|
+
function findMinStepY(a, b, dxMm) {
|
|
4393
|
+
const dxSamples = Math.round(dxMm / SAMPLE_STEP);
|
|
4394
|
+
let maxOverlap = -Infinity;
|
|
4395
|
+
for (let ia = 0; ia < a.nX; ia++) {
|
|
4396
|
+
const ib = ia - dxSamples;
|
|
4397
|
+
if (ib < 0 || ib >= b.nX) continue;
|
|
4398
|
+
if (a.bottomY[ia] === -Infinity || b.topY[ib] === Infinity) continue;
|
|
4399
|
+
const overlap = a.bottomY[ia] - b.topY[ib];
|
|
4400
|
+
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
4401
|
+
}
|
|
4402
|
+
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
4403
|
+
}
|
|
4404
|
+
function findMinStepY_multi(profA, stepX_A, profB, offsetX) {
|
|
4405
|
+
const reach = Math.max(profA.width, profB.width);
|
|
4406
|
+
let maxStep = 0;
|
|
4407
|
+
const nMin = Math.floor((offsetX - reach) / stepX_A);
|
|
4408
|
+
const nMax = Math.ceil((offsetX + reach) / stepX_A);
|
|
4409
|
+
for (let n = nMin; n <= nMax; n++) {
|
|
4410
|
+
const s = findMinStepY(profA, profB, offsetX - n * stepX_A);
|
|
4411
|
+
if (s > maxStep) maxStep = s;
|
|
4412
|
+
}
|
|
4413
|
+
return maxStep;
|
|
4414
|
+
}
|
|
4415
|
+
function emptyResult() {
|
|
4416
|
+
return { placements: [], count: 0, minX: 0, minY: 0, maxX: 0, maxY: 0 };
|
|
4417
|
+
}
|
|
4418
|
+
function singleRotGrid(rd, bounds) {
|
|
4419
|
+
const p = rd.profile;
|
|
4420
|
+
const stepX = findMinStepX(p, p, 0);
|
|
4421
|
+
const stepY = findMinStepY(p, p, 0);
|
|
4422
|
+
if (stepX <= 0 || stepY <= 0) return emptyResult();
|
|
4423
|
+
const cols = Math.max(0, Math.floor((bounds.right - bounds.left - p.width) / stepX) + 1);
|
|
4424
|
+
const rows = Math.max(0, Math.floor((bounds.bottom - bounds.top - p.height) / stepY) + 1);
|
|
4425
|
+
if (cols === 0 || rows === 0) return emptyResult();
|
|
4426
|
+
const placements = [];
|
|
4427
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4428
|
+
for (let r = 0; r < rows; r++) {
|
|
4429
|
+
for (let c = 0; c < cols; c++) {
|
|
4430
|
+
const ox = bounds.left + c * stepX;
|
|
4431
|
+
const oy = bounds.top + r * stepY;
|
|
4432
|
+
placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
|
|
4433
|
+
if (ox < minX) minX = ox;
|
|
4434
|
+
if (oy < minY) minY = oy;
|
|
4435
|
+
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
4436
|
+
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
4437
|
+
}
|
|
4438
|
+
}
|
|
4439
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4440
|
+
}
|
|
4441
|
+
function dualRotGrid(rdA, rdB, offsetX, bounds) {
|
|
4442
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
4443
|
+
const stepX_A = findMinStepX(pA, pA, 0);
|
|
4444
|
+
const stepX_B = findMinStepX(pB, pB, 0);
|
|
4445
|
+
if (stepX_A <= 0 || stepX_B <= 0) return emptyResult();
|
|
4446
|
+
const stepY_AB = findMinStepY_multi(pA, stepX_A, pB, offsetX);
|
|
4447
|
+
const stepY_BA = findMinStepY_multi(pB, stepX_B, pA, -offsetX);
|
|
4448
|
+
if (stepY_AB + stepY_BA <= 0) return emptyResult();
|
|
4449
|
+
const placements = [];
|
|
4450
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4451
|
+
let oy = bounds.top;
|
|
4452
|
+
let isRowA = true;
|
|
4453
|
+
while (true) {
|
|
4454
|
+
const rd = isRowA ? rdA : rdB;
|
|
4455
|
+
const p = rd.profile;
|
|
4456
|
+
const stepX = isRowA ? stepX_A : stepX_B;
|
|
4457
|
+
if (oy + p.height > bounds.bottom) break;
|
|
4458
|
+
let sx = isRowA ? bounds.left : bounds.left + offsetX;
|
|
4459
|
+
if (sx < bounds.left) sx += stepX * Math.ceil((bounds.left - sx) / stepX);
|
|
4460
|
+
for (let ox = sx; ox + p.width <= bounds.right; ox += stepX) {
|
|
4461
|
+
placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
|
|
4462
|
+
if (ox < minX) minX = ox;
|
|
4463
|
+
if (oy < minY) minY = oy;
|
|
4464
|
+
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
4465
|
+
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
4466
|
+
}
|
|
4467
|
+
oy += isRowA ? stepY_AB : stepY_BA;
|
|
4468
|
+
isRowA = !isRowA;
|
|
4469
|
+
}
|
|
4470
|
+
if (placements.length === 0) return emptyResult();
|
|
4471
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4472
|
+
}
|
|
4473
|
+
function centerLayout(result, bounds) {
|
|
4474
|
+
if (result.count === 0) return;
|
|
4475
|
+
const offX = (bounds.right - bounds.left - (result.maxX - result.minX)) / 2 - (result.minX - bounds.left);
|
|
4476
|
+
const offY = (bounds.bottom - bounds.top - (result.maxY - result.minY)) / 2 - (result.minY - bounds.top);
|
|
4477
|
+
for (const p of result.placements) {
|
|
4478
|
+
p.x += offX;
|
|
4479
|
+
p.y += offY;
|
|
4480
|
+
}
|
|
4481
|
+
}
|
|
4482
|
+
function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4483
|
+
const rots = [0, 90, 180, 270];
|
|
4484
|
+
const rd = /* @__PURE__ */ new Map();
|
|
4485
|
+
for (const deg of rots) {
|
|
4486
|
+
rd.set(deg, prepareRotation(contourPoints, dielineW, dielineH, deg));
|
|
4487
|
+
}
|
|
4488
|
+
const results = [];
|
|
4489
|
+
for (const deg of rots) {
|
|
4490
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
4491
|
+
}
|
|
4492
|
+
const pairs = [
|
|
4493
|
+
[0, 180],
|
|
4494
|
+
[90, 270],
|
|
4495
|
+
[0, 90],
|
|
4496
|
+
[0, 270],
|
|
4497
|
+
[90, 180],
|
|
4498
|
+
[180, 270]
|
|
4499
|
+
];
|
|
4500
|
+
for (const [a, b] of pairs) {
|
|
4501
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
4502
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
4503
|
+
if (stepA <= 0) continue;
|
|
4504
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
4505
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
4506
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
4507
|
+
}
|
|
4508
|
+
}
|
|
4509
|
+
let best = results[0];
|
|
4510
|
+
for (const r of results) {
|
|
4511
|
+
if (r.count > best.count) best = r;
|
|
4512
|
+
}
|
|
4513
|
+
centerLayout(best, bounds);
|
|
4514
|
+
return {
|
|
4515
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
4516
|
+
placements: best.placements,
|
|
4517
|
+
producedPerSheet: best.count
|
|
4518
|
+
};
|
|
4519
|
+
}
|
|
4520
|
+
|
|
4521
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1030a/index.ts
|
|
4522
|
+
function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
|
|
4523
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
4524
|
+
return {
|
|
4525
|
+
profile: buildProfile(rotated),
|
|
4526
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
4527
|
+
deg
|
|
4528
|
+
};
|
|
4529
|
+
}
|
|
4530
|
+
function pairGrid(rdA, rdB, bounds) {
|
|
4531
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
4532
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
4533
|
+
if (gapAB <= 0) return emptyResult();
|
|
4534
|
+
const pairW = gapAB + pB.width;
|
|
4535
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
4536
|
+
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
4537
|
+
const pairStepY = Math.max(
|
|
4538
|
+
findMinStepY(pA, pA, 0),
|
|
4539
|
+
findMinStepY(pA, pB, gapAB),
|
|
4540
|
+
findMinStepY(pB, pA, -gapAB),
|
|
4541
|
+
findMinStepY(pB, pB, 0)
|
|
4542
|
+
);
|
|
4543
|
+
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
4544
|
+
const usableW = bounds.right - bounds.left;
|
|
4545
|
+
const usableH = bounds.bottom - bounds.top;
|
|
4546
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
4547
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
4548
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
4549
|
+
const placements = [];
|
|
4550
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4551
|
+
for (let r = 0; r < pairRows; r++) {
|
|
4552
|
+
for (let c = 0; c < pairCols; c++) {
|
|
4553
|
+
const baseX = bounds.left + c * pairStepX;
|
|
4554
|
+
const baseY = bounds.top + r * pairStepY;
|
|
4555
|
+
const oxA = baseX;
|
|
4556
|
+
const oyA = baseY;
|
|
4557
|
+
placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
4558
|
+
if (oxA < minX) minX = oxA;
|
|
4559
|
+
if (oyA < minY) minY = oyA;
|
|
4560
|
+
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
4561
|
+
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
4562
|
+
const oxB = baseX + gapAB;
|
|
4563
|
+
const oyB = baseY;
|
|
4564
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
4565
|
+
if (oxB < minX) minX = oxB;
|
|
4566
|
+
if (oyB < minY) minY = oyB;
|
|
4567
|
+
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
4568
|
+
if (oyB + pB.height > maxY) maxY = oyB + pB.height;
|
|
4569
|
+
}
|
|
3131
4570
|
}
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
const
|
|
3136
|
-
const
|
|
3137
|
-
const
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
const rotatedContour = normalizePoints(contourPoints, deg);
|
|
3147
|
-
const pieceBitmap = rasterizePolygon(rotatedContour, RESOLUTION);
|
|
3148
|
-
const bbOffset = computeDielineBBOffset(contourPoints, dielineW, dielineH, deg);
|
|
3149
|
-
const paperGrid = new Uint8Array(paperW * paperH);
|
|
3150
|
-
const placements = [];
|
|
3151
|
-
const gridPositions = [];
|
|
3152
|
-
for (let py = usableTop; py <= usableBottom - pieceBitmap.height; py++) {
|
|
3153
|
-
for (let px = usableLeft; px <= usableRight - pieceBitmap.width; px++) {
|
|
3154
|
-
if (canPlace(paperGrid, paperW, paperH, pieceBitmap, px, py)) {
|
|
3155
|
-
placePiece(paperGrid, paperW, pieceBitmap, px, py);
|
|
3156
|
-
gridPositions.push({ px, py });
|
|
3157
|
-
placements.push({
|
|
3158
|
-
x: px * RESOLUTION + bbOffset.dx,
|
|
3159
|
-
y: py * RESOLUTION + bbOffset.dy,
|
|
3160
|
-
rotation: deg
|
|
3161
|
-
});
|
|
4571
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
4572
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
4573
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
4574
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
4575
|
+
const extraRotations = [rdA, rdB];
|
|
4576
|
+
for (const rdExtra of extraRotations) {
|
|
4577
|
+
const pe = rdExtra.profile;
|
|
4578
|
+
if (pe.width <= gapRight) {
|
|
4579
|
+
for (let r = 0; r < pairRows; r++) {
|
|
4580
|
+
const ox = pairsRightEdge;
|
|
4581
|
+
const oy = bounds.top + r * pairStepY;
|
|
4582
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4583
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4584
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
3162
4585
|
}
|
|
3163
4586
|
}
|
|
3164
|
-
|
|
3165
|
-
if (placements.length > bestCandidate.producedPerSheet) {
|
|
3166
|
-
bestCandidate = { rotation: deg, placements, producedPerSheet: placements.length };
|
|
3167
|
-
bestGridPositions = gridPositions;
|
|
3168
|
-
bestBitmapW = pieceBitmap.width;
|
|
3169
|
-
bestBitmapH = pieceBitmap.height;
|
|
4587
|
+
break;
|
|
3170
4588
|
}
|
|
3171
4589
|
}
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
const groupH = gridMaxY - gridMinY;
|
|
3185
|
-
const usableW = usableRight - usableLeft;
|
|
3186
|
-
const usableH = usableBottom - usableTop;
|
|
3187
|
-
const offsetX = ((usableW - groupW) / 2 - (gridMinX - usableLeft)) * RESOLUTION;
|
|
3188
|
-
const offsetY = ((usableH - groupH) / 2 - (gridMinY - usableTop)) * RESOLUTION;
|
|
3189
|
-
for (const p of bestCandidate.placements) {
|
|
3190
|
-
p.x += offsetX;
|
|
3191
|
-
p.y += offsetY;
|
|
4590
|
+
for (const rdExtra of extraRotations) {
|
|
4591
|
+
const pe = rdExtra.profile;
|
|
4592
|
+
if (pe.height <= gapBottom) {
|
|
4593
|
+
for (let c = 0; c < pairCols; c++) {
|
|
4594
|
+
const oxA = bounds.left + c * pairStepX;
|
|
4595
|
+
const oy = pairsBottomEdge;
|
|
4596
|
+
if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4597
|
+
placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4598
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
4599
|
+
}
|
|
4600
|
+
}
|
|
4601
|
+
break;
|
|
3192
4602
|
}
|
|
3193
4603
|
}
|
|
3194
|
-
return
|
|
4604
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3195
4605
|
}
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
for (const p of points) {
|
|
3202
|
-
if (p.x > maxX) maxX = p.x;
|
|
3203
|
-
if (p.y > maxY) maxY = p.y;
|
|
4606
|
+
function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4607
|
+
const rots = [0, 90, 180, 270];
|
|
4608
|
+
const rd = /* @__PURE__ */ new Map();
|
|
4609
|
+
for (const deg of rots) {
|
|
4610
|
+
rd.set(deg, prepareRotation2(contourPoints, dielineW, dielineH, deg));
|
|
3204
4611
|
}
|
|
3205
|
-
const
|
|
3206
|
-
const
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
const
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
4612
|
+
const results = [];
|
|
4613
|
+
for (const deg of rots) {
|
|
4614
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
4615
|
+
}
|
|
4616
|
+
const allPairs = [
|
|
4617
|
+
[0, 180],
|
|
4618
|
+
[90, 270],
|
|
4619
|
+
[0, 90],
|
|
4620
|
+
[0, 270],
|
|
4621
|
+
[90, 180],
|
|
4622
|
+
[180, 270]
|
|
4623
|
+
];
|
|
4624
|
+
for (const [a, b] of allPairs) {
|
|
4625
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
4626
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
4627
|
+
if (stepA <= 0) continue;
|
|
4628
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
4629
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
4630
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
3223
4631
|
}
|
|
3224
4632
|
}
|
|
3225
|
-
for (
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
4633
|
+
for (const [a, b] of allPairs) {
|
|
4634
|
+
results.push(pairGrid(rd.get(a), rd.get(b), bounds));
|
|
4635
|
+
results.push(pairGrid(rd.get(b), rd.get(a), bounds));
|
|
4636
|
+
}
|
|
4637
|
+
const singleResults = [];
|
|
4638
|
+
const multiResults = [];
|
|
4639
|
+
for (const r of results) {
|
|
4640
|
+
if (r.count === 0) continue;
|
|
4641
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
4642
|
+
if (rotations.size > 1) {
|
|
4643
|
+
multiResults.push(r);
|
|
4644
|
+
} else {
|
|
4645
|
+
singleResults.push(r);
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4648
|
+
function pickBest(arr) {
|
|
4649
|
+
let b = arr[0] ?? emptyResult();
|
|
4650
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
4651
|
+
for (const r of arr) {
|
|
4652
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
4653
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
4654
|
+
b = r;
|
|
4655
|
+
bArea = area;
|
|
3234
4656
|
}
|
|
3235
4657
|
}
|
|
4658
|
+
return b;
|
|
3236
4659
|
}
|
|
3237
|
-
|
|
4660
|
+
const bestSingle = pickBest(singleResults);
|
|
4661
|
+
const bestMulti = pickBest(multiResults);
|
|
4662
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
4663
|
+
centerLayout(best, bounds);
|
|
4664
|
+
return {
|
|
4665
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
4666
|
+
placements: best.placements,
|
|
4667
|
+
producedPerSheet: best.count
|
|
4668
|
+
};
|
|
3238
4669
|
}
|
|
3239
|
-
|
|
4670
|
+
|
|
4671
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1040a/index.ts
|
|
4672
|
+
function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
|
|
3240
4673
|
const rotated = normalizePoints(contourPoints, deg);
|
|
3241
4674
|
return {
|
|
3242
4675
|
profile: buildProfile(rotated),
|
|
@@ -3244,119 +4677,160 @@ function prepareRotation(contourPoints, dielineW, dielineH, deg) {
|
|
|
3244
4677
|
deg
|
|
3245
4678
|
};
|
|
3246
4679
|
}
|
|
3247
|
-
function
|
|
3248
|
-
const
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
const ib = ia - dySamples;
|
|
3252
|
-
if (ib < 0 || ib >= b.nY) continue;
|
|
3253
|
-
if (a.rightX[ia] === -Infinity || b.leftX[ib] === Infinity) continue;
|
|
3254
|
-
const overlap = a.rightX[ia] - b.leftX[ib];
|
|
3255
|
-
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
3256
|
-
}
|
|
3257
|
-
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
3258
|
-
}
|
|
3259
|
-
function findMinStepY(a, b, dxMm) {
|
|
3260
|
-
const dxSamples = Math.round(dxMm / SAMPLE_STEP);
|
|
3261
|
-
let maxOverlap = -Infinity;
|
|
3262
|
-
for (let ia = 0; ia < a.nX; ia++) {
|
|
3263
|
-
const ib = ia - dxSamples;
|
|
3264
|
-
if (ib < 0 || ib >= b.nX) continue;
|
|
3265
|
-
if (a.bottomY[ia] === -Infinity || b.topY[ib] === Infinity) continue;
|
|
3266
|
-
const overlap = a.bottomY[ia] - b.topY[ib];
|
|
3267
|
-
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
3268
|
-
}
|
|
3269
|
-
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
3270
|
-
}
|
|
3271
|
-
function findMinStepY_multi(profA, stepX_A, profB, offsetX) {
|
|
3272
|
-
const reach = Math.max(profA.width, profB.width);
|
|
4680
|
+
function findPairRowStepY(pA, pB, gapAB, pairStepX) {
|
|
4681
|
+
const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
|
|
4682
|
+
const nMin = Math.floor(-reach / pairStepX) - 1;
|
|
4683
|
+
const nMax = Math.ceil(reach / pairStepX) + 1;
|
|
3273
4684
|
let maxStep = 0;
|
|
3274
|
-
const nMin = Math.floor((offsetX - reach) / stepX_A);
|
|
3275
|
-
const nMax = Math.ceil((offsetX + reach) / stepX_A);
|
|
3276
4685
|
for (let n = nMin; n <= nMax; n++) {
|
|
3277
|
-
const
|
|
3278
|
-
|
|
4686
|
+
const dx = n * pairStepX;
|
|
4687
|
+
const s1 = findMinStepY(pA, pA, dx);
|
|
4688
|
+
if (s1 > maxStep) maxStep = s1;
|
|
4689
|
+
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
4690
|
+
if (s2 > maxStep) maxStep = s2;
|
|
4691
|
+
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
4692
|
+
if (s3 > maxStep) maxStep = s3;
|
|
4693
|
+
const s4 = findMinStepY(pB, pB, dx);
|
|
4694
|
+
if (s4 > maxStep) maxStep = s4;
|
|
3279
4695
|
}
|
|
3280
4696
|
return maxStep;
|
|
3281
4697
|
}
|
|
3282
|
-
function
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
const
|
|
3287
|
-
const
|
|
3288
|
-
const
|
|
3289
|
-
if (
|
|
3290
|
-
const
|
|
3291
|
-
|
|
3292
|
-
|
|
4698
|
+
function pairGrid2(rdA, rdB, bounds) {
|
|
4699
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
4700
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
4701
|
+
if (gapAB <= 0) return emptyResult();
|
|
4702
|
+
const pairW = gapAB + pB.width;
|
|
4703
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
4704
|
+
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
4705
|
+
if (pairStepX <= 0) return emptyResult();
|
|
4706
|
+
const pairStepY = findPairRowStepY(pA, pB, gapAB, pairStepX);
|
|
4707
|
+
if (pairStepY <= 0) return emptyResult();
|
|
4708
|
+
const usableW = bounds.right - bounds.left;
|
|
4709
|
+
const usableH = bounds.bottom - bounds.top;
|
|
4710
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
4711
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
4712
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
3293
4713
|
const placements = [];
|
|
3294
4714
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
3295
|
-
for (let r = 0; r <
|
|
3296
|
-
for (let c = 0; c <
|
|
3297
|
-
const
|
|
3298
|
-
const
|
|
3299
|
-
placements.push({ x:
|
|
3300
|
-
if (
|
|
3301
|
-
if (
|
|
3302
|
-
if (
|
|
3303
|
-
if (
|
|
4715
|
+
for (let r = 0; r < pairRows; r++) {
|
|
4716
|
+
for (let c = 0; c < pairCols; c++) {
|
|
4717
|
+
const baseX = bounds.left + c * pairStepX;
|
|
4718
|
+
const baseY = bounds.top + r * pairStepY;
|
|
4719
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
4720
|
+
if (baseX < minX) minX = baseX;
|
|
4721
|
+
if (baseY < minY) minY = baseY;
|
|
4722
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
4723
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
4724
|
+
const bx = baseX + gapAB;
|
|
4725
|
+
placements.push({ x: bx + rdB.bbOffset.dx, y: baseY + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
4726
|
+
if (bx < minX) minX = bx;
|
|
4727
|
+
if (bx + pB.width > maxX) maxX = bx + pB.width;
|
|
4728
|
+
if (baseY + pB.height > maxY) maxY = baseY + pB.height;
|
|
4729
|
+
}
|
|
4730
|
+
}
|
|
4731
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
4732
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
4733
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
4734
|
+
const pe = rdExtra.profile;
|
|
4735
|
+
if (pe.width > gapRight) continue;
|
|
4736
|
+
const dxFromB = pairsRightEdge - (bounds.left + (pairCols - 1) * pairStepX + gapAB);
|
|
4737
|
+
const dxFromA = pairsRightEdge - bounds.left - (pairCols - 1) * pairStepX;
|
|
4738
|
+
const extraStepY = Math.max(
|
|
4739
|
+
findMinStepY(pA, pe, dxFromA),
|
|
4740
|
+
findMinStepY(pB, pe, dxFromB),
|
|
4741
|
+
findMinStepY(pe, pe, 0)
|
|
4742
|
+
);
|
|
4743
|
+
if (extraStepY <= 0) continue;
|
|
4744
|
+
const effectiveStepY = Math.max(pairStepY, extraStepY);
|
|
4745
|
+
const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
|
|
4746
|
+
for (let r = 0; r < extraRows; r++) {
|
|
4747
|
+
const ox = pairsRightEdge;
|
|
4748
|
+
const oy = bounds.top + r * effectiveStepY;
|
|
4749
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4750
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4751
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
4752
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
4753
|
+
}
|
|
4754
|
+
}
|
|
4755
|
+
break;
|
|
4756
|
+
}
|
|
4757
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
4758
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
4759
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
4760
|
+
const pe = rdExtra.profile;
|
|
4761
|
+
if (pe.height > gapBottom) continue;
|
|
4762
|
+
const extraStepX = findMinStepX(pe, pe, 0);
|
|
4763
|
+
if (extraStepX <= 0) continue;
|
|
4764
|
+
const dyFromPairRow = pairsBottomEdge - (bounds.top + (pairRows - 1) * pairStepY);
|
|
4765
|
+
const stepFromA = findMinStepY(pA, pe, 0);
|
|
4766
|
+
const stepFromB = findMinStepY(pB, pe, gapAB);
|
|
4767
|
+
if (dyFromPairRow < stepFromA || dyFromPairRow < stepFromB) continue;
|
|
4768
|
+
const extraCols = Math.max(0, Math.floor((usableW - pe.width) / extraStepX) + 1);
|
|
4769
|
+
for (let c = 0; c < extraCols; c++) {
|
|
4770
|
+
const ox = bounds.left + c * extraStepX;
|
|
4771
|
+
const oy = pairsBottomEdge;
|
|
4772
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4773
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4774
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
4775
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
4776
|
+
}
|
|
3304
4777
|
}
|
|
4778
|
+
break;
|
|
3305
4779
|
}
|
|
3306
4780
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3307
4781
|
}
|
|
3308
|
-
function
|
|
4782
|
+
function verticalPairGrid(rdA, rdB, bounds) {
|
|
3309
4783
|
const pA = rdA.profile, pB = rdB.profile;
|
|
3310
|
-
const
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
const
|
|
3314
|
-
|
|
3315
|
-
|
|
4784
|
+
const gapAB_Y = findMinStepY(pA, pB, 0);
|
|
4785
|
+
if (gapAB_Y <= 0) return emptyResult();
|
|
4786
|
+
const vpairH = gapAB_Y + pB.height;
|
|
4787
|
+
const vpairW = Math.max(pA.width, pB.width);
|
|
4788
|
+
Math.max(pA.height, pB.height) + Math.abs(gapAB_Y);
|
|
4789
|
+
let vpairStepX = 0;
|
|
4790
|
+
{
|
|
4791
|
+
const stepXAA = findMinStepX(pA, pA, 0);
|
|
4792
|
+
const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
|
|
4793
|
+
const stepXBA = findMinStepX(pB, pA, gapAB_Y);
|
|
4794
|
+
const stepXBB = findMinStepX(pB, pB, 0);
|
|
4795
|
+
vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
|
|
4796
|
+
}
|
|
4797
|
+
if (vpairStepX <= 0) return emptyResult();
|
|
4798
|
+
const vpairStepY = gapAB_Y + findMinStepY(pB, pA, 0);
|
|
4799
|
+
if (vpairStepY <= 0) return emptyResult();
|
|
4800
|
+
const usableW = bounds.right - bounds.left;
|
|
4801
|
+
const usableH = bounds.bottom - bounds.top;
|
|
4802
|
+
const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
|
|
4803
|
+
const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
|
|
4804
|
+
if (cols === 0 || rows === 0) return emptyResult();
|
|
3316
4805
|
const placements = [];
|
|
3317
4806
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
3318
|
-
let
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
placements.push({ x:
|
|
3329
|
-
if (
|
|
3330
|
-
if (oy < minY) minY = oy;
|
|
3331
|
-
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
3332
|
-
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
4807
|
+
for (let r = 0; r < rows; r++) {
|
|
4808
|
+
for (let c = 0; c < cols; c++) {
|
|
4809
|
+
const baseX = bounds.left + c * vpairStepX;
|
|
4810
|
+
const baseY = bounds.top + r * vpairStepY;
|
|
4811
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
4812
|
+
if (baseX < minX) minX = baseX;
|
|
4813
|
+
if (baseY < minY) minY = baseY;
|
|
4814
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
4815
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
4816
|
+
const by = baseY + gapAB_Y;
|
|
4817
|
+
placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
4818
|
+
if (by + pB.height > maxY) maxY = by + pB.height;
|
|
3333
4819
|
}
|
|
3334
|
-
oy += isRowA ? stepY_AB : stepY_BA;
|
|
3335
|
-
isRowA = !isRowA;
|
|
3336
4820
|
}
|
|
3337
|
-
if (placements.length === 0) return emptyResult();
|
|
3338
4821
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3339
4822
|
}
|
|
3340
|
-
function
|
|
3341
|
-
if (result.count === 0) return;
|
|
3342
|
-
const offX = (bounds.right - bounds.left - (result.maxX - result.minX)) / 2 - (result.minX - bounds.left);
|
|
3343
|
-
const offY = (bounds.bottom - bounds.top - (result.maxY - result.minY)) / 2 - (result.minY - bounds.top);
|
|
3344
|
-
for (const p of result.placements) {
|
|
3345
|
-
p.x += offX;
|
|
3346
|
-
p.y += offY;
|
|
3347
|
-
}
|
|
3348
|
-
}
|
|
3349
|
-
function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4823
|
+
function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
3350
4824
|
const rots = [0, 90, 180, 270];
|
|
3351
4825
|
const rd = /* @__PURE__ */ new Map();
|
|
3352
4826
|
for (const deg of rots) {
|
|
3353
|
-
rd.set(deg,
|
|
4827
|
+
rd.set(deg, prepareRotation3(contourPoints, dielineW, dielineH, deg));
|
|
3354
4828
|
}
|
|
3355
4829
|
const results = [];
|
|
3356
4830
|
for (const deg of rots) {
|
|
3357
4831
|
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
3358
4832
|
}
|
|
3359
|
-
const
|
|
4833
|
+
const allPairs = [
|
|
3360
4834
|
[0, 180],
|
|
3361
4835
|
[90, 270],
|
|
3362
4836
|
[0, 90],
|
|
@@ -3364,7 +4838,7 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
3364
4838
|
[90, 180],
|
|
3365
4839
|
[180, 270]
|
|
3366
4840
|
];
|
|
3367
|
-
for (const [a, b] of
|
|
4841
|
+
for (const [a, b] of allPairs) {
|
|
3368
4842
|
const rdA = rd.get(a), rdB = rd.get(b);
|
|
3369
4843
|
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
3370
4844
|
if (stepA <= 0) continue;
|
|
@@ -3373,10 +4847,40 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
3373
4847
|
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
3374
4848
|
}
|
|
3375
4849
|
}
|
|
3376
|
-
|
|
4850
|
+
for (const [a, b] of allPairs) {
|
|
4851
|
+
results.push(pairGrid2(rd.get(a), rd.get(b), bounds));
|
|
4852
|
+
results.push(pairGrid2(rd.get(b), rd.get(a), bounds));
|
|
4853
|
+
}
|
|
4854
|
+
for (const [a, b] of allPairs) {
|
|
4855
|
+
results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
|
|
4856
|
+
results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
|
|
4857
|
+
}
|
|
4858
|
+
const singleResults = [];
|
|
4859
|
+
const multiResults = [];
|
|
3377
4860
|
for (const r of results) {
|
|
3378
|
-
if (r.count
|
|
4861
|
+
if (r.count === 0) continue;
|
|
4862
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
4863
|
+
if (rotations.size > 1) {
|
|
4864
|
+
multiResults.push(r);
|
|
4865
|
+
} else {
|
|
4866
|
+
singleResults.push(r);
|
|
4867
|
+
}
|
|
4868
|
+
}
|
|
4869
|
+
function pickBest(arr) {
|
|
4870
|
+
let b = arr[0] ?? emptyResult();
|
|
4871
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
4872
|
+
for (const r of arr) {
|
|
4873
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
4874
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
4875
|
+
b = r;
|
|
4876
|
+
bArea = area;
|
|
4877
|
+
}
|
|
4878
|
+
}
|
|
4879
|
+
return b;
|
|
3379
4880
|
}
|
|
4881
|
+
const bestSingle = pickBest(singleResults);
|
|
4882
|
+
const bestMulti = pickBest(multiResults);
|
|
4883
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
3380
4884
|
centerLayout(best, bounds);
|
|
3381
4885
|
return {
|
|
3382
4886
|
rotation: best.placements[0]?.rotation ?? 0,
|
|
@@ -3385,8 +4889,8 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
3385
4889
|
};
|
|
3386
4890
|
}
|
|
3387
4891
|
|
|
3388
|
-
// src/utils/autoLayout/calculate/
|
|
3389
|
-
function
|
|
4892
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-12101/index.ts
|
|
4893
|
+
function prepareRotation4(contourPoints, dielineW, dielineH, deg) {
|
|
3390
4894
|
const rotated = normalizePoints(contourPoints, deg);
|
|
3391
4895
|
return {
|
|
3392
4896
|
profile: buildProfile(rotated),
|
|
@@ -3394,7 +4898,7 @@ function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
|
|
|
3394
4898
|
deg
|
|
3395
4899
|
};
|
|
3396
4900
|
}
|
|
3397
|
-
function
|
|
4901
|
+
function pairGrid3(rdA, rdB, bounds) {
|
|
3398
4902
|
const pA = rdA.profile, pB = rdB.profile;
|
|
3399
4903
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
3400
4904
|
if (gapAB <= 0) return emptyResult();
|
|
@@ -3470,11 +4974,11 @@ function pairGrid(rdA, rdB, bounds) {
|
|
|
3470
4974
|
}
|
|
3471
4975
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3472
4976
|
}
|
|
3473
|
-
function
|
|
4977
|
+
function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
3474
4978
|
const rots = [0, 90, 180, 270];
|
|
3475
4979
|
const rd = /* @__PURE__ */ new Map();
|
|
3476
4980
|
for (const deg of rots) {
|
|
3477
|
-
rd.set(deg,
|
|
4981
|
+
rd.set(deg, prepareRotation4(contourPoints, dielineW, dielineH, deg));
|
|
3478
4982
|
}
|
|
3479
4983
|
const results = [];
|
|
3480
4984
|
for (const deg of rots) {
|
|
@@ -3498,8 +5002,8 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
3498
5002
|
}
|
|
3499
5003
|
}
|
|
3500
5004
|
for (const [a, b] of allPairs) {
|
|
3501
|
-
results.push(
|
|
3502
|
-
results.push(
|
|
5005
|
+
results.push(pairGrid3(rd.get(a), rd.get(b), bounds));
|
|
5006
|
+
results.push(pairGrid3(rd.get(b), rd.get(a), bounds));
|
|
3503
5007
|
}
|
|
3504
5008
|
const singleResults = [];
|
|
3505
5009
|
const multiResults = [];
|
|
@@ -3538,6 +5042,14 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
3538
5042
|
// src/utils/autoLayout/calculate/index.ts
|
|
3539
5043
|
function resolveModelFunctions(modelId, attrs) {
|
|
3540
5044
|
switch (modelId) {
|
|
5045
|
+
case "BECF-1040A": {
|
|
5046
|
+
const a = attrs;
|
|
5047
|
+
return {
|
|
5048
|
+
contour: generateOuterContour3(a),
|
|
5049
|
+
dieline: generateBecf1040a(a),
|
|
5050
|
+
offsetContour: offsetContour3
|
|
5051
|
+
};
|
|
5052
|
+
}
|
|
3541
5053
|
case "BECF-1030A": {
|
|
3542
5054
|
const a = attrs;
|
|
3543
5055
|
return {
|
|
@@ -3549,9 +5061,17 @@ function resolveModelFunctions(modelId, attrs) {
|
|
|
3549
5061
|
case "BECF-11D01": {
|
|
3550
5062
|
const a = attrs;
|
|
3551
5063
|
return {
|
|
3552
|
-
contour:
|
|
5064
|
+
contour: generateOuterContour4(a),
|
|
3553
5065
|
dieline: generateBecf11d01(a),
|
|
3554
|
-
offsetContour:
|
|
5066
|
+
offsetContour: offsetContour4
|
|
5067
|
+
};
|
|
5068
|
+
}
|
|
5069
|
+
case "BECF-12101": {
|
|
5070
|
+
const a = attrs;
|
|
5071
|
+
return {
|
|
5072
|
+
contour: generateOuterContour5(a),
|
|
5073
|
+
dieline: generateBecf12101(a),
|
|
5074
|
+
offsetContour: offsetContour5
|
|
3555
5075
|
};
|
|
3556
5076
|
}
|
|
3557
5077
|
case "BECF-1010A":
|
|
@@ -3571,16 +5091,28 @@ function resolveLayoutCalculator(modelId) {
|
|
|
3571
5091
|
return computeLayoutForPaper;
|
|
3572
5092
|
case "BECF-1030A":
|
|
3573
5093
|
return computeLayoutForPaper2;
|
|
5094
|
+
case "BECF-1040A":
|
|
5095
|
+
return computeLayoutForPaper3;
|
|
5096
|
+
case "BECF-12101":
|
|
5097
|
+
return computeLayoutForPaper4;
|
|
3574
5098
|
default:
|
|
3575
5099
|
return computeLayoutForPaperDefault;
|
|
3576
5100
|
}
|
|
3577
5101
|
}
|
|
3578
|
-
function calculateAutoLayout(
|
|
3579
|
-
const
|
|
5102
|
+
function calculateAutoLayout(rawConfig) {
|
|
5103
|
+
const config = {
|
|
5104
|
+
...rawConfig,
|
|
5105
|
+
layoutDistance: rawConfig.layoutDistance ?? 3,
|
|
5106
|
+
spacing: rawConfig.spacing ?? 5,
|
|
5107
|
+
griper: rawConfig.griper ?? 10,
|
|
5108
|
+
colorbarHeight: rawConfig.colorbarHeight ?? 5,
|
|
5109
|
+
isShowColorbar: rawConfig.isShowColorbar ?? true
|
|
5110
|
+
};
|
|
5111
|
+
const { contour, dieline, offsetContour: offsetContour6 } = resolveModelFunctions(
|
|
3580
5112
|
config.model.modelId,
|
|
3581
5113
|
config.model.attributes
|
|
3582
5114
|
);
|
|
3583
|
-
const offsetContourPoints = config.layoutDistance > 0 ?
|
|
5115
|
+
const offsetContourPoints = config.layoutDistance > 0 ? offsetContour6(contour, config.layoutDistance / 2) : contour;
|
|
3584
5116
|
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
3585
5117
|
const computeLayout = resolveLayoutCalculator(config.model.modelId);
|
|
3586
5118
|
const paperResults = [];
|
|
@@ -3917,6 +5449,30 @@ function renderDieLine(modelId, attrs) {
|
|
|
3917
5449
|
renderAs: "group"
|
|
3918
5450
|
}
|
|
3919
5451
|
);
|
|
5452
|
+
case "BECF-1040A":
|
|
5453
|
+
return /* @__PURE__ */ jsx(
|
|
5454
|
+
DIE_LINE_BECF_1040A,
|
|
5455
|
+
{
|
|
5456
|
+
attributes: attrs,
|
|
5457
|
+
renderAs: "group"
|
|
5458
|
+
}
|
|
5459
|
+
);
|
|
5460
|
+
case "BECF-11D01":
|
|
5461
|
+
return /* @__PURE__ */ jsx(
|
|
5462
|
+
DIE_LINE_BECF_11D01,
|
|
5463
|
+
{
|
|
5464
|
+
attributes: attrs,
|
|
5465
|
+
renderAs: "group"
|
|
5466
|
+
}
|
|
5467
|
+
);
|
|
5468
|
+
case "BECF-12101":
|
|
5469
|
+
return /* @__PURE__ */ jsx(
|
|
5470
|
+
DIE_LINE_BECF_12101,
|
|
5471
|
+
{
|
|
5472
|
+
attributes: attrs,
|
|
5473
|
+
renderAs: "group"
|
|
5474
|
+
}
|
|
5475
|
+
);
|
|
3920
5476
|
case "BECF-1010A":
|
|
3921
5477
|
default:
|
|
3922
5478
|
return /* @__PURE__ */ jsx(
|
|
@@ -3966,9 +5522,9 @@ function getTransformedContour(normalizedPoints, x, y, rotation) {
|
|
|
3966
5522
|
}
|
|
3967
5523
|
return translatePolygon(rotated, x - rMinX, y - rMinY);
|
|
3968
5524
|
}
|
|
3969
|
-
function checkCollisions(items,
|
|
5525
|
+
function checkCollisions(items, shrunkContour, paperWidth, paperHeight) {
|
|
3970
5526
|
const polys = items.map(
|
|
3971
|
-
(item) => getTransformedContour(
|
|
5527
|
+
(item) => getTransformedContour(shrunkContour, item.x, item.y, item.rotation)
|
|
3972
5528
|
);
|
|
3973
5529
|
return items.map((item, i) => {
|
|
3974
5530
|
let colliding = false;
|
|
@@ -4026,7 +5582,10 @@ function ModifyLayout({
|
|
|
4026
5582
|
const [panX, setPanX] = useState(0);
|
|
4027
5583
|
const [panY, setPanY] = useState(0);
|
|
4028
5584
|
const theme = useMemo(() => getAutoLayoutTheme(), []);
|
|
4029
|
-
const
|
|
5585
|
+
const shrunkContour = useMemo(
|
|
5586
|
+
() => normalizeContour(offsetContour(offsetContourPoints, -0.15)),
|
|
5587
|
+
[offsetContourPoints]
|
|
5588
|
+
);
|
|
4030
5589
|
const pw = paperResult.paperWidth;
|
|
4031
5590
|
const ph = paperResult.paperHeight;
|
|
4032
5591
|
const padding = 20;
|
|
@@ -4039,7 +5598,7 @@ function ModifyLayout({
|
|
|
4039
5598
|
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
4040
5599
|
const layoutDistance = config.layoutDistance;
|
|
4041
5600
|
useEffect(() => {
|
|
4042
|
-
setItems((prev) => checkCollisions(prev,
|
|
5601
|
+
setItems((prev) => checkCollisions(prev, shrunkContour, pw, ph));
|
|
4043
5602
|
}, []);
|
|
4044
5603
|
const itemsRef = useRef(items);
|
|
4045
5604
|
itemsRef.current = items;
|
|
@@ -4056,7 +5615,7 @@ function ModifyLayout({
|
|
|
4056
5615
|
const updated = prev.map(
|
|
4057
5616
|
(it) => it.id === dragItemId ? { ...it, x: newX, y: newY } : it
|
|
4058
5617
|
);
|
|
4059
|
-
return checkCollisions(updated,
|
|
5618
|
+
return checkCollisions(updated, shrunkContour, pw, ph);
|
|
4060
5619
|
});
|
|
4061
5620
|
return;
|
|
4062
5621
|
}
|
|
@@ -4090,7 +5649,7 @@ function ModifyLayout({
|
|
|
4090
5649
|
window.removeEventListener("pointerup", handleMouseUp);
|
|
4091
5650
|
window.removeEventListener("pointercancel", handleMouseUp);
|
|
4092
5651
|
};
|
|
4093
|
-
}, [
|
|
5652
|
+
}, [shrunkContour, pw, ph, zoom, padding]);
|
|
4094
5653
|
const handleItemMouseDown = useCallback((e, itemId) => {
|
|
4095
5654
|
e.stopPropagation();
|
|
4096
5655
|
e.preventDefault();
|
|
@@ -4129,9 +5688,9 @@ function ModifyLayout({
|
|
|
4129
5688
|
const updated = prev.map(
|
|
4130
5689
|
(it) => it.id === selectedId ? { ...it, rotation: degrees } : it
|
|
4131
5690
|
);
|
|
4132
|
-
return checkCollisions(updated,
|
|
5691
|
+
return checkCollisions(updated, shrunkContour, pw, ph);
|
|
4133
5692
|
});
|
|
4134
|
-
}, [selectedId,
|
|
5693
|
+
}, [selectedId, shrunkContour, pw, ph]);
|
|
4135
5694
|
const handleAdd = useCallback(() => {
|
|
4136
5695
|
const newItem = {
|
|
4137
5696
|
id: `item-${nextItemId++}`,
|
|
@@ -4142,17 +5701,17 @@ function ModifyLayout({
|
|
|
4142
5701
|
};
|
|
4143
5702
|
setItems((prev) => {
|
|
4144
5703
|
const updated = [...prev, newItem];
|
|
4145
|
-
return checkCollisions(updated,
|
|
5704
|
+
return checkCollisions(updated, shrunkContour, pw, ph);
|
|
4146
5705
|
});
|
|
4147
5706
|
setSelectedId(newItem.id);
|
|
4148
|
-
}, [pw, ph, dielineViewBox,
|
|
5707
|
+
}, [pw, ph, dielineViewBox, shrunkContour]);
|
|
4149
5708
|
const handleRemove = useCallback((itemId) => {
|
|
4150
5709
|
setItems((prev) => {
|
|
4151
5710
|
const filtered = prev.filter((it) => it.id !== itemId);
|
|
4152
|
-
return checkCollisions(filtered,
|
|
5711
|
+
return checkCollisions(filtered, shrunkContour, pw, ph);
|
|
4153
5712
|
});
|
|
4154
5713
|
if (selectedId === itemId) setSelectedId(null);
|
|
4155
|
-
}, [selectedId,
|
|
5714
|
+
}, [selectedId, shrunkContour, pw, ph]);
|
|
4156
5715
|
const handleSubmit = useCallback(() => {
|
|
4157
5716
|
const validItems = items.filter((it) => !it.isColliding);
|
|
4158
5717
|
const placements = validItems.map((it) => ({
|
|
@@ -4460,17 +6019,39 @@ function resolveModel(modelId, attrs, layoutDistance) {
|
|
|
4460
6019
|
generateContour: (a) => generateOuterContour2(a)
|
|
4461
6020
|
};
|
|
4462
6021
|
}
|
|
4463
|
-
case "BECF-
|
|
6022
|
+
case "BECF-1040A": {
|
|
4464
6023
|
const typedAttrs = attrs;
|
|
4465
6024
|
const contour = generateOuterContour3(typedAttrs);
|
|
4466
6025
|
return {
|
|
4467
|
-
dieline:
|
|
6026
|
+
dieline: generateBecf1040a(typedAttrs),
|
|
4468
6027
|
contourPath: contourToPath3(contour),
|
|
4469
6028
|
offsetContourPoints: layoutDistance > 0 ? offsetContour3(contour, layoutDistance / 2) : contour,
|
|
4470
|
-
generate: (a) =>
|
|
6029
|
+
generate: (a) => generateBecf1040a(a),
|
|
4471
6030
|
generateContour: (a) => generateOuterContour3(a)
|
|
4472
6031
|
};
|
|
4473
6032
|
}
|
|
6033
|
+
case "BECF-11D01": {
|
|
6034
|
+
const typedAttrs = attrs;
|
|
6035
|
+
const contour = generateOuterContour4(typedAttrs);
|
|
6036
|
+
return {
|
|
6037
|
+
dieline: generateBecf11d01(typedAttrs),
|
|
6038
|
+
contourPath: contourToPath4(contour),
|
|
6039
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour4(contour, layoutDistance / 2) : contour,
|
|
6040
|
+
generate: (a) => generateBecf11d01(a),
|
|
6041
|
+
generateContour: (a) => generateOuterContour4(a)
|
|
6042
|
+
};
|
|
6043
|
+
}
|
|
6044
|
+
case "BECF-12101": {
|
|
6045
|
+
const typedAttrs = attrs;
|
|
6046
|
+
const contour = generateOuterContour5(typedAttrs);
|
|
6047
|
+
return {
|
|
6048
|
+
dieline: generateBecf12101(typedAttrs),
|
|
6049
|
+
contourPath: contourToPath5(contour),
|
|
6050
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour5(contour, layoutDistance / 2) : contour,
|
|
6051
|
+
generate: (a) => generateBecf12101(a),
|
|
6052
|
+
generateContour: (a) => generateOuterContour5(a)
|
|
6053
|
+
};
|
|
6054
|
+
}
|
|
4474
6055
|
case "BECF-1010A":
|
|
4475
6056
|
default: {
|
|
4476
6057
|
const typedAttrs = attrs;
|
|
@@ -4496,6 +6077,14 @@ function renderDieLine2(modelId, attrs) {
|
|
|
4496
6077
|
renderAs: "group"
|
|
4497
6078
|
}
|
|
4498
6079
|
);
|
|
6080
|
+
case "BECF-1040A":
|
|
6081
|
+
return /* @__PURE__ */ jsx(
|
|
6082
|
+
DIE_LINE_BECF_1040A,
|
|
6083
|
+
{
|
|
6084
|
+
attributes: attrs,
|
|
6085
|
+
renderAs: "group"
|
|
6086
|
+
}
|
|
6087
|
+
);
|
|
4499
6088
|
case "BECF-11D01":
|
|
4500
6089
|
return /* @__PURE__ */ jsx(
|
|
4501
6090
|
DIE_LINE_BECF_11D01,
|
|
@@ -4504,6 +6093,14 @@ function renderDieLine2(modelId, attrs) {
|
|
|
4504
6093
|
renderAs: "group"
|
|
4505
6094
|
}
|
|
4506
6095
|
);
|
|
6096
|
+
case "BECF-12101":
|
|
6097
|
+
return /* @__PURE__ */ jsx(
|
|
6098
|
+
DIE_LINE_BECF_12101,
|
|
6099
|
+
{
|
|
6100
|
+
attributes: attrs,
|
|
6101
|
+
renderAs: "group"
|
|
6102
|
+
}
|
|
6103
|
+
);
|
|
4507
6104
|
case "BECF-1010A":
|
|
4508
6105
|
default:
|
|
4509
6106
|
return /* @__PURE__ */ jsx(
|
|
@@ -4517,7 +6114,7 @@ function renderDieLine2(modelId, attrs) {
|
|
|
4517
6114
|
})();
|
|
4518
6115
|
}
|
|
4519
6116
|
var PAPER_GAP = 20;
|
|
4520
|
-
var
|
|
6117
|
+
var PX_PER_MM7 = 96 / 25.4;
|
|
4521
6118
|
var RESULT_PANEL_HEIGHT = 55;
|
|
4522
6119
|
var RESULT_GAP = 5;
|
|
4523
6120
|
function getOpposite2(side) {
|
|
@@ -4644,7 +6241,7 @@ function getDielineTransform2(x, y, rotation, w, h) {
|
|
|
4644
6241
|
}
|
|
4645
6242
|
}
|
|
4646
6243
|
var AUTO_LAYOUT = forwardRef(
|
|
4647
|
-
({ config, onResult, onModifiedPapers }, ref) => {
|
|
6244
|
+
({ config, onResult, onModifiedPapers, isShowSummary = true, isShowAction }, ref) => {
|
|
4648
6245
|
const canvasRef = useRef(null);
|
|
4649
6246
|
const [result, setResult] = useState(null);
|
|
4650
6247
|
const [modifiedPapers, setModifiedPapers] = useState([]);
|
|
@@ -4667,7 +6264,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
4667
6264
|
);
|
|
4668
6265
|
const modelId = config?.model.modelId ?? "";
|
|
4669
6266
|
const attrs = config?.model.attributes;
|
|
4670
|
-
const layoutDistance = config?.layoutDistance ??
|
|
6267
|
+
const layoutDistance = config?.layoutDistance ?? 3;
|
|
4671
6268
|
const resolved = useMemo(
|
|
4672
6269
|
() => modelId && attrs ? resolveModel(modelId, attrs, layoutDistance) : null,
|
|
4673
6270
|
[modelId, attrs, layoutDistance]
|
|
@@ -4694,8 +6291,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
4694
6291
|
const svg = document.createElementNS(svgNs, "svg");
|
|
4695
6292
|
svg.setAttribute("xmlns", svgNs);
|
|
4696
6293
|
svg.setAttribute("viewBox", `0 0 ${vw} ${vh}`);
|
|
4697
|
-
svg.setAttribute("width", String(Math.round(vw *
|
|
4698
|
-
svg.setAttribute("height", String(Math.round(vh *
|
|
6294
|
+
svg.setAttribute("width", String(Math.round(vw * PX_PER_MM7)));
|
|
6295
|
+
svg.setAttribute("height", String(Math.round(vh * PX_PER_MM7)));
|
|
4699
6296
|
const bg = document.createElementNS(svgNs, "rect");
|
|
4700
6297
|
bg.setAttribute("width", String(vw));
|
|
4701
6298
|
bg.setAttribute("height", String(vh));
|
|
@@ -4728,8 +6325,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
4728
6325
|
img.src = url;
|
|
4729
6326
|
});
|
|
4730
6327
|
const canvas = document.createElement("canvas");
|
|
4731
|
-
canvas.width = Math.round(vw *
|
|
4732
|
-
canvas.height = Math.round(vh *
|
|
6328
|
+
canvas.width = Math.round(vw * PX_PER_MM7);
|
|
6329
|
+
canvas.height = Math.round(vh * PX_PER_MM7);
|
|
4733
6330
|
const ctx = canvas.getContext("2d");
|
|
4734
6331
|
ctx.fillStyle = "#ffffff";
|
|
4735
6332
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -4748,13 +6345,13 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
4748
6345
|
if (!paperResult) throw new Error("Invalid paper index");
|
|
4749
6346
|
const dl = resolved.generate(attrs);
|
|
4750
6347
|
const cPath = contourToPath(resolved.generateContour(attrs));
|
|
4751
|
-
const dist = config.layoutDistance;
|
|
6348
|
+
const dist = config.layoutDistance ?? 3;
|
|
4752
6349
|
const svgNs = "http://www.w3.org/2000/svg";
|
|
4753
6350
|
const svg = document.createElementNS(svgNs, "svg");
|
|
4754
6351
|
svg.setAttribute("xmlns", svgNs);
|
|
4755
6352
|
svg.setAttribute("viewBox", `0 0 ${paperResult.paperWidth} ${paperResult.paperHeight}`);
|
|
4756
|
-
svg.setAttribute("width", String(Math.round(paperResult.paperWidth *
|
|
4757
|
-
svg.setAttribute("height", String(Math.round(paperResult.paperHeight *
|
|
6353
|
+
svg.setAttribute("width", String(Math.round(paperResult.paperWidth * PX_PER_MM7)));
|
|
6354
|
+
svg.setAttribute("height", String(Math.round(paperResult.paperHeight * PX_PER_MM7)));
|
|
4758
6355
|
const bg = document.createElementNS(svgNs, "rect");
|
|
4759
6356
|
bg.setAttribute("width", String(paperResult.paperWidth));
|
|
4760
6357
|
bg.setAttribute("height", String(paperResult.paperHeight));
|
|
@@ -4764,12 +6361,16 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
4764
6361
|
svg.appendChild(bg);
|
|
4765
6362
|
const gripperSide = paperResult.gripperSide;
|
|
4766
6363
|
const colorbarSide = getOpposite2(gripperSide);
|
|
4767
|
-
const
|
|
4768
|
-
|
|
4769
|
-
|
|
6364
|
+
const colorbarHeight = config.colorbarHeight ?? 5;
|
|
6365
|
+
const isShowColorbar = config.isShowColorbar ?? true;
|
|
6366
|
+
const spacing = config.spacing ?? 5;
|
|
6367
|
+
const griper = config.griper ?? 10;
|
|
6368
|
+
const cbDepth = isShowColorbar ? colorbarHeight : 0;
|
|
6369
|
+
if (isShowColorbar) {
|
|
6370
|
+
appendColorbarToSvg(svg, svgNs, colorbarSide, colorbarHeight, paperResult.paperWidth, paperResult.paperHeight);
|
|
4770
6371
|
}
|
|
4771
|
-
if (
|
|
4772
|
-
const rects = getSpacingRects2(gripperSide, paperResult.paperWidth, paperResult.paperHeight,
|
|
6372
|
+
if (spacing > 0) {
|
|
6373
|
+
const rects = getSpacingRects2(gripperSide, paperResult.paperWidth, paperResult.paperHeight, spacing, griper, cbDepth);
|
|
4773
6374
|
for (const sr of rects) {
|
|
4774
6375
|
const r = document.createElementNS(svgNs, "rect");
|
|
4775
6376
|
r.setAttribute("x", String(sr.x));
|
|
@@ -4780,8 +6381,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
4780
6381
|
svg.appendChild(r);
|
|
4781
6382
|
}
|
|
4782
6383
|
}
|
|
4783
|
-
if (
|
|
4784
|
-
appendGripperToSvg(svg, svgNs, gripperSide, paperResult.paperWidth, paperResult.paperHeight,
|
|
6384
|
+
if (griper > 0) {
|
|
6385
|
+
appendGripperToSvg(svg, svgNs, gripperSide, paperResult.paperWidth, paperResult.paperHeight, griper, theme.colorGriper);
|
|
4785
6386
|
}
|
|
4786
6387
|
if (dist > 0) {
|
|
4787
6388
|
const defs = document.createElementNS(svgNs, "defs");
|
|
@@ -4854,8 +6455,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
4854
6455
|
img.src = url;
|
|
4855
6456
|
});
|
|
4856
6457
|
const canvas = document.createElement("canvas");
|
|
4857
|
-
canvas.width = Math.round(paperResult.paperWidth *
|
|
4858
|
-
canvas.height = Math.round(paperResult.paperHeight *
|
|
6458
|
+
canvas.width = Math.round(paperResult.paperWidth * PX_PER_MM7);
|
|
6459
|
+
canvas.height = Math.round(paperResult.paperHeight * PX_PER_MM7);
|
|
4859
6460
|
const ctx = canvas.getContext("2d");
|
|
4860
6461
|
ctx.fillStyle = theme.colorPaperFill;
|
|
4861
6462
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -4883,7 +6484,10 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
4883
6484
|
unit: "mm",
|
|
4884
6485
|
format: [pw, ph]
|
|
4885
6486
|
});
|
|
4886
|
-
|
|
6487
|
+
const pdfColorbarHeight = config.colorbarHeight ?? 5;
|
|
6488
|
+
const pdfIsShowColorbar = config.isShowColorbar ?? true;
|
|
6489
|
+
const pdfGriper = config.griper ?? 10;
|
|
6490
|
+
if (pdfIsShowColorbar) {
|
|
4887
6491
|
const BASE_COLORS2 = ["#02FFFF", "#FF00FF", "#FFFF00", "#000000"];
|
|
4888
6492
|
const FADE_LEVELS2 = [1, 0.8, 0.6, 0.4, 0.2];
|
|
4889
6493
|
const fadeToWhite2 = (hex, opacity) => {
|
|
@@ -4901,7 +6505,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
4901
6505
|
);
|
|
4902
6506
|
const count = colors.length;
|
|
4903
6507
|
const isHoriz = colorbarSide === "top" || colorbarSide === "bottom";
|
|
4904
|
-
const cbH =
|
|
6508
|
+
const cbH = pdfColorbarHeight;
|
|
4905
6509
|
colors.forEach((c, i) => {
|
|
4906
6510
|
doc.setFillColor(c.r, c.g, c.b);
|
|
4907
6511
|
if (isHoriz) {
|
|
@@ -4915,7 +6519,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
4915
6519
|
}
|
|
4916
6520
|
});
|
|
4917
6521
|
}
|
|
4918
|
-
if (
|
|
6522
|
+
if (pdfGriper > 0) {
|
|
4919
6523
|
const hexToRgb2 = (hex) => ({
|
|
4920
6524
|
r: parseInt(hex.slice(1, 3), 16),
|
|
4921
6525
|
g: parseInt(hex.slice(3, 5), 16),
|
|
@@ -4923,7 +6527,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
4923
6527
|
});
|
|
4924
6528
|
const gc = hexToRgb2(theme.colorGriper);
|
|
4925
6529
|
doc.setFillColor(gc.r, gc.g, gc.b);
|
|
4926
|
-
const depth =
|
|
6530
|
+
const depth = pdfGriper;
|
|
4927
6531
|
switch (gripperSide) {
|
|
4928
6532
|
case "bottom":
|
|
4929
6533
|
doc.rect(0, ph - depth, pw, depth, "F");
|
|
@@ -5048,7 +6652,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5048
6652
|
exportImage,
|
|
5049
6653
|
exportPdf
|
|
5050
6654
|
}), [result, getPackedResult, exportDielineImage, exportImage, exportPdf]);
|
|
5051
|
-
const
|
|
6655
|
+
const showAction = (action) => !isShowAction || isShowAction.includes(action);
|
|
6656
|
+
const paperOriginY = isShowSummary ? RESULT_PANEL_HEIGHT + RESULT_GAP : 0;
|
|
5052
6657
|
const viewBox = useMemo(() => {
|
|
5053
6658
|
if (allPapers.length === 0) {
|
|
5054
6659
|
return { x: 0, y: 0, width: 400, height: 300 };
|
|
@@ -5092,7 +6697,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5092
6697
|
}
|
|
5093
6698
|
const gripperSide = paperResult.gripperSide;
|
|
5094
6699
|
const colorbarSide = getOpposite2(gripperSide);
|
|
5095
|
-
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
6700
|
+
const cbDepth = config.isShowColorbar ?? true ? config.colorbarHeight ?? 5 : 0;
|
|
5096
6701
|
const panelW = paperResult.paperWidth;
|
|
5097
6702
|
const fontSize = Math.min(4, panelW / 30);
|
|
5098
6703
|
const padX = fontSize * 1.2;
|
|
@@ -5116,148 +6721,150 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5116
6721
|
curY += gap;
|
|
5117
6722
|
const exportBtnY = curY;
|
|
5118
6723
|
return /* @__PURE__ */ jsxs("g", { transform: `translate(${offsetX}, 0)`, children: [
|
|
5119
|
-
/* @__PURE__ */
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
"
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
"
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
"
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
"
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
"
|
|
5156
|
-
|
|
5157
|
-
|
|
6724
|
+
isShowSummary && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6725
|
+
/* @__PURE__ */ jsx(
|
|
6726
|
+
"rect",
|
|
6727
|
+
{
|
|
6728
|
+
x: 0,
|
|
6729
|
+
y: 0,
|
|
6730
|
+
width: panelW,
|
|
6731
|
+
height: RESULT_PANEL_HEIGHT,
|
|
6732
|
+
rx: 2,
|
|
6733
|
+
ry: 2,
|
|
6734
|
+
fill: "#f8fafc",
|
|
6735
|
+
stroke: "#d4dce7",
|
|
6736
|
+
strokeWidth: 0.3
|
|
6737
|
+
}
|
|
6738
|
+
),
|
|
6739
|
+
/* @__PURE__ */ jsx("text", { x: padX, y: titleY, fontSize: fontSize + 1, fontWeight: "bold", fill: "#0f172a", children: paperResult.paperName }),
|
|
6740
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: recY, fontSize, fontWeight: "bold", fill: rank === 1 ? "#10b981" : "#475569", children: [
|
|
6741
|
+
"Recommended: #",
|
|
6742
|
+
rank
|
|
6743
|
+
] }),
|
|
6744
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: perSheetY, fontSize, fill: "#475569", children: [
|
|
6745
|
+
"Produced per sheet: ",
|
|
6746
|
+
paperResult.producedPerSheet,
|
|
6747
|
+
" pcs"
|
|
6748
|
+
] }),
|
|
6749
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: sheetsY, fontSize, fill: "#475569", children: [
|
|
6750
|
+
"Sheets needed: ",
|
|
6751
|
+
paperResult.independentSheets
|
|
6752
|
+
] }),
|
|
6753
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: producedY, fontSize, fill: "#475569", children: [
|
|
6754
|
+
"Produced: ",
|
|
6755
|
+
paperResult.independentSheets * paperResult.producedPerSheet,
|
|
6756
|
+
" pcs (excess ",
|
|
6757
|
+
paperResult.independentSheets * paperResult.producedPerSheet - (config?.quantity ?? 0),
|
|
6758
|
+
")"
|
|
6759
|
+
] }),
|
|
6760
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: wasteY, fontSize, fill: "#475569", children: [
|
|
6761
|
+
"Waste per sheet: ",
|
|
6762
|
+
paperResult.wastePercent,
|
|
6763
|
+
"%"
|
|
6764
|
+
] }),
|
|
6765
|
+
showAction("EXPORT_SHEET") && /* @__PURE__ */ jsxs(
|
|
6766
|
+
"g",
|
|
6767
|
+
{
|
|
6768
|
+
style: { cursor: "pointer" },
|
|
6769
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
6770
|
+
onClick: () => handleExportImage(paperIdx),
|
|
6771
|
+
children: [
|
|
6772
|
+
/* @__PURE__ */ jsx(
|
|
6773
|
+
"rect",
|
|
6774
|
+
{
|
|
6775
|
+
x: padX,
|
|
6776
|
+
y: exportBtnY,
|
|
6777
|
+
width: exportBtnW,
|
|
6778
|
+
height: exportBtnH,
|
|
6779
|
+
rx: 1.5,
|
|
6780
|
+
ry: 1.5,
|
|
6781
|
+
fill: "#0f172a"
|
|
6782
|
+
}
|
|
6783
|
+
),
|
|
6784
|
+
/* @__PURE__ */ jsx(
|
|
6785
|
+
"text",
|
|
6786
|
+
{
|
|
6787
|
+
x: padX + exportBtnW / 2,
|
|
6788
|
+
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
6789
|
+
textAnchor: "middle",
|
|
6790
|
+
fontSize,
|
|
6791
|
+
fill: "#fff",
|
|
6792
|
+
style: { pointerEvents: "none" },
|
|
6793
|
+
children: "Export Sheet"
|
|
6794
|
+
}
|
|
6795
|
+
)
|
|
6796
|
+
]
|
|
6797
|
+
}
|
|
6798
|
+
),
|
|
6799
|
+
showAction("EXPORT_PDF") && /* @__PURE__ */ jsxs(
|
|
6800
|
+
"g",
|
|
6801
|
+
{
|
|
6802
|
+
style: { cursor: "pointer" },
|
|
6803
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
6804
|
+
onClick: () => handleExportPdf(paperIdx),
|
|
6805
|
+
children: [
|
|
6806
|
+
/* @__PURE__ */ jsx(
|
|
6807
|
+
"rect",
|
|
6808
|
+
{
|
|
6809
|
+
x: padX + exportBtnW + fontSize * 2,
|
|
6810
|
+
y: exportBtnY,
|
|
6811
|
+
width: exportBtnW,
|
|
6812
|
+
height: exportBtnH,
|
|
6813
|
+
rx: 1.5,
|
|
6814
|
+
ry: 1.5,
|
|
6815
|
+
fill: "#1e40af"
|
|
6816
|
+
}
|
|
6817
|
+
),
|
|
6818
|
+
/* @__PURE__ */ jsx(
|
|
6819
|
+
"text",
|
|
6820
|
+
{
|
|
6821
|
+
x: padX + exportBtnW + fontSize * 2 + exportBtnW / 2,
|
|
6822
|
+
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
6823
|
+
textAnchor: "middle",
|
|
6824
|
+
fontSize,
|
|
6825
|
+
fill: "#fff",
|
|
6826
|
+
style: { pointerEvents: "none" },
|
|
6827
|
+
children: "Export PDF"
|
|
6828
|
+
}
|
|
6829
|
+
)
|
|
6830
|
+
]
|
|
6831
|
+
}
|
|
6832
|
+
),
|
|
6833
|
+
showAction("MODIFY_LAYOUT") && paperResult.producedPerSheet > 0 && /* @__PURE__ */ jsxs(
|
|
6834
|
+
"g",
|
|
6835
|
+
{
|
|
6836
|
+
style: { cursor: "pointer" },
|
|
6837
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
6838
|
+
onClick: () => setModifyingPaper(paperResult),
|
|
6839
|
+
children: [
|
|
6840
|
+
/* @__PURE__ */ jsx(
|
|
6841
|
+
"rect",
|
|
6842
|
+
{
|
|
6843
|
+
x: padX + (exportBtnW + fontSize * 2) * 2,
|
|
6844
|
+
y: exportBtnY,
|
|
6845
|
+
width: exportBtnW,
|
|
6846
|
+
height: exportBtnH,
|
|
6847
|
+
rx: 1.5,
|
|
6848
|
+
ry: 1.5,
|
|
6849
|
+
fill: "#7c3aed"
|
|
6850
|
+
}
|
|
6851
|
+
),
|
|
6852
|
+
/* @__PURE__ */ jsx(
|
|
6853
|
+
"text",
|
|
6854
|
+
{
|
|
6855
|
+
x: padX + (exportBtnW + fontSize * 2) * 2 + exportBtnW / 2,
|
|
6856
|
+
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
6857
|
+
textAnchor: "middle",
|
|
6858
|
+
fontSize,
|
|
6859
|
+
fill: "#fff",
|
|
6860
|
+
style: { pointerEvents: "none" },
|
|
6861
|
+
children: "Modify Layout"
|
|
6862
|
+
}
|
|
6863
|
+
)
|
|
6864
|
+
]
|
|
6865
|
+
}
|
|
6866
|
+
)
|
|
5158
6867
|
] }),
|
|
5159
|
-
/* @__PURE__ */ jsxs(
|
|
5160
|
-
"g",
|
|
5161
|
-
{
|
|
5162
|
-
style: { cursor: "pointer" },
|
|
5163
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
5164
|
-
onClick: () => handleExportImage(paperIdx),
|
|
5165
|
-
children: [
|
|
5166
|
-
/* @__PURE__ */ jsx(
|
|
5167
|
-
"rect",
|
|
5168
|
-
{
|
|
5169
|
-
x: padX,
|
|
5170
|
-
y: exportBtnY,
|
|
5171
|
-
width: exportBtnW,
|
|
5172
|
-
height: exportBtnH,
|
|
5173
|
-
rx: 1.5,
|
|
5174
|
-
ry: 1.5,
|
|
5175
|
-
fill: "#0f172a"
|
|
5176
|
-
}
|
|
5177
|
-
),
|
|
5178
|
-
/* @__PURE__ */ jsx(
|
|
5179
|
-
"text",
|
|
5180
|
-
{
|
|
5181
|
-
x: padX + exportBtnW / 2,
|
|
5182
|
-
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
5183
|
-
textAnchor: "middle",
|
|
5184
|
-
fontSize,
|
|
5185
|
-
fill: "#fff",
|
|
5186
|
-
style: { pointerEvents: "none" },
|
|
5187
|
-
children: "Export Sheet"
|
|
5188
|
-
}
|
|
5189
|
-
)
|
|
5190
|
-
]
|
|
5191
|
-
}
|
|
5192
|
-
),
|
|
5193
|
-
/* @__PURE__ */ jsxs(
|
|
5194
|
-
"g",
|
|
5195
|
-
{
|
|
5196
|
-
style: { cursor: "pointer" },
|
|
5197
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
5198
|
-
onClick: () => handleExportPdf(paperIdx),
|
|
5199
|
-
children: [
|
|
5200
|
-
/* @__PURE__ */ jsx(
|
|
5201
|
-
"rect",
|
|
5202
|
-
{
|
|
5203
|
-
x: padX + exportBtnW + fontSize * 2,
|
|
5204
|
-
y: exportBtnY,
|
|
5205
|
-
width: exportBtnW,
|
|
5206
|
-
height: exportBtnH,
|
|
5207
|
-
rx: 1.5,
|
|
5208
|
-
ry: 1.5,
|
|
5209
|
-
fill: "#1e40af"
|
|
5210
|
-
}
|
|
5211
|
-
),
|
|
5212
|
-
/* @__PURE__ */ jsx(
|
|
5213
|
-
"text",
|
|
5214
|
-
{
|
|
5215
|
-
x: padX + exportBtnW + fontSize * 2 + exportBtnW / 2,
|
|
5216
|
-
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
5217
|
-
textAnchor: "middle",
|
|
5218
|
-
fontSize,
|
|
5219
|
-
fill: "#fff",
|
|
5220
|
-
style: { pointerEvents: "none" },
|
|
5221
|
-
children: "Export PDF"
|
|
5222
|
-
}
|
|
5223
|
-
)
|
|
5224
|
-
]
|
|
5225
|
-
}
|
|
5226
|
-
),
|
|
5227
|
-
paperResult.producedPerSheet > 0 && /* @__PURE__ */ jsxs(
|
|
5228
|
-
"g",
|
|
5229
|
-
{
|
|
5230
|
-
style: { cursor: "pointer" },
|
|
5231
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
5232
|
-
onClick: () => setModifyingPaper(paperResult),
|
|
5233
|
-
children: [
|
|
5234
|
-
/* @__PURE__ */ jsx(
|
|
5235
|
-
"rect",
|
|
5236
|
-
{
|
|
5237
|
-
x: padX + (exportBtnW + fontSize * 2) * 2,
|
|
5238
|
-
y: exportBtnY,
|
|
5239
|
-
width: exportBtnW,
|
|
5240
|
-
height: exportBtnH,
|
|
5241
|
-
rx: 1.5,
|
|
5242
|
-
ry: 1.5,
|
|
5243
|
-
fill: "#7c3aed"
|
|
5244
|
-
}
|
|
5245
|
-
),
|
|
5246
|
-
/* @__PURE__ */ jsx(
|
|
5247
|
-
"text",
|
|
5248
|
-
{
|
|
5249
|
-
x: padX + (exportBtnW + fontSize * 2) * 2 + exportBtnW / 2,
|
|
5250
|
-
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
5251
|
-
textAnchor: "middle",
|
|
5252
|
-
fontSize,
|
|
5253
|
-
fill: "#fff",
|
|
5254
|
-
style: { pointerEvents: "none" },
|
|
5255
|
-
children: "Modify Layout"
|
|
5256
|
-
}
|
|
5257
|
-
)
|
|
5258
|
-
]
|
|
5259
|
-
}
|
|
5260
|
-
),
|
|
5261
6868
|
/* @__PURE__ */ jsxs("g", { transform: `translate(0, ${paperOriginY})`, children: [
|
|
5262
6869
|
/* @__PURE__ */ jsx(
|
|
5263
6870
|
"rect",
|
|
@@ -5269,30 +6876,30 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5269
6876
|
strokeWidth: 0.5
|
|
5270
6877
|
}
|
|
5271
6878
|
),
|
|
5272
|
-
config.isShowColorbar && /* @__PURE__ */ jsx(
|
|
6879
|
+
(config.isShowColorbar ?? true) && /* @__PURE__ */ jsx(
|
|
5273
6880
|
Colorbar,
|
|
5274
6881
|
{
|
|
5275
6882
|
side: colorbarSide,
|
|
5276
|
-
colorbarHeight: config.colorbarHeight,
|
|
6883
|
+
colorbarHeight: config.colorbarHeight ?? 5,
|
|
5277
6884
|
paperWidth: paperResult.paperWidth,
|
|
5278
6885
|
paperHeight: paperResult.paperHeight
|
|
5279
6886
|
}
|
|
5280
6887
|
),
|
|
5281
|
-
config.spacing > 0 && getSpacingRects2(
|
|
6888
|
+
(config.spacing ?? 5) > 0 && getSpacingRects2(
|
|
5282
6889
|
gripperSide,
|
|
5283
6890
|
paperResult.paperWidth,
|
|
5284
6891
|
paperResult.paperHeight,
|
|
5285
|
-
config.spacing,
|
|
5286
|
-
config.griper,
|
|
6892
|
+
config.spacing ?? 5,
|
|
6893
|
+
config.griper ?? 10,
|
|
5287
6894
|
cbDepth
|
|
5288
6895
|
).map((r, i) => /* @__PURE__ */ jsx("rect", { x: r.x, y: r.y, width: r.w, height: r.h, fill: theme.colorSpacing }, `sp-${i}`)),
|
|
5289
|
-
config.griper > 0 && /* @__PURE__ */ jsx(
|
|
6896
|
+
(config.griper ?? 10) > 0 && /* @__PURE__ */ jsx(
|
|
5290
6897
|
Gripper,
|
|
5291
6898
|
{
|
|
5292
6899
|
side: gripperSide,
|
|
5293
6900
|
paperWidth: paperResult.paperWidth,
|
|
5294
6901
|
paperHeight: paperResult.paperHeight,
|
|
5295
|
-
depth: config.griper,
|
|
6902
|
+
depth: config.griper ?? 10,
|
|
5296
6903
|
fillColor: theme.colorGriper
|
|
5297
6904
|
}
|
|
5298
6905
|
),
|
|
@@ -5354,6 +6961,10 @@ var DIE_LINE_LAYOUT = forwardRef(
|
|
|
5354
6961
|
return /* @__PURE__ */ jsx(MODEL_BECF_1040A, { ref, ...props });
|
|
5355
6962
|
case "BECF-11D01":
|
|
5356
6963
|
return /* @__PURE__ */ jsx(MODEL_BECF_11D01, { ref, ...props });
|
|
6964
|
+
case "BECF-12101":
|
|
6965
|
+
return /* @__PURE__ */ jsx(MODEL_BECF_12101, { ref, ...props });
|
|
6966
|
+
case "BECF-12109":
|
|
6967
|
+
return /* @__PURE__ */ jsx(MODEL_BECF_12109, { ref, ...props });
|
|
5357
6968
|
default:
|
|
5358
6969
|
return null;
|
|
5359
6970
|
}
|
|
@@ -5390,12 +7001,19 @@ var BECF_1040A_DEFAULT_ATTRIBUTES = {
|
|
|
5390
7001
|
tuckFlap: 14
|
|
5391
7002
|
};
|
|
5392
7003
|
|
|
5393
|
-
// src/statics/
|
|
5394
|
-
var
|
|
7004
|
+
// src/statics/bags-pillows/becf-12101/DEFAULT_ATTRIBUTES.ts
|
|
7005
|
+
var BECF_12101_DEFAULT_ATTRIBUTES = {
|
|
7006
|
+
length: 100,
|
|
7007
|
+
width: 50,
|
|
7008
|
+
height: 150,
|
|
7009
|
+
glueArea: 13
|
|
7010
|
+
};
|
|
7011
|
+
|
|
7012
|
+
// src/statics/bags-pillows/becf-12109/DEFAULT_ATTRIBUTES.ts
|
|
7013
|
+
var BECF_12109_DEFAULT_ATTRIBUTES = {
|
|
5395
7014
|
length: 100,
|
|
5396
7015
|
width: 50,
|
|
5397
7016
|
height: 150,
|
|
5398
|
-
flapHeight: 50,
|
|
5399
7017
|
glueArea: 13
|
|
5400
7018
|
};
|
|
5401
7019
|
|
|
@@ -5422,15 +7040,38 @@ var modelList = [
|
|
|
5422
7040
|
dimension: ["DIE_LINE"],
|
|
5423
7041
|
attributes: { ...BECF_1030A_DEFAULT_ATTRIBUTES }
|
|
5424
7042
|
},
|
|
7043
|
+
// {
|
|
7044
|
+
// id: "BECF-11D01",
|
|
7045
|
+
// nameEN: "Standard Box BECF-11D01",
|
|
7046
|
+
// nameTH: "กล่องทั่วไป BECF-11D01",
|
|
7047
|
+
// dimension: ["DIE_LINE"],
|
|
7048
|
+
// attributes: { ...BECF_11D01_DEFAULT_ATTRIBUTES },
|
|
7049
|
+
// },
|
|
5425
7050
|
{
|
|
5426
|
-
id: "BECF-
|
|
5427
|
-
nameEN: "
|
|
5428
|
-
nameTH: "\
|
|
7051
|
+
id: "BECF-12101",
|
|
7052
|
+
nameEN: "SHOPPING BAGS TYPE A",
|
|
7053
|
+
nameTH: "\u0E16\u0E38\u0E07\u0E23\u0E49\u0E2D\u0E22\u0E40\u0E0A\u0E37\u0E2D\u0E01\u0E40\u0E1B\u0E35\u0E22 \u0E21\u0E31\u0E14\u0E1B\u0E21 A",
|
|
5429
7054
|
dimension: ["DIE_LINE"],
|
|
5430
|
-
attributes: { ...
|
|
7055
|
+
attributes: { ...BECF_12101_DEFAULT_ATTRIBUTES }
|
|
7056
|
+
},
|
|
7057
|
+
{
|
|
7058
|
+
id: "BECF-12109",
|
|
7059
|
+
nameEN: "SHOPPING BAGS TYPE B",
|
|
7060
|
+
nameTH: "\u0E16\u0E38\u0E07\u0E23\u0E49\u0E2D\u0E22\u0E40\u0E0A\u0E37\u0E2D\u0E01\u0E40\u0E1B\u0E35\u0E22 \u0E21\u0E31\u0E14\u0E1B\u0E21 B",
|
|
7061
|
+
dimension: ["DIE_LINE"],
|
|
7062
|
+
attributes: { ...BECF_12109_DEFAULT_ATTRIBUTES }
|
|
5431
7063
|
}
|
|
5432
7064
|
];
|
|
5433
7065
|
|
|
5434
|
-
|
|
7066
|
+
// src/statics/standard-boxes/becf-11d01/DEFAULT_ATTRIBUTES.ts
|
|
7067
|
+
var BECF_11D01_DEFAULT_ATTRIBUTES = {
|
|
7068
|
+
length: 100,
|
|
7069
|
+
width: 50,
|
|
7070
|
+
height: 150,
|
|
7071
|
+
flapHeight: 50,
|
|
7072
|
+
glueArea: 13
|
|
7073
|
+
};
|
|
7074
|
+
|
|
7075
|
+
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 };
|
|
5435
7076
|
//# sourceMappingURL=index.mjs.map
|
|
5436
7077
|
//# sourceMappingURL=index.mjs.map
|