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