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