@lucablockltd/ultimate-packaging 1.3.0 → 1.4.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 +79 -5
- package/dist/index.d.mts +174 -33
- package/dist/index.d.ts +174 -33
- package/dist/index.js +2349 -606
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2343 -607
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -444,12 +444,14 @@ var BaseCanvas = forwardRef(
|
|
|
444
444
|
const svgRef = useRef(null);
|
|
445
445
|
const dragRef = useRef(null);
|
|
446
446
|
const hasInitialFit = useRef(false);
|
|
447
|
+
const frozenViewBox = useRef(null);
|
|
447
448
|
const [zoom, setZoom] = useState(1);
|
|
448
449
|
const [panX, setPanX] = useState(0);
|
|
449
450
|
const [panY, setPanY] = useState(0);
|
|
450
451
|
const [dragging, setDragging] = useState(false);
|
|
451
|
-
const
|
|
452
|
-
const
|
|
452
|
+
const refVB = frozenViewBox.current ?? initialViewBox;
|
|
453
|
+
const vbWidth = refVB.width / zoom;
|
|
454
|
+
const vbHeight = refVB.height / zoom;
|
|
453
455
|
const centerX = initialViewBox.x + initialViewBox.width / 2;
|
|
454
456
|
const centerY = initialViewBox.y + initialViewBox.height / 2;
|
|
455
457
|
const vbX = centerX - vbWidth / 2 - panX;
|
|
@@ -457,10 +459,11 @@ var BaseCanvas = forwardRef(
|
|
|
457
459
|
const fitView = useCallback(() => {
|
|
458
460
|
const container = containerRef.current;
|
|
459
461
|
if (!container) return;
|
|
462
|
+
frozenViewBox.current = { ...initialViewBox };
|
|
460
463
|
setZoom(clamp(fitPadding, minZoom, maxZoom));
|
|
461
464
|
setPanX(0);
|
|
462
465
|
setPanY(0);
|
|
463
|
-
}, [initialViewBox.width, initialViewBox.height, fitPadding, minZoom, maxZoom]);
|
|
466
|
+
}, [initialViewBox.x, initialViewBox.y, initialViewBox.width, initialViewBox.height, fitPadding, minZoom, maxZoom]);
|
|
464
467
|
const resetView = useCallback(() => {
|
|
465
468
|
fitView();
|
|
466
469
|
}, [fitView]);
|
|
@@ -474,10 +477,6 @@ var BaseCanvas = forwardRef(
|
|
|
474
477
|
hasInitialFit.current = true;
|
|
475
478
|
fitView();
|
|
476
479
|
}, [fitView]);
|
|
477
|
-
useEffect(() => {
|
|
478
|
-
if (!hasInitialFit.current) return;
|
|
479
|
-
fitView();
|
|
480
|
-
}, [initialViewBox.width, initialViewBox.height, fitView]);
|
|
481
480
|
useEffect(() => {
|
|
482
481
|
const container = containerRef.current;
|
|
483
482
|
if (!container) return;
|
|
@@ -489,12 +488,13 @@ var BaseCanvas = forwardRef(
|
|
|
489
488
|
const cursorXRatio = (e.clientX - rect.left) / rect.width;
|
|
490
489
|
const cursorYRatio = (e.clientY - rect.top) / rect.height;
|
|
491
490
|
const zoomFactor = Math.exp(-e.deltaY * 2e-3);
|
|
491
|
+
const currentRefVB = frozenViewBox.current ?? initialViewBox;
|
|
492
492
|
setZoom((prevZoom) => {
|
|
493
493
|
const nextZoom = clamp(prevZoom * zoomFactor, minZoom, maxZoom);
|
|
494
|
-
const prevW =
|
|
495
|
-
const prevH =
|
|
496
|
-
const nextW =
|
|
497
|
-
const nextH =
|
|
494
|
+
const prevW = currentRefVB.width / prevZoom;
|
|
495
|
+
const prevH = currentRefVB.height / prevZoom;
|
|
496
|
+
const nextW = currentRefVB.width / nextZoom;
|
|
497
|
+
const nextH = currentRefVB.height / nextZoom;
|
|
498
498
|
const dx = (prevW - nextW) * (cursorXRatio - 0.5);
|
|
499
499
|
const dy = (prevH - nextH) * (cursorYRatio - 0.5);
|
|
500
500
|
setPanX((prev) => prev + dx);
|
|
@@ -504,7 +504,7 @@ var BaseCanvas = forwardRef(
|
|
|
504
504
|
};
|
|
505
505
|
container.addEventListener("wheel", handleWheel, { passive: false });
|
|
506
506
|
return () => container.removeEventListener("wheel", handleWheel);
|
|
507
|
-
}, [initialViewBox
|
|
507
|
+
}, [initialViewBox, minZoom, maxZoom]);
|
|
508
508
|
const onPointerDown = (e) => {
|
|
509
509
|
dragRef.current = { pointerId: e.pointerId, x: e.clientX, y: e.clientY };
|
|
510
510
|
setDragging(true);
|
|
@@ -5283,249 +5283,1895 @@ var MODEL_BECF_C_12109 = forwardRef(
|
|
|
5283
5283
|
}
|
|
5284
5284
|
);
|
|
5285
5285
|
|
|
5286
|
-
// src/
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
}
|
|
5295
|
-
const offsetX = Math.floor(minX / resolution);
|
|
5296
|
-
const offsetY = Math.floor(minY / resolution);
|
|
5297
|
-
const w = Math.ceil((maxX - offsetX * resolution) / resolution) + 1;
|
|
5298
|
-
const h = Math.ceil((maxY - offsetY * resolution) / resolution) + 1;
|
|
5299
|
-
const data = new Uint8Array(w * h);
|
|
5300
|
-
for (let gy = 0; gy < h; gy++) {
|
|
5301
|
-
const worldY = (offsetY + gy) * resolution + resolution / 2;
|
|
5302
|
-
const crossings = [];
|
|
5303
|
-
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
|
|
5304
|
-
const yi = points[i].y, yj = points[j].y;
|
|
5305
|
-
if (yi <= worldY && yj > worldY || yj <= worldY && yi > worldY) {
|
|
5306
|
-
const t = (worldY - yi) / (yj - yi);
|
|
5307
|
-
crossings.push(points[i].x + t * (points[j].x - points[i].x));
|
|
5308
|
-
}
|
|
5309
|
-
}
|
|
5310
|
-
crossings.sort((a, b) => a - b);
|
|
5311
|
-
for (let c = 0; c < crossings.length - 1; c += 2) {
|
|
5312
|
-
const startGx = Math.max(0, Math.floor((crossings[c] - offsetX * resolution) / resolution));
|
|
5313
|
-
const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
|
|
5314
|
-
for (let gx = startGx; gx <= endGx; gx++) {
|
|
5315
|
-
data[gy * w + gx] = 1;
|
|
5316
|
-
}
|
|
5317
|
-
}
|
|
5318
|
-
}
|
|
5319
|
-
return { data, width: w, height: h, offsetX, offsetY };
|
|
5286
|
+
// src/components/dieline/bags-pillows/becf-b-12101/generate.ts
|
|
5287
|
+
var DIP5 = 15;
|
|
5288
|
+
function calcKulak5(b) {
|
|
5289
|
+
if (b <= 13) return b - 1;
|
|
5290
|
+
if (b <= 99) return 13;
|
|
5291
|
+
if (b <= 249) return 20;
|
|
5292
|
+
if (b <= 499) return 25;
|
|
5293
|
+
return 30;
|
|
5320
5294
|
}
|
|
5321
|
-
function
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5295
|
+
function getAutoCalcValues5(attr) {
|
|
5296
|
+
const { width: B, glueArea } = attr;
|
|
5297
|
+
const kulak = glueArea ?? calcKulak5(B);
|
|
5298
|
+
return { kulak, dip: DIP5 };
|
|
5299
|
+
}
|
|
5300
|
+
function line9(x1, y1, x2, y2) {
|
|
5301
|
+
return `M${x1} ${y1} L${x2} ${y2}`;
|
|
5302
|
+
}
|
|
5303
|
+
function generateBecfB12101(attr) {
|
|
5304
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
5305
|
+
const kulak = glueArea ?? calcKulak5(B);
|
|
5306
|
+
const xFront = kulak;
|
|
5307
|
+
const xSide1 = kulak + A;
|
|
5308
|
+
const xSide1Mid = kulak + A + B / 2;
|
|
5309
|
+
const xBack = kulak + A + B;
|
|
5310
|
+
const xSide2 = kulak + 2 * A + B;
|
|
5311
|
+
const xSide2Mid = kulak + 2 * A + B + B / 2;
|
|
5312
|
+
const xEnd = kulak + 2 * A + 2 * B - 2;
|
|
5313
|
+
const yFoldBottomStart = C - B / 2;
|
|
5314
|
+
const yFoldBottom = C;
|
|
5315
|
+
const yBottomFlap = C + B / 2;
|
|
5316
|
+
const yEnd = C + B / 2 + DIP5;
|
|
5317
|
+
const totalWidth = xEnd;
|
|
5318
|
+
const totalHeight = yEnd;
|
|
5319
|
+
const cut = [];
|
|
5320
|
+
const crease = [];
|
|
5321
|
+
cut.push(line9(0, 0, totalWidth, 0));
|
|
5322
|
+
cut.push(line9(totalWidth, 0, totalWidth, totalHeight));
|
|
5323
|
+
cut.push(line9(totalWidth, totalHeight, 0, totalHeight));
|
|
5324
|
+
cut.push(line9(0, totalHeight, 0, 0));
|
|
5325
|
+
cut.push(line9(kulak + B / 2, yBottomFlap, kulak + B / 2, yEnd));
|
|
5326
|
+
cut.push(line9(kulak + A - B / 2, yBottomFlap, kulak + A - B / 2, yEnd));
|
|
5327
|
+
cut.push(line9(kulak + A + B + B / 2, yBottomFlap, kulak + A + B + B / 2, yEnd));
|
|
5328
|
+
cut.push(line9(kulak + 2 * A + B - B / 2, yBottomFlap, kulak + 2 * A + B - B / 2, yEnd));
|
|
5329
|
+
crease.push(line9(0, yFoldBottomStart, totalWidth, yFoldBottomStart));
|
|
5330
|
+
crease.push(line9(0, yFoldBottom, totalWidth, yFoldBottom));
|
|
5331
|
+
crease.push(line9(xFront, 0, xFront, totalHeight));
|
|
5332
|
+
crease.push(line9(xSide1, 0, xSide1, totalHeight));
|
|
5333
|
+
crease.push(line9(xSide1Mid, 0, xSide1Mid, totalHeight));
|
|
5334
|
+
crease.push(line9(xBack, 0, xBack, totalHeight));
|
|
5335
|
+
crease.push(line9(xSide2, 0, xSide2, totalHeight));
|
|
5336
|
+
crease.push(line9(xSide2Mid, 0, xSide2Mid, totalHeight));
|
|
5337
|
+
crease.push(line9(0, yFoldBottom - kulak, kulak + B / 2, yBottomFlap));
|
|
5338
|
+
crease.push(line9(kulak + A - B / 2, yBottomFlap, xSide1Mid, yFoldBottomStart));
|
|
5339
|
+
crease.push(line9(xSide1Mid, yFoldBottomStart, kulak + A + B + B / 2, yBottomFlap));
|
|
5340
|
+
crease.push(line9(kulak + 2 * A + B - B / 2, yBottomFlap, xSide2Mid, yFoldBottomStart));
|
|
5341
|
+
crease.push(line9(xSide2Mid, yFoldBottomStart, xEnd, C - 2));
|
|
5342
|
+
return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
|
|
5343
|
+
}
|
|
5344
|
+
function generateOuterContour9(attr) {
|
|
5345
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
5346
|
+
const kulak = glueArea ?? calcKulak5(B);
|
|
5347
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
5348
|
+
const totalHeight = C + B / 2 + DIP5;
|
|
5349
|
+
return [
|
|
5350
|
+
{ x: 0, y: 0 },
|
|
5351
|
+
{ x: totalWidth, y: 0 },
|
|
5352
|
+
{ x: totalWidth, y: totalHeight },
|
|
5353
|
+
{ x: 0, y: totalHeight }
|
|
5354
|
+
];
|
|
5355
|
+
}
|
|
5356
|
+
function offsetContour9(points, distance) {
|
|
5357
|
+
const n = points.length;
|
|
5358
|
+
const result = [];
|
|
5359
|
+
for (let i = 0; i < n; i++) {
|
|
5360
|
+
const prev = points[(i - 1 + n) % n];
|
|
5361
|
+
const curr = points[i];
|
|
5362
|
+
const next = points[(i + 1) % n];
|
|
5363
|
+
const e1x = curr.x - prev.x;
|
|
5364
|
+
const e1y = curr.y - prev.y;
|
|
5365
|
+
const e2x = next.x - curr.x;
|
|
5366
|
+
const e2y = next.y - curr.y;
|
|
5367
|
+
const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
|
|
5368
|
+
const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
|
|
5369
|
+
if (len1 === 0 || len2 === 0) {
|
|
5370
|
+
result.push(curr);
|
|
5328
5371
|
continue;
|
|
5329
5372
|
}
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5373
|
+
const n1x = e1y / len1;
|
|
5374
|
+
const n1y = -e1x / len1;
|
|
5375
|
+
const n2x = e2y / len2;
|
|
5376
|
+
const n2y = -e2x / len2;
|
|
5377
|
+
const ax = n1x + n2x;
|
|
5378
|
+
const ay = n1y + n2y;
|
|
5379
|
+
const aLen = Math.sqrt(ax * ax + ay * ay);
|
|
5380
|
+
if (aLen < 1e-3) {
|
|
5381
|
+
result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
|
|
5382
|
+
continue;
|
|
5335
5383
|
}
|
|
5384
|
+
const nx = ax / aLen;
|
|
5385
|
+
const ny = ay / aLen;
|
|
5386
|
+
const dot = n1x * nx + n1y * ny;
|
|
5387
|
+
const d = distance / Math.max(dot, 0.1);
|
|
5388
|
+
result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
|
|
5336
5389
|
}
|
|
5337
|
-
return
|
|
5390
|
+
return result;
|
|
5338
5391
|
}
|
|
5339
|
-
function
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
}
|
|
5345
|
-
}
|
|
5392
|
+
function contourToPath9(points) {
|
|
5393
|
+
if (points.length === 0) return "";
|
|
5394
|
+
let d = `M${points[0].x} ${points[0].y}`;
|
|
5395
|
+
for (let i = 1; i < points.length; i++) {
|
|
5396
|
+
d += ` L${points[i].x} ${points[i].y}`;
|
|
5346
5397
|
}
|
|
5398
|
+
d += " Z";
|
|
5399
|
+
return d;
|
|
5347
5400
|
}
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5401
|
+
function generateDimensions9(attr, unit) {
|
|
5402
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
5403
|
+
const kulak = glueArea ?? calcKulak5(B);
|
|
5404
|
+
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
5405
|
+
const suffix = unit;
|
|
5406
|
+
const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
|
|
5407
|
+
const xFront = kulak;
|
|
5408
|
+
const xSide1 = kulak + A;
|
|
5409
|
+
const xBack = kulak + A + B;
|
|
5410
|
+
const yFoldBottom = C;
|
|
5411
|
+
const yEnd = C + B / 2 + DIP5;
|
|
5412
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
5413
|
+
const totalHeight = yEnd;
|
|
5414
|
+
const bottomSection = B / 2 + DIP5;
|
|
5415
|
+
return [
|
|
5416
|
+
{
|
|
5417
|
+
x1: 0,
|
|
5418
|
+
y1: 0,
|
|
5419
|
+
x2: totalWidth,
|
|
5420
|
+
y2: 0,
|
|
5421
|
+
label: `Overall Width : ${fmt(totalWidth)}`,
|
|
5422
|
+
orientation: "horizontal",
|
|
5423
|
+
offset: -12
|
|
5424
|
+
},
|
|
5425
|
+
{
|
|
5426
|
+
x1: 0,
|
|
5427
|
+
y1: 0,
|
|
5428
|
+
x2: 0,
|
|
5429
|
+
y2: totalHeight,
|
|
5430
|
+
label: `Overall Height : ${fmt(totalHeight)}`,
|
|
5431
|
+
orientation: "vertical",
|
|
5432
|
+
offset: -12
|
|
5433
|
+
},
|
|
5434
|
+
// Height (C) — body area
|
|
5435
|
+
{
|
|
5436
|
+
x1: xBack + A * 0.6,
|
|
5437
|
+
y1: 0,
|
|
5438
|
+
x2: xBack + A * 0.6,
|
|
5439
|
+
y2: yFoldBottom,
|
|
5440
|
+
label: fmt(C),
|
|
5441
|
+
orientation: "vertical",
|
|
5442
|
+
offset: -10
|
|
5443
|
+
},
|
|
5444
|
+
// Bottom section (B/2 + DIP)
|
|
5445
|
+
{
|
|
5446
|
+
x1: xBack + A * 0.6,
|
|
5447
|
+
y1: yFoldBottom,
|
|
5448
|
+
x2: xBack + A * 0.6,
|
|
5449
|
+
y2: yEnd,
|
|
5450
|
+
label: fmt(bottomSection),
|
|
5451
|
+
orientation: "vertical",
|
|
5452
|
+
offset: -10
|
|
5453
|
+
},
|
|
5454
|
+
// Length (A)
|
|
5455
|
+
{
|
|
5456
|
+
x1: xFront,
|
|
5457
|
+
y1: C * 0.65,
|
|
5458
|
+
x2: xSide1,
|
|
5459
|
+
y2: C * 0.65,
|
|
5460
|
+
label: fmt(A),
|
|
5461
|
+
orientation: "horizontal",
|
|
5462
|
+
offset: -20
|
|
5463
|
+
},
|
|
5464
|
+
// Width (B)
|
|
5465
|
+
{
|
|
5466
|
+
x1: xSide1,
|
|
5467
|
+
y1: C * 0.65,
|
|
5468
|
+
x2: xBack,
|
|
5469
|
+
y2: C * 0.65,
|
|
5470
|
+
label: fmt(B),
|
|
5471
|
+
orientation: "horizontal",
|
|
5472
|
+
offset: -20
|
|
5473
|
+
},
|
|
5474
|
+
// Glue Area (kulak)
|
|
5475
|
+
{
|
|
5476
|
+
x1: 0,
|
|
5477
|
+
y1: C * 0.65,
|
|
5478
|
+
x2: xFront,
|
|
5479
|
+
y2: C * 0.65,
|
|
5480
|
+
label: fmt(kulak),
|
|
5481
|
+
orientation: "horizontal",
|
|
5482
|
+
offset: -20
|
|
5483
|
+
}
|
|
5484
|
+
];
|
|
5354
5485
|
}
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
}
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
bottom: paperHeight - spacing,
|
|
5375
|
-
left: griper,
|
|
5376
|
-
right: paperWidth - colorbarDepth - spacing
|
|
5377
|
-
};
|
|
5378
|
-
case "right":
|
|
5379
|
-
return {
|
|
5380
|
-
top: spacing,
|
|
5381
|
-
bottom: paperHeight - spacing,
|
|
5382
|
-
left: colorbarDepth + spacing,
|
|
5383
|
-
right: paperWidth - griper
|
|
5384
|
-
};
|
|
5486
|
+
var MODEL_ID9 = "BECF-B-12101";
|
|
5487
|
+
var UNIT_FACTOR9 = {
|
|
5488
|
+
mm: 1,
|
|
5489
|
+
cm: 0.1,
|
|
5490
|
+
in: 1 / 25.4
|
|
5491
|
+
};
|
|
5492
|
+
var PX_PER_MM9 = 96 / 25.4;
|
|
5493
|
+
function renderDimension9(dim, i, fs) {
|
|
5494
|
+
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
5495
|
+
const tick = 1.5;
|
|
5496
|
+
if (orientation === "horizontal") {
|
|
5497
|
+
const y = y1 + offset;
|
|
5498
|
+
const midX = (x1 + x2) / 2;
|
|
5499
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
5500
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
|
|
5501
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
5502
|
+
/* @__PURE__ */ jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
5503
|
+
/* @__PURE__ */ jsx("text", { x: midX, y: y - 1.5, textAnchor: "middle", fontSize: fs, fontFamily: "sans-serif", fill: "#000", children: label })
|
|
5504
|
+
] }, `dim-${i}`);
|
|
5385
5505
|
}
|
|
5506
|
+
const x = x1 + offset;
|
|
5507
|
+
const midY = (y1 + y2) / 2;
|
|
5508
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
5509
|
+
/* @__PURE__ */ jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
|
|
5510
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
|
|
5511
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
|
|
5512
|
+
/* @__PURE__ */ jsx("text", { x: x - 1.5, y: midY - 1, textAnchor: "middle", dominantBaseline: "central", fontSize: fs, fontFamily: "sans-serif", fill: "#000", transform: `rotate(-90, ${x - 1.5}, ${midY})`, children: label })
|
|
5513
|
+
] }, `dim-${i}`);
|
|
5386
5514
|
}
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5515
|
+
var DIE_LINE_BECF_B_12101 = forwardRef(
|
|
5516
|
+
({ attributes, unit = "mm", isShowDimensions = false, renderAs = "svg" }, ref) => {
|
|
5517
|
+
const theme = useMemo(() => getModelTheme(), []);
|
|
5518
|
+
const svgRef = useRef(null);
|
|
5519
|
+
const dieline = useMemo(() => generateBecfB12101(attributes), [attributes]);
|
|
5520
|
+
const dimensions = useMemo(() => generateDimensions9(attributes, unit), [attributes, unit]);
|
|
5521
|
+
const factor = UNIT_FACTOR9[unit] ?? 1;
|
|
5522
|
+
const serializeSvg = useCallback((showDimensions) => {
|
|
5523
|
+
const svg = svgRef.current;
|
|
5524
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
5525
|
+
const clone = svg.cloneNode(true);
|
|
5526
|
+
if (!showDimensions) {
|
|
5527
|
+
clone.querySelector("#dimensions")?.remove();
|
|
5528
|
+
}
|
|
5529
|
+
return new XMLSerializer().serializeToString(clone);
|
|
5530
|
+
}, []);
|
|
5531
|
+
useImperativeHandle(ref, () => {
|
|
5532
|
+
const auto = getAutoCalcValues5(attributes);
|
|
5533
|
+
return {
|
|
5534
|
+
getAttributes: () => ({
|
|
5535
|
+
modelId: MODEL_ID9,
|
|
5536
|
+
overallWidth: dieline.viewBox.width * factor,
|
|
5537
|
+
overallHeight: dieline.viewBox.height * factor,
|
|
5538
|
+
length: attributes.length * factor,
|
|
5539
|
+
width: attributes.width * factor,
|
|
5540
|
+
height: attributes.height * factor,
|
|
5541
|
+
glueArea: auto.kulak * factor,
|
|
5542
|
+
kulak: auto.kulak * factor,
|
|
5543
|
+
dip: auto.dip * factor
|
|
5544
|
+
}),
|
|
5545
|
+
exportImage: async (options) => {
|
|
5546
|
+
const svgStr = serializeSvg(options.isShowDimension);
|
|
5547
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
5548
|
+
const url = URL.createObjectURL(blob);
|
|
5549
|
+
const img = new Image();
|
|
5550
|
+
await new Promise((resolve, reject) => {
|
|
5551
|
+
img.onload = () => resolve();
|
|
5552
|
+
img.onerror = reject;
|
|
5553
|
+
img.src = url;
|
|
5554
|
+
});
|
|
5555
|
+
const canvas = document.createElement("canvas");
|
|
5556
|
+
if (options.originalSize) {
|
|
5557
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM9);
|
|
5558
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM9);
|
|
5559
|
+
} else {
|
|
5560
|
+
canvas.width = 1920;
|
|
5561
|
+
canvas.height = 1080;
|
|
5562
|
+
}
|
|
5563
|
+
const ctx = canvas.getContext("2d");
|
|
5564
|
+
ctx.fillStyle = "#ffffff";
|
|
5565
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
5566
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
5567
|
+
URL.revokeObjectURL(url);
|
|
5568
|
+
return new Promise((resolve, reject) => {
|
|
5569
|
+
canvas.toBlob((b) => b ? resolve(b) : reject(new Error("Export failed")), "image/png");
|
|
5570
|
+
});
|
|
5571
|
+
},
|
|
5572
|
+
exportDimension: async () => {
|
|
5573
|
+
const dimData = generateDimensions9(attributes, unit);
|
|
5574
|
+
return exportDimensionPdf({ modelId: MODEL_ID9, dieline, dimensions: dimData, attributes, unit, factor, theme });
|
|
5575
|
+
}
|
|
5576
|
+
};
|
|
5577
|
+
}, [attributes, dieline, factor, unit, serializeSvg, theme]);
|
|
5578
|
+
const padding = isShowDimensions ? 15 : 0;
|
|
5579
|
+
const vbX = -padding;
|
|
5580
|
+
const vbY = -padding;
|
|
5581
|
+
const vbW = dieline.viewBox.width + padding * 2;
|
|
5582
|
+
const vbH = dieline.viewBox.height + padding * 2;
|
|
5583
|
+
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5584
|
+
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
5585
|
+
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
5586
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension9(d, i, getFontDimensionSize())) })
|
|
5587
|
+
] });
|
|
5588
|
+
if (renderAs === "group") return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
5589
|
+
return /* @__PURE__ */ jsx("svg", { ref: svgRef, xmlns: "http://www.w3.org/2000/svg", viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`, preserveAspectRatio: "xMidYMid meet", style: { backgroundColor: theme.colorBackground }, children: svgChildren });
|
|
5590
|
+
}
|
|
5591
|
+
);
|
|
5592
|
+
var CANVAS_BECF_B_12101 = forwardRef(
|
|
5593
|
+
(props, ref) => {
|
|
5594
|
+
const dieLineRef = useRef(null);
|
|
5595
|
+
const canvasRef = useRef(null);
|
|
5596
|
+
const { attributes } = props;
|
|
5597
|
+
const theme = useMemo(() => getModelTheme(), []);
|
|
5598
|
+
const dieline = useMemo(() => generateBecfB12101(attributes), [attributes]);
|
|
5599
|
+
const stablePadding = 15;
|
|
5600
|
+
const viewBox = useMemo(() => ({ x: -stablePadding, y: -stablePadding, width: dieline.viewBox.width + stablePadding * 2, height: dieline.viewBox.height + stablePadding * 2 }), [dieline.viewBox.width, dieline.viewBox.height]);
|
|
5601
|
+
const serializeCanvasSvg = useCallback((showDimensions) => {
|
|
5602
|
+
const svg = canvasRef.current?.getSvgElement();
|
|
5603
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
5604
|
+
const clone = svg.cloneNode(true);
|
|
5605
|
+
if (!showDimensions) {
|
|
5606
|
+
clone.querySelector("#dimensions")?.remove();
|
|
5607
|
+
}
|
|
5608
|
+
return new XMLSerializer().serializeToString(clone);
|
|
5609
|
+
}, []);
|
|
5610
|
+
useImperativeHandle(ref, () => ({
|
|
5611
|
+
getAttributes: () => dieLineRef.current.getAttributes(),
|
|
5612
|
+
exportImage: async (options) => {
|
|
5613
|
+
const svgStr = serializeCanvasSvg(options.isShowDimension);
|
|
5614
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
5615
|
+
const url = URL.createObjectURL(blob);
|
|
5616
|
+
const img = new Image();
|
|
5617
|
+
await new Promise((resolve, reject) => {
|
|
5618
|
+
img.onload = () => resolve();
|
|
5619
|
+
img.onerror = reject;
|
|
5620
|
+
img.src = url;
|
|
5621
|
+
});
|
|
5622
|
+
const canvas = document.createElement("canvas");
|
|
5623
|
+
if (options.originalSize) {
|
|
5624
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM9);
|
|
5625
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM9);
|
|
5626
|
+
} else {
|
|
5627
|
+
canvas.width = 1920;
|
|
5628
|
+
canvas.height = 1080;
|
|
5629
|
+
}
|
|
5630
|
+
const ctx = canvas.getContext("2d");
|
|
5631
|
+
ctx.fillStyle = "#ffffff";
|
|
5632
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
5633
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
5634
|
+
URL.revokeObjectURL(url);
|
|
5635
|
+
return new Promise((resolve, reject) => {
|
|
5636
|
+
canvas.toBlob((b) => b ? resolve(b) : reject(new Error("Export failed")), "image/png");
|
|
5637
|
+
});
|
|
5638
|
+
},
|
|
5639
|
+
exportDimension: () => dieLineRef.current.exportDimension(),
|
|
5640
|
+
resetView: () => canvasRef.current?.resetView(),
|
|
5641
|
+
fitView: () => canvasRef.current?.fitView()
|
|
5642
|
+
}), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
|
|
5643
|
+
return /* @__PURE__ */ jsx(BaseCanvas, { ref: canvasRef, viewBox, backgroundColor: theme.colorBackground, children: /* @__PURE__ */ jsx(DIE_LINE_BECF_B_12101, { ref: dieLineRef, ...props, renderAs: "group" }) });
|
|
5644
|
+
}
|
|
5645
|
+
);
|
|
5646
|
+
var MODEL_BECF_B_12101 = forwardRef(
|
|
5647
|
+
({ mode = "DIE_LINE", ...props }, ref) => {
|
|
5648
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (() => {
|
|
5649
|
+
switch (mode) {
|
|
5650
|
+
case "DIE_LINE":
|
|
5651
|
+
return /* @__PURE__ */ jsx(CANVAS_BECF_B_12101, { ref, ...props });
|
|
5652
|
+
case "3D":
|
|
5653
|
+
return null;
|
|
5654
|
+
case "AUTO_LAYOUT":
|
|
5655
|
+
return /* @__PURE__ */ jsx(DIE_LINE_BECF_B_12101, { ref, ...props });
|
|
5656
|
+
default:
|
|
5657
|
+
return null;
|
|
5658
|
+
}
|
|
5659
|
+
})() });
|
|
5660
|
+
}
|
|
5661
|
+
);
|
|
5662
|
+
|
|
5663
|
+
// src/components/dieline/bags-pillows/becf-b-12109/generate.ts
|
|
5664
|
+
var DIP6 = 13;
|
|
5665
|
+
var NOTCH_X3 = 3;
|
|
5666
|
+
var NOTCH_Y3 = 5;
|
|
5667
|
+
function calcKulak6(b) {
|
|
5668
|
+
if (b <= 13) return b - 1;
|
|
5669
|
+
if (b <= 99) return 13;
|
|
5670
|
+
if (b <= 249) return 20;
|
|
5671
|
+
if (b <= 499) return 25;
|
|
5672
|
+
return 30;
|
|
5673
|
+
}
|
|
5674
|
+
function getAutoCalcValues6(attr) {
|
|
5675
|
+
const { width: B, glueArea } = attr;
|
|
5676
|
+
const kulak = glueArea ?? calcKulak6(B);
|
|
5677
|
+
return { kulak, dip: DIP6 };
|
|
5678
|
+
}
|
|
5679
|
+
function line10(x1, y1, x2, y2) {
|
|
5680
|
+
return `M${x1} ${y1} L${x2} ${y2}`;
|
|
5681
|
+
}
|
|
5682
|
+
function generateBecfB12109(attr) {
|
|
5683
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
5684
|
+
const kulak = glueArea ?? calcKulak6(B);
|
|
5685
|
+
const xFront = kulak;
|
|
5686
|
+
const xSide1 = kulak + A;
|
|
5687
|
+
const xSide1Mid = kulak + A + B / 2;
|
|
5688
|
+
const xBack = kulak + A + B;
|
|
5689
|
+
const xSide2 = kulak + 2 * A + B;
|
|
5690
|
+
const xSide2Mid = kulak + 2 * A + B + B / 2;
|
|
5691
|
+
const xEnd = kulak + 2 * A + 2 * B - 2;
|
|
5692
|
+
const yFoldBottomStart = C - B / 2;
|
|
5693
|
+
const yFoldBottom = C;
|
|
5694
|
+
const yNotchStart = yFoldBottom + NOTCH_Y3;
|
|
5695
|
+
const yEnd = C + B / 2 + DIP6;
|
|
5696
|
+
const totalWidth = xEnd;
|
|
5697
|
+
const totalHeight = yEnd;
|
|
5698
|
+
const cut = [];
|
|
5699
|
+
const crease = [];
|
|
5700
|
+
cut.push(line10(0, 0, 0, yFoldBottom - kulak));
|
|
5701
|
+
cut.push(line10(0, 0, totalWidth, 0));
|
|
5702
|
+
cut.push(line10(totalWidth, 0, totalWidth, yFoldBottom));
|
|
5703
|
+
cut.push(line10(0, yFoldBottom - kulak, kulak, yFoldBottom));
|
|
5704
|
+
const boundaries = [xFront, xSide1, xBack, xSide2, xEnd];
|
|
5705
|
+
for (let i = 0; i < boundaries.length; i++) {
|
|
5706
|
+
const xb = boundaries[i];
|
|
5707
|
+
const isFirst = i === 0;
|
|
5708
|
+
const isLast = i === boundaries.length - 1;
|
|
5709
|
+
if (!isFirst) {
|
|
5710
|
+
cut.push(line10(xb - NOTCH_X3, yNotchStart, xb - NOTCH_X3, totalHeight));
|
|
5711
|
+
cut.push(line10(xb - NOTCH_X3, yNotchStart, xb, yFoldBottom));
|
|
5712
|
+
}
|
|
5713
|
+
if (!isLast) {
|
|
5714
|
+
cut.push(line10(xb + NOTCH_X3, yNotchStart, xb + NOTCH_X3, totalHeight));
|
|
5715
|
+
cut.push(line10(xb + NOTCH_X3, yNotchStart, xb, yFoldBottom));
|
|
5716
|
+
}
|
|
5717
|
+
}
|
|
5718
|
+
cut.push(line10(xFront + NOTCH_X3, totalHeight, xSide1 - NOTCH_X3, totalHeight));
|
|
5719
|
+
cut.push(line10(xSide1 + NOTCH_X3, totalHeight, xBack - NOTCH_X3, totalHeight));
|
|
5720
|
+
cut.push(line10(xBack + NOTCH_X3, totalHeight, xSide2 - NOTCH_X3, totalHeight));
|
|
5721
|
+
cut.push(line10(xSide2 + NOTCH_X3, totalHeight, xEnd - NOTCH_X3, totalHeight));
|
|
5722
|
+
crease.push(line10(0, yFoldBottomStart, totalWidth, yFoldBottomStart));
|
|
5723
|
+
crease.push(line10(kulak, yFoldBottom, xEnd, yFoldBottom));
|
|
5724
|
+
crease.push(line10(xFront, 0, xFront, yFoldBottom));
|
|
5725
|
+
crease.push(line10(xSide1, 0, xSide1, yFoldBottom));
|
|
5726
|
+
crease.push(line10(xBack, 0, xBack, yFoldBottom));
|
|
5727
|
+
crease.push(line10(xSide2, 0, xSide2, yFoldBottom));
|
|
5728
|
+
crease.push(line10(xSide1Mid, 0, xSide1Mid, totalHeight));
|
|
5729
|
+
crease.push(line10(xSide2Mid, 0, xSide2Mid, totalHeight));
|
|
5730
|
+
crease.push(line10(xBack, yFoldBottom, xSide1Mid, yFoldBottomStart));
|
|
5731
|
+
crease.push(line10(xSide1Mid, yFoldBottomStart, xSide1, yFoldBottom));
|
|
5732
|
+
crease.push(line10(xSide2Mid, yFoldBottomStart, xSide2, yFoldBottom));
|
|
5733
|
+
crease.push(line10(xSide2Mid, yFoldBottomStart, xEnd, C - 2));
|
|
5734
|
+
return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
|
|
5735
|
+
}
|
|
5736
|
+
function generateOuterContour10(attr) {
|
|
5737
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
5738
|
+
const kulak = glueArea ?? calcKulak6(B);
|
|
5739
|
+
const xFront = kulak;
|
|
5740
|
+
const xSide1 = kulak + A;
|
|
5741
|
+
const xBack = kulak + A + B;
|
|
5742
|
+
const xSide2 = kulak + 2 * A + B;
|
|
5743
|
+
const xEnd = kulak + 2 * A + 2 * B - 2;
|
|
5744
|
+
const yFoldBottom = C;
|
|
5745
|
+
const yNotchStart = yFoldBottom + NOTCH_Y3;
|
|
5746
|
+
const yEnd = C + B / 2 + DIP6;
|
|
5747
|
+
return [
|
|
5748
|
+
{ x: 0, y: 0 },
|
|
5749
|
+
{ x: xEnd, y: 0 },
|
|
5750
|
+
{ x: xEnd, y: yFoldBottom },
|
|
5751
|
+
{ x: xEnd - NOTCH_X3, y: yNotchStart },
|
|
5752
|
+
{ x: xEnd - NOTCH_X3, y: yEnd },
|
|
5753
|
+
{ x: xSide2 + NOTCH_X3, y: yEnd },
|
|
5754
|
+
{ x: xSide2 + NOTCH_X3, y: yNotchStart },
|
|
5755
|
+
{ x: xSide2, y: yFoldBottom },
|
|
5756
|
+
{ x: xSide2 - NOTCH_X3, y: yNotchStart },
|
|
5757
|
+
{ x: xSide2 - NOTCH_X3, y: yEnd },
|
|
5758
|
+
{ x: xBack + NOTCH_X3, y: yEnd },
|
|
5759
|
+
{ x: xBack + NOTCH_X3, y: yNotchStart },
|
|
5760
|
+
{ x: xBack, y: yFoldBottom },
|
|
5761
|
+
{ x: xBack - NOTCH_X3, y: yNotchStart },
|
|
5762
|
+
{ x: xBack - NOTCH_X3, y: yEnd },
|
|
5763
|
+
{ x: xSide1 + NOTCH_X3, y: yEnd },
|
|
5764
|
+
{ x: xSide1 + NOTCH_X3, y: yNotchStart },
|
|
5765
|
+
{ x: xSide1, y: yFoldBottom },
|
|
5766
|
+
{ x: xSide1 - NOTCH_X3, y: yNotchStart },
|
|
5767
|
+
{ x: xSide1 - NOTCH_X3, y: yEnd },
|
|
5768
|
+
{ x: xFront + NOTCH_X3, y: yEnd },
|
|
5769
|
+
{ x: xFront + NOTCH_X3, y: yNotchStart },
|
|
5770
|
+
{ x: xFront, y: yFoldBottom },
|
|
5771
|
+
{ x: 0, y: yFoldBottom - kulak }
|
|
5772
|
+
];
|
|
5773
|
+
}
|
|
5774
|
+
function offsetContour10(points, distance) {
|
|
5775
|
+
const n = points.length;
|
|
5776
|
+
const result = [];
|
|
5777
|
+
for (let i = 0; i < n; i++) {
|
|
5778
|
+
const prev = points[(i - 1 + n) % n];
|
|
5779
|
+
const curr = points[i];
|
|
5780
|
+
const next = points[(i + 1) % n];
|
|
5781
|
+
const e1x = curr.x - prev.x;
|
|
5782
|
+
const e1y = curr.y - prev.y;
|
|
5783
|
+
const e2x = next.x - curr.x;
|
|
5784
|
+
const e2y = next.y - curr.y;
|
|
5785
|
+
const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
|
|
5786
|
+
const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
|
|
5787
|
+
if (len1 === 0 || len2 === 0) {
|
|
5788
|
+
result.push(curr);
|
|
5789
|
+
continue;
|
|
5790
|
+
}
|
|
5791
|
+
const n1x = e1y / len1;
|
|
5792
|
+
const n1y = -e1x / len1;
|
|
5793
|
+
const n2x = e2y / len2;
|
|
5794
|
+
const n2y = -e2x / len2;
|
|
5795
|
+
const ax = n1x + n2x;
|
|
5796
|
+
const ay = n1y + n2y;
|
|
5797
|
+
const aLen = Math.sqrt(ax * ax + ay * ay);
|
|
5798
|
+
if (aLen < 1e-3) {
|
|
5799
|
+
result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
|
|
5800
|
+
continue;
|
|
5801
|
+
}
|
|
5802
|
+
const nx = ax / aLen;
|
|
5803
|
+
const ny = ay / aLen;
|
|
5804
|
+
const dot = n1x * nx + n1y * ny;
|
|
5805
|
+
const d = distance / Math.max(dot, 0.1);
|
|
5806
|
+
result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
|
|
5807
|
+
}
|
|
5808
|
+
return result;
|
|
5809
|
+
}
|
|
5810
|
+
function contourToPath10(points) {
|
|
5811
|
+
if (points.length === 0) return "";
|
|
5812
|
+
let d = `M${points[0].x} ${points[0].y}`;
|
|
5813
|
+
for (let i = 1; i < points.length; i++) {
|
|
5814
|
+
d += ` L${points[i].x} ${points[i].y}`;
|
|
5815
|
+
}
|
|
5816
|
+
d += " Z";
|
|
5817
|
+
return d;
|
|
5818
|
+
}
|
|
5819
|
+
function generateDimensions10(attr, unit) {
|
|
5820
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
5821
|
+
const kulak = glueArea ?? calcKulak6(B);
|
|
5822
|
+
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
5823
|
+
const suffix = unit;
|
|
5824
|
+
const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
|
|
5825
|
+
const xFront = kulak;
|
|
5826
|
+
const xSide1 = kulak + A;
|
|
5827
|
+
const xBack = kulak + A + B;
|
|
5828
|
+
const yFoldBottom = C;
|
|
5829
|
+
const yEnd = C + B / 2 + DIP6;
|
|
5830
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
5831
|
+
const totalHeight = yEnd;
|
|
5832
|
+
const bottomSection = B / 2 + DIP6;
|
|
5833
|
+
return [
|
|
5834
|
+
{
|
|
5835
|
+
x1: 0,
|
|
5836
|
+
y1: 0,
|
|
5837
|
+
x2: totalWidth,
|
|
5838
|
+
y2: 0,
|
|
5839
|
+
label: `Overall Width : ${fmt(totalWidth)}`,
|
|
5840
|
+
orientation: "horizontal",
|
|
5841
|
+
offset: -12
|
|
5842
|
+
},
|
|
5843
|
+
{
|
|
5844
|
+
x1: 0,
|
|
5845
|
+
y1: 0,
|
|
5846
|
+
x2: 0,
|
|
5847
|
+
y2: totalHeight,
|
|
5848
|
+
label: `Overall Height : ${fmt(totalHeight)}`,
|
|
5849
|
+
orientation: "vertical",
|
|
5850
|
+
offset: -12
|
|
5851
|
+
},
|
|
5852
|
+
{
|
|
5853
|
+
x1: xBack + A * 0.6,
|
|
5854
|
+
y1: 0,
|
|
5855
|
+
x2: xBack + A * 0.6,
|
|
5856
|
+
y2: yFoldBottom,
|
|
5857
|
+
label: fmt(C),
|
|
5858
|
+
orientation: "vertical",
|
|
5859
|
+
offset: -10
|
|
5860
|
+
},
|
|
5861
|
+
{
|
|
5862
|
+
x1: xBack + A * 0.6,
|
|
5863
|
+
y1: yFoldBottom,
|
|
5864
|
+
x2: xBack + A * 0.6,
|
|
5865
|
+
y2: yEnd,
|
|
5866
|
+
label: fmt(bottomSection),
|
|
5867
|
+
orientation: "vertical",
|
|
5868
|
+
offset: -10
|
|
5869
|
+
},
|
|
5870
|
+
{
|
|
5871
|
+
x1: xFront,
|
|
5872
|
+
y1: C * 0.65,
|
|
5873
|
+
x2: xSide1,
|
|
5874
|
+
y2: C * 0.65,
|
|
5875
|
+
label: fmt(A),
|
|
5876
|
+
orientation: "horizontal",
|
|
5877
|
+
offset: -20
|
|
5878
|
+
},
|
|
5879
|
+
{
|
|
5880
|
+
x1: xSide1,
|
|
5881
|
+
y1: C * 0.65,
|
|
5882
|
+
x2: xBack,
|
|
5883
|
+
y2: C * 0.65,
|
|
5884
|
+
label: fmt(B),
|
|
5885
|
+
orientation: "horizontal",
|
|
5886
|
+
offset: -20
|
|
5887
|
+
},
|
|
5888
|
+
{
|
|
5889
|
+
x1: 0,
|
|
5890
|
+
y1: C * 0.65,
|
|
5891
|
+
x2: xFront,
|
|
5892
|
+
y2: C * 0.65,
|
|
5893
|
+
label: fmt(kulak),
|
|
5894
|
+
orientation: "horizontal",
|
|
5895
|
+
offset: -20
|
|
5896
|
+
}
|
|
5897
|
+
];
|
|
5898
|
+
}
|
|
5899
|
+
var MODEL_ID10 = "BECF-B-12109";
|
|
5900
|
+
var UNIT_FACTOR10 = {
|
|
5901
|
+
mm: 1,
|
|
5902
|
+
cm: 0.1,
|
|
5903
|
+
in: 1 / 25.4
|
|
5904
|
+
};
|
|
5905
|
+
var PX_PER_MM10 = 96 / 25.4;
|
|
5906
|
+
function renderDimension10(dim, i, fs) {
|
|
5907
|
+
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
5908
|
+
const tick = 1.5;
|
|
5909
|
+
if (orientation === "horizontal") {
|
|
5910
|
+
const y = y1 + offset;
|
|
5911
|
+
const midX = (x1 + x2) / 2;
|
|
5912
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
5913
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
|
|
5914
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
5915
|
+
/* @__PURE__ */ jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
5916
|
+
/* @__PURE__ */ jsx("text", { x: midX, y: y - 1.5, textAnchor: "middle", fontSize: fs, fontFamily: "sans-serif", fill: "#000", children: label })
|
|
5917
|
+
] }, `dim-${i}`);
|
|
5918
|
+
}
|
|
5919
|
+
const x = x1 + offset;
|
|
5920
|
+
const midY = (y1 + y2) / 2;
|
|
5921
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
5922
|
+
/* @__PURE__ */ jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
|
|
5923
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
|
|
5924
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
|
|
5925
|
+
/* @__PURE__ */ jsx("text", { x: x - 1.5, y: midY - 1, textAnchor: "middle", dominantBaseline: "central", fontSize: fs, fontFamily: "sans-serif", fill: "#000", transform: `rotate(-90, ${x - 1.5}, ${midY})`, children: label })
|
|
5926
|
+
] }, `dim-${i}`);
|
|
5927
|
+
}
|
|
5928
|
+
var DIE_LINE_BECF_B_12109 = forwardRef(
|
|
5929
|
+
({ attributes, unit = "mm", isShowDimensions = false, renderAs = "svg" }, ref) => {
|
|
5930
|
+
const theme = useMemo(() => getModelTheme(), []);
|
|
5931
|
+
const svgRef = useRef(null);
|
|
5932
|
+
const dieline = useMemo(() => generateBecfB12109(attributes), [attributes]);
|
|
5933
|
+
const dimensions = useMemo(() => generateDimensions10(attributes, unit), [attributes, unit]);
|
|
5934
|
+
const factor = UNIT_FACTOR10[unit] ?? 1;
|
|
5935
|
+
const serializeSvg = useCallback((showDimensions) => {
|
|
5936
|
+
const svg = svgRef.current;
|
|
5937
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
5938
|
+
const clone = svg.cloneNode(true);
|
|
5939
|
+
if (!showDimensions) {
|
|
5940
|
+
clone.querySelector("#dimensions")?.remove();
|
|
5941
|
+
}
|
|
5942
|
+
return new XMLSerializer().serializeToString(clone);
|
|
5943
|
+
}, []);
|
|
5944
|
+
useImperativeHandle(ref, () => {
|
|
5945
|
+
const auto = getAutoCalcValues6(attributes);
|
|
5946
|
+
return {
|
|
5947
|
+
getAttributes: () => ({
|
|
5948
|
+
modelId: MODEL_ID10,
|
|
5949
|
+
overallWidth: dieline.viewBox.width * factor,
|
|
5950
|
+
overallHeight: dieline.viewBox.height * factor,
|
|
5951
|
+
length: attributes.length * factor,
|
|
5952
|
+
width: attributes.width * factor,
|
|
5953
|
+
height: attributes.height * factor,
|
|
5954
|
+
glueArea: auto.kulak * factor,
|
|
5955
|
+
kulak: auto.kulak * factor,
|
|
5956
|
+
dip: auto.dip * factor
|
|
5957
|
+
}),
|
|
5958
|
+
exportImage: async (options) => {
|
|
5959
|
+
const svgStr = serializeSvg(options.isShowDimension);
|
|
5960
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
5961
|
+
const url = URL.createObjectURL(blob);
|
|
5962
|
+
const img = new Image();
|
|
5963
|
+
await new Promise((resolve, reject) => {
|
|
5964
|
+
img.onload = () => resolve();
|
|
5965
|
+
img.onerror = reject;
|
|
5966
|
+
img.src = url;
|
|
5967
|
+
});
|
|
5968
|
+
const canvas = document.createElement("canvas");
|
|
5969
|
+
if (options.originalSize) {
|
|
5970
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM10);
|
|
5971
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM10);
|
|
5972
|
+
} else {
|
|
5973
|
+
canvas.width = 1920;
|
|
5974
|
+
canvas.height = 1080;
|
|
5975
|
+
}
|
|
5976
|
+
const ctx = canvas.getContext("2d");
|
|
5977
|
+
ctx.fillStyle = "#ffffff";
|
|
5978
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
5979
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
5980
|
+
URL.revokeObjectURL(url);
|
|
5981
|
+
return new Promise((resolve, reject) => {
|
|
5982
|
+
canvas.toBlob((b) => b ? resolve(b) : reject(new Error("Export failed")), "image/png");
|
|
5983
|
+
});
|
|
5984
|
+
},
|
|
5985
|
+
exportDimension: async () => {
|
|
5986
|
+
const dimData = generateDimensions10(attributes, unit);
|
|
5987
|
+
return exportDimensionPdf({ modelId: MODEL_ID10, dieline, dimensions: dimData, attributes, unit, factor, theme });
|
|
5988
|
+
}
|
|
5989
|
+
};
|
|
5990
|
+
}, [attributes, dieline, factor, unit, serializeSvg, theme]);
|
|
5991
|
+
const padding = isShowDimensions ? 15 : 0;
|
|
5992
|
+
const vbX = -padding;
|
|
5993
|
+
const vbY = -padding;
|
|
5994
|
+
const vbW = dieline.viewBox.width + padding * 2;
|
|
5995
|
+
const vbH = dieline.viewBox.height + padding * 2;
|
|
5996
|
+
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5997
|
+
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
5998
|
+
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
5999
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension10(d, i, getFontDimensionSize())) })
|
|
6000
|
+
] });
|
|
6001
|
+
if (renderAs === "group") return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
6002
|
+
return /* @__PURE__ */ jsx("svg", { ref: svgRef, xmlns: "http://www.w3.org/2000/svg", viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`, preserveAspectRatio: "xMidYMid meet", style: { backgroundColor: theme.colorBackground }, children: svgChildren });
|
|
6003
|
+
}
|
|
6004
|
+
);
|
|
6005
|
+
var CANVAS_BECF_B_12109 = forwardRef(
|
|
6006
|
+
(props, ref) => {
|
|
6007
|
+
const dieLineRef = useRef(null);
|
|
6008
|
+
const canvasRef = useRef(null);
|
|
6009
|
+
const { attributes } = props;
|
|
6010
|
+
const theme = useMemo(() => getModelTheme(), []);
|
|
6011
|
+
const dieline = useMemo(() => generateBecfB12109(attributes), [attributes]);
|
|
6012
|
+
const stablePadding = 15;
|
|
6013
|
+
const viewBox = useMemo(() => ({ x: -stablePadding, y: -stablePadding, width: dieline.viewBox.width + stablePadding * 2, height: dieline.viewBox.height + stablePadding * 2 }), [dieline.viewBox.width, dieline.viewBox.height]);
|
|
6014
|
+
const serializeCanvasSvg = useCallback((showDimensions) => {
|
|
6015
|
+
const svg = canvasRef.current?.getSvgElement();
|
|
6016
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
6017
|
+
const clone = svg.cloneNode(true);
|
|
6018
|
+
if (!showDimensions) {
|
|
6019
|
+
clone.querySelector("#dimensions")?.remove();
|
|
6020
|
+
}
|
|
6021
|
+
return new XMLSerializer().serializeToString(clone);
|
|
6022
|
+
}, []);
|
|
6023
|
+
useImperativeHandle(ref, () => ({
|
|
6024
|
+
getAttributes: () => dieLineRef.current.getAttributes(),
|
|
6025
|
+
exportImage: async (options) => {
|
|
6026
|
+
const svgStr = serializeCanvasSvg(options.isShowDimension);
|
|
6027
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
6028
|
+
const url = URL.createObjectURL(blob);
|
|
6029
|
+
const img = new Image();
|
|
6030
|
+
await new Promise((resolve, reject) => {
|
|
6031
|
+
img.onload = () => resolve();
|
|
6032
|
+
img.onerror = reject;
|
|
6033
|
+
img.src = url;
|
|
6034
|
+
});
|
|
6035
|
+
const canvas = document.createElement("canvas");
|
|
6036
|
+
if (options.originalSize) {
|
|
6037
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM10);
|
|
6038
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM10);
|
|
6039
|
+
} else {
|
|
6040
|
+
canvas.width = 1920;
|
|
6041
|
+
canvas.height = 1080;
|
|
6042
|
+
}
|
|
6043
|
+
const ctx = canvas.getContext("2d");
|
|
6044
|
+
ctx.fillStyle = "#ffffff";
|
|
6045
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
6046
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
6047
|
+
URL.revokeObjectURL(url);
|
|
6048
|
+
return new Promise((resolve, reject) => {
|
|
6049
|
+
canvas.toBlob((b) => b ? resolve(b) : reject(new Error("Export failed")), "image/png");
|
|
6050
|
+
});
|
|
6051
|
+
},
|
|
6052
|
+
exportDimension: () => dieLineRef.current.exportDimension(),
|
|
6053
|
+
resetView: () => canvasRef.current?.resetView(),
|
|
6054
|
+
fitView: () => canvasRef.current?.fitView()
|
|
6055
|
+
}), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
|
|
6056
|
+
return /* @__PURE__ */ jsx(BaseCanvas, { ref: canvasRef, viewBox, backgroundColor: theme.colorBackground, children: /* @__PURE__ */ jsx(DIE_LINE_BECF_B_12109, { ref: dieLineRef, ...props, renderAs: "group" }) });
|
|
6057
|
+
}
|
|
6058
|
+
);
|
|
6059
|
+
var MODEL_BECF_B_12109 = forwardRef(
|
|
6060
|
+
({ mode = "DIE_LINE", ...props }, ref) => {
|
|
6061
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (() => {
|
|
6062
|
+
switch (mode) {
|
|
6063
|
+
case "DIE_LINE":
|
|
6064
|
+
return /* @__PURE__ */ jsx(CANVAS_BECF_B_12109, { ref, ...props });
|
|
6065
|
+
case "3D":
|
|
6066
|
+
return null;
|
|
6067
|
+
case "AUTO_LAYOUT":
|
|
6068
|
+
return /* @__PURE__ */ jsx(DIE_LINE_BECF_B_12109, { ref, ...props });
|
|
6069
|
+
default:
|
|
6070
|
+
return null;
|
|
6071
|
+
}
|
|
6072
|
+
})() });
|
|
6073
|
+
}
|
|
6074
|
+
);
|
|
6075
|
+
|
|
6076
|
+
// src/components/dieline/snap-lock-boxes/becf-10a0a/generate.ts
|
|
6077
|
+
var MT5 = 0.5;
|
|
6078
|
+
var ARC_R4 = 5;
|
|
6079
|
+
var SNAP_R = 3;
|
|
6080
|
+
var TAPER = Math.tan(15 * Math.PI / 180);
|
|
6081
|
+
var TAB_W = 8;
|
|
6082
|
+
var CORNER = 3;
|
|
6083
|
+
var NOTCH = 10;
|
|
6084
|
+
function calcKulak7(b) {
|
|
6085
|
+
if (b < 100) return 13;
|
|
6086
|
+
if (b < 250) return 15;
|
|
6087
|
+
if (b < 500) return 20;
|
|
6088
|
+
return 25;
|
|
6089
|
+
}
|
|
6090
|
+
function calcDil(a, b, c) {
|
|
6091
|
+
const base = Math.max(15, Math.min(30, (a + b + 50) / 20));
|
|
6092
|
+
return Math.max(9, Math.min(a / 2, b - 1, c / 2, base));
|
|
6093
|
+
}
|
|
6094
|
+
function calcDip(b) {
|
|
6095
|
+
if (b <= 22) return 9;
|
|
6096
|
+
if (b <= 28) return Math.floor((b - 4) / 2);
|
|
6097
|
+
if (b <= 77) return 12;
|
|
6098
|
+
if (b <= 120) return Math.floor(b / 6);
|
|
6099
|
+
if (b <= 167) return 20;
|
|
6100
|
+
if (b <= 199) return Math.floor(b / 8);
|
|
6101
|
+
if (b < 300) return 30;
|
|
6102
|
+
if (b < 400) return 35;
|
|
6103
|
+
return 40;
|
|
6104
|
+
}
|
|
6105
|
+
function generateBecf10a0a(attr) {
|
|
6106
|
+
const { length: A, width: B, height: C } = attr;
|
|
6107
|
+
const kulak = calcKulak7(B);
|
|
6108
|
+
const dil = calcDil(A, B, C);
|
|
6109
|
+
const dip = calcDip(B);
|
|
6110
|
+
const glueTaper = kulak * TAPER;
|
|
6111
|
+
const tuckH = B / 2 + ARC_R4;
|
|
6112
|
+
const xFront = kulak;
|
|
6113
|
+
const xSide1 = kulak + A;
|
|
6114
|
+
const xBack = kulak + A + B;
|
|
6115
|
+
const xSide2 = kulak + 2 * A + B;
|
|
6116
|
+
const xEnd = kulak + 2 * A + 2 * B - 0.5;
|
|
6117
|
+
const yTop = 0;
|
|
6118
|
+
const yTuckTop = dil - 1;
|
|
6119
|
+
const yLockCrease = dil;
|
|
6120
|
+
const yTuckFlapTop = B + dil - 1 - tuckH;
|
|
6121
|
+
const yFoldTop = B + dil - 1;
|
|
6122
|
+
const yFoldBottom = yFoldTop + C;
|
|
6123
|
+
const yFoldBottomB2 = yFoldBottom + B / 2;
|
|
6124
|
+
const ySideBottom = yFoldBottom + A / 4 + dip + SNAP_R;
|
|
6125
|
+
const yBottom = yFoldBottom + B / 2 + dip + SNAP_R;
|
|
6126
|
+
const totalWidth = xEnd;
|
|
6127
|
+
const totalHeight = yBottom;
|
|
6128
|
+
const cut = [];
|
|
6129
|
+
const crease = [];
|
|
6130
|
+
crease.push(
|
|
6131
|
+
line11(xFront, yFoldTop, xFront, yFoldBottom),
|
|
6132
|
+
line11(xSide1, yFoldTop, xSide1, yFoldBottom),
|
|
6133
|
+
line11(xBack, yFoldTop, xBack, yFoldBottom),
|
|
6134
|
+
line11(xSide2, yFoldTop, xSide2, yFoldBottom)
|
|
6135
|
+
);
|
|
6136
|
+
crease.push(
|
|
6137
|
+
line11(xFront, yFoldBottom, xSide1, yFoldBottom),
|
|
6138
|
+
line11(xSide1, yFoldBottom, xBack, yFoldBottom),
|
|
6139
|
+
line11(xBack, yFoldBottom, xSide2, yFoldBottom),
|
|
6140
|
+
line11(xSide2, yFoldBottom, xEnd, yFoldBottom)
|
|
6141
|
+
);
|
|
6142
|
+
crease.push(
|
|
6143
|
+
line11(xBack, yFoldTop, xSide1 + MT5, yFoldTop),
|
|
6144
|
+
// Side1 panel
|
|
6145
|
+
line11(xBack, yFoldTop - MT5, xSide2, yFoldTop - MT5),
|
|
6146
|
+
// Back panel (MT offset)
|
|
6147
|
+
line11(xSide2, yFoldTop, xEnd, yFoldTop)
|
|
6148
|
+
// Side2 panel
|
|
6149
|
+
);
|
|
6150
|
+
crease.push(
|
|
6151
|
+
line11(xBack + NOTCH, yLockCrease, xSide2 - NOTCH, yLockCrease)
|
|
6152
|
+
);
|
|
6153
|
+
cut.push(
|
|
6154
|
+
line11(xSide1, yFoldTop, xFront, yFoldTop),
|
|
6155
|
+
line11(xSide1, yFoldTop, xSide1 + MT5, yFoldTop)
|
|
6156
|
+
);
|
|
6157
|
+
cut.push(
|
|
6158
|
+
`M${xFront} ${yFoldBottom} L${0} ${yFoldBottom - glueTaper} L${0} ${yFoldTop + glueTaper} L${xFront} ${yFoldTop}`
|
|
6159
|
+
);
|
|
6160
|
+
cut.push(line11(xEnd, yFoldTop, xEnd, yFoldBottom));
|
|
6161
|
+
cut.push(...lockTab(xBack, xSide2, yTop, yTuckTop, yLockCrease, yFoldTop));
|
|
6162
|
+
cut.push(...side1TuckFlap(xSide1, xBack, yFoldTop, yTuckFlapTop, tuckH));
|
|
6163
|
+
cut.push(...side2TuckFlap(xSide2, xEnd, yFoldTop, yTuckFlapTop, tuckH));
|
|
6164
|
+
cut.push(...frontPanelBottom(xFront, xSide1, A, yFoldBottom, yFoldBottomB2, yBottom, dip));
|
|
6165
|
+
cut.push(...backPanelBottom(xBack, xSide2, A, yFoldBottom, yFoldBottomB2, yBottom, ySideBottom, dip));
|
|
6166
|
+
cut.push(...side1Bottom(xSide1, xBack, B, A, yFoldBottom, ySideBottom, dip));
|
|
6167
|
+
cut.push(...side2Bottom(xSide2, xEnd, B, A, yFoldBottom, ySideBottom, dip));
|
|
6168
|
+
return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
|
|
6169
|
+
}
|
|
6170
|
+
function line11(x1, y1, x2, y2) {
|
|
6171
|
+
return `M${x1} ${y1} L${x2} ${y2}`;
|
|
6172
|
+
}
|
|
6173
|
+
function lockTab(xBack, xSide2, yTop, yTuckTop, yLockCrease, yFoldTop) {
|
|
6174
|
+
const paths = [];
|
|
6175
|
+
paths.push(line11(xBack, yFoldTop, xBack, yTuckTop));
|
|
6176
|
+
paths.push(line11(xSide2, yTuckTop, xSide2, yFoldTop));
|
|
6177
|
+
paths.push(line11(xBack, yTuckTop, xBack + NOTCH, yTuckTop));
|
|
6178
|
+
paths.push(line11(xSide2 - NOTCH, yTuckTop, xSide2, yTuckTop));
|
|
6179
|
+
paths.push(line11(xBack + NOTCH, yTuckTop, xBack + NOTCH, yLockCrease));
|
|
6180
|
+
paths.push(line11(xSide2 - NOTCH, yLockCrease, xSide2 - NOTCH, yTuckTop));
|
|
6181
|
+
paths.push(line11(xBack + MT5, yTuckTop, xBack + MT5, ARC_R4));
|
|
6182
|
+
paths.push(line11(xSide2 - MT5, yTuckTop, xSide2 - MT5, ARC_R4));
|
|
6183
|
+
paths.push(line11(xBack + MT5 + ARC_R4, yTop, xSide2 - MT5 - ARC_R4, yTop));
|
|
6184
|
+
paths.push(
|
|
6185
|
+
`M${xBack + MT5 + ARC_R4} ${yTop} A${ARC_R4} ${ARC_R4} 0 0 0 ${xBack + MT5} ${ARC_R4}`
|
|
6186
|
+
);
|
|
6187
|
+
paths.push(
|
|
6188
|
+
`M${xSide2 - MT5} ${ARC_R4} A${ARC_R4} ${ARC_R4} 0 0 0 ${xSide2 - MT5 - ARC_R4} ${yTop}`
|
|
6189
|
+
);
|
|
6190
|
+
return paths;
|
|
6191
|
+
}
|
|
6192
|
+
function side1TuckFlap(xSide1, xBack, yFoldTop, yTuckFlapTop, tuckH) {
|
|
6193
|
+
const slopeV = tuckH - TAB_W - CORNER;
|
|
6194
|
+
const slopeH = slopeV * TAPER;
|
|
6195
|
+
const leftTargetX = xSide1 + MT5 + CORNER + slopeH;
|
|
6196
|
+
const rightTargetX = xBack - ARC_R4;
|
|
6197
|
+
const leftPath = `M${xSide1 + MT5} ${yFoldTop} L${xSide1 + MT5} ${yFoldTop - TAB_W} L${xSide1 + MT5 + CORNER} ${yFoldTop - TAB_W - CORNER} L${leftTargetX} ${yTuckFlapTop}`;
|
|
6198
|
+
const topRight = `M${leftTargetX} ${yTuckFlapTop} L${rightTargetX} ${yTuckFlapTop} L${xBack - CORNER} ${yFoldTop - CORNER} L${xBack} ${yFoldTop}`;
|
|
6199
|
+
return [leftPath, topRight];
|
|
6200
|
+
}
|
|
6201
|
+
function side2TuckFlap(xSide2, xEnd, yFoldTop, yTuckFlapTop, tuckH) {
|
|
6202
|
+
const slopeV = tuckH - TAB_W - CORNER;
|
|
6203
|
+
const slopeH = slopeV * TAPER;
|
|
6204
|
+
const leftTargetX = xSide2 + ARC_R4;
|
|
6205
|
+
const rightTargetX = xEnd - CORNER - slopeH;
|
|
6206
|
+
const leftTop = `M${xSide2} ${yFoldTop} L${xSide2 + CORNER} ${yFoldTop - CORNER} L${leftTargetX} ${yTuckFlapTop} L${rightTargetX} ${yTuckFlapTop}`;
|
|
6207
|
+
const rightPath = `M${rightTargetX} ${yTuckFlapTop} L${xEnd - CORNER} ${yFoldTop - TAB_W - CORNER} L${xEnd} ${yFoldTop - TAB_W} L${xEnd} ${yFoldTop}`;
|
|
6208
|
+
return [leftTop, rightPath];
|
|
6209
|
+
}
|
|
6210
|
+
function frontPanelBottom(xFront, xSide1, A, yFoldBottom, yFoldBottomB2, yBottom, dip) {
|
|
6211
|
+
const paths = [];
|
|
6212
|
+
paths.push(line11(xFront, yFoldBottom, xFront, yBottom));
|
|
6213
|
+
paths.push(line11(xSide1, yBottom, xSide1, yFoldBottom));
|
|
6214
|
+
const notchHalfTop = A / 4 + MT5;
|
|
6215
|
+
const notchTaperH = (dip + SNAP_R) * TAPER;
|
|
6216
|
+
const center = xFront + A / 2;
|
|
6217
|
+
const nlt = center - notchHalfTop;
|
|
6218
|
+
const nrt = center + notchHalfTop;
|
|
6219
|
+
const nlb = nlt + notchTaperH;
|
|
6220
|
+
const nrb = nrt - notchTaperH;
|
|
6221
|
+
paths.push(line11(xFront, yBottom, nlb, yBottom));
|
|
6222
|
+
paths.push(line11(nlb, yBottom, nlt, yFoldBottomB2));
|
|
6223
|
+
paths.push(line11(nlt, yFoldBottomB2, nrt, yFoldBottomB2));
|
|
6224
|
+
paths.push(line11(nrt, yFoldBottomB2, nrb, yBottom));
|
|
6225
|
+
paths.push(line11(nrb, yBottom, xSide1, yBottom));
|
|
6226
|
+
return paths;
|
|
6227
|
+
}
|
|
6228
|
+
function backPanelBottom(xBack, xSide2, A, yFoldBottom, yFoldBottomB2, yBottom, ySideBottom, dip) {
|
|
6229
|
+
const paths = [];
|
|
6230
|
+
const diagH = A / 4;
|
|
6231
|
+
paths.push(line11(xBack, yFoldBottom, xBack, ySideBottom));
|
|
6232
|
+
paths.push(line11(xSide2, ySideBottom, xSide2, yFoldBottom));
|
|
6233
|
+
paths.push(line11(xBack, yFoldBottom, xBack + diagH, yFoldBottomB2));
|
|
6234
|
+
paths.push(line11(xSide2, yFoldBottom, xSide2 - diagH, yFoldBottomB2));
|
|
6235
|
+
paths.push(line11(xBack + diagH, yFoldBottomB2, xBack + diagH, yFoldBottomB2 + dip));
|
|
6236
|
+
paths.push(line11(xSide2 - diagH, yFoldBottomB2 + dip, xSide2 - diagH, yFoldBottomB2));
|
|
6237
|
+
paths.push(
|
|
6238
|
+
`M${xBack + diagH} ${yFoldBottomB2 + dip} A${SNAP_R} ${SNAP_R} 0 0 0 ${xBack + diagH + SNAP_R} ${yBottom}`
|
|
6239
|
+
);
|
|
6240
|
+
paths.push(
|
|
6241
|
+
`M${xSide2 - diagH - SNAP_R} ${yBottom} A${SNAP_R} ${SNAP_R} 0 0 0 ${xSide2 - diagH} ${yFoldBottomB2 + dip}`
|
|
6242
|
+
);
|
|
6243
|
+
paths.push(line11(xBack + diagH + SNAP_R, yBottom, xSide2 - diagH - SNAP_R, yBottom));
|
|
6244
|
+
return paths;
|
|
6245
|
+
}
|
|
6246
|
+
function side1Bottom(xSide1, xBack, B, A, yFoldBottom, ySideBottom, dip) {
|
|
6247
|
+
const paths = [];
|
|
6248
|
+
const diagEndX = xSide1 + B / 2;
|
|
6249
|
+
const diagEndY = yFoldBottom + A / 4;
|
|
6250
|
+
const taperV = dip + SNAP_R;
|
|
6251
|
+
const taperH = taperV * TAPER;
|
|
6252
|
+
paths.push(line11(xSide1, yFoldBottom, diagEndX, diagEndY));
|
|
6253
|
+
paths.push(line11(diagEndX, diagEndY, diagEndX - taperH, ySideBottom));
|
|
6254
|
+
paths.push(line11(diagEndX - taperH, ySideBottom, xBack, ySideBottom));
|
|
6255
|
+
return paths;
|
|
6256
|
+
}
|
|
6257
|
+
function side2Bottom(xSide2, xEnd, B, A, yFoldBottom, ySideBottom, dip) {
|
|
6258
|
+
const paths = [];
|
|
6259
|
+
const diagEndX = xSide2 + B / 2;
|
|
6260
|
+
const diagEndY = yFoldBottom + A / 4;
|
|
6261
|
+
const taperV = dip + SNAP_R;
|
|
6262
|
+
const taperH = taperV * TAPER;
|
|
6263
|
+
paths.push(line11(xEnd, yFoldBottom, diagEndX, diagEndY));
|
|
6264
|
+
paths.push(line11(diagEndX, diagEndY, diagEndX + taperH, ySideBottom));
|
|
6265
|
+
paths.push(line11(diagEndX + taperH, ySideBottom, xSide2, ySideBottom));
|
|
6266
|
+
return paths;
|
|
6267
|
+
}
|
|
6268
|
+
function generateDimensions11(attr, unit) {
|
|
6269
|
+
const { length: A, width: B, height: C } = attr;
|
|
6270
|
+
const kulak = calcKulak7(B);
|
|
6271
|
+
const dil = calcDil(A, B, C);
|
|
6272
|
+
const dip = calcDip(B);
|
|
6273
|
+
const xFront = kulak;
|
|
6274
|
+
const xSide1 = kulak + A;
|
|
6275
|
+
const xSide2 = kulak + 2 * A + B;
|
|
6276
|
+
const xEnd = kulak + 2 * A + 2 * B - 0.5;
|
|
6277
|
+
const yFoldTop = B + dil - 1;
|
|
6278
|
+
const yFoldBottom = yFoldTop + C;
|
|
6279
|
+
const yBottom = yFoldBottom + B / 2 + dip + SNAP_R;
|
|
6280
|
+
const totalWidth = xEnd;
|
|
6281
|
+
const totalHeight = yBottom;
|
|
6282
|
+
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
6283
|
+
const suffix = unit;
|
|
6284
|
+
const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
|
|
6285
|
+
return [
|
|
6286
|
+
{
|
|
6287
|
+
x1: 0,
|
|
6288
|
+
y1: 0,
|
|
6289
|
+
x2: 0,
|
|
6290
|
+
y2: totalHeight,
|
|
6291
|
+
label: `Overall Height : ${fmt(totalHeight)}`,
|
|
6292
|
+
orientation: "vertical",
|
|
6293
|
+
offset: -12
|
|
6294
|
+
},
|
|
6295
|
+
{
|
|
6296
|
+
x1: 0,
|
|
6297
|
+
y1: 0,
|
|
6298
|
+
x2: totalWidth,
|
|
6299
|
+
y2: 0,
|
|
6300
|
+
label: `Overall Width : ${fmt(totalWidth)}`,
|
|
6301
|
+
orientation: "horizontal",
|
|
6302
|
+
offset: -12
|
|
6303
|
+
},
|
|
6304
|
+
{
|
|
6305
|
+
x1: xSide2,
|
|
6306
|
+
y1: yFoldTop,
|
|
6307
|
+
x2: xSide2,
|
|
6308
|
+
y2: yFoldBottom,
|
|
6309
|
+
label: fmt(C),
|
|
6310
|
+
orientation: "vertical",
|
|
6311
|
+
offset: -14
|
|
6312
|
+
},
|
|
6313
|
+
{
|
|
6314
|
+
x1: xFront,
|
|
6315
|
+
y1: yFoldBottom,
|
|
6316
|
+
x2: xSide1,
|
|
6317
|
+
y2: yFoldBottom,
|
|
6318
|
+
label: fmt(A),
|
|
6319
|
+
orientation: "horizontal",
|
|
6320
|
+
offset: -20
|
|
6321
|
+
},
|
|
6322
|
+
{
|
|
6323
|
+
x1: xSide1,
|
|
6324
|
+
y1: yFoldBottom,
|
|
6325
|
+
x2: xSide1 + B,
|
|
6326
|
+
y2: yFoldBottom,
|
|
6327
|
+
label: fmt(B),
|
|
6328
|
+
orientation: "horizontal",
|
|
6329
|
+
offset: -20
|
|
6330
|
+
}
|
|
6331
|
+
];
|
|
6332
|
+
}
|
|
6333
|
+
var MODEL_ID11 = "BECF-10A0A";
|
|
6334
|
+
var UNIT_FACTOR11 = {
|
|
6335
|
+
mm: 1,
|
|
6336
|
+
cm: 0.1,
|
|
6337
|
+
in: 1 / 25.4
|
|
6338
|
+
};
|
|
6339
|
+
var PX_PER_MM11 = 96 / 25.4;
|
|
6340
|
+
function renderDimension11(dim, i, fs) {
|
|
6341
|
+
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
6342
|
+
const tick = 1.5;
|
|
6343
|
+
if (orientation === "horizontal") {
|
|
6344
|
+
const y = y1 + offset;
|
|
6345
|
+
const midX = (x1 + x2) / 2;
|
|
6346
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
6347
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
|
|
6348
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
6349
|
+
/* @__PURE__ */ jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
6350
|
+
/* @__PURE__ */ jsx(
|
|
6351
|
+
"text",
|
|
6352
|
+
{
|
|
6353
|
+
x: midX,
|
|
6354
|
+
y: y - 1.5,
|
|
6355
|
+
textAnchor: "middle",
|
|
6356
|
+
fontSize: fs,
|
|
6357
|
+
fontFamily: "sans-serif",
|
|
6358
|
+
fill: "#000",
|
|
6359
|
+
children: label
|
|
6360
|
+
}
|
|
6361
|
+
)
|
|
6362
|
+
] }, `dim-${i}`);
|
|
6363
|
+
}
|
|
6364
|
+
const x = x1 + offset;
|
|
6365
|
+
const midY = (y1 + y2) / 2;
|
|
6366
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
6367
|
+
/* @__PURE__ */ jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
|
|
6368
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
|
|
6369
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
|
|
6370
|
+
/* @__PURE__ */ jsx(
|
|
6371
|
+
"text",
|
|
6372
|
+
{
|
|
6373
|
+
x: x - 1.5,
|
|
6374
|
+
y: midY - 1,
|
|
6375
|
+
textAnchor: "middle",
|
|
6376
|
+
dominantBaseline: "central",
|
|
6377
|
+
fontSize: fs,
|
|
6378
|
+
fontFamily: "sans-serif",
|
|
6379
|
+
fill: "#000",
|
|
6380
|
+
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
6381
|
+
children: label
|
|
6382
|
+
}
|
|
6383
|
+
)
|
|
6384
|
+
] }, `dim-${i}`);
|
|
6385
|
+
}
|
|
6386
|
+
var DIE_LINE_BECF_10A0A = forwardRef(
|
|
6387
|
+
({
|
|
6388
|
+
attributes,
|
|
6389
|
+
unit = "mm",
|
|
6390
|
+
isShowDimensions = false,
|
|
6391
|
+
renderAs = "svg"
|
|
6392
|
+
}, ref) => {
|
|
6393
|
+
const theme = useMemo(
|
|
6394
|
+
() => getModelTheme(),
|
|
6395
|
+
[]
|
|
6396
|
+
);
|
|
6397
|
+
const svgRef = useRef(null);
|
|
6398
|
+
const dieline = useMemo(() => generateBecf10a0a(attributes), [attributes]);
|
|
6399
|
+
const dimensions = useMemo(
|
|
6400
|
+
() => generateDimensions11(attributes, unit),
|
|
6401
|
+
[attributes, unit]
|
|
6402
|
+
);
|
|
6403
|
+
const factor = UNIT_FACTOR11[unit] ?? 1;
|
|
6404
|
+
const serializeSvg = useCallback(
|
|
6405
|
+
(showDimensions) => {
|
|
6406
|
+
const svg = svgRef.current;
|
|
6407
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
6408
|
+
const clone = svg.cloneNode(true);
|
|
6409
|
+
if (!showDimensions) {
|
|
6410
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
6411
|
+
dimGroup?.remove();
|
|
6412
|
+
}
|
|
6413
|
+
return new XMLSerializer().serializeToString(clone);
|
|
6414
|
+
},
|
|
6415
|
+
[]
|
|
6416
|
+
);
|
|
6417
|
+
useImperativeHandle(
|
|
6418
|
+
ref,
|
|
6419
|
+
() => {
|
|
6420
|
+
const { length: A, width: B, height: C } = attributes;
|
|
6421
|
+
const kulak = calcKulak7(B);
|
|
6422
|
+
const dil = calcDil(A, B, C);
|
|
6423
|
+
const dip = calcDip(B);
|
|
6424
|
+
const flap = Math.min(A / 2, B / 2 + dil / 2 - 0.5);
|
|
6425
|
+
return {
|
|
6426
|
+
getAttributes: () => ({
|
|
6427
|
+
modelId: MODEL_ID11,
|
|
6428
|
+
overallWidth: dieline.viewBox.width * factor,
|
|
6429
|
+
overallHeight: dieline.viewBox.height * factor,
|
|
6430
|
+
length: A * factor,
|
|
6431
|
+
width: B * factor,
|
|
6432
|
+
height: C * factor,
|
|
6433
|
+
kulak: kulak * factor,
|
|
6434
|
+
dil: dil * factor,
|
|
6435
|
+
flap: flap * factor,
|
|
6436
|
+
dip: dip * factor
|
|
6437
|
+
}),
|
|
6438
|
+
exportImage: async (options) => {
|
|
6439
|
+
const svgStr = serializeSvg(options.isShowDimension);
|
|
6440
|
+
const blob = new Blob([svgStr], {
|
|
6441
|
+
type: "image/svg+xml;charset=utf-8"
|
|
6442
|
+
});
|
|
6443
|
+
const url = URL.createObjectURL(blob);
|
|
6444
|
+
const img = new Image();
|
|
6445
|
+
await new Promise((resolve, reject) => {
|
|
6446
|
+
img.onload = () => resolve();
|
|
6447
|
+
img.onerror = reject;
|
|
6448
|
+
img.src = url;
|
|
6449
|
+
});
|
|
6450
|
+
const canvas = document.createElement("canvas");
|
|
6451
|
+
if (options.originalSize) {
|
|
6452
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM11);
|
|
6453
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM11);
|
|
6454
|
+
} else {
|
|
6455
|
+
canvas.width = 1920;
|
|
6456
|
+
canvas.height = 1080;
|
|
6457
|
+
}
|
|
6458
|
+
const ctx = canvas.getContext("2d");
|
|
6459
|
+
ctx.fillStyle = "#ffffff";
|
|
6460
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
6461
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
6462
|
+
URL.revokeObjectURL(url);
|
|
6463
|
+
return new Promise((resolve, reject) => {
|
|
6464
|
+
canvas.toBlob(
|
|
6465
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
6466
|
+
"image/png"
|
|
6467
|
+
);
|
|
6468
|
+
});
|
|
6469
|
+
},
|
|
6470
|
+
exportDimension: async () => {
|
|
6471
|
+
const dimData = generateDimensions11(attributes, unit);
|
|
6472
|
+
return exportDimensionPdf({
|
|
6473
|
+
modelId: MODEL_ID11,
|
|
6474
|
+
dieline,
|
|
6475
|
+
dimensions: dimData,
|
|
6476
|
+
attributes,
|
|
6477
|
+
unit,
|
|
6478
|
+
factor,
|
|
6479
|
+
theme
|
|
6480
|
+
});
|
|
6481
|
+
}
|
|
6482
|
+
};
|
|
6483
|
+
},
|
|
6484
|
+
[attributes, dieline, factor, unit, serializeSvg, theme]
|
|
6485
|
+
);
|
|
6486
|
+
const padding = isShowDimensions ? 15 : 0;
|
|
6487
|
+
const vbX = -padding;
|
|
6488
|
+
const vbY = -padding;
|
|
6489
|
+
const vbW = dieline.viewBox.width + padding * 2;
|
|
6490
|
+
const vbH = dieline.viewBox.height + padding * 2;
|
|
6491
|
+
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6492
|
+
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
6493
|
+
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
6494
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension11(d, i, getFontDimensionSize())) })
|
|
6495
|
+
] });
|
|
6496
|
+
if (renderAs === "group") {
|
|
6497
|
+
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
6498
|
+
}
|
|
6499
|
+
return /* @__PURE__ */ jsx(
|
|
6500
|
+
"svg",
|
|
6501
|
+
{
|
|
6502
|
+
ref: svgRef,
|
|
6503
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6504
|
+
viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`,
|
|
6505
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
6506
|
+
style: { backgroundColor: theme.colorBackground },
|
|
6507
|
+
children: svgChildren
|
|
6508
|
+
}
|
|
6509
|
+
);
|
|
6510
|
+
}
|
|
6511
|
+
);
|
|
6512
|
+
var CANVAS_BECF_10A0A = forwardRef(
|
|
6513
|
+
(props, ref) => {
|
|
6514
|
+
const dieLineRef = useRef(null);
|
|
6515
|
+
const canvasRef = useRef(null);
|
|
6516
|
+
const { attributes } = props;
|
|
6517
|
+
const theme = useMemo(
|
|
6518
|
+
() => getModelTheme(),
|
|
6519
|
+
[]
|
|
6520
|
+
);
|
|
6521
|
+
const dieline = useMemo(() => generateBecf10a0a(attributes), [attributes]);
|
|
6522
|
+
const stablePadding = 15;
|
|
6523
|
+
const viewBox = useMemo(
|
|
6524
|
+
() => ({
|
|
6525
|
+
x: -stablePadding,
|
|
6526
|
+
y: -stablePadding,
|
|
6527
|
+
width: dieline.viewBox.width + stablePadding * 2,
|
|
6528
|
+
height: dieline.viewBox.height + stablePadding * 2
|
|
6529
|
+
}),
|
|
6530
|
+
[dieline.viewBox.width, dieline.viewBox.height]
|
|
6531
|
+
);
|
|
6532
|
+
const serializeCanvasSvg = useCallback((showDimensions) => {
|
|
6533
|
+
const svg = canvasRef.current?.getSvgElement();
|
|
6534
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
6535
|
+
const clone = svg.cloneNode(true);
|
|
6536
|
+
if (!showDimensions) {
|
|
6537
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
6538
|
+
dimGroup?.remove();
|
|
6539
|
+
}
|
|
6540
|
+
return new XMLSerializer().serializeToString(clone);
|
|
6541
|
+
}, []);
|
|
6542
|
+
useImperativeHandle(ref, () => ({
|
|
6543
|
+
getAttributes: () => dieLineRef.current.getAttributes(),
|
|
6544
|
+
exportImage: async (options) => {
|
|
6545
|
+
const svgStr = serializeCanvasSvg(options.isShowDimension);
|
|
6546
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
6547
|
+
const url = URL.createObjectURL(blob);
|
|
6548
|
+
const img = new Image();
|
|
6549
|
+
await new Promise((resolve, reject) => {
|
|
6550
|
+
img.onload = () => resolve();
|
|
6551
|
+
img.onerror = reject;
|
|
6552
|
+
img.src = url;
|
|
6553
|
+
});
|
|
6554
|
+
const canvas = document.createElement("canvas");
|
|
6555
|
+
if (options.originalSize) {
|
|
6556
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM11);
|
|
6557
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM11);
|
|
6558
|
+
} else {
|
|
6559
|
+
canvas.width = 1920;
|
|
6560
|
+
canvas.height = 1080;
|
|
6561
|
+
}
|
|
6562
|
+
const ctx = canvas.getContext("2d");
|
|
6563
|
+
ctx.fillStyle = "#ffffff";
|
|
6564
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
6565
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
6566
|
+
URL.revokeObjectURL(url);
|
|
6567
|
+
return new Promise((resolve, reject) => {
|
|
6568
|
+
canvas.toBlob(
|
|
6569
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
6570
|
+
"image/png"
|
|
6571
|
+
);
|
|
6572
|
+
});
|
|
6573
|
+
},
|
|
6574
|
+
exportDimension: () => dieLineRef.current.exportDimension(),
|
|
6575
|
+
resetView: () => canvasRef.current?.resetView(),
|
|
6576
|
+
fitView: () => canvasRef.current?.fitView()
|
|
6577
|
+
}), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
|
|
6578
|
+
return /* @__PURE__ */ jsx(
|
|
6579
|
+
BaseCanvas,
|
|
6580
|
+
{
|
|
6581
|
+
ref: canvasRef,
|
|
6582
|
+
viewBox,
|
|
6583
|
+
backgroundColor: theme.colorBackground,
|
|
6584
|
+
children: /* @__PURE__ */ jsx(DIE_LINE_BECF_10A0A, { ref: dieLineRef, ...props, renderAs: "group" })
|
|
6585
|
+
}
|
|
6586
|
+
);
|
|
6587
|
+
}
|
|
6588
|
+
);
|
|
6589
|
+
var MODEL_BECF_10A0A = forwardRef(
|
|
6590
|
+
({ mode = "DIE_LINE", ...props }, ref) => {
|
|
6591
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (() => {
|
|
6592
|
+
switch (mode) {
|
|
6593
|
+
case "DIE_LINE":
|
|
6594
|
+
return /* @__PURE__ */ jsx(CANVAS_BECF_10A0A, { ref, ...props });
|
|
6595
|
+
case "3D":
|
|
6596
|
+
return null;
|
|
6597
|
+
case "AUTO_LAYOUT":
|
|
6598
|
+
return /* @__PURE__ */ jsx(DIE_LINE_BECF_10A0A, { ref, ...props });
|
|
6599
|
+
default:
|
|
6600
|
+
return null;
|
|
6601
|
+
}
|
|
6602
|
+
})() });
|
|
6603
|
+
}
|
|
6604
|
+
);
|
|
6605
|
+
|
|
6606
|
+
// src/utils/autoLayout/rasterize.ts
|
|
6607
|
+
function rasterizePolygon(points, resolution) {
|
|
6608
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
6609
|
+
for (const p of points) {
|
|
6610
|
+
if (p.x < minX) minX = p.x;
|
|
6611
|
+
if (p.y < minY) minY = p.y;
|
|
6612
|
+
if (p.x > maxX) maxX = p.x;
|
|
6613
|
+
if (p.y > maxY) maxY = p.y;
|
|
6614
|
+
}
|
|
6615
|
+
const offsetX = Math.floor(minX / resolution);
|
|
6616
|
+
const offsetY = Math.floor(minY / resolution);
|
|
6617
|
+
const w = Math.ceil((maxX - offsetX * resolution) / resolution) + 1;
|
|
6618
|
+
const h = Math.ceil((maxY - offsetY * resolution) / resolution) + 1;
|
|
6619
|
+
const data = new Uint8Array(w * h);
|
|
6620
|
+
for (let gy = 0; gy < h; gy++) {
|
|
6621
|
+
const worldY = (offsetY + gy) * resolution + resolution / 2;
|
|
6622
|
+
const crossings = [];
|
|
6623
|
+
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
|
|
6624
|
+
const yi = points[i].y, yj = points[j].y;
|
|
6625
|
+
if (yi <= worldY && yj > worldY || yj <= worldY && yi > worldY) {
|
|
6626
|
+
const t = (worldY - yi) / (yj - yi);
|
|
6627
|
+
crossings.push(points[i].x + t * (points[j].x - points[i].x));
|
|
6628
|
+
}
|
|
6629
|
+
}
|
|
6630
|
+
crossings.sort((a, b) => a - b);
|
|
6631
|
+
for (let c = 0; c < crossings.length - 1; c += 2) {
|
|
6632
|
+
const startGx = Math.max(0, Math.floor((crossings[c] - offsetX * resolution) / resolution));
|
|
6633
|
+
const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
|
|
6634
|
+
for (let gx = startGx; gx <= endGx; gx++) {
|
|
6635
|
+
data[gy * w + gx] = 1;
|
|
6636
|
+
}
|
|
6637
|
+
}
|
|
6638
|
+
}
|
|
6639
|
+
return { data, width: w, height: h, offsetX, offsetY };
|
|
6640
|
+
}
|
|
6641
|
+
function canPlace(paperGrid, paperW, paperH, piece, px, py) {
|
|
6642
|
+
for (let y = 0; y < piece.height; y++) {
|
|
6643
|
+
const paperY = py + y;
|
|
6644
|
+
if (paperY < 0 || paperY >= paperH) {
|
|
6645
|
+
for (let x = 0; x < piece.width; x++) {
|
|
6646
|
+
if (piece.data[y * piece.width + x]) return false;
|
|
6647
|
+
}
|
|
6648
|
+
continue;
|
|
6649
|
+
}
|
|
6650
|
+
for (let x = 0; x < piece.width; x++) {
|
|
6651
|
+
if (!piece.data[y * piece.width + x]) continue;
|
|
6652
|
+
const paperX = px + x;
|
|
6653
|
+
if (paperX < 0 || paperX >= paperW) return false;
|
|
6654
|
+
if (paperGrid[paperY * paperW + paperX]) return false;
|
|
6655
|
+
}
|
|
6656
|
+
}
|
|
6657
|
+
return true;
|
|
6658
|
+
}
|
|
6659
|
+
function placePiece(paperGrid, paperW, piece, px, py) {
|
|
6660
|
+
for (let y = 0; y < piece.height; y++) {
|
|
6661
|
+
for (let x = 0; x < piece.width; x++) {
|
|
6662
|
+
if (piece.data[y * piece.width + x]) {
|
|
6663
|
+
paperGrid[(py + y) * paperW + (px + x)] = 1;
|
|
6664
|
+
}
|
|
6665
|
+
}
|
|
6666
|
+
}
|
|
6667
|
+
}
|
|
6668
|
+
|
|
6669
|
+
// src/utils/autoLayout/calculate/shared.ts
|
|
6670
|
+
var RESOLUTION = 1;
|
|
6671
|
+
function resolveGripperSide(paperWidth, paperHeight) {
|
|
6672
|
+
if (paperWidth >= paperHeight) return "bottom";
|
|
6673
|
+
return "left";
|
|
6674
|
+
}
|
|
6675
|
+
function computeUsableBounds(paperWidth, paperHeight, gripperSide, spacing, griper, colorbarDepth) {
|
|
6676
|
+
switch (gripperSide) {
|
|
6677
|
+
case "bottom":
|
|
6678
|
+
return {
|
|
6679
|
+
top: colorbarDepth + spacing,
|
|
6680
|
+
bottom: paperHeight - griper,
|
|
6681
|
+
left: spacing,
|
|
6682
|
+
right: paperWidth - spacing
|
|
6683
|
+
};
|
|
6684
|
+
case "top":
|
|
6685
|
+
return {
|
|
6686
|
+
top: griper,
|
|
6687
|
+
bottom: paperHeight - colorbarDepth - spacing,
|
|
6688
|
+
left: spacing,
|
|
6689
|
+
right: paperWidth - spacing
|
|
6690
|
+
};
|
|
6691
|
+
case "left":
|
|
6692
|
+
return {
|
|
6693
|
+
top: spacing,
|
|
6694
|
+
bottom: paperHeight - spacing,
|
|
6695
|
+
left: griper,
|
|
6696
|
+
right: paperWidth - colorbarDepth - spacing
|
|
6697
|
+
};
|
|
6698
|
+
case "right":
|
|
6699
|
+
return {
|
|
6700
|
+
top: spacing,
|
|
6701
|
+
bottom: paperHeight - spacing,
|
|
6702
|
+
left: colorbarDepth + spacing,
|
|
6703
|
+
right: paperWidth - griper
|
|
6704
|
+
};
|
|
6705
|
+
}
|
|
6706
|
+
}
|
|
6707
|
+
function normalizePoints(points, degrees) {
|
|
6708
|
+
const rad = degrees * Math.PI / 180;
|
|
6709
|
+
const cos = Math.cos(rad);
|
|
6710
|
+
const sin = Math.sin(rad);
|
|
6711
|
+
const rotated = points.map((p) => ({
|
|
6712
|
+
x: p.x * cos - p.y * sin,
|
|
6713
|
+
y: p.x * sin + p.y * cos
|
|
5394
6714
|
}));
|
|
5395
6715
|
let minX = Infinity, minY = Infinity;
|
|
5396
6716
|
for (const p of rotated) {
|
|
5397
6717
|
if (p.x < minX) minX = p.x;
|
|
5398
6718
|
if (p.y < minY) minY = p.y;
|
|
5399
6719
|
}
|
|
5400
|
-
return rotated.map((p) => ({ x: p.x - minX, y: p.y - minY }));
|
|
5401
|
-
}
|
|
5402
|
-
function computeDielineBBOffset(offsetContourPoints, dielineW, dielineH, degrees) {
|
|
5403
|
-
const rad = degrees * Math.PI / 180;
|
|
5404
|
-
const cos = Math.cos(rad);
|
|
5405
|
-
const sin = Math.sin(rad);
|
|
5406
|
-
let ocMinX = Infinity, ocMinY = Infinity;
|
|
5407
|
-
for (const p of offsetContourPoints) {
|
|
5408
|
-
const rx = p.x * cos - p.y * sin;
|
|
5409
|
-
const ry = p.x * sin + p.y * cos;
|
|
5410
|
-
if (rx < ocMinX) ocMinX = rx;
|
|
5411
|
-
if (ry < ocMinY) ocMinY = ry;
|
|
6720
|
+
return rotated.map((p) => ({ x: p.x - minX, y: p.y - minY }));
|
|
6721
|
+
}
|
|
6722
|
+
function computeDielineBBOffset(offsetContourPoints, dielineW, dielineH, degrees) {
|
|
6723
|
+
const rad = degrees * Math.PI / 180;
|
|
6724
|
+
const cos = Math.cos(rad);
|
|
6725
|
+
const sin = Math.sin(rad);
|
|
6726
|
+
let ocMinX = Infinity, ocMinY = Infinity;
|
|
6727
|
+
for (const p of offsetContourPoints) {
|
|
6728
|
+
const rx = p.x * cos - p.y * sin;
|
|
6729
|
+
const ry = p.x * sin + p.y * cos;
|
|
6730
|
+
if (rx < ocMinX) ocMinX = rx;
|
|
6731
|
+
if (ry < ocMinY) ocMinY = ry;
|
|
6732
|
+
}
|
|
6733
|
+
const corners = [[0, 0], [dielineW, 0], [0, dielineH], [dielineW, dielineH]];
|
|
6734
|
+
let dlMinX = Infinity, dlMinY = Infinity;
|
|
6735
|
+
for (const [cx, cy] of corners) {
|
|
6736
|
+
const rx = cx * cos - cy * sin;
|
|
6737
|
+
const ry = cx * sin + cy * cos;
|
|
6738
|
+
if (rx < dlMinX) dlMinX = rx;
|
|
6739
|
+
if (ry < dlMinY) dlMinY = ry;
|
|
6740
|
+
}
|
|
6741
|
+
return { dx: dlMinX - ocMinX, dy: dlMinY - ocMinY };
|
|
6742
|
+
}
|
|
6743
|
+
function computeLayoutForPaperDefault(contourPoints, dielineW, dielineH, paperWidth, paperHeight, bounds) {
|
|
6744
|
+
const usableLeft = Math.ceil(bounds.left / RESOLUTION);
|
|
6745
|
+
const usableTop = Math.ceil(bounds.top / RESOLUTION);
|
|
6746
|
+
const usableRight = Math.floor(bounds.right / RESOLUTION);
|
|
6747
|
+
const usableBottom = Math.floor(bounds.bottom / RESOLUTION);
|
|
6748
|
+
const paperW = Math.floor(paperWidth / RESOLUTION);
|
|
6749
|
+
const paperH = Math.floor(paperHeight / RESOLUTION);
|
|
6750
|
+
let bestCandidate = { rotation: 0, placements: [], producedPerSheet: 0 };
|
|
6751
|
+
let bestGridPositions = [];
|
|
6752
|
+
let bestBitmapW = 0;
|
|
6753
|
+
let bestBitmapH = 0;
|
|
6754
|
+
for (const deg of [0, 90, 180, 270]) {
|
|
6755
|
+
const rotatedContour = normalizePoints(contourPoints, deg);
|
|
6756
|
+
const pieceBitmap = rasterizePolygon(rotatedContour, RESOLUTION);
|
|
6757
|
+
const bbOffset = computeDielineBBOffset(contourPoints, dielineW, dielineH, deg);
|
|
6758
|
+
const paperGrid = new Uint8Array(paperW * paperH);
|
|
6759
|
+
const placements = [];
|
|
6760
|
+
const gridPositions = [];
|
|
6761
|
+
for (let py = usableTop; py <= usableBottom - pieceBitmap.height; py++) {
|
|
6762
|
+
for (let px = usableLeft; px <= usableRight - pieceBitmap.width; px++) {
|
|
6763
|
+
if (canPlace(paperGrid, paperW, paperH, pieceBitmap, px, py)) {
|
|
6764
|
+
placePiece(paperGrid, paperW, pieceBitmap, px, py);
|
|
6765
|
+
gridPositions.push({ px, py });
|
|
6766
|
+
placements.push({
|
|
6767
|
+
x: px * RESOLUTION + bbOffset.dx,
|
|
6768
|
+
y: py * RESOLUTION + bbOffset.dy,
|
|
6769
|
+
rotation: deg
|
|
6770
|
+
});
|
|
6771
|
+
}
|
|
6772
|
+
}
|
|
6773
|
+
}
|
|
6774
|
+
if (placements.length > bestCandidate.producedPerSheet) {
|
|
6775
|
+
bestCandidate = { rotation: deg, placements, producedPerSheet: placements.length };
|
|
6776
|
+
bestGridPositions = gridPositions;
|
|
6777
|
+
bestBitmapW = pieceBitmap.width;
|
|
6778
|
+
bestBitmapH = pieceBitmap.height;
|
|
6779
|
+
}
|
|
6780
|
+
}
|
|
6781
|
+
if (bestCandidate.placements.length > 0) {
|
|
6782
|
+
let gridMinX = Infinity;
|
|
6783
|
+
let gridMinY = Infinity;
|
|
6784
|
+
let gridMaxX = -Infinity;
|
|
6785
|
+
let gridMaxY = -Infinity;
|
|
6786
|
+
for (const { px, py } of bestGridPositions) {
|
|
6787
|
+
if (px < gridMinX) gridMinX = px;
|
|
6788
|
+
if (py < gridMinY) gridMinY = py;
|
|
6789
|
+
if (px + bestBitmapW > gridMaxX) gridMaxX = px + bestBitmapW;
|
|
6790
|
+
if (py + bestBitmapH > gridMaxY) gridMaxY = py + bestBitmapH;
|
|
6791
|
+
}
|
|
6792
|
+
const groupW = gridMaxX - gridMinX;
|
|
6793
|
+
const groupH = gridMaxY - gridMinY;
|
|
6794
|
+
const usableW = usableRight - usableLeft;
|
|
6795
|
+
const usableH = usableBottom - usableTop;
|
|
6796
|
+
const offsetX = ((usableW - groupW) / 2 - (gridMinX - usableLeft)) * RESOLUTION;
|
|
6797
|
+
const offsetY = ((usableH - groupH) / 2 - (gridMinY - usableTop)) * RESOLUTION;
|
|
6798
|
+
for (const p of bestCandidate.placements) {
|
|
6799
|
+
p.x += offsetX;
|
|
6800
|
+
p.y += offsetY;
|
|
6801
|
+
}
|
|
6802
|
+
}
|
|
6803
|
+
return bestCandidate;
|
|
6804
|
+
}
|
|
6805
|
+
|
|
6806
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1010a/index.ts
|
|
6807
|
+
var SAMPLE_STEP = 0.1;
|
|
6808
|
+
function buildProfile(points) {
|
|
6809
|
+
let maxX = 0, maxY = 0;
|
|
6810
|
+
for (const p of points) {
|
|
6811
|
+
if (p.x > maxX) maxX = p.x;
|
|
6812
|
+
if (p.y > maxY) maxY = p.y;
|
|
6813
|
+
}
|
|
6814
|
+
const width = maxX, height = maxY;
|
|
6815
|
+
const nY = Math.ceil(height / SAMPLE_STEP) + 1;
|
|
6816
|
+
const nX = Math.ceil(width / SAMPLE_STEP) + 1;
|
|
6817
|
+
const rightX = new Float64Array(nY).fill(-Infinity);
|
|
6818
|
+
const leftX = new Float64Array(nY).fill(Infinity);
|
|
6819
|
+
const bottomY = new Float64Array(nX).fill(-Infinity);
|
|
6820
|
+
const topY = new Float64Array(nX).fill(Infinity);
|
|
6821
|
+
const nPts = points.length;
|
|
6822
|
+
for (let iy = 0; iy < nY; iy++) {
|
|
6823
|
+
const y = iy * SAMPLE_STEP;
|
|
6824
|
+
for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
|
|
6825
|
+
const yj = points[j].y, yk = points[k].y;
|
|
6826
|
+
if (yj <= y && yk > y || yk <= y && yj > y) {
|
|
6827
|
+
const t = (y - yj) / (yk - yj);
|
|
6828
|
+
const x = points[j].x + t * (points[k].x - points[j].x);
|
|
6829
|
+
if (x > rightX[iy]) rightX[iy] = x;
|
|
6830
|
+
if (x < leftX[iy]) leftX[iy] = x;
|
|
6831
|
+
}
|
|
6832
|
+
}
|
|
6833
|
+
}
|
|
6834
|
+
for (let ix = 0; ix < nX; ix++) {
|
|
6835
|
+
const x = ix * SAMPLE_STEP;
|
|
6836
|
+
for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
|
|
6837
|
+
const xj = points[j].x, xk = points[k].x;
|
|
6838
|
+
if (xj <= x && xk > x || xk <= x && xj > x) {
|
|
6839
|
+
const t = (x - xj) / (xk - xj);
|
|
6840
|
+
const y = points[j].y + t * (points[k].y - points[j].y);
|
|
6841
|
+
if (y > bottomY[ix]) bottomY[ix] = y;
|
|
6842
|
+
if (y < topY[ix]) topY[ix] = y;
|
|
6843
|
+
}
|
|
6844
|
+
}
|
|
6845
|
+
}
|
|
6846
|
+
return { width, height, nY, nX, rightX, leftX, bottomY, topY };
|
|
6847
|
+
}
|
|
6848
|
+
function prepareRotation(contourPoints, dielineW, dielineH, deg) {
|
|
6849
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
6850
|
+
return {
|
|
6851
|
+
profile: buildProfile(rotated),
|
|
6852
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
6853
|
+
deg
|
|
6854
|
+
};
|
|
6855
|
+
}
|
|
6856
|
+
function findMinStepX(a, b, dyMm) {
|
|
6857
|
+
const dySamples = Math.round(dyMm / SAMPLE_STEP);
|
|
6858
|
+
let maxOverlap = -Infinity;
|
|
6859
|
+
for (let ia = 0; ia < a.nY; ia++) {
|
|
6860
|
+
const ib = ia - dySamples;
|
|
6861
|
+
if (ib < 0 || ib >= b.nY) continue;
|
|
6862
|
+
if (a.rightX[ia] === -Infinity || b.leftX[ib] === Infinity) continue;
|
|
6863
|
+
const overlap = a.rightX[ia] - b.leftX[ib];
|
|
6864
|
+
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
6865
|
+
}
|
|
6866
|
+
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
6867
|
+
}
|
|
6868
|
+
function findMinStepY(a, b, dxMm) {
|
|
6869
|
+
const dxSamples = Math.round(dxMm / SAMPLE_STEP);
|
|
6870
|
+
let maxOverlap = -Infinity;
|
|
6871
|
+
for (let ia = 0; ia < a.nX; ia++) {
|
|
6872
|
+
const ib = ia - dxSamples;
|
|
6873
|
+
if (ib < 0 || ib >= b.nX) continue;
|
|
6874
|
+
if (a.bottomY[ia] === -Infinity || b.topY[ib] === Infinity) continue;
|
|
6875
|
+
const overlap = a.bottomY[ia] - b.topY[ib];
|
|
6876
|
+
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
6877
|
+
}
|
|
6878
|
+
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
6879
|
+
}
|
|
6880
|
+
function findMinStepY_multi(profA, stepX_A, profB, offsetX) {
|
|
6881
|
+
const reach = Math.max(profA.width, profB.width);
|
|
6882
|
+
let maxStep = 0;
|
|
6883
|
+
const nMin = Math.floor((offsetX - reach) / stepX_A);
|
|
6884
|
+
const nMax = Math.ceil((offsetX + reach) / stepX_A);
|
|
6885
|
+
for (let n = nMin; n <= nMax; n++) {
|
|
6886
|
+
const s = findMinStepY(profA, profB, offsetX - n * stepX_A);
|
|
6887
|
+
if (s > maxStep) maxStep = s;
|
|
6888
|
+
}
|
|
6889
|
+
return maxStep;
|
|
6890
|
+
}
|
|
6891
|
+
function emptyResult() {
|
|
6892
|
+
return { placements: [], count: 0, minX: 0, minY: 0, maxX: 0, maxY: 0 };
|
|
6893
|
+
}
|
|
6894
|
+
function singleRotGrid(rd, bounds) {
|
|
6895
|
+
const p = rd.profile;
|
|
6896
|
+
const stepX = findMinStepX(p, p, 0);
|
|
6897
|
+
const stepY = findMinStepY(p, p, 0);
|
|
6898
|
+
if (stepX <= 0 || stepY <= 0) return emptyResult();
|
|
6899
|
+
const cols = Math.max(0, Math.floor((bounds.right - bounds.left - p.width) / stepX) + 1);
|
|
6900
|
+
const rows = Math.max(0, Math.floor((bounds.bottom - bounds.top - p.height) / stepY) + 1);
|
|
6901
|
+
if (cols === 0 || rows === 0) return emptyResult();
|
|
6902
|
+
const placements = [];
|
|
6903
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
6904
|
+
for (let r = 0; r < rows; r++) {
|
|
6905
|
+
for (let c = 0; c < cols; c++) {
|
|
6906
|
+
const ox = bounds.left + c * stepX;
|
|
6907
|
+
const oy = bounds.top + r * stepY;
|
|
6908
|
+
placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
|
|
6909
|
+
if (ox < minX) minX = ox;
|
|
6910
|
+
if (oy < minY) minY = oy;
|
|
6911
|
+
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
6912
|
+
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
6913
|
+
}
|
|
6914
|
+
}
|
|
6915
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
6916
|
+
}
|
|
6917
|
+
function dualRotGrid(rdA, rdB, offsetX, bounds) {
|
|
6918
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
6919
|
+
const stepX_A = findMinStepX(pA, pA, 0);
|
|
6920
|
+
const stepX_B = findMinStepX(pB, pB, 0);
|
|
6921
|
+
if (stepX_A <= 0 || stepX_B <= 0) return emptyResult();
|
|
6922
|
+
let stepY_AB = findMinStepY_multi(pA, stepX_A, pB, offsetX);
|
|
6923
|
+
let stepY_BA = findMinStepY_multi(pB, stepX_B, pA, -offsetX);
|
|
6924
|
+
if (stepY_AB + stepY_BA <= 0) return emptyResult();
|
|
6925
|
+
const minAA = findMinStepY_multi(pA, stepX_A, pA, 0);
|
|
6926
|
+
const minBB = findMinStepY_multi(pB, stepX_B, pB, 0);
|
|
6927
|
+
const cycle = stepY_AB + stepY_BA;
|
|
6928
|
+
const neededCycle = Math.max(cycle, minAA, minBB);
|
|
6929
|
+
if (neededCycle > cycle) {
|
|
6930
|
+
const scale = neededCycle / cycle;
|
|
6931
|
+
stepY_AB *= scale;
|
|
6932
|
+
stepY_BA *= scale;
|
|
6933
|
+
}
|
|
6934
|
+
const placements = [];
|
|
6935
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
6936
|
+
let oy = bounds.top;
|
|
6937
|
+
let isRowA = true;
|
|
6938
|
+
while (true) {
|
|
6939
|
+
const rd = isRowA ? rdA : rdB;
|
|
6940
|
+
const p = rd.profile;
|
|
6941
|
+
const stepX = isRowA ? stepX_A : stepX_B;
|
|
6942
|
+
if (oy + p.height > bounds.bottom) break;
|
|
6943
|
+
let sx = isRowA ? bounds.left : bounds.left + offsetX;
|
|
6944
|
+
if (sx < bounds.left) sx += stepX * Math.ceil((bounds.left - sx) / stepX);
|
|
6945
|
+
for (let ox = sx; ox + p.width <= bounds.right; ox += stepX) {
|
|
6946
|
+
placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
|
|
6947
|
+
if (ox < minX) minX = ox;
|
|
6948
|
+
if (oy < minY) minY = oy;
|
|
6949
|
+
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
6950
|
+
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
6951
|
+
}
|
|
6952
|
+
oy += isRowA ? stepY_AB : stepY_BA;
|
|
6953
|
+
isRowA = !isRowA;
|
|
6954
|
+
}
|
|
6955
|
+
if (placements.length === 0) return emptyResult();
|
|
6956
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
6957
|
+
}
|
|
6958
|
+
function centerLayout(result, bounds) {
|
|
6959
|
+
if (result.count === 0) return;
|
|
6960
|
+
const offX = (bounds.right - bounds.left - (result.maxX - result.minX)) / 2 - (result.minX - bounds.left);
|
|
6961
|
+
const offY = (bounds.bottom - bounds.top - (result.maxY - result.minY)) / 2 - (result.minY - bounds.top);
|
|
6962
|
+
for (const p of result.placements) {
|
|
6963
|
+
p.x += offX;
|
|
6964
|
+
p.y += offY;
|
|
6965
|
+
}
|
|
6966
|
+
}
|
|
6967
|
+
function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
6968
|
+
const rots = [0, 90, 180, 270];
|
|
6969
|
+
const rd = /* @__PURE__ */ new Map();
|
|
6970
|
+
for (const deg of rots) {
|
|
6971
|
+
rd.set(deg, prepareRotation(contourPoints, dielineW, dielineH, deg));
|
|
6972
|
+
}
|
|
6973
|
+
const results = [];
|
|
6974
|
+
for (const deg of rots) {
|
|
6975
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
6976
|
+
}
|
|
6977
|
+
const pairs = [
|
|
6978
|
+
[0, 180],
|
|
6979
|
+
[90, 270],
|
|
6980
|
+
[0, 90],
|
|
6981
|
+
[0, 270],
|
|
6982
|
+
[90, 180],
|
|
6983
|
+
[180, 270]
|
|
6984
|
+
];
|
|
6985
|
+
for (const [a, b] of pairs) {
|
|
6986
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
6987
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
6988
|
+
if (stepA <= 0) continue;
|
|
6989
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
6990
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
6991
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
6992
|
+
}
|
|
6993
|
+
}
|
|
6994
|
+
let best = results[0];
|
|
6995
|
+
for (const r of results) {
|
|
6996
|
+
if (r.count > best.count) best = r;
|
|
5412
6997
|
}
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
6998
|
+
centerLayout(best, bounds);
|
|
6999
|
+
return {
|
|
7000
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
7001
|
+
placements: best.placements,
|
|
7002
|
+
producedPerSheet: best.count
|
|
7003
|
+
};
|
|
7004
|
+
}
|
|
7005
|
+
|
|
7006
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1030a/index.ts
|
|
7007
|
+
function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
|
|
7008
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
7009
|
+
return {
|
|
7010
|
+
profile: buildProfile(rotated),
|
|
7011
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
7012
|
+
deg
|
|
7013
|
+
};
|
|
7014
|
+
}
|
|
7015
|
+
function findPairRowStepY(pA, pB, gapAB, pairStepX) {
|
|
7016
|
+
const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
|
|
7017
|
+
const nMin = Math.floor(-reach / pairStepX) - 1;
|
|
7018
|
+
const nMax = Math.ceil(reach / pairStepX) + 1;
|
|
7019
|
+
let maxStep = 0;
|
|
7020
|
+
for (let n = nMin; n <= nMax; n++) {
|
|
7021
|
+
const dx = n * pairStepX;
|
|
7022
|
+
const s1 = findMinStepY(pA, pA, dx);
|
|
7023
|
+
if (s1 > maxStep) maxStep = s1;
|
|
7024
|
+
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
7025
|
+
if (s2 > maxStep) maxStep = s2;
|
|
7026
|
+
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
7027
|
+
if (s3 > maxStep) maxStep = s3;
|
|
7028
|
+
const s4 = findMinStepY(pB, pB, dx);
|
|
7029
|
+
if (s4 > maxStep) maxStep = s4;
|
|
5420
7030
|
}
|
|
5421
|
-
return
|
|
7031
|
+
return maxStep;
|
|
5422
7032
|
}
|
|
5423
|
-
function
|
|
5424
|
-
const
|
|
5425
|
-
const
|
|
5426
|
-
|
|
5427
|
-
const
|
|
5428
|
-
const
|
|
5429
|
-
const
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
7033
|
+
function pairGrid(rdA, rdB, bounds) {
|
|
7034
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
7035
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
7036
|
+
if (gapAB <= 0) return emptyResult();
|
|
7037
|
+
const pairW = gapAB + pB.width;
|
|
7038
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
7039
|
+
const pairStepX = Math.max(
|
|
7040
|
+
gapAB + findMinStepX(pB, pA, 0),
|
|
7041
|
+
findMinStepX(pA, pA, 0),
|
|
7042
|
+
findMinStepX(pB, pB, 0)
|
|
7043
|
+
);
|
|
7044
|
+
const pairStepY = findPairRowStepY(pA, pB, gapAB, pairStepX);
|
|
7045
|
+
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
7046
|
+
const usableW = bounds.right - bounds.left;
|
|
7047
|
+
const usableH = bounds.bottom - bounds.top;
|
|
7048
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
7049
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
7050
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
7051
|
+
const placements = [];
|
|
7052
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
7053
|
+
for (let r = 0; r < pairRows; r++) {
|
|
7054
|
+
for (let c = 0; c < pairCols; c++) {
|
|
7055
|
+
const baseX = bounds.left + c * pairStepX;
|
|
7056
|
+
const baseY = bounds.top + r * pairStepY;
|
|
7057
|
+
const oxA = baseX;
|
|
7058
|
+
const oyA = baseY;
|
|
7059
|
+
placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
7060
|
+
if (oxA < minX) minX = oxA;
|
|
7061
|
+
if (oyA < minY) minY = oyA;
|
|
7062
|
+
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
7063
|
+
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
7064
|
+
const oxB = baseX + gapAB;
|
|
7065
|
+
const oyB = baseY;
|
|
7066
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
7067
|
+
if (oxB < minX) minX = oxB;
|
|
7068
|
+
if (oyB < minY) minY = oyB;
|
|
7069
|
+
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
7070
|
+
if (oyB + pB.height > maxY) maxY = oyB + pB.height;
|
|
7071
|
+
}
|
|
7072
|
+
}
|
|
7073
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
7074
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
7075
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
7076
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
7077
|
+
const extraRotations = [rdA, rdB];
|
|
7078
|
+
for (const rdExtra of extraRotations) {
|
|
7079
|
+
const pe = rdExtra.profile;
|
|
7080
|
+
if (pe.width <= gapRight) {
|
|
7081
|
+
for (let r = 0; r < pairRows; r++) {
|
|
7082
|
+
const ox = pairsRightEdge;
|
|
7083
|
+
const oy = bounds.top + r * pairStepY;
|
|
7084
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
7085
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
7086
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
5451
7087
|
}
|
|
5452
7088
|
}
|
|
5453
|
-
|
|
5454
|
-
if (placements.length > bestCandidate.producedPerSheet) {
|
|
5455
|
-
bestCandidate = { rotation: deg, placements, producedPerSheet: placements.length };
|
|
5456
|
-
bestGridPositions = gridPositions;
|
|
5457
|
-
bestBitmapW = pieceBitmap.width;
|
|
5458
|
-
bestBitmapH = pieceBitmap.height;
|
|
7089
|
+
break;
|
|
5459
7090
|
}
|
|
5460
7091
|
}
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
const groupH = gridMaxY - gridMinY;
|
|
5474
|
-
const usableW = usableRight - usableLeft;
|
|
5475
|
-
const usableH = usableBottom - usableTop;
|
|
5476
|
-
const offsetX = ((usableW - groupW) / 2 - (gridMinX - usableLeft)) * RESOLUTION;
|
|
5477
|
-
const offsetY = ((usableH - groupH) / 2 - (gridMinY - usableTop)) * RESOLUTION;
|
|
5478
|
-
for (const p of bestCandidate.placements) {
|
|
5479
|
-
p.x += offsetX;
|
|
5480
|
-
p.y += offsetY;
|
|
7092
|
+
for (const rdExtra of extraRotations) {
|
|
7093
|
+
const pe = rdExtra.profile;
|
|
7094
|
+
if (pe.height <= gapBottom) {
|
|
7095
|
+
for (let c = 0; c < pairCols; c++) {
|
|
7096
|
+
const oxA = bounds.left + c * pairStepX;
|
|
7097
|
+
const oy = pairsBottomEdge;
|
|
7098
|
+
if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
7099
|
+
placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
7100
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
7101
|
+
}
|
|
7102
|
+
}
|
|
7103
|
+
break;
|
|
5481
7104
|
}
|
|
5482
7105
|
}
|
|
5483
|
-
return
|
|
7106
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5484
7107
|
}
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
for (const p of points) {
|
|
5491
|
-
if (p.x > maxX) maxX = p.x;
|
|
5492
|
-
if (p.y > maxY) maxY = p.y;
|
|
7108
|
+
function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
7109
|
+
const rots = [0, 90, 180, 270];
|
|
7110
|
+
const rd = /* @__PURE__ */ new Map();
|
|
7111
|
+
for (const deg of rots) {
|
|
7112
|
+
rd.set(deg, prepareRotation2(contourPoints, dielineW, dielineH, deg));
|
|
5493
7113
|
}
|
|
5494
|
-
const
|
|
5495
|
-
const
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
const
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
7114
|
+
const results = [];
|
|
7115
|
+
for (const deg of rots) {
|
|
7116
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
7117
|
+
}
|
|
7118
|
+
const allPairs = [
|
|
7119
|
+
[0, 180],
|
|
7120
|
+
[90, 270],
|
|
7121
|
+
[0, 90],
|
|
7122
|
+
[0, 270],
|
|
7123
|
+
[90, 180],
|
|
7124
|
+
[180, 270]
|
|
7125
|
+
];
|
|
7126
|
+
for (const [a, b] of allPairs) {
|
|
7127
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
7128
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
7129
|
+
if (stepA <= 0) continue;
|
|
7130
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
7131
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
7132
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
5512
7133
|
}
|
|
5513
7134
|
}
|
|
5514
|
-
for (
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
7135
|
+
for (const [a, b] of allPairs) {
|
|
7136
|
+
results.push(pairGrid(rd.get(a), rd.get(b), bounds));
|
|
7137
|
+
results.push(pairGrid(rd.get(b), rd.get(a), bounds));
|
|
7138
|
+
}
|
|
7139
|
+
const singleResults = [];
|
|
7140
|
+
const multiResults = [];
|
|
7141
|
+
for (const r of results) {
|
|
7142
|
+
if (r.count === 0) continue;
|
|
7143
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
7144
|
+
if (rotations.size > 1) {
|
|
7145
|
+
multiResults.push(r);
|
|
7146
|
+
} else {
|
|
7147
|
+
singleResults.push(r);
|
|
7148
|
+
}
|
|
7149
|
+
}
|
|
7150
|
+
function pickBest(arr) {
|
|
7151
|
+
let b = arr[0] ?? emptyResult();
|
|
7152
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
7153
|
+
for (const r of arr) {
|
|
7154
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
7155
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
7156
|
+
b = r;
|
|
7157
|
+
bArea = area;
|
|
5523
7158
|
}
|
|
5524
7159
|
}
|
|
7160
|
+
return b;
|
|
5525
7161
|
}
|
|
5526
|
-
|
|
7162
|
+
const bestSingle = pickBest(singleResults);
|
|
7163
|
+
const bestMulti = pickBest(multiResults);
|
|
7164
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
7165
|
+
centerLayout(best, bounds);
|
|
7166
|
+
return {
|
|
7167
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
7168
|
+
placements: best.placements,
|
|
7169
|
+
producedPerSheet: best.count
|
|
7170
|
+
};
|
|
5527
7171
|
}
|
|
5528
|
-
|
|
7172
|
+
|
|
7173
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1040a/index.ts
|
|
7174
|
+
function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
|
|
5529
7175
|
const rotated = normalizePoints(contourPoints, deg);
|
|
5530
7176
|
return {
|
|
5531
7177
|
profile: buildProfile(rotated),
|
|
@@ -5533,128 +7179,176 @@ function prepareRotation(contourPoints, dielineW, dielineH, deg) {
|
|
|
5533
7179
|
deg
|
|
5534
7180
|
};
|
|
5535
7181
|
}
|
|
5536
|
-
function
|
|
5537
|
-
const
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
const ib = ia - dySamples;
|
|
5541
|
-
if (ib < 0 || ib >= b.nY) continue;
|
|
5542
|
-
if (a.rightX[ia] === -Infinity || b.leftX[ib] === Infinity) continue;
|
|
5543
|
-
const overlap = a.rightX[ia] - b.leftX[ib];
|
|
5544
|
-
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
5545
|
-
}
|
|
5546
|
-
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
5547
|
-
}
|
|
5548
|
-
function findMinStepY(a, b, dxMm) {
|
|
5549
|
-
const dxSamples = Math.round(dxMm / SAMPLE_STEP);
|
|
5550
|
-
let maxOverlap = -Infinity;
|
|
5551
|
-
for (let ia = 0; ia < a.nX; ia++) {
|
|
5552
|
-
const ib = ia - dxSamples;
|
|
5553
|
-
if (ib < 0 || ib >= b.nX) continue;
|
|
5554
|
-
if (a.bottomY[ia] === -Infinity || b.topY[ib] === Infinity) continue;
|
|
5555
|
-
const overlap = a.bottomY[ia] - b.topY[ib];
|
|
5556
|
-
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
5557
|
-
}
|
|
5558
|
-
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
5559
|
-
}
|
|
5560
|
-
function findMinStepY_multi(profA, stepX_A, profB, offsetX) {
|
|
5561
|
-
const reach = Math.max(profA.width, profB.width);
|
|
7182
|
+
function findPairRowStepY2(pA, pB, gapAB, pairStepX) {
|
|
7183
|
+
const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
|
|
7184
|
+
const nMin = Math.floor(-reach / pairStepX) - 1;
|
|
7185
|
+
const nMax = Math.ceil(reach / pairStepX) + 1;
|
|
5562
7186
|
let maxStep = 0;
|
|
5563
|
-
const nMin = Math.floor((offsetX - reach) / stepX_A);
|
|
5564
|
-
const nMax = Math.ceil((offsetX + reach) / stepX_A);
|
|
5565
7187
|
for (let n = nMin; n <= nMax; n++) {
|
|
5566
|
-
const
|
|
5567
|
-
|
|
7188
|
+
const dx = n * pairStepX;
|
|
7189
|
+
const s1 = findMinStepY(pA, pA, dx);
|
|
7190
|
+
if (s1 > maxStep) maxStep = s1;
|
|
7191
|
+
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
7192
|
+
if (s2 > maxStep) maxStep = s2;
|
|
7193
|
+
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
7194
|
+
if (s3 > maxStep) maxStep = s3;
|
|
7195
|
+
const s4 = findMinStepY(pB, pB, dx);
|
|
7196
|
+
if (s4 > maxStep) maxStep = s4;
|
|
5568
7197
|
}
|
|
5569
7198
|
return maxStep;
|
|
5570
7199
|
}
|
|
5571
|
-
function
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
const
|
|
5576
|
-
const
|
|
5577
|
-
const
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
7200
|
+
function pairGrid2(rdA, rdB, bounds) {
|
|
7201
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
7202
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
7203
|
+
if (gapAB <= 0) return emptyResult();
|
|
7204
|
+
const pairW = gapAB + pB.width;
|
|
7205
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
7206
|
+
const pairStepX = Math.max(
|
|
7207
|
+
gapAB + findMinStepX(pB, pA, 0),
|
|
7208
|
+
findMinStepX(pA, pA, 0),
|
|
7209
|
+
findMinStepX(pB, pB, 0)
|
|
7210
|
+
);
|
|
7211
|
+
if (pairStepX <= 0) return emptyResult();
|
|
7212
|
+
const pairStepY = findPairRowStepY2(pA, pB, gapAB, pairStepX);
|
|
7213
|
+
if (pairStepY <= 0) return emptyResult();
|
|
7214
|
+
const usableW = bounds.right - bounds.left;
|
|
7215
|
+
const usableH = bounds.bottom - bounds.top;
|
|
7216
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
7217
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
7218
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
5582
7219
|
const placements = [];
|
|
5583
7220
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
5584
|
-
for (let r = 0; r <
|
|
5585
|
-
for (let c = 0; c <
|
|
5586
|
-
const
|
|
5587
|
-
const
|
|
5588
|
-
placements.push({ x:
|
|
5589
|
-
if (
|
|
5590
|
-
if (
|
|
5591
|
-
if (
|
|
5592
|
-
if (
|
|
7221
|
+
for (let r = 0; r < pairRows; r++) {
|
|
7222
|
+
for (let c = 0; c < pairCols; c++) {
|
|
7223
|
+
const baseX = bounds.left + c * pairStepX;
|
|
7224
|
+
const baseY = bounds.top + r * pairStepY;
|
|
7225
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
7226
|
+
if (baseX < minX) minX = baseX;
|
|
7227
|
+
if (baseY < minY) minY = baseY;
|
|
7228
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
7229
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
7230
|
+
const bx = baseX + gapAB;
|
|
7231
|
+
placements.push({ x: bx + rdB.bbOffset.dx, y: baseY + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
7232
|
+
if (bx < minX) minX = bx;
|
|
7233
|
+
if (bx + pB.width > maxX) maxX = bx + pB.width;
|
|
7234
|
+
if (baseY + pB.height > maxY) maxY = baseY + pB.height;
|
|
7235
|
+
}
|
|
7236
|
+
}
|
|
7237
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
7238
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
7239
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
7240
|
+
const pe = rdExtra.profile;
|
|
7241
|
+
if (pe.width > gapRight) continue;
|
|
7242
|
+
const dxFromB = pairsRightEdge - (bounds.left + (pairCols - 1) * pairStepX + gapAB);
|
|
7243
|
+
const dxFromA = pairsRightEdge - bounds.left - (pairCols - 1) * pairStepX;
|
|
7244
|
+
const extraStepY = Math.max(
|
|
7245
|
+
findMinStepY(pA, pe, dxFromA),
|
|
7246
|
+
findMinStepY(pB, pe, dxFromB),
|
|
7247
|
+
findMinStepY(pe, pe, 0)
|
|
7248
|
+
);
|
|
7249
|
+
if (extraStepY <= 0) continue;
|
|
7250
|
+
const effectiveStepY = Math.max(pairStepY, extraStepY);
|
|
7251
|
+
const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
|
|
7252
|
+
for (let r = 0; r < extraRows; r++) {
|
|
7253
|
+
const ox = pairsRightEdge;
|
|
7254
|
+
const oy = bounds.top + r * effectiveStepY;
|
|
7255
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
7256
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
7257
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
7258
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
7259
|
+
}
|
|
7260
|
+
}
|
|
7261
|
+
break;
|
|
7262
|
+
}
|
|
7263
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
7264
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
7265
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
7266
|
+
const pe = rdExtra.profile;
|
|
7267
|
+
if (pe.height > gapBottom) continue;
|
|
7268
|
+
const extraStepX = findMinStepX(pe, pe, 0);
|
|
7269
|
+
if (extraStepX <= 0) continue;
|
|
7270
|
+
const dyFromPairRow = pairsBottomEdge - (bounds.top + (pairRows - 1) * pairStepY);
|
|
7271
|
+
const stepFromA = findMinStepY(pA, pe, 0);
|
|
7272
|
+
const stepFromB = findMinStepY(pB, pe, gapAB);
|
|
7273
|
+
if (dyFromPairRow < stepFromA || dyFromPairRow < stepFromB) continue;
|
|
7274
|
+
const extraCols = Math.max(0, Math.floor((usableW - pe.width) / extraStepX) + 1);
|
|
7275
|
+
for (let c = 0; c < extraCols; c++) {
|
|
7276
|
+
const ox = bounds.left + c * extraStepX;
|
|
7277
|
+
const oy = pairsBottomEdge;
|
|
7278
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
7279
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
7280
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
7281
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
7282
|
+
}
|
|
5593
7283
|
}
|
|
7284
|
+
break;
|
|
5594
7285
|
}
|
|
5595
7286
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5596
7287
|
}
|
|
5597
|
-
function
|
|
7288
|
+
function verticalPairGrid(rdA, rdB, bounds) {
|
|
5598
7289
|
const pA = rdA.profile, pB = rdB.profile;
|
|
5599
|
-
const
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
const
|
|
5606
|
-
const
|
|
5607
|
-
const
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
7290
|
+
const gapAB_Y = findMinStepY(pA, pB, 0);
|
|
7291
|
+
if (gapAB_Y <= 0) return emptyResult();
|
|
7292
|
+
const vpairH = gapAB_Y + pB.height;
|
|
7293
|
+
const vpairW = Math.max(pA.width, pB.width);
|
|
7294
|
+
const stepXAA = findMinStepX(pA, pA, 0);
|
|
7295
|
+
const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
|
|
7296
|
+
const stepXBA = findMinStepX(pB, pA, gapAB_Y);
|
|
7297
|
+
const stepXBB = findMinStepX(pB, pB, 0);
|
|
7298
|
+
const vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
|
|
7299
|
+
if (vpairStepX <= 0) return emptyResult();
|
|
7300
|
+
let vpairStepY = 0;
|
|
7301
|
+
{
|
|
7302
|
+
const reach = Math.max(pA.width, pB.width);
|
|
7303
|
+
const nMin = Math.floor(-reach / vpairStepX) - 1;
|
|
7304
|
+
const nMax = Math.ceil(reach / vpairStepX) + 1;
|
|
7305
|
+
for (let n = nMin; n <= nMax; n++) {
|
|
7306
|
+
const dx = n * vpairStepX;
|
|
7307
|
+
const sAA = findMinStepY(pA, pA, dx);
|
|
7308
|
+
if (sAA > vpairStepY) vpairStepY = sAA;
|
|
7309
|
+
const sAB = findMinStepY(pA, pB, dx) - gapAB_Y;
|
|
7310
|
+
if (sAB > vpairStepY) vpairStepY = sAB;
|
|
7311
|
+
const sBA = findMinStepY(pB, pA, dx) + gapAB_Y;
|
|
7312
|
+
if (sBA > vpairStepY) vpairStepY = sBA;
|
|
7313
|
+
const sBB = findMinStepY(pB, pB, dx);
|
|
7314
|
+
if (sBB > vpairStepY) vpairStepY = sBB;
|
|
7315
|
+
}
|
|
5613
7316
|
}
|
|
7317
|
+
if (vpairStepY <= 0) return emptyResult();
|
|
7318
|
+
const usableW = bounds.right - bounds.left;
|
|
7319
|
+
const usableH = bounds.bottom - bounds.top;
|
|
7320
|
+
const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
|
|
7321
|
+
const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
|
|
7322
|
+
if (cols === 0 || rows === 0) return emptyResult();
|
|
5614
7323
|
const placements = [];
|
|
5615
7324
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
5616
|
-
let
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
placements.push({ x:
|
|
5627
|
-
if (
|
|
5628
|
-
|
|
5629
|
-
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
5630
|
-
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
5631
|
-
}
|
|
5632
|
-
oy += isRowA ? stepY_AB : stepY_BA;
|
|
5633
|
-
isRowA = !isRowA;
|
|
5634
|
-
}
|
|
5635
|
-
if (placements.length === 0) return emptyResult();
|
|
5636
|
-
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5637
|
-
}
|
|
5638
|
-
function centerLayout(result, bounds) {
|
|
5639
|
-
if (result.count === 0) return;
|
|
5640
|
-
const offX = (bounds.right - bounds.left - (result.maxX - result.minX)) / 2 - (result.minX - bounds.left);
|
|
5641
|
-
const offY = (bounds.bottom - bounds.top - (result.maxY - result.minY)) / 2 - (result.minY - bounds.top);
|
|
5642
|
-
for (const p of result.placements) {
|
|
5643
|
-
p.x += offX;
|
|
5644
|
-
p.y += offY;
|
|
7325
|
+
for (let r = 0; r < rows; r++) {
|
|
7326
|
+
for (let c = 0; c < cols; c++) {
|
|
7327
|
+
const baseX = bounds.left + c * vpairStepX;
|
|
7328
|
+
const baseY = bounds.top + r * vpairStepY;
|
|
7329
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
7330
|
+
if (baseX < minX) minX = baseX;
|
|
7331
|
+
if (baseY < minY) minY = baseY;
|
|
7332
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
7333
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
7334
|
+
const by = baseY + gapAB_Y;
|
|
7335
|
+
placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
7336
|
+
if (by + pB.height > maxY) maxY = by + pB.height;
|
|
7337
|
+
}
|
|
5645
7338
|
}
|
|
7339
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5646
7340
|
}
|
|
5647
|
-
function
|
|
7341
|
+
function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
5648
7342
|
const rots = [0, 90, 180, 270];
|
|
5649
7343
|
const rd = /* @__PURE__ */ new Map();
|
|
5650
7344
|
for (const deg of rots) {
|
|
5651
|
-
rd.set(deg,
|
|
7345
|
+
rd.set(deg, prepareRotation3(contourPoints, dielineW, dielineH, deg));
|
|
5652
7346
|
}
|
|
5653
7347
|
const results = [];
|
|
5654
7348
|
for (const deg of rots) {
|
|
5655
7349
|
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
5656
7350
|
}
|
|
5657
|
-
const
|
|
7351
|
+
const allPairs = [
|
|
5658
7352
|
[0, 180],
|
|
5659
7353
|
[90, 270],
|
|
5660
7354
|
[0, 90],
|
|
@@ -5662,7 +7356,7 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
5662
7356
|
[90, 180],
|
|
5663
7357
|
[180, 270]
|
|
5664
7358
|
];
|
|
5665
|
-
for (const [a, b] of
|
|
7359
|
+
for (const [a, b] of allPairs) {
|
|
5666
7360
|
const rdA = rd.get(a), rdB = rd.get(b);
|
|
5667
7361
|
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
5668
7362
|
if (stepA <= 0) continue;
|
|
@@ -5671,10 +7365,40 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
5671
7365
|
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
5672
7366
|
}
|
|
5673
7367
|
}
|
|
5674
|
-
|
|
7368
|
+
for (const [a, b] of allPairs) {
|
|
7369
|
+
results.push(pairGrid2(rd.get(a), rd.get(b), bounds));
|
|
7370
|
+
results.push(pairGrid2(rd.get(b), rd.get(a), bounds));
|
|
7371
|
+
}
|
|
7372
|
+
for (const [a, b] of allPairs) {
|
|
7373
|
+
results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
|
|
7374
|
+
results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
|
|
7375
|
+
}
|
|
7376
|
+
const singleResults = [];
|
|
7377
|
+
const multiResults = [];
|
|
5675
7378
|
for (const r of results) {
|
|
5676
|
-
if (r.count
|
|
7379
|
+
if (r.count === 0) continue;
|
|
7380
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
7381
|
+
if (rotations.size > 1) {
|
|
7382
|
+
multiResults.push(r);
|
|
7383
|
+
} else {
|
|
7384
|
+
singleResults.push(r);
|
|
7385
|
+
}
|
|
7386
|
+
}
|
|
7387
|
+
function pickBest(arr) {
|
|
7388
|
+
let b = arr[0] ?? emptyResult();
|
|
7389
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
7390
|
+
for (const r of arr) {
|
|
7391
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
7392
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
7393
|
+
b = r;
|
|
7394
|
+
bArea = area;
|
|
7395
|
+
}
|
|
7396
|
+
}
|
|
7397
|
+
return b;
|
|
5677
7398
|
}
|
|
7399
|
+
const bestSingle = pickBest(singleResults);
|
|
7400
|
+
const bestMulti = pickBest(multiResults);
|
|
7401
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
5678
7402
|
centerLayout(best, bounds);
|
|
5679
7403
|
return {
|
|
5680
7404
|
rotation: best.placements[0]?.rotation ?? 0,
|
|
@@ -5683,8 +7407,8 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
5683
7407
|
};
|
|
5684
7408
|
}
|
|
5685
7409
|
|
|
5686
|
-
// src/utils/autoLayout/calculate/
|
|
5687
|
-
function
|
|
7410
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-12101/index.ts
|
|
7411
|
+
function prepareRotation4(contourPoints, dielineW, dielineH, deg) {
|
|
5688
7412
|
const rotated = normalizePoints(contourPoints, deg);
|
|
5689
7413
|
return {
|
|
5690
7414
|
profile: buildProfile(rotated),
|
|
@@ -5692,36 +7416,19 @@ function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
|
|
|
5692
7416
|
deg
|
|
5693
7417
|
};
|
|
5694
7418
|
}
|
|
5695
|
-
function
|
|
5696
|
-
const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
|
|
5697
|
-
const nMin = Math.floor(-reach / pairStepX) - 1;
|
|
5698
|
-
const nMax = Math.ceil(reach / pairStepX) + 1;
|
|
5699
|
-
let maxStep = 0;
|
|
5700
|
-
for (let n = nMin; n <= nMax; n++) {
|
|
5701
|
-
const dx = n * pairStepX;
|
|
5702
|
-
const s1 = findMinStepY(pA, pA, dx);
|
|
5703
|
-
if (s1 > maxStep) maxStep = s1;
|
|
5704
|
-
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
5705
|
-
if (s2 > maxStep) maxStep = s2;
|
|
5706
|
-
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
5707
|
-
if (s3 > maxStep) maxStep = s3;
|
|
5708
|
-
const s4 = findMinStepY(pB, pB, dx);
|
|
5709
|
-
if (s4 > maxStep) maxStep = s4;
|
|
5710
|
-
}
|
|
5711
|
-
return maxStep;
|
|
5712
|
-
}
|
|
5713
|
-
function pairGrid(rdA, rdB, bounds) {
|
|
7419
|
+
function pairGrid3(rdA, rdB, bounds) {
|
|
5714
7420
|
const pA = rdA.profile, pB = rdB.profile;
|
|
5715
7421
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
5716
7422
|
if (gapAB <= 0) return emptyResult();
|
|
5717
7423
|
const pairW = gapAB + pB.width;
|
|
5718
7424
|
const pairH = Math.max(pA.height, pB.height);
|
|
5719
|
-
const pairStepX =
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
7425
|
+
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
7426
|
+
const pairStepY = Math.max(
|
|
7427
|
+
findMinStepY(pA, pA, 0),
|
|
7428
|
+
findMinStepY(pA, pB, gapAB),
|
|
7429
|
+
findMinStepY(pB, pA, -gapAB),
|
|
7430
|
+
findMinStepY(pB, pB, 0)
|
|
5723
7431
|
);
|
|
5724
|
-
const pairStepY = findPairRowStepY(pA, pB, gapAB, pairStepX);
|
|
5725
7432
|
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
5726
7433
|
const usableW = bounds.right - bounds.left;
|
|
5727
7434
|
const usableH = bounds.bottom - bounds.top;
|
|
@@ -5785,11 +7492,11 @@ function pairGrid(rdA, rdB, bounds) {
|
|
|
5785
7492
|
}
|
|
5786
7493
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5787
7494
|
}
|
|
5788
|
-
function
|
|
7495
|
+
function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
5789
7496
|
const rots = [0, 90, 180, 270];
|
|
5790
7497
|
const rd = /* @__PURE__ */ new Map();
|
|
5791
7498
|
for (const deg of rots) {
|
|
5792
|
-
rd.set(deg,
|
|
7499
|
+
rd.set(deg, prepareRotation4(contourPoints, dielineW, dielineH, deg));
|
|
5793
7500
|
}
|
|
5794
7501
|
const results = [];
|
|
5795
7502
|
for (const deg of rots) {
|
|
@@ -5813,8 +7520,8 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
5813
7520
|
}
|
|
5814
7521
|
}
|
|
5815
7522
|
for (const [a, b] of allPairs) {
|
|
5816
|
-
results.push(
|
|
5817
|
-
results.push(
|
|
7523
|
+
results.push(pairGrid3(rd.get(a), rd.get(b), bounds));
|
|
7524
|
+
results.push(pairGrid3(rd.get(b), rd.get(a), bounds));
|
|
5818
7525
|
}
|
|
5819
7526
|
const singleResults = [];
|
|
5820
7527
|
const multiResults = [];
|
|
@@ -5850,8 +7557,8 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
5850
7557
|
};
|
|
5851
7558
|
}
|
|
5852
7559
|
|
|
5853
|
-
// src/utils/autoLayout/calculate/
|
|
5854
|
-
function
|
|
7560
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-12109/index.ts
|
|
7561
|
+
function prepareRotation5(contourPoints, dielineW, dielineH, deg) {
|
|
5855
7562
|
const rotated = normalizePoints(contourPoints, deg);
|
|
5856
7563
|
return {
|
|
5857
7564
|
profile: buildProfile(rotated),
|
|
@@ -5859,38 +7566,20 @@ function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
|
|
|
5859
7566
|
deg
|
|
5860
7567
|
};
|
|
5861
7568
|
}
|
|
5862
|
-
function
|
|
5863
|
-
const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
|
|
5864
|
-
const nMin = Math.floor(-reach / pairStepX) - 1;
|
|
5865
|
-
const nMax = Math.ceil(reach / pairStepX) + 1;
|
|
5866
|
-
let maxStep = 0;
|
|
5867
|
-
for (let n = nMin; n <= nMax; n++) {
|
|
5868
|
-
const dx = n * pairStepX;
|
|
5869
|
-
const s1 = findMinStepY(pA, pA, dx);
|
|
5870
|
-
if (s1 > maxStep) maxStep = s1;
|
|
5871
|
-
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
5872
|
-
if (s2 > maxStep) maxStep = s2;
|
|
5873
|
-
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
5874
|
-
if (s3 > maxStep) maxStep = s3;
|
|
5875
|
-
const s4 = findMinStepY(pB, pB, dx);
|
|
5876
|
-
if (s4 > maxStep) maxStep = s4;
|
|
5877
|
-
}
|
|
5878
|
-
return maxStep;
|
|
5879
|
-
}
|
|
5880
|
-
function pairGrid2(rdA, rdB, bounds) {
|
|
7569
|
+
function pairGrid4(rdA, rdB, bounds) {
|
|
5881
7570
|
const pA = rdA.profile, pB = rdB.profile;
|
|
5882
7571
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
5883
7572
|
if (gapAB <= 0) return emptyResult();
|
|
5884
7573
|
const pairW = gapAB + pB.width;
|
|
5885
7574
|
const pairH = Math.max(pA.height, pB.height);
|
|
5886
|
-
const pairStepX =
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
7575
|
+
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
7576
|
+
const pairStepY = Math.max(
|
|
7577
|
+
findMinStepY(pA, pA, 0),
|
|
7578
|
+
findMinStepY(pA, pB, gapAB),
|
|
7579
|
+
findMinStepY(pB, pA, -gapAB),
|
|
7580
|
+
findMinStepY(pB, pB, 0)
|
|
5890
7581
|
);
|
|
5891
|
-
if (pairStepX <= 0) return emptyResult();
|
|
5892
|
-
const pairStepY = findPairRowStepY2(pA, pB, gapAB, pairStepX);
|
|
5893
|
-
if (pairStepY <= 0) return emptyResult();
|
|
7582
|
+
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
5894
7583
|
const usableW = bounds.right - bounds.left;
|
|
5895
7584
|
const usableH = bounds.bottom - bounds.top;
|
|
5896
7585
|
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
@@ -5902,127 +7591,62 @@ function pairGrid2(rdA, rdB, bounds) {
|
|
|
5902
7591
|
for (let c = 0; c < pairCols; c++) {
|
|
5903
7592
|
const baseX = bounds.left + c * pairStepX;
|
|
5904
7593
|
const baseY = bounds.top + r * pairStepY;
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
if (
|
|
5909
|
-
if (
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
7594
|
+
const oxA = baseX;
|
|
7595
|
+
const oyA = baseY;
|
|
7596
|
+
placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
7597
|
+
if (oxA < minX) minX = oxA;
|
|
7598
|
+
if (oyA < minY) minY = oyA;
|
|
7599
|
+
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
7600
|
+
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
7601
|
+
const oxB = baseX + gapAB;
|
|
7602
|
+
const oyB = baseY;
|
|
7603
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
7604
|
+
if (oxB < minX) minX = oxB;
|
|
7605
|
+
if (oyB < minY) minY = oyB;
|
|
7606
|
+
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
7607
|
+
if (oyB + pB.height > maxY) maxY = oyB + pB.height;
|
|
5915
7608
|
}
|
|
5916
7609
|
}
|
|
5917
7610
|
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
5918
|
-
const gapRight = bounds.right - pairsRightEdge;
|
|
5919
|
-
for (const rdExtra of [rdA, rdB]) {
|
|
5920
|
-
const pe = rdExtra.profile;
|
|
5921
|
-
if (pe.width > gapRight) continue;
|
|
5922
|
-
const dxFromB = pairsRightEdge - (bounds.left + (pairCols - 1) * pairStepX + gapAB);
|
|
5923
|
-
const dxFromA = pairsRightEdge - bounds.left - (pairCols - 1) * pairStepX;
|
|
5924
|
-
const extraStepY = Math.max(
|
|
5925
|
-
findMinStepY(pA, pe, dxFromA),
|
|
5926
|
-
findMinStepY(pB, pe, dxFromB),
|
|
5927
|
-
findMinStepY(pe, pe, 0)
|
|
5928
|
-
);
|
|
5929
|
-
if (extraStepY <= 0) continue;
|
|
5930
|
-
const effectiveStepY = Math.max(pairStepY, extraStepY);
|
|
5931
|
-
const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
|
|
5932
|
-
for (let r = 0; r < extraRows; r++) {
|
|
5933
|
-
const ox = pairsRightEdge;
|
|
5934
|
-
const oy = bounds.top + r * effectiveStepY;
|
|
5935
|
-
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
5936
|
-
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
5937
|
-
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
5938
|
-
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
5939
|
-
}
|
|
5940
|
-
}
|
|
5941
|
-
break;
|
|
5942
|
-
}
|
|
5943
7611
|
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
7612
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
5944
7613
|
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
5945
|
-
|
|
7614
|
+
const extraRotations = [rdA, rdB];
|
|
7615
|
+
for (const rdExtra of extraRotations) {
|
|
5946
7616
|
const pe = rdExtra.profile;
|
|
5947
|
-
if (pe.
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
if (gapAB_Y <= 0) return emptyResult();
|
|
5972
|
-
const vpairH = gapAB_Y + pB.height;
|
|
5973
|
-
const vpairW = Math.max(pA.width, pB.width);
|
|
5974
|
-
const stepXAA = findMinStepX(pA, pA, 0);
|
|
5975
|
-
const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
|
|
5976
|
-
const stepXBA = findMinStepX(pB, pA, gapAB_Y);
|
|
5977
|
-
const stepXBB = findMinStepX(pB, pB, 0);
|
|
5978
|
-
const vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
|
|
5979
|
-
if (vpairStepX <= 0) return emptyResult();
|
|
5980
|
-
let vpairStepY = 0;
|
|
5981
|
-
{
|
|
5982
|
-
const reach = Math.max(pA.width, pB.width);
|
|
5983
|
-
const nMin = Math.floor(-reach / vpairStepX) - 1;
|
|
5984
|
-
const nMax = Math.ceil(reach / vpairStepX) + 1;
|
|
5985
|
-
for (let n = nMin; n <= nMax; n++) {
|
|
5986
|
-
const dx = n * vpairStepX;
|
|
5987
|
-
const sAA = findMinStepY(pA, pA, dx);
|
|
5988
|
-
if (sAA > vpairStepY) vpairStepY = sAA;
|
|
5989
|
-
const sAB = findMinStepY(pA, pB, dx) - gapAB_Y;
|
|
5990
|
-
if (sAB > vpairStepY) vpairStepY = sAB;
|
|
5991
|
-
const sBA = findMinStepY(pB, pA, dx) + gapAB_Y;
|
|
5992
|
-
if (sBA > vpairStepY) vpairStepY = sBA;
|
|
5993
|
-
const sBB = findMinStepY(pB, pB, dx);
|
|
5994
|
-
if (sBB > vpairStepY) vpairStepY = sBB;
|
|
5995
|
-
}
|
|
5996
|
-
}
|
|
5997
|
-
if (vpairStepY <= 0) return emptyResult();
|
|
5998
|
-
const usableW = bounds.right - bounds.left;
|
|
5999
|
-
const usableH = bounds.bottom - bounds.top;
|
|
6000
|
-
const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
|
|
6001
|
-
const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
|
|
6002
|
-
if (cols === 0 || rows === 0) return emptyResult();
|
|
6003
|
-
const placements = [];
|
|
6004
|
-
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
6005
|
-
for (let r = 0; r < rows; r++) {
|
|
6006
|
-
for (let c = 0; c < cols; c++) {
|
|
6007
|
-
const baseX = bounds.left + c * vpairStepX;
|
|
6008
|
-
const baseY = bounds.top + r * vpairStepY;
|
|
6009
|
-
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
6010
|
-
if (baseX < minX) minX = baseX;
|
|
6011
|
-
if (baseY < minY) minY = baseY;
|
|
6012
|
-
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
6013
|
-
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
6014
|
-
const by = baseY + gapAB_Y;
|
|
6015
|
-
placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
6016
|
-
if (by + pB.height > maxY) maxY = by + pB.height;
|
|
7617
|
+
if (pe.width <= gapRight) {
|
|
7618
|
+
for (let r = 0; r < pairRows; r++) {
|
|
7619
|
+
const ox = pairsRightEdge;
|
|
7620
|
+
const oy = bounds.top + r * pairStepY;
|
|
7621
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
7622
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
7623
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
7624
|
+
}
|
|
7625
|
+
}
|
|
7626
|
+
break;
|
|
7627
|
+
}
|
|
7628
|
+
}
|
|
7629
|
+
for (const rdExtra of extraRotations) {
|
|
7630
|
+
const pe = rdExtra.profile;
|
|
7631
|
+
if (pe.height <= gapBottom) {
|
|
7632
|
+
for (let c = 0; c < pairCols; c++) {
|
|
7633
|
+
const oxA = bounds.left + c * pairStepX;
|
|
7634
|
+
const oy = pairsBottomEdge;
|
|
7635
|
+
if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
7636
|
+
placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
7637
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
7638
|
+
}
|
|
7639
|
+
}
|
|
7640
|
+
break;
|
|
6017
7641
|
}
|
|
6018
7642
|
}
|
|
6019
7643
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
6020
7644
|
}
|
|
6021
|
-
function
|
|
7645
|
+
function computeLayoutForPaper5(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
6022
7646
|
const rots = [0, 90, 180, 270];
|
|
6023
7647
|
const rd = /* @__PURE__ */ new Map();
|
|
6024
7648
|
for (const deg of rots) {
|
|
6025
|
-
rd.set(deg,
|
|
7649
|
+
rd.set(deg, prepareRotation5(contourPoints, dielineW, dielineH, deg));
|
|
6026
7650
|
}
|
|
6027
7651
|
const results = [];
|
|
6028
7652
|
for (const deg of rots) {
|
|
@@ -6046,12 +7670,8 @@ function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
6046
7670
|
}
|
|
6047
7671
|
}
|
|
6048
7672
|
for (const [a, b] of allPairs) {
|
|
6049
|
-
results.push(
|
|
6050
|
-
results.push(
|
|
6051
|
-
}
|
|
6052
|
-
for (const [a, b] of allPairs) {
|
|
6053
|
-
results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
|
|
6054
|
-
results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
|
|
7673
|
+
results.push(pairGrid4(rd.get(a), rd.get(b), bounds));
|
|
7674
|
+
results.push(pairGrid4(rd.get(b), rd.get(a), bounds));
|
|
6055
7675
|
}
|
|
6056
7676
|
const singleResults = [];
|
|
6057
7677
|
const multiResults = [];
|
|
@@ -6087,8 +7707,8 @@ function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
6087
7707
|
};
|
|
6088
7708
|
}
|
|
6089
7709
|
|
|
6090
|
-
// src/utils/autoLayout/calculate/bags-pillows/becf-12101/index.ts
|
|
6091
|
-
function
|
|
7710
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-c-12101/index.ts
|
|
7711
|
+
function prepareRotation6(contourPoints, dielineW, dielineH, deg) {
|
|
6092
7712
|
const rotated = normalizePoints(contourPoints, deg);
|
|
6093
7713
|
return {
|
|
6094
7714
|
profile: buildProfile(rotated),
|
|
@@ -6096,7 +7716,7 @@ function prepareRotation4(contourPoints, dielineW, dielineH, deg) {
|
|
|
6096
7716
|
deg
|
|
6097
7717
|
};
|
|
6098
7718
|
}
|
|
6099
|
-
function
|
|
7719
|
+
function pairGrid5(rdA, rdB, bounds) {
|
|
6100
7720
|
const pA = rdA.profile, pB = rdB.profile;
|
|
6101
7721
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
6102
7722
|
if (gapAB <= 0) return emptyResult();
|
|
@@ -6172,11 +7792,11 @@ function pairGrid3(rdA, rdB, bounds) {
|
|
|
6172
7792
|
}
|
|
6173
7793
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
6174
7794
|
}
|
|
6175
|
-
function
|
|
7795
|
+
function computeLayoutForPaper6(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
6176
7796
|
const rots = [0, 90, 180, 270];
|
|
6177
7797
|
const rd = /* @__PURE__ */ new Map();
|
|
6178
7798
|
for (const deg of rots) {
|
|
6179
|
-
rd.set(deg,
|
|
7799
|
+
rd.set(deg, prepareRotation6(contourPoints, dielineW, dielineH, deg));
|
|
6180
7800
|
}
|
|
6181
7801
|
const results = [];
|
|
6182
7802
|
for (const deg of rots) {
|
|
@@ -6200,8 +7820,8 @@ function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
6200
7820
|
}
|
|
6201
7821
|
}
|
|
6202
7822
|
for (const [a, b] of allPairs) {
|
|
6203
|
-
results.push(
|
|
6204
|
-
results.push(
|
|
7823
|
+
results.push(pairGrid5(rd.get(a), rd.get(b), bounds));
|
|
7824
|
+
results.push(pairGrid5(rd.get(b), rd.get(a), bounds));
|
|
6205
7825
|
}
|
|
6206
7826
|
const singleResults = [];
|
|
6207
7827
|
const multiResults = [];
|
|
@@ -6237,8 +7857,8 @@ function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
6237
7857
|
};
|
|
6238
7858
|
}
|
|
6239
7859
|
|
|
6240
|
-
// src/utils/autoLayout/calculate/bags-pillows/becf-12109/index.ts
|
|
6241
|
-
function
|
|
7860
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-c-12109/index.ts
|
|
7861
|
+
function prepareRotation7(contourPoints, dielineW, dielineH, deg) {
|
|
6242
7862
|
const rotated = normalizePoints(contourPoints, deg);
|
|
6243
7863
|
return {
|
|
6244
7864
|
profile: buildProfile(rotated),
|
|
@@ -6246,7 +7866,7 @@ function prepareRotation5(contourPoints, dielineW, dielineH, deg) {
|
|
|
6246
7866
|
deg
|
|
6247
7867
|
};
|
|
6248
7868
|
}
|
|
6249
|
-
function
|
|
7869
|
+
function pairGrid6(rdA, rdB, bounds) {
|
|
6250
7870
|
const pA = rdA.profile, pB = rdB.profile;
|
|
6251
7871
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
6252
7872
|
if (gapAB <= 0) return emptyResult();
|
|
@@ -6322,11 +7942,11 @@ function pairGrid4(rdA, rdB, bounds) {
|
|
|
6322
7942
|
}
|
|
6323
7943
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
6324
7944
|
}
|
|
6325
|
-
function
|
|
7945
|
+
function computeLayoutForPaper7(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
6326
7946
|
const rots = [0, 90, 180, 270];
|
|
6327
7947
|
const rd = /* @__PURE__ */ new Map();
|
|
6328
7948
|
for (const deg of rots) {
|
|
6329
|
-
rd.set(deg,
|
|
7949
|
+
rd.set(deg, prepareRotation7(contourPoints, dielineW, dielineH, deg));
|
|
6330
7950
|
}
|
|
6331
7951
|
const results = [];
|
|
6332
7952
|
for (const deg of rots) {
|
|
@@ -6350,8 +7970,8 @@ function computeLayoutForPaper5(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
6350
7970
|
}
|
|
6351
7971
|
}
|
|
6352
7972
|
for (const [a, b] of allPairs) {
|
|
6353
|
-
results.push(
|
|
6354
|
-
results.push(
|
|
7973
|
+
results.push(pairGrid6(rd.get(a), rd.get(b), bounds));
|
|
7974
|
+
results.push(pairGrid6(rd.get(b), rd.get(a), bounds));
|
|
6355
7975
|
}
|
|
6356
7976
|
const singleResults = [];
|
|
6357
7977
|
const multiResults = [];
|
|
@@ -6387,8 +8007,8 @@ function computeLayoutForPaper5(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
6387
8007
|
};
|
|
6388
8008
|
}
|
|
6389
8009
|
|
|
6390
|
-
// src/utils/autoLayout/calculate/bags-pillows/becf-
|
|
6391
|
-
function
|
|
8010
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-b-12101/index.ts
|
|
8011
|
+
function prepareRotation8(contourPoints, dielineW, dielineH, deg) {
|
|
6392
8012
|
const rotated = normalizePoints(contourPoints, deg);
|
|
6393
8013
|
return {
|
|
6394
8014
|
profile: buildProfile(rotated),
|
|
@@ -6396,7 +8016,7 @@ function prepareRotation6(contourPoints, dielineW, dielineH, deg) {
|
|
|
6396
8016
|
deg
|
|
6397
8017
|
};
|
|
6398
8018
|
}
|
|
6399
|
-
function
|
|
8019
|
+
function pairGrid7(rdA, rdB, bounds) {
|
|
6400
8020
|
const pA = rdA.profile, pB = rdB.profile;
|
|
6401
8021
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
6402
8022
|
if (gapAB <= 0) return emptyResult();
|
|
@@ -6421,28 +8041,23 @@ function pairGrid5(rdA, rdB, bounds) {
|
|
|
6421
8041
|
for (let c = 0; c < pairCols; c++) {
|
|
6422
8042
|
const baseX = bounds.left + c * pairStepX;
|
|
6423
8043
|
const baseY = bounds.top + r * pairStepY;
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
if (
|
|
6428
|
-
if (
|
|
6429
|
-
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
6430
|
-
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
8044
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
8045
|
+
if (baseX < minX) minX = baseX;
|
|
8046
|
+
if (baseY < minY) minY = baseY;
|
|
8047
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
8048
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
6431
8049
|
const oxB = baseX + gapAB;
|
|
6432
|
-
|
|
6433
|
-
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
8050
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: baseY + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
6434
8051
|
if (oxB < minX) minX = oxB;
|
|
6435
|
-
if (oyB < minY) minY = oyB;
|
|
6436
8052
|
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
6437
|
-
if (
|
|
8053
|
+
if (baseY + pB.height > maxY) maxY = baseY + pB.height;
|
|
6438
8054
|
}
|
|
6439
8055
|
}
|
|
6440
8056
|
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
6441
8057
|
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
6442
8058
|
const gapRight = bounds.right - pairsRightEdge;
|
|
6443
8059
|
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
6444
|
-
const
|
|
6445
|
-
for (const rdExtra of extraRotations) {
|
|
8060
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
6446
8061
|
const pe = rdExtra.profile;
|
|
6447
8062
|
if (pe.width <= gapRight) {
|
|
6448
8063
|
for (let r = 0; r < pairRows; r++) {
|
|
@@ -6456,7 +8071,7 @@ function pairGrid5(rdA, rdB, bounds) {
|
|
|
6456
8071
|
break;
|
|
6457
8072
|
}
|
|
6458
8073
|
}
|
|
6459
|
-
for (const rdExtra of
|
|
8074
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
6460
8075
|
const pe = rdExtra.profile;
|
|
6461
8076
|
if (pe.height <= gapBottom) {
|
|
6462
8077
|
for (let c = 0; c < pairCols; c++) {
|
|
@@ -6472,24 +8087,13 @@ function pairGrid5(rdA, rdB, bounds) {
|
|
|
6472
8087
|
}
|
|
6473
8088
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
6474
8089
|
}
|
|
6475
|
-
function
|
|
8090
|
+
function computeLayoutForPaper8(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
6476
8091
|
const rots = [0, 90, 180, 270];
|
|
6477
8092
|
const rd = /* @__PURE__ */ new Map();
|
|
6478
|
-
for (const deg of rots)
|
|
6479
|
-
rd.set(deg, prepareRotation6(contourPoints, dielineW, dielineH, deg));
|
|
6480
|
-
}
|
|
8093
|
+
for (const deg of rots) rd.set(deg, prepareRotation8(contourPoints, dielineW, dielineH, deg));
|
|
6481
8094
|
const results = [];
|
|
6482
|
-
for (const deg of rots)
|
|
6483
|
-
|
|
6484
|
-
}
|
|
6485
|
-
const allPairs = [
|
|
6486
|
-
[0, 180],
|
|
6487
|
-
[90, 270],
|
|
6488
|
-
[0, 90],
|
|
6489
|
-
[0, 270],
|
|
6490
|
-
[90, 180],
|
|
6491
|
-
[180, 270]
|
|
6492
|
-
];
|
|
8095
|
+
for (const deg of rots) results.push(singleRotGrid(rd.get(deg), bounds));
|
|
8096
|
+
const allPairs = [[0, 180], [90, 270], [0, 90], [0, 270], [90, 180], [180, 270]];
|
|
6493
8097
|
for (const [a, b] of allPairs) {
|
|
6494
8098
|
const rdA = rd.get(a), rdB = rd.get(b);
|
|
6495
8099
|
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
@@ -6500,19 +8104,15 @@ function computeLayoutForPaper6(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
6500
8104
|
}
|
|
6501
8105
|
}
|
|
6502
8106
|
for (const [a, b] of allPairs) {
|
|
6503
|
-
results.push(
|
|
6504
|
-
results.push(
|
|
8107
|
+
results.push(pairGrid7(rd.get(a), rd.get(b), bounds));
|
|
8108
|
+
results.push(pairGrid7(rd.get(b), rd.get(a), bounds));
|
|
6505
8109
|
}
|
|
6506
8110
|
const singleResults = [];
|
|
6507
8111
|
const multiResults = [];
|
|
6508
8112
|
for (const r of results) {
|
|
6509
8113
|
if (r.count === 0) continue;
|
|
6510
8114
|
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
6511
|
-
|
|
6512
|
-
multiResults.push(r);
|
|
6513
|
-
} else {
|
|
6514
|
-
singleResults.push(r);
|
|
6515
|
-
}
|
|
8115
|
+
(rotations.size > 1 ? multiResults : singleResults).push(r);
|
|
6516
8116
|
}
|
|
6517
8117
|
function pickBest(arr) {
|
|
6518
8118
|
let b = arr[0] ?? emptyResult();
|
|
@@ -6530,15 +8130,11 @@ function computeLayoutForPaper6(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
6530
8130
|
const bestMulti = pickBest(multiResults);
|
|
6531
8131
|
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
6532
8132
|
centerLayout(best, bounds);
|
|
6533
|
-
return {
|
|
6534
|
-
rotation: best.placements[0]?.rotation ?? 0,
|
|
6535
|
-
placements: best.placements,
|
|
6536
|
-
producedPerSheet: best.count
|
|
6537
|
-
};
|
|
8133
|
+
return { rotation: best.placements[0]?.rotation ?? 0, placements: best.placements, producedPerSheet: best.count };
|
|
6538
8134
|
}
|
|
6539
8135
|
|
|
6540
|
-
// src/utils/autoLayout/calculate/bags-pillows/becf-
|
|
6541
|
-
function
|
|
8136
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-b-12109/index.ts
|
|
8137
|
+
function prepareRotation9(contourPoints, dielineW, dielineH, deg) {
|
|
6542
8138
|
const rotated = normalizePoints(contourPoints, deg);
|
|
6543
8139
|
return {
|
|
6544
8140
|
profile: buildProfile(rotated),
|
|
@@ -6546,7 +8142,7 @@ function prepareRotation7(contourPoints, dielineW, dielineH, deg) {
|
|
|
6546
8142
|
deg
|
|
6547
8143
|
};
|
|
6548
8144
|
}
|
|
6549
|
-
function
|
|
8145
|
+
function pairGrid8(rdA, rdB, bounds) {
|
|
6550
8146
|
const pA = rdA.profile, pB = rdB.profile;
|
|
6551
8147
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
6552
8148
|
if (gapAB <= 0) return emptyResult();
|
|
@@ -6571,28 +8167,23 @@ function pairGrid6(rdA, rdB, bounds) {
|
|
|
6571
8167
|
for (let c = 0; c < pairCols; c++) {
|
|
6572
8168
|
const baseX = bounds.left + c * pairStepX;
|
|
6573
8169
|
const baseY = bounds.top + r * pairStepY;
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
if (
|
|
6578
|
-
if (
|
|
6579
|
-
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
6580
|
-
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
8170
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
8171
|
+
if (baseX < minX) minX = baseX;
|
|
8172
|
+
if (baseY < minY) minY = baseY;
|
|
8173
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
8174
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
6581
8175
|
const oxB = baseX + gapAB;
|
|
6582
|
-
|
|
6583
|
-
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
8176
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: baseY + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
6584
8177
|
if (oxB < minX) minX = oxB;
|
|
6585
|
-
if (oyB < minY) minY = oyB;
|
|
6586
8178
|
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
6587
|
-
if (
|
|
8179
|
+
if (baseY + pB.height > maxY) maxY = baseY + pB.height;
|
|
6588
8180
|
}
|
|
6589
8181
|
}
|
|
6590
8182
|
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
6591
8183
|
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
6592
8184
|
const gapRight = bounds.right - pairsRightEdge;
|
|
6593
8185
|
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
6594
|
-
const
|
|
6595
|
-
for (const rdExtra of extraRotations) {
|
|
8186
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
6596
8187
|
const pe = rdExtra.profile;
|
|
6597
8188
|
if (pe.width <= gapRight) {
|
|
6598
8189
|
for (let r = 0; r < pairRows; r++) {
|
|
@@ -6606,7 +8197,7 @@ function pairGrid6(rdA, rdB, bounds) {
|
|
|
6606
8197
|
break;
|
|
6607
8198
|
}
|
|
6608
8199
|
}
|
|
6609
|
-
for (const rdExtra of
|
|
8200
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
6610
8201
|
const pe = rdExtra.profile;
|
|
6611
8202
|
if (pe.height <= gapBottom) {
|
|
6612
8203
|
for (let c = 0; c < pairCols; c++) {
|
|
@@ -6622,24 +8213,13 @@ function pairGrid6(rdA, rdB, bounds) {
|
|
|
6622
8213
|
}
|
|
6623
8214
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
6624
8215
|
}
|
|
6625
|
-
function
|
|
8216
|
+
function computeLayoutForPaper9(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
6626
8217
|
const rots = [0, 90, 180, 270];
|
|
6627
8218
|
const rd = /* @__PURE__ */ new Map();
|
|
6628
|
-
for (const deg of rots)
|
|
6629
|
-
rd.set(deg, prepareRotation7(contourPoints, dielineW, dielineH, deg));
|
|
6630
|
-
}
|
|
8219
|
+
for (const deg of rots) rd.set(deg, prepareRotation9(contourPoints, dielineW, dielineH, deg));
|
|
6631
8220
|
const results = [];
|
|
6632
|
-
for (const deg of rots)
|
|
6633
|
-
|
|
6634
|
-
}
|
|
6635
|
-
const allPairs = [
|
|
6636
|
-
[0, 180],
|
|
6637
|
-
[90, 270],
|
|
6638
|
-
[0, 90],
|
|
6639
|
-
[0, 270],
|
|
6640
|
-
[90, 180],
|
|
6641
|
-
[180, 270]
|
|
6642
|
-
];
|
|
8221
|
+
for (const deg of rots) results.push(singleRotGrid(rd.get(deg), bounds));
|
|
8222
|
+
const allPairs = [[0, 180], [90, 270], [0, 90], [0, 270], [90, 180], [180, 270]];
|
|
6643
8223
|
for (const [a, b] of allPairs) {
|
|
6644
8224
|
const rdA = rd.get(a), rdB = rd.get(b);
|
|
6645
8225
|
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
@@ -6650,19 +8230,15 @@ function computeLayoutForPaper7(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
6650
8230
|
}
|
|
6651
8231
|
}
|
|
6652
8232
|
for (const [a, b] of allPairs) {
|
|
6653
|
-
results.push(
|
|
6654
|
-
results.push(
|
|
8233
|
+
results.push(pairGrid8(rd.get(a), rd.get(b), bounds));
|
|
8234
|
+
results.push(pairGrid8(rd.get(b), rd.get(a), bounds));
|
|
6655
8235
|
}
|
|
6656
8236
|
const singleResults = [];
|
|
6657
8237
|
const multiResults = [];
|
|
6658
8238
|
for (const r of results) {
|
|
6659
8239
|
if (r.count === 0) continue;
|
|
6660
8240
|
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
6661
|
-
|
|
6662
|
-
multiResults.push(r);
|
|
6663
|
-
} else {
|
|
6664
|
-
singleResults.push(r);
|
|
6665
|
-
}
|
|
8241
|
+
(rotations.size > 1 ? multiResults : singleResults).push(r);
|
|
6666
8242
|
}
|
|
6667
8243
|
function pickBest(arr) {
|
|
6668
8244
|
let b = arr[0] ?? emptyResult();
|
|
@@ -6680,11 +8256,7 @@ function computeLayoutForPaper7(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
6680
8256
|
const bestMulti = pickBest(multiResults);
|
|
6681
8257
|
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
6682
8258
|
centerLayout(best, bounds);
|
|
6683
|
-
return {
|
|
6684
|
-
rotation: best.placements[0]?.rotation ?? 0,
|
|
6685
|
-
placements: best.placements,
|
|
6686
|
-
producedPerSheet: best.count
|
|
6687
|
-
};
|
|
8259
|
+
return { rotation: best.placements[0]?.rotation ?? 0, placements: best.placements, producedPerSheet: best.count };
|
|
6688
8260
|
}
|
|
6689
8261
|
|
|
6690
8262
|
// src/utils/autoLayout/calculate/index.ts
|
|
@@ -6746,6 +8318,22 @@ function resolveModelFunctions(modelId, attrs) {
|
|
|
6746
8318
|
offsetContour: offsetContour8
|
|
6747
8319
|
};
|
|
6748
8320
|
}
|
|
8321
|
+
case "BECF-B-12101": {
|
|
8322
|
+
const a = attrs;
|
|
8323
|
+
return {
|
|
8324
|
+
contour: generateOuterContour9(a),
|
|
8325
|
+
dieline: generateBecfB12101(a),
|
|
8326
|
+
offsetContour: offsetContour9
|
|
8327
|
+
};
|
|
8328
|
+
}
|
|
8329
|
+
case "BECF-B-12109": {
|
|
8330
|
+
const a = attrs;
|
|
8331
|
+
return {
|
|
8332
|
+
contour: generateOuterContour10(a),
|
|
8333
|
+
dieline: generateBecfB12109(a),
|
|
8334
|
+
offsetContour: offsetContour10
|
|
8335
|
+
};
|
|
8336
|
+
}
|
|
6749
8337
|
case "BECF-1010A":
|
|
6750
8338
|
default: {
|
|
6751
8339
|
const a = attrs;
|
|
@@ -6773,6 +8361,10 @@ function resolveLayoutCalculator(modelId) {
|
|
|
6773
8361
|
return computeLayoutForPaper6;
|
|
6774
8362
|
case "BECF-C-12109":
|
|
6775
8363
|
return computeLayoutForPaper7;
|
|
8364
|
+
case "BECF-B-12101":
|
|
8365
|
+
return computeLayoutForPaper8;
|
|
8366
|
+
case "BECF-B-12109":
|
|
8367
|
+
return computeLayoutForPaper9;
|
|
6776
8368
|
default:
|
|
6777
8369
|
return computeLayoutForPaperDefault;
|
|
6778
8370
|
}
|
|
@@ -6786,11 +8378,11 @@ function calculateAutoLayout(rawConfig) {
|
|
|
6786
8378
|
colorbarHeight: rawConfig.colorbarHeight ?? 5,
|
|
6787
8379
|
isShowColorbar: rawConfig.isShowColorbar ?? true
|
|
6788
8380
|
};
|
|
6789
|
-
const { contour, dieline, offsetContour:
|
|
8381
|
+
const { contour, dieline, offsetContour: offsetContour11 } = resolveModelFunctions(
|
|
6790
8382
|
config.model.modelId,
|
|
6791
8383
|
config.model.attributes
|
|
6792
8384
|
);
|
|
6793
|
-
const offsetContourPoints = config.layoutDistance > 0 ?
|
|
8385
|
+
const offsetContourPoints = config.layoutDistance > 0 ? offsetContour11(contour, config.layoutDistance / 2) : contour;
|
|
6794
8386
|
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
6795
8387
|
const computeLayout = resolveLayoutCalculator(config.model.modelId);
|
|
6796
8388
|
const paperResults = [];
|
|
@@ -7151,6 +8743,46 @@ function renderDieLine(modelId, attrs) {
|
|
|
7151
8743
|
renderAs: "group"
|
|
7152
8744
|
}
|
|
7153
8745
|
);
|
|
8746
|
+
case "BECF-12109":
|
|
8747
|
+
return /* @__PURE__ */ jsx(
|
|
8748
|
+
DIE_LINE_BECF_12109,
|
|
8749
|
+
{
|
|
8750
|
+
attributes: attrs,
|
|
8751
|
+
renderAs: "group"
|
|
8752
|
+
}
|
|
8753
|
+
);
|
|
8754
|
+
case "BECF-C-12101":
|
|
8755
|
+
return /* @__PURE__ */ jsx(
|
|
8756
|
+
DIE_LINE_BECF_C_12101,
|
|
8757
|
+
{
|
|
8758
|
+
attributes: attrs,
|
|
8759
|
+
renderAs: "group"
|
|
8760
|
+
}
|
|
8761
|
+
);
|
|
8762
|
+
case "BECF-C-12109":
|
|
8763
|
+
return /* @__PURE__ */ jsx(
|
|
8764
|
+
DIE_LINE_BECF_C_12109,
|
|
8765
|
+
{
|
|
8766
|
+
attributes: attrs,
|
|
8767
|
+
renderAs: "group"
|
|
8768
|
+
}
|
|
8769
|
+
);
|
|
8770
|
+
case "BECF-B-12101":
|
|
8771
|
+
return /* @__PURE__ */ jsx(
|
|
8772
|
+
DIE_LINE_BECF_B_12101,
|
|
8773
|
+
{
|
|
8774
|
+
attributes: attrs,
|
|
8775
|
+
renderAs: "group"
|
|
8776
|
+
}
|
|
8777
|
+
);
|
|
8778
|
+
case "BECF-B-12109":
|
|
8779
|
+
return /* @__PURE__ */ jsx(
|
|
8780
|
+
DIE_LINE_BECF_B_12109,
|
|
8781
|
+
{
|
|
8782
|
+
attributes: attrs,
|
|
8783
|
+
renderAs: "group"
|
|
8784
|
+
}
|
|
8785
|
+
);
|
|
7154
8786
|
case "BECF-1010A":
|
|
7155
8787
|
default:
|
|
7156
8788
|
return /* @__PURE__ */ jsx(
|
|
@@ -7763,6 +9395,28 @@ function resolveModel(modelId, attrs, layoutDistance) {
|
|
|
7763
9395
|
generateContour: (a) => generateOuterContour8(a)
|
|
7764
9396
|
};
|
|
7765
9397
|
}
|
|
9398
|
+
case "BECF-B-12101": {
|
|
9399
|
+
const typedAttrs = attrs;
|
|
9400
|
+
const contour = generateOuterContour9(typedAttrs);
|
|
9401
|
+
return {
|
|
9402
|
+
dieline: generateBecfB12101(typedAttrs),
|
|
9403
|
+
contourPath: contourToPath9(contour),
|
|
9404
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour9(contour, layoutDistance / 2) : contour,
|
|
9405
|
+
generate: (a) => generateBecfB12101(a),
|
|
9406
|
+
generateContour: (a) => generateOuterContour9(a)
|
|
9407
|
+
};
|
|
9408
|
+
}
|
|
9409
|
+
case "BECF-B-12109": {
|
|
9410
|
+
const typedAttrs = attrs;
|
|
9411
|
+
const contour = generateOuterContour10(typedAttrs);
|
|
9412
|
+
return {
|
|
9413
|
+
dieline: generateBecfB12109(typedAttrs),
|
|
9414
|
+
contourPath: contourToPath10(contour),
|
|
9415
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour10(contour, layoutDistance / 2) : contour,
|
|
9416
|
+
generate: (a) => generateBecfB12109(a),
|
|
9417
|
+
generateContour: (a) => generateOuterContour10(a)
|
|
9418
|
+
};
|
|
9419
|
+
}
|
|
7766
9420
|
case "BECF-1010A":
|
|
7767
9421
|
default: {
|
|
7768
9422
|
const typedAttrs = attrs;
|
|
@@ -7836,6 +9490,22 @@ function renderDieLine2(modelId, attrs) {
|
|
|
7836
9490
|
renderAs: "group"
|
|
7837
9491
|
}
|
|
7838
9492
|
);
|
|
9493
|
+
case "BECF-B-12101":
|
|
9494
|
+
return /* @__PURE__ */ jsx(
|
|
9495
|
+
DIE_LINE_BECF_B_12101,
|
|
9496
|
+
{
|
|
9497
|
+
attributes: attrs,
|
|
9498
|
+
renderAs: "group"
|
|
9499
|
+
}
|
|
9500
|
+
);
|
|
9501
|
+
case "BECF-B-12109":
|
|
9502
|
+
return /* @__PURE__ */ jsx(
|
|
9503
|
+
DIE_LINE_BECF_B_12109,
|
|
9504
|
+
{
|
|
9505
|
+
attributes: attrs,
|
|
9506
|
+
renderAs: "group"
|
|
9507
|
+
}
|
|
9508
|
+
);
|
|
7839
9509
|
case "BECF-1010A":
|
|
7840
9510
|
default:
|
|
7841
9511
|
return /* @__PURE__ */ jsx(
|
|
@@ -7849,7 +9519,7 @@ function renderDieLine2(modelId, attrs) {
|
|
|
7849
9519
|
})();
|
|
7850
9520
|
}
|
|
7851
9521
|
var PAPER_GAP = 20;
|
|
7852
|
-
var
|
|
9522
|
+
var PX_PER_MM12 = 96 / 25.4;
|
|
7853
9523
|
var RESULT_PANEL_HEIGHT = 55;
|
|
7854
9524
|
var RESULT_GAP = 5;
|
|
7855
9525
|
function getOpposite2(side) {
|
|
@@ -8026,8 +9696,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
8026
9696
|
const svg = document.createElementNS(svgNs, "svg");
|
|
8027
9697
|
svg.setAttribute("xmlns", svgNs);
|
|
8028
9698
|
svg.setAttribute("viewBox", `0 0 ${vw} ${vh}`);
|
|
8029
|
-
svg.setAttribute("width", String(Math.round(vw *
|
|
8030
|
-
svg.setAttribute("height", String(Math.round(vh *
|
|
9699
|
+
svg.setAttribute("width", String(Math.round(vw * PX_PER_MM12)));
|
|
9700
|
+
svg.setAttribute("height", String(Math.round(vh * PX_PER_MM12)));
|
|
8031
9701
|
const bg = document.createElementNS(svgNs, "rect");
|
|
8032
9702
|
bg.setAttribute("width", String(vw));
|
|
8033
9703
|
bg.setAttribute("height", String(vh));
|
|
@@ -8060,8 +9730,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
8060
9730
|
img.src = url;
|
|
8061
9731
|
});
|
|
8062
9732
|
const canvas = document.createElement("canvas");
|
|
8063
|
-
canvas.width = Math.round(vw *
|
|
8064
|
-
canvas.height = Math.round(vh *
|
|
9733
|
+
canvas.width = Math.round(vw * PX_PER_MM12);
|
|
9734
|
+
canvas.height = Math.round(vh * PX_PER_MM12);
|
|
8065
9735
|
const ctx = canvas.getContext("2d");
|
|
8066
9736
|
ctx.fillStyle = "#ffffff";
|
|
8067
9737
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -8085,8 +9755,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
8085
9755
|
const svg = document.createElementNS(svgNs, "svg");
|
|
8086
9756
|
svg.setAttribute("xmlns", svgNs);
|
|
8087
9757
|
svg.setAttribute("viewBox", `0 0 ${paperResult.paperWidth} ${paperResult.paperHeight}`);
|
|
8088
|
-
svg.setAttribute("width", String(Math.round(paperResult.paperWidth *
|
|
8089
|
-
svg.setAttribute("height", String(Math.round(paperResult.paperHeight *
|
|
9758
|
+
svg.setAttribute("width", String(Math.round(paperResult.paperWidth * PX_PER_MM12)));
|
|
9759
|
+
svg.setAttribute("height", String(Math.round(paperResult.paperHeight * PX_PER_MM12)));
|
|
8090
9760
|
const bg = document.createElementNS(svgNs, "rect");
|
|
8091
9761
|
bg.setAttribute("width", String(paperResult.paperWidth));
|
|
8092
9762
|
bg.setAttribute("height", String(paperResult.paperHeight));
|
|
@@ -8190,8 +9860,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
8190
9860
|
img.src = url;
|
|
8191
9861
|
});
|
|
8192
9862
|
const canvas = document.createElement("canvas");
|
|
8193
|
-
canvas.width = Math.round(paperResult.paperWidth *
|
|
8194
|
-
canvas.height = Math.round(paperResult.paperHeight *
|
|
9863
|
+
canvas.width = Math.round(paperResult.paperWidth * PX_PER_MM12);
|
|
9864
|
+
canvas.height = Math.round(paperResult.paperHeight * PX_PER_MM12);
|
|
8195
9865
|
const ctx = canvas.getContext("2d");
|
|
8196
9866
|
ctx.fillStyle = theme.colorPaperFill;
|
|
8197
9867
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -8700,6 +10370,16 @@ var DIE_LINE_LAYOUT = forwardRef(
|
|
|
8700
10370
|
return /* @__PURE__ */ jsx(MODEL_BECF_12101, { ref, ...props });
|
|
8701
10371
|
case "BECF-12109":
|
|
8702
10372
|
return /* @__PURE__ */ jsx(MODEL_BECF_12109, { ref, ...props });
|
|
10373
|
+
case "BECF-C-12101":
|
|
10374
|
+
return /* @__PURE__ */ jsx(MODEL_BECF_C_12101, { ref, ...props });
|
|
10375
|
+
case "BECF-C-12109":
|
|
10376
|
+
return /* @__PURE__ */ jsx(MODEL_BECF_C_12109, { ref, ...props });
|
|
10377
|
+
case "BECF-B-12101":
|
|
10378
|
+
return /* @__PURE__ */ jsx(MODEL_BECF_B_12101, { ref, ...props });
|
|
10379
|
+
case "BECF-B-12109":
|
|
10380
|
+
return /* @__PURE__ */ jsx(MODEL_BECF_B_12109, { ref, ...props });
|
|
10381
|
+
case "BECF-10A0A":
|
|
10382
|
+
return /* @__PURE__ */ jsx(MODEL_BECF_10A0A, { ref, ...props });
|
|
8703
10383
|
default:
|
|
8704
10384
|
return null;
|
|
8705
10385
|
}
|
|
@@ -8768,7 +10448,42 @@ var BECF_C_12109_DEFAULT_ATTRIBUTES = {
|
|
|
8768
10448
|
glueArea: 13
|
|
8769
10449
|
};
|
|
8770
10450
|
|
|
10451
|
+
// src/statics/bags-pillows/becf-b-12101/DEFAULT_ATTRIBUTES.ts
|
|
10452
|
+
var BECF_B_12101_DEFAULT_ATTRIBUTES = {
|
|
10453
|
+
length: 100,
|
|
10454
|
+
width: 50,
|
|
10455
|
+
height: 150,
|
|
10456
|
+
glueArea: 13
|
|
10457
|
+
};
|
|
10458
|
+
|
|
10459
|
+
// src/statics/bags-pillows/becf-b-12109/DEFAULT_ATTRIBUTES.ts
|
|
10460
|
+
var BECF_B_12109_DEFAULT_ATTRIBUTES = {
|
|
10461
|
+
length: 100,
|
|
10462
|
+
width: 50,
|
|
10463
|
+
height: 150,
|
|
10464
|
+
glueArea: 13
|
|
10465
|
+
};
|
|
10466
|
+
|
|
10467
|
+
// src/statics/snap-lock-boxes/becf-10a0a/DEFAULT_ATTRIBUTES.ts
|
|
10468
|
+
var BECF_10A0A_DEFAULT_ATTRIBUTES = {
|
|
10469
|
+
length: 150,
|
|
10470
|
+
width: 50,
|
|
10471
|
+
height: 150
|
|
10472
|
+
};
|
|
10473
|
+
|
|
8771
10474
|
// src/statics/modelList.ts
|
|
10475
|
+
var MODEL_DEFAULT_ATTRIBUTES = {
|
|
10476
|
+
"BECF-1010A": { ...BECF_1010A_DEFAULT_ATTRIBUTES },
|
|
10477
|
+
"BECF-1040A": { ...BECF_1040A_DEFAULT_ATTRIBUTES },
|
|
10478
|
+
"BECF-1030A": { ...BECF_1030A_DEFAULT_ATTRIBUTES },
|
|
10479
|
+
"BECF-12101": { ...BECF_12101_DEFAULT_ATTRIBUTES },
|
|
10480
|
+
"BECF-12109": { ...BECF_12109_DEFAULT_ATTRIBUTES },
|
|
10481
|
+
"BECF-B-12101": { ...BECF_B_12101_DEFAULT_ATTRIBUTES },
|
|
10482
|
+
"BECF-B-12109": { ...BECF_B_12109_DEFAULT_ATTRIBUTES },
|
|
10483
|
+
"BECF-C-12101": { ...BECF_C_12101_DEFAULT_ATTRIBUTES },
|
|
10484
|
+
"BECF-C-12109": { ...BECF_C_12109_DEFAULT_ATTRIBUTES },
|
|
10485
|
+
"BECF-10A0A": { ...BECF_10A0A_DEFAULT_ATTRIBUTES }
|
|
10486
|
+
};
|
|
8772
10487
|
var modelList = [
|
|
8773
10488
|
{
|
|
8774
10489
|
id: "BECF-1010A",
|
|
@@ -8812,6 +10527,20 @@ var modelList = [
|
|
|
8812
10527
|
dimension: ["DIE_LINE"],
|
|
8813
10528
|
attributes: { ...BECF_12109_DEFAULT_ATTRIBUTES }
|
|
8814
10529
|
},
|
|
10530
|
+
{
|
|
10531
|
+
id: "BECF-B-12101",
|
|
10532
|
+
nameEN: "SHOPPING BAGS TYPE B",
|
|
10533
|
+
nameTH: "\u0E16\u0E38\u0E07\u0E2B\u0E39\u0E40\u0E01\u0E25\u0E35\u0E22\u0E27\u0E01\u0E23\u0E30\u0E14\u0E32\u0E29 B",
|
|
10534
|
+
dimension: ["DIE_LINE"],
|
|
10535
|
+
attributes: { ...BECF_B_12101_DEFAULT_ATTRIBUTES }
|
|
10536
|
+
},
|
|
10537
|
+
{
|
|
10538
|
+
id: "BECF-B-12109",
|
|
10539
|
+
nameEN: "SHOPPING BAGS TYPE B1",
|
|
10540
|
+
nameTH: "\u0E16\u0E38\u0E07\u0E2B\u0E39\u0E40\u0E01\u0E25\u0E35\u0E22\u0E27\u0E01\u0E23\u0E30\u0E14\u0E32\u0E29 B1",
|
|
10541
|
+
dimension: ["DIE_LINE"],
|
|
10542
|
+
attributes: { ...BECF_B_12109_DEFAULT_ATTRIBUTES }
|
|
10543
|
+
},
|
|
8815
10544
|
{
|
|
8816
10545
|
id: "BECF-C-12101",
|
|
8817
10546
|
nameEN: "SHOPPING BAGS TYPE C",
|
|
@@ -8825,6 +10554,13 @@ var modelList = [
|
|
|
8825
10554
|
nameTH: "\u0E16\u0E38\u0E07\u0E2B\u0E39\u0E23\u0E34\u0E1A\u0E1A\u0E34\u0E49\u0E19 C1",
|
|
8826
10555
|
dimension: ["DIE_LINE"],
|
|
8827
10556
|
attributes: { ...BECF_C_12109_DEFAULT_ATTRIBUTES }
|
|
10557
|
+
},
|
|
10558
|
+
{
|
|
10559
|
+
id: "BECF-10A0A",
|
|
10560
|
+
nameEN: "SNAP LOCK BOTTOM BOX",
|
|
10561
|
+
nameTH: "\u0E01\u0E25\u0E48\u0E2D\u0E07\u0E01\u0E49\u0E19\u0E25\u0E47\u0E2D\u0E04",
|
|
10562
|
+
dimension: ["DIE_LINE"],
|
|
10563
|
+
attributes: { ...BECF_10A0A_DEFAULT_ATTRIBUTES }
|
|
8828
10564
|
}
|
|
8829
10565
|
];
|
|
8830
10566
|
|
|
@@ -8837,6 +10573,6 @@ var BECF_11D01_DEFAULT_ATTRIBUTES = {
|
|
|
8837
10573
|
glueArea: 13
|
|
8838
10574
|
};
|
|
8839
10575
|
|
|
8840
|
-
export { AUTO_LAYOUT, AUTO_LAYOUT_THEME_CONFIG, BECF_1010A_DEFAULT_ATTRIBUTES, BECF_1030A_DEFAULT_ATTRIBUTES, BECF_1040A_DEFAULT_ATTRIBUTES, BECF_11D01_DEFAULT_ATTRIBUTES, BECF_12101_DEFAULT_ATTRIBUTES, BECF_12109_DEFAULT_ATTRIBUTES, BECF_C_12101_DEFAULT_ATTRIBUTES, BECF_C_12109_DEFAULT_ATTRIBUTES, Colorbar, DIE_LINE_LAYOUT, Gripper, MODEL_BECF_1010A, MODEL_BECF_1030A, MODEL_BECF_1040A, MODEL_BECF_11D01, MODEL_BECF_12101, MODEL_BECF_12109, MODEL_BECF_C_12101, MODEL_BECF_C_12109, MODEL_THEME_CONFIG, appendColorbarToSvg, appendGripperToSvg, calculateAutoLayout, configurePackaging, modelList };
|
|
10576
|
+
export { AUTO_LAYOUT, AUTO_LAYOUT_THEME_CONFIG, BECF_1010A_DEFAULT_ATTRIBUTES, BECF_1030A_DEFAULT_ATTRIBUTES, BECF_1040A_DEFAULT_ATTRIBUTES, BECF_10A0A_DEFAULT_ATTRIBUTES, BECF_11D01_DEFAULT_ATTRIBUTES, BECF_12101_DEFAULT_ATTRIBUTES, BECF_12109_DEFAULT_ATTRIBUTES, BECF_B_12101_DEFAULT_ATTRIBUTES, BECF_B_12109_DEFAULT_ATTRIBUTES, BECF_C_12101_DEFAULT_ATTRIBUTES, BECF_C_12109_DEFAULT_ATTRIBUTES, Colorbar, DIE_LINE_LAYOUT, Gripper, MODEL_BECF_1010A, MODEL_BECF_1030A, MODEL_BECF_1040A, MODEL_BECF_10A0A, MODEL_BECF_11D01, MODEL_BECF_12101, MODEL_BECF_12109, MODEL_BECF_B_12101, MODEL_BECF_B_12109, MODEL_BECF_C_12101, MODEL_BECF_C_12109, MODEL_DEFAULT_ATTRIBUTES, MODEL_THEME_CONFIG, appendColorbarToSvg, appendGripperToSvg, calculateAutoLayout, configurePackaging, modelList };
|
|
8841
10577
|
//# sourceMappingURL=index.mjs.map
|
|
8842
10578
|
//# sourceMappingURL=index.mjs.map
|