@lucablockltd/ultimate-packaging 1.2.0 → 1.3.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/index.d.mts +129 -25
- package/dist/index.d.ts +129 -25
- package/dist/index.js +2000 -468
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1997 -469
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3759,13 +3759,48 @@ function generateOuterContour6(attr) {
|
|
|
3759
3759
|
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3760
3760
|
const D = calcD2(C, B);
|
|
3761
3761
|
const kulak = glueArea ?? calcKulak2(B);
|
|
3762
|
-
const
|
|
3763
|
-
const
|
|
3762
|
+
const xFront = kulak;
|
|
3763
|
+
const xSide1 = kulak + A;
|
|
3764
|
+
const xBack = kulak + A + B;
|
|
3765
|
+
const xSide2 = kulak + 2 * A + B;
|
|
3766
|
+
const xEnd = kulak + 2 * A + 2 * B - 2;
|
|
3767
|
+
const yFoldBottom = D + C;
|
|
3768
|
+
const yNotchStart = yFoldBottom + NOTCH_Y;
|
|
3769
|
+
const yEnd = D + C + B / 2 + DIP2;
|
|
3764
3770
|
return [
|
|
3771
|
+
// Top edge
|
|
3765
3772
|
{ x: 0, y: 0 },
|
|
3766
|
-
{ x:
|
|
3767
|
-
|
|
3768
|
-
{ x:
|
|
3773
|
+
{ x: xEnd, y: 0 },
|
|
3774
|
+
// Right edge (stops at yFoldBottom)
|
|
3775
|
+
{ x: xEnd, y: yFoldBottom },
|
|
3776
|
+
// xEnd V-notch (left side only — last boundary)
|
|
3777
|
+
{ x: xEnd - NOTCH_X, y: yNotchStart },
|
|
3778
|
+
{ x: xEnd - NOTCH_X, y: yEnd },
|
|
3779
|
+
// Bottom segment → xSide2 notch
|
|
3780
|
+
{ x: xSide2 + NOTCH_X, y: yEnd },
|
|
3781
|
+
{ x: xSide2 + NOTCH_X, y: yNotchStart },
|
|
3782
|
+
{ x: xSide2, y: yFoldBottom },
|
|
3783
|
+
{ x: xSide2 - NOTCH_X, y: yNotchStart },
|
|
3784
|
+
{ x: xSide2 - NOTCH_X, y: yEnd },
|
|
3785
|
+
// Bottom segment → xBack notch
|
|
3786
|
+
{ x: xBack + NOTCH_X, y: yEnd },
|
|
3787
|
+
{ x: xBack + NOTCH_X, y: yNotchStart },
|
|
3788
|
+
{ x: xBack, y: yFoldBottom },
|
|
3789
|
+
{ x: xBack - NOTCH_X, y: yNotchStart },
|
|
3790
|
+
{ x: xBack - NOTCH_X, y: yEnd },
|
|
3791
|
+
// Bottom segment → xSide1 notch
|
|
3792
|
+
{ x: xSide1 + NOTCH_X, y: yEnd },
|
|
3793
|
+
{ x: xSide1 + NOTCH_X, y: yNotchStart },
|
|
3794
|
+
{ x: xSide1, y: yFoldBottom },
|
|
3795
|
+
{ x: xSide1 - NOTCH_X, y: yNotchStart },
|
|
3796
|
+
{ x: xSide1 - NOTCH_X, y: yEnd },
|
|
3797
|
+
// Bottom segment → xFront notch (right side only — first boundary)
|
|
3798
|
+
{ x: xFront + NOTCH_X, y: yEnd },
|
|
3799
|
+
{ x: xFront + NOTCH_X, y: yNotchStart },
|
|
3800
|
+
{ x: xFront, y: yFoldBottom },
|
|
3801
|
+
// Glue flap diagonal
|
|
3802
|
+
{ x: 0, y: yFoldBottom - kulak }
|
|
3803
|
+
// Left edge back to top
|
|
3769
3804
|
];
|
|
3770
3805
|
}
|
|
3771
3806
|
function offsetContour6(points, distance) {
|
|
@@ -4185,194 +4220,1257 @@ var MODEL_BECF_12109 = forwardRef(
|
|
|
4185
4220
|
}
|
|
4186
4221
|
);
|
|
4187
4222
|
|
|
4188
|
-
// src/
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
const worldY = (offsetY + gy) * resolution + resolution / 2;
|
|
4204
|
-
const crossings = [];
|
|
4205
|
-
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
|
|
4206
|
-
const yi = points[i].y, yj = points[j].y;
|
|
4207
|
-
if (yi <= worldY && yj > worldY || yj <= worldY && yi > worldY) {
|
|
4208
|
-
const t = (worldY - yi) / (yj - yi);
|
|
4209
|
-
crossings.push(points[i].x + t * (points[j].x - points[i].x));
|
|
4210
|
-
}
|
|
4211
|
-
}
|
|
4212
|
-
crossings.sort((a, b) => a - b);
|
|
4213
|
-
for (let c = 0; c < crossings.length - 1; c += 2) {
|
|
4214
|
-
const startGx = Math.max(0, Math.floor((crossings[c] - offsetX * resolution) / resolution));
|
|
4215
|
-
const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
|
|
4216
|
-
for (let gx = startGx; gx <= endGx; gx++) {
|
|
4217
|
-
data[gy * w + gx] = 1;
|
|
4218
|
-
}
|
|
4219
|
-
}
|
|
4220
|
-
}
|
|
4221
|
-
return { data, width: w, height: h, offsetX, offsetY };
|
|
4222
|
-
}
|
|
4223
|
-
function canPlace(paperGrid, paperW, paperH, piece, px, py) {
|
|
4224
|
-
for (let y = 0; y < piece.height; y++) {
|
|
4225
|
-
const paperY = py + y;
|
|
4226
|
-
if (paperY < 0 || paperY >= paperH) {
|
|
4227
|
-
for (let x = 0; x < piece.width; x++) {
|
|
4228
|
-
if (piece.data[y * piece.width + x]) return false;
|
|
4229
|
-
}
|
|
4230
|
-
continue;
|
|
4231
|
-
}
|
|
4232
|
-
for (let x = 0; x < piece.width; x++) {
|
|
4233
|
-
if (!piece.data[y * piece.width + x]) continue;
|
|
4234
|
-
const paperX = px + x;
|
|
4235
|
-
if (paperX < 0 || paperX >= paperW) return false;
|
|
4236
|
-
if (paperGrid[paperY * paperW + paperX]) return false;
|
|
4237
|
-
}
|
|
4238
|
-
}
|
|
4239
|
-
return true;
|
|
4223
|
+
// src/components/dieline/bags-pillows/becf-c-12101/generate.ts
|
|
4224
|
+
var DIP3 = 15;
|
|
4225
|
+
var RIBBON_HALF_W = 9;
|
|
4226
|
+
var RIBBON_DX = 2;
|
|
4227
|
+
var RIBBON_DY = 2;
|
|
4228
|
+
var D_MAX3 = 40;
|
|
4229
|
+
function calcD3(c, b) {
|
|
4230
|
+
return Math.min(c - 2 - b / 2, D_MAX3);
|
|
4231
|
+
}
|
|
4232
|
+
function calcKulak3(b) {
|
|
4233
|
+
if (b <= 13) return b - 1;
|
|
4234
|
+
if (b <= 99) return 13;
|
|
4235
|
+
if (b <= 249) return 20;
|
|
4236
|
+
if (b <= 499) return 25;
|
|
4237
|
+
return 30;
|
|
4240
4238
|
}
|
|
4241
|
-
function
|
|
4242
|
-
|
|
4243
|
-
for (let x = 0; x < piece.width; x++) {
|
|
4244
|
-
if (piece.data[y * piece.width + x]) {
|
|
4245
|
-
paperGrid[(py + y) * paperW + (px + x)] = 1;
|
|
4246
|
-
}
|
|
4247
|
-
}
|
|
4248
|
-
}
|
|
4239
|
+
function calcX3(a) {
|
|
4240
|
+
return Math.min(a / 2, 110);
|
|
4249
4241
|
}
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
return
|
|
4242
|
+
function getAutoCalcValues3(attr) {
|
|
4243
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
4244
|
+
const D = calcD3(C, B);
|
|
4245
|
+
const kulak = glueArea ?? calcKulak3(B);
|
|
4246
|
+
const X = calcX3(A);
|
|
4247
|
+
return { d: D, kulak, dip: DIP3, ribbonHW: RIBBON_HALF_W, ribbonDX: RIBBON_DX, ribbonDY: RIBBON_DY, ribbonX: X };
|
|
4256
4248
|
}
|
|
4257
|
-
function
|
|
4258
|
-
|
|
4259
|
-
case "bottom":
|
|
4260
|
-
return {
|
|
4261
|
-
top: colorbarDepth + spacing,
|
|
4262
|
-
bottom: paperHeight - griper,
|
|
4263
|
-
left: spacing,
|
|
4264
|
-
right: paperWidth - spacing
|
|
4265
|
-
};
|
|
4266
|
-
case "top":
|
|
4267
|
-
return {
|
|
4268
|
-
top: griper,
|
|
4269
|
-
bottom: paperHeight - colorbarDepth - spacing,
|
|
4270
|
-
left: spacing,
|
|
4271
|
-
right: paperWidth - spacing
|
|
4272
|
-
};
|
|
4273
|
-
case "left":
|
|
4274
|
-
return {
|
|
4275
|
-
top: spacing,
|
|
4276
|
-
bottom: paperHeight - spacing,
|
|
4277
|
-
left: griper,
|
|
4278
|
-
right: paperWidth - colorbarDepth - spacing
|
|
4279
|
-
};
|
|
4280
|
-
case "right":
|
|
4281
|
-
return {
|
|
4282
|
-
top: spacing,
|
|
4283
|
-
bottom: paperHeight - spacing,
|
|
4284
|
-
left: colorbarDepth + spacing,
|
|
4285
|
-
right: paperWidth - griper
|
|
4286
|
-
};
|
|
4287
|
-
}
|
|
4249
|
+
function line7(x1, y1, x2, y2) {
|
|
4250
|
+
return `M${x1} ${y1} L${x2} ${y2}`;
|
|
4288
4251
|
}
|
|
4289
|
-
function
|
|
4290
|
-
const
|
|
4291
|
-
const
|
|
4292
|
-
const
|
|
4293
|
-
const
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4252
|
+
function generateBecfC12101(attr) {
|
|
4253
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
4254
|
+
const D = calcD3(C, B);
|
|
4255
|
+
const kulak = glueArea ?? calcKulak3(B);
|
|
4256
|
+
const X = calcX3(A);
|
|
4257
|
+
const xFront = kulak;
|
|
4258
|
+
const xSide1 = kulak + A;
|
|
4259
|
+
const xSide1Mid = kulak + A + B / 2;
|
|
4260
|
+
const xBack = kulak + A + B;
|
|
4261
|
+
const xSide2 = kulak + 2 * A + B;
|
|
4262
|
+
const xSide2Mid = kulak + 2 * A + B + B / 2;
|
|
4263
|
+
const xEnd = kulak + 2 * A + 2 * B - 2;
|
|
4264
|
+
const yFoldTop = D;
|
|
4265
|
+
const yFoldBottomStart = D + C - B / 2;
|
|
4266
|
+
const yFoldBottom = D + C;
|
|
4267
|
+
const yBottomFlap = D + C + B / 2;
|
|
4268
|
+
const yEnd = D + C + B / 2 + DIP3;
|
|
4269
|
+
const totalWidth = xEnd;
|
|
4270
|
+
const totalHeight = yEnd;
|
|
4271
|
+
const cut = [];
|
|
4272
|
+
const crease = [];
|
|
4273
|
+
cut.push(line7(0, 0, totalWidth, 0));
|
|
4274
|
+
cut.push(line7(totalWidth, 0, totalWidth, totalHeight));
|
|
4275
|
+
cut.push(line7(totalWidth, totalHeight, 0, totalHeight));
|
|
4276
|
+
cut.push(line7(0, totalHeight, 0, 0));
|
|
4277
|
+
cut.push(line7(kulak + B / 2, yBottomFlap, kulak + B / 2, yEnd));
|
|
4278
|
+
cut.push(line7(kulak + A - B / 2, yBottomFlap, kulak + A - B / 2, yEnd));
|
|
4279
|
+
cut.push(line7(kulak + A + B + B / 2, yBottomFlap, kulak + A + B + B / 2, yEnd));
|
|
4280
|
+
cut.push(line7(kulak + 2 * A + B - B / 2, yBottomFlap, kulak + 2 * A + B - B / 2, yEnd));
|
|
4281
|
+
const frontCx = kulak + A / 2;
|
|
4282
|
+
const backCx = kulak + A + B + A / 2;
|
|
4283
|
+
const yNotchTop = yFoldTop - RIBBON_DY / 2;
|
|
4284
|
+
const yNotchBot = yFoldTop + RIBBON_DY / 2;
|
|
4285
|
+
function addRibbonNotch(cx) {
|
|
4286
|
+
cut.push(line7(cx - RIBBON_HALF_W, yNotchBot, cx + RIBBON_HALF_W, yNotchBot));
|
|
4287
|
+
cut.push(line7(cx - RIBBON_HALF_W - RIBBON_DX, yNotchTop, cx - RIBBON_HALF_W, yNotchBot));
|
|
4288
|
+
cut.push(line7(cx + RIBBON_HALF_W + RIBBON_DX, yNotchTop, cx + RIBBON_HALF_W, yNotchBot));
|
|
4289
|
+
}
|
|
4290
|
+
addRibbonNotch(frontCx - X / 2);
|
|
4291
|
+
addRibbonNotch(frontCx + X / 2);
|
|
4292
|
+
addRibbonNotch(backCx - X / 2);
|
|
4293
|
+
addRibbonNotch(backCx + X / 2);
|
|
4294
|
+
crease.push(line7(0, yFoldTop, totalWidth, yFoldTop));
|
|
4295
|
+
crease.push(line7(0, yFoldBottomStart, totalWidth, yFoldBottomStart));
|
|
4296
|
+
crease.push(line7(0, yFoldBottom, totalWidth, yFoldBottom));
|
|
4297
|
+
crease.push(line7(xFront, 0, xFront, totalHeight));
|
|
4298
|
+
crease.push(line7(xSide1, 0, xSide1, totalHeight));
|
|
4299
|
+
crease.push(line7(xSide1Mid, 0, xSide1Mid, totalHeight));
|
|
4300
|
+
crease.push(line7(xBack, 0, xBack, totalHeight));
|
|
4301
|
+
crease.push(line7(xSide2, 0, xSide2, totalHeight));
|
|
4302
|
+
crease.push(line7(xSide2Mid, 0, xSide2Mid, totalHeight));
|
|
4303
|
+
crease.push(line7(0, yFoldBottom - kulak, kulak + B / 2, yBottomFlap));
|
|
4304
|
+
crease.push(line7(kulak + A - B / 2, yBottomFlap, xSide1Mid, yFoldBottomStart));
|
|
4305
|
+
crease.push(line7(xSide1Mid, yFoldBottomStart, kulak + A + B + B / 2, yBottomFlap));
|
|
4306
|
+
crease.push(line7(kulak + 2 * A + B - B / 2, yBottomFlap, xSide2Mid, yFoldBottomStart));
|
|
4307
|
+
crease.push(line7(xSide2Mid, yFoldBottomStart, xEnd, D + C - 2));
|
|
4308
|
+
return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
|
|
4303
4309
|
}
|
|
4304
|
-
function
|
|
4305
|
-
const
|
|
4306
|
-
const
|
|
4307
|
-
const
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
let dlMinX = Infinity, dlMinY = Infinity;
|
|
4317
|
-
for (const [cx, cy] of corners) {
|
|
4318
|
-
const rx = cx * cos - cy * sin;
|
|
4319
|
-
const ry = cx * sin + cy * cos;
|
|
4320
|
-
if (rx < dlMinX) dlMinX = rx;
|
|
4321
|
-
if (ry < dlMinY) dlMinY = ry;
|
|
4322
|
-
}
|
|
4323
|
-
return { dx: dlMinX - ocMinX, dy: dlMinY - ocMinY };
|
|
4310
|
+
function generateOuterContour7(attr) {
|
|
4311
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
4312
|
+
const D = calcD3(C, B);
|
|
4313
|
+
const kulak = glueArea ?? calcKulak3(B);
|
|
4314
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
4315
|
+
const totalHeight = D + C + B / 2 + DIP3;
|
|
4316
|
+
return [
|
|
4317
|
+
{ x: 0, y: 0 },
|
|
4318
|
+
{ x: totalWidth, y: 0 },
|
|
4319
|
+
{ x: totalWidth, y: totalHeight },
|
|
4320
|
+
{ x: 0, y: totalHeight }
|
|
4321
|
+
];
|
|
4324
4322
|
}
|
|
4325
|
-
function
|
|
4326
|
-
const
|
|
4327
|
-
const
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
const
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
const placements = [];
|
|
4342
|
-
const gridPositions = [];
|
|
4343
|
-
for (let py = usableTop; py <= usableBottom - pieceBitmap.height; py++) {
|
|
4344
|
-
for (let px = usableLeft; px <= usableRight - pieceBitmap.width; px++) {
|
|
4345
|
-
if (canPlace(paperGrid, paperW, paperH, pieceBitmap, px, py)) {
|
|
4346
|
-
placePiece(paperGrid, paperW, pieceBitmap, px, py);
|
|
4347
|
-
gridPositions.push({ px, py });
|
|
4348
|
-
placements.push({
|
|
4349
|
-
x: px * RESOLUTION + bbOffset.dx,
|
|
4350
|
-
y: py * RESOLUTION + bbOffset.dy,
|
|
4351
|
-
rotation: deg
|
|
4352
|
-
});
|
|
4353
|
-
}
|
|
4354
|
-
}
|
|
4323
|
+
function offsetContour7(points, distance) {
|
|
4324
|
+
const n = points.length;
|
|
4325
|
+
const result = [];
|
|
4326
|
+
for (let i = 0; i < n; i++) {
|
|
4327
|
+
const prev = points[(i - 1 + n) % n];
|
|
4328
|
+
const curr = points[i];
|
|
4329
|
+
const next = points[(i + 1) % n];
|
|
4330
|
+
const e1x = curr.x - prev.x;
|
|
4331
|
+
const e1y = curr.y - prev.y;
|
|
4332
|
+
const e2x = next.x - curr.x;
|
|
4333
|
+
const e2y = next.y - curr.y;
|
|
4334
|
+
const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
|
|
4335
|
+
const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
|
|
4336
|
+
if (len1 === 0 || len2 === 0) {
|
|
4337
|
+
result.push(curr);
|
|
4338
|
+
continue;
|
|
4355
4339
|
}
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4340
|
+
const n1x = e1y / len1;
|
|
4341
|
+
const n1y = -e1x / len1;
|
|
4342
|
+
const n2x = e2y / len2;
|
|
4343
|
+
const n2y = -e2x / len2;
|
|
4344
|
+
const ax = n1x + n2x;
|
|
4345
|
+
const ay = n1y + n2y;
|
|
4346
|
+
const aLen = Math.sqrt(ax * ax + ay * ay);
|
|
4347
|
+
if (aLen < 1e-3) {
|
|
4348
|
+
result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
|
|
4349
|
+
continue;
|
|
4361
4350
|
}
|
|
4351
|
+
const nx = ax / aLen;
|
|
4352
|
+
const ny = ay / aLen;
|
|
4353
|
+
const dot = n1x * nx + n1y * ny;
|
|
4354
|
+
const d = distance / Math.max(dot, 0.1);
|
|
4355
|
+
result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
|
|
4362
4356
|
}
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4357
|
+
return result;
|
|
4358
|
+
}
|
|
4359
|
+
function contourToPath7(points) {
|
|
4360
|
+
if (points.length === 0) return "";
|
|
4361
|
+
let d = `M${points[0].x} ${points[0].y}`;
|
|
4362
|
+
for (let i = 1; i < points.length; i++) {
|
|
4363
|
+
d += ` L${points[i].x} ${points[i].y}`;
|
|
4364
|
+
}
|
|
4365
|
+
d += " Z";
|
|
4366
|
+
return d;
|
|
4367
|
+
}
|
|
4368
|
+
function generateDimensions7(attr, unit) {
|
|
4369
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
4370
|
+
const D = calcD3(C, B);
|
|
4371
|
+
const kulak = glueArea ?? calcKulak3(B);
|
|
4372
|
+
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
4373
|
+
const suffix = unit;
|
|
4374
|
+
const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
|
|
4375
|
+
const xFront = kulak;
|
|
4376
|
+
const xSide1 = kulak + A;
|
|
4377
|
+
const xBack = kulak + A + B;
|
|
4378
|
+
const yFoldTop = D;
|
|
4379
|
+
const yFoldBottom = D + C;
|
|
4380
|
+
const yEnd = D + C + B / 2 + DIP3;
|
|
4381
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
4382
|
+
const totalHeight = yEnd;
|
|
4383
|
+
const bottomSection = B / 2 + DIP3;
|
|
4384
|
+
return [
|
|
4385
|
+
{
|
|
4386
|
+
x1: 0,
|
|
4387
|
+
y1: 0,
|
|
4388
|
+
x2: totalWidth,
|
|
4389
|
+
y2: 0,
|
|
4390
|
+
label: `Overall Width : ${fmt(totalWidth)}`,
|
|
4391
|
+
orientation: "horizontal",
|
|
4392
|
+
offset: -12
|
|
4393
|
+
},
|
|
4394
|
+
{
|
|
4395
|
+
x1: 0,
|
|
4396
|
+
y1: 0,
|
|
4397
|
+
x2: 0,
|
|
4398
|
+
y2: totalHeight,
|
|
4399
|
+
label: `Overall Height : ${fmt(totalHeight)}`,
|
|
4400
|
+
orientation: "vertical",
|
|
4401
|
+
offset: -12
|
|
4402
|
+
},
|
|
4403
|
+
{
|
|
4404
|
+
x1: xBack + A * 0.6,
|
|
4405
|
+
y1: yFoldTop,
|
|
4406
|
+
x2: xBack + A * 0.6,
|
|
4407
|
+
y2: yFoldBottom,
|
|
4408
|
+
label: fmt(C),
|
|
4409
|
+
orientation: "vertical",
|
|
4410
|
+
offset: -10
|
|
4411
|
+
},
|
|
4412
|
+
{
|
|
4413
|
+
x1: xBack + A * 0.6,
|
|
4414
|
+
y1: 0,
|
|
4415
|
+
x2: xBack + A * 0.6,
|
|
4416
|
+
y2: yFoldTop,
|
|
4417
|
+
label: fmt(D),
|
|
4418
|
+
orientation: "vertical",
|
|
4419
|
+
offset: -10
|
|
4420
|
+
},
|
|
4421
|
+
{
|
|
4422
|
+
x1: xBack + A * 0.6,
|
|
4423
|
+
y1: yFoldBottom,
|
|
4424
|
+
x2: xBack + A * 0.6,
|
|
4425
|
+
y2: yEnd,
|
|
4426
|
+
label: fmt(bottomSection),
|
|
4427
|
+
orientation: "vertical",
|
|
4428
|
+
offset: -10
|
|
4429
|
+
},
|
|
4430
|
+
{
|
|
4431
|
+
x1: xFront,
|
|
4432
|
+
y1: yFoldTop + C * 0.65,
|
|
4433
|
+
x2: xSide1,
|
|
4434
|
+
y2: yFoldTop + C * 0.65,
|
|
4435
|
+
label: fmt(A),
|
|
4436
|
+
orientation: "horizontal",
|
|
4437
|
+
offset: -20
|
|
4438
|
+
},
|
|
4439
|
+
{
|
|
4440
|
+
x1: xSide1,
|
|
4441
|
+
y1: yFoldTop + C * 0.65,
|
|
4442
|
+
x2: xBack,
|
|
4443
|
+
y2: yFoldTop + C * 0.65,
|
|
4444
|
+
label: fmt(B),
|
|
4445
|
+
orientation: "horizontal",
|
|
4446
|
+
offset: -20
|
|
4447
|
+
},
|
|
4448
|
+
{
|
|
4449
|
+
x1: 0,
|
|
4450
|
+
y1: yFoldTop + C * 0.65,
|
|
4451
|
+
x2: xFront,
|
|
4452
|
+
y2: yFoldTop + C * 0.65,
|
|
4453
|
+
label: fmt(kulak),
|
|
4454
|
+
orientation: "horizontal",
|
|
4455
|
+
offset: -20
|
|
4456
|
+
}
|
|
4457
|
+
];
|
|
4458
|
+
}
|
|
4459
|
+
var MODEL_ID7 = "BECF-C-12101";
|
|
4460
|
+
var UNIT_FACTOR7 = {
|
|
4461
|
+
mm: 1,
|
|
4462
|
+
cm: 0.1,
|
|
4463
|
+
in: 1 / 25.4
|
|
4464
|
+
};
|
|
4465
|
+
var PX_PER_MM7 = 96 / 25.4;
|
|
4466
|
+
function renderDimension7(dim, i, fs) {
|
|
4467
|
+
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
4468
|
+
const tick = 1.5;
|
|
4469
|
+
if (orientation === "horizontal") {
|
|
4470
|
+
const y = y1 + offset;
|
|
4471
|
+
const midX = (x1 + x2) / 2;
|
|
4472
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
4473
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
|
|
4474
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
4475
|
+
/* @__PURE__ */ jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
4476
|
+
/* @__PURE__ */ jsx(
|
|
4477
|
+
"text",
|
|
4478
|
+
{
|
|
4479
|
+
x: midX,
|
|
4480
|
+
y: y - 1.5,
|
|
4481
|
+
textAnchor: "middle",
|
|
4482
|
+
fontSize: fs,
|
|
4483
|
+
fontFamily: "sans-serif",
|
|
4484
|
+
fill: "#000",
|
|
4485
|
+
children: label
|
|
4486
|
+
}
|
|
4487
|
+
)
|
|
4488
|
+
] }, `dim-${i}`);
|
|
4489
|
+
}
|
|
4490
|
+
const x = x1 + offset;
|
|
4491
|
+
const midY = (y1 + y2) / 2;
|
|
4492
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
4493
|
+
/* @__PURE__ */ jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
|
|
4494
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
|
|
4495
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
|
|
4496
|
+
/* @__PURE__ */ jsx(
|
|
4497
|
+
"text",
|
|
4498
|
+
{
|
|
4499
|
+
x: x - 1.5,
|
|
4500
|
+
y: midY - 1,
|
|
4501
|
+
textAnchor: "middle",
|
|
4502
|
+
dominantBaseline: "central",
|
|
4503
|
+
fontSize: fs,
|
|
4504
|
+
fontFamily: "sans-serif",
|
|
4505
|
+
fill: "#000",
|
|
4506
|
+
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
4507
|
+
children: label
|
|
4508
|
+
}
|
|
4509
|
+
)
|
|
4510
|
+
] }, `dim-${i}`);
|
|
4511
|
+
}
|
|
4512
|
+
var DIE_LINE_BECF_C_12101 = forwardRef(
|
|
4513
|
+
({
|
|
4514
|
+
attributes,
|
|
4515
|
+
unit = "mm",
|
|
4516
|
+
isShowDimensions = false,
|
|
4517
|
+
renderAs = "svg"
|
|
4518
|
+
}, ref) => {
|
|
4519
|
+
const theme = useMemo(
|
|
4520
|
+
() => getModelTheme(),
|
|
4521
|
+
[]
|
|
4522
|
+
);
|
|
4523
|
+
const svgRef = useRef(null);
|
|
4524
|
+
const dieline = useMemo(() => generateBecfC12101(attributes), [attributes]);
|
|
4525
|
+
const dimensions = useMemo(
|
|
4526
|
+
() => generateDimensions7(attributes, unit),
|
|
4527
|
+
[attributes, unit]
|
|
4528
|
+
);
|
|
4529
|
+
const factor = UNIT_FACTOR7[unit] ?? 1;
|
|
4530
|
+
const serializeSvg = useCallback(
|
|
4531
|
+
(showDimensions) => {
|
|
4532
|
+
const svg = svgRef.current;
|
|
4533
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
4534
|
+
const clone = svg.cloneNode(true);
|
|
4535
|
+
if (!showDimensions) {
|
|
4536
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
4537
|
+
dimGroup?.remove();
|
|
4538
|
+
}
|
|
4539
|
+
return new XMLSerializer().serializeToString(clone);
|
|
4540
|
+
},
|
|
4541
|
+
[]
|
|
4542
|
+
);
|
|
4543
|
+
useImperativeHandle(
|
|
4544
|
+
ref,
|
|
4545
|
+
() => {
|
|
4546
|
+
const auto = getAutoCalcValues3(attributes);
|
|
4547
|
+
return {
|
|
4548
|
+
getAttributes: () => ({
|
|
4549
|
+
modelId: MODEL_ID7,
|
|
4550
|
+
overallWidth: dieline.viewBox.width * factor,
|
|
4551
|
+
overallHeight: dieline.viewBox.height * factor,
|
|
4552
|
+
length: attributes.length * factor,
|
|
4553
|
+
width: attributes.width * factor,
|
|
4554
|
+
height: attributes.height * factor,
|
|
4555
|
+
glueArea: auto.kulak * factor,
|
|
4556
|
+
d: auto.d * factor,
|
|
4557
|
+
kulak: auto.kulak * factor,
|
|
4558
|
+
dip: auto.dip * factor,
|
|
4559
|
+
ribbonHW: auto.ribbonHW * factor,
|
|
4560
|
+
ribbonDX: auto.ribbonDX * factor,
|
|
4561
|
+
ribbonDY: auto.ribbonDY * factor,
|
|
4562
|
+
ribbonX: auto.ribbonX * factor
|
|
4563
|
+
}),
|
|
4564
|
+
exportImage: async (options) => {
|
|
4565
|
+
const svgStr = serializeSvg(options.isShowDimension);
|
|
4566
|
+
const blob = new Blob([svgStr], {
|
|
4567
|
+
type: "image/svg+xml;charset=utf-8"
|
|
4568
|
+
});
|
|
4569
|
+
const url = URL.createObjectURL(blob);
|
|
4570
|
+
const img = new Image();
|
|
4571
|
+
await new Promise((resolve, reject) => {
|
|
4572
|
+
img.onload = () => resolve();
|
|
4573
|
+
img.onerror = reject;
|
|
4574
|
+
img.src = url;
|
|
4575
|
+
});
|
|
4576
|
+
const canvas = document.createElement("canvas");
|
|
4577
|
+
if (options.originalSize) {
|
|
4578
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM7);
|
|
4579
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM7);
|
|
4580
|
+
} else {
|
|
4581
|
+
canvas.width = 1920;
|
|
4582
|
+
canvas.height = 1080;
|
|
4583
|
+
}
|
|
4584
|
+
const ctx = canvas.getContext("2d");
|
|
4585
|
+
ctx.fillStyle = "#ffffff";
|
|
4586
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
4587
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
4588
|
+
URL.revokeObjectURL(url);
|
|
4589
|
+
return new Promise((resolve, reject) => {
|
|
4590
|
+
canvas.toBlob(
|
|
4591
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
4592
|
+
"image/png"
|
|
4593
|
+
);
|
|
4594
|
+
});
|
|
4595
|
+
},
|
|
4596
|
+
exportDimension: async () => {
|
|
4597
|
+
const dimData = generateDimensions7(attributes, unit);
|
|
4598
|
+
return exportDimensionPdf({
|
|
4599
|
+
modelId: MODEL_ID7,
|
|
4600
|
+
dieline,
|
|
4601
|
+
dimensions: dimData,
|
|
4602
|
+
attributes,
|
|
4603
|
+
unit,
|
|
4604
|
+
factor,
|
|
4605
|
+
theme
|
|
4606
|
+
});
|
|
4607
|
+
}
|
|
4608
|
+
};
|
|
4609
|
+
},
|
|
4610
|
+
[attributes, dieline, factor, unit, serializeSvg, theme]
|
|
4611
|
+
);
|
|
4612
|
+
const padding = isShowDimensions ? 15 : 0;
|
|
4613
|
+
const vbX = -padding;
|
|
4614
|
+
const vbY = -padding;
|
|
4615
|
+
const vbW = dieline.viewBox.width + padding * 2;
|
|
4616
|
+
const vbH = dieline.viewBox.height + padding * 2;
|
|
4617
|
+
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4618
|
+
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
4619
|
+
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
4620
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension7(d, i, getFontDimensionSize())) })
|
|
4621
|
+
] });
|
|
4622
|
+
if (renderAs === "group") {
|
|
4623
|
+
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
4624
|
+
}
|
|
4625
|
+
return /* @__PURE__ */ jsx(
|
|
4626
|
+
"svg",
|
|
4627
|
+
{
|
|
4628
|
+
ref: svgRef,
|
|
4629
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4630
|
+
viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`,
|
|
4631
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
4632
|
+
style: { backgroundColor: theme.colorBackground },
|
|
4633
|
+
children: svgChildren
|
|
4634
|
+
}
|
|
4635
|
+
);
|
|
4636
|
+
}
|
|
4637
|
+
);
|
|
4638
|
+
var CANVAS_BECF_C_12101 = forwardRef(
|
|
4639
|
+
(props, ref) => {
|
|
4640
|
+
const dieLineRef = useRef(null);
|
|
4641
|
+
const canvasRef = useRef(null);
|
|
4642
|
+
const {
|
|
4643
|
+
attributes
|
|
4644
|
+
} = props;
|
|
4645
|
+
const theme = useMemo(
|
|
4646
|
+
() => getModelTheme(),
|
|
4647
|
+
[]
|
|
4648
|
+
);
|
|
4649
|
+
const dieline = useMemo(() => generateBecfC12101(attributes), [attributes]);
|
|
4650
|
+
const stablePadding = 15;
|
|
4651
|
+
const viewBox = useMemo(
|
|
4652
|
+
() => ({
|
|
4653
|
+
x: -stablePadding,
|
|
4654
|
+
y: -stablePadding,
|
|
4655
|
+
width: dieline.viewBox.width + stablePadding * 2,
|
|
4656
|
+
height: dieline.viewBox.height + stablePadding * 2
|
|
4657
|
+
}),
|
|
4658
|
+
[dieline.viewBox.width, dieline.viewBox.height]
|
|
4659
|
+
);
|
|
4660
|
+
const serializeCanvasSvg = useCallback((showDimensions) => {
|
|
4661
|
+
const svg = canvasRef.current?.getSvgElement();
|
|
4662
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
4663
|
+
const clone = svg.cloneNode(true);
|
|
4664
|
+
if (!showDimensions) {
|
|
4665
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
4666
|
+
dimGroup?.remove();
|
|
4667
|
+
}
|
|
4668
|
+
return new XMLSerializer().serializeToString(clone);
|
|
4669
|
+
}, []);
|
|
4670
|
+
useImperativeHandle(ref, () => ({
|
|
4671
|
+
getAttributes: () => dieLineRef.current.getAttributes(),
|
|
4672
|
+
exportImage: async (options) => {
|
|
4673
|
+
const svgStr = serializeCanvasSvg(options.isShowDimension);
|
|
4674
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
4675
|
+
const url = URL.createObjectURL(blob);
|
|
4676
|
+
const img = new Image();
|
|
4677
|
+
await new Promise((resolve, reject) => {
|
|
4678
|
+
img.onload = () => resolve();
|
|
4679
|
+
img.onerror = reject;
|
|
4680
|
+
img.src = url;
|
|
4681
|
+
});
|
|
4682
|
+
const canvas = document.createElement("canvas");
|
|
4683
|
+
if (options.originalSize) {
|
|
4684
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM7);
|
|
4685
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM7);
|
|
4686
|
+
} else {
|
|
4687
|
+
canvas.width = 1920;
|
|
4688
|
+
canvas.height = 1080;
|
|
4689
|
+
}
|
|
4690
|
+
const ctx = canvas.getContext("2d");
|
|
4691
|
+
ctx.fillStyle = "#ffffff";
|
|
4692
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
4693
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
4694
|
+
URL.revokeObjectURL(url);
|
|
4695
|
+
return new Promise((resolve, reject) => {
|
|
4696
|
+
canvas.toBlob(
|
|
4697
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
4698
|
+
"image/png"
|
|
4699
|
+
);
|
|
4700
|
+
});
|
|
4701
|
+
},
|
|
4702
|
+
exportDimension: () => dieLineRef.current.exportDimension(),
|
|
4703
|
+
resetView: () => canvasRef.current?.resetView(),
|
|
4704
|
+
fitView: () => canvasRef.current?.fitView()
|
|
4705
|
+
}), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
|
|
4706
|
+
return /* @__PURE__ */ jsx(
|
|
4707
|
+
BaseCanvas,
|
|
4708
|
+
{
|
|
4709
|
+
ref: canvasRef,
|
|
4710
|
+
viewBox,
|
|
4711
|
+
backgroundColor: theme.colorBackground,
|
|
4712
|
+
children: /* @__PURE__ */ jsx(DIE_LINE_BECF_C_12101, { ref: dieLineRef, ...props, renderAs: "group" })
|
|
4713
|
+
}
|
|
4714
|
+
);
|
|
4715
|
+
}
|
|
4716
|
+
);
|
|
4717
|
+
var MODEL_BECF_C_12101 = forwardRef(
|
|
4718
|
+
({ mode = "DIE_LINE", ...props }, ref) => {
|
|
4719
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (() => {
|
|
4720
|
+
switch (mode) {
|
|
4721
|
+
case "DIE_LINE":
|
|
4722
|
+
return /* @__PURE__ */ jsx(CANVAS_BECF_C_12101, { ref, ...props });
|
|
4723
|
+
case "3D":
|
|
4724
|
+
return null;
|
|
4725
|
+
case "AUTO_LAYOUT":
|
|
4726
|
+
return /* @__PURE__ */ jsx(DIE_LINE_BECF_C_12101, { ref, ...props });
|
|
4727
|
+
default:
|
|
4728
|
+
return null;
|
|
4729
|
+
}
|
|
4730
|
+
})() });
|
|
4731
|
+
}
|
|
4732
|
+
);
|
|
4733
|
+
|
|
4734
|
+
// src/components/dieline/bags-pillows/becf-c-12109/generate.ts
|
|
4735
|
+
var DIP4 = 13;
|
|
4736
|
+
var RIBBON_HALF_W2 = 9;
|
|
4737
|
+
var RIBBON_DX2 = 2;
|
|
4738
|
+
var RIBBON_DY2 = 2;
|
|
4739
|
+
var D_MAX4 = 40;
|
|
4740
|
+
var NOTCH_X2 = 3;
|
|
4741
|
+
var NOTCH_Y2 = 5;
|
|
4742
|
+
function calcD4(c, b) {
|
|
4743
|
+
return Math.min(c - 2 - b / 2, D_MAX4);
|
|
4744
|
+
}
|
|
4745
|
+
function calcKulak4(b) {
|
|
4746
|
+
if (b <= 13) return b - 1;
|
|
4747
|
+
if (b <= 99) return 13;
|
|
4748
|
+
if (b <= 249) return 20;
|
|
4749
|
+
if (b <= 499) return 25;
|
|
4750
|
+
return 30;
|
|
4751
|
+
}
|
|
4752
|
+
function calcX4(a) {
|
|
4753
|
+
return a / 2;
|
|
4754
|
+
}
|
|
4755
|
+
function getAutoCalcValues4(attr) {
|
|
4756
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
4757
|
+
const D = calcD4(C, B);
|
|
4758
|
+
const kulak = glueArea ?? calcKulak4(B);
|
|
4759
|
+
const X = calcX4(A);
|
|
4760
|
+
return { d: D, kulak, dip: DIP4, ribbonHW: RIBBON_HALF_W2, ribbonDX: RIBBON_DX2, ribbonDY: RIBBON_DY2, ribbonX: X };
|
|
4761
|
+
}
|
|
4762
|
+
function line8(x1, y1, x2, y2) {
|
|
4763
|
+
return `M${x1} ${y1} L${x2} ${y2}`;
|
|
4764
|
+
}
|
|
4765
|
+
function generateBecfC12109(attr) {
|
|
4766
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
4767
|
+
const D = calcD4(C, B);
|
|
4768
|
+
const kulak = glueArea ?? calcKulak4(B);
|
|
4769
|
+
const X = calcX4(A);
|
|
4770
|
+
const xFront = kulak;
|
|
4771
|
+
const xSide1 = kulak + A;
|
|
4772
|
+
const xSide1Mid = kulak + A + B / 2;
|
|
4773
|
+
const xBack = kulak + A + B;
|
|
4774
|
+
const xSide2 = kulak + 2 * A + B;
|
|
4775
|
+
const xSide2Mid = kulak + 2 * A + B + B / 2;
|
|
4776
|
+
const xEnd = kulak + 2 * A + 2 * B - 2;
|
|
4777
|
+
const yFoldTop = D;
|
|
4778
|
+
const yFoldBottomStart = D + C - B / 2;
|
|
4779
|
+
const yFoldBottom = D + C;
|
|
4780
|
+
const yNotchStart = yFoldBottom + NOTCH_Y2;
|
|
4781
|
+
const yEnd = D + C + B / 2 + DIP4;
|
|
4782
|
+
const totalWidth = xEnd;
|
|
4783
|
+
const totalHeight = yEnd;
|
|
4784
|
+
const cut = [];
|
|
4785
|
+
const crease = [];
|
|
4786
|
+
cut.push(line8(0, 0, 0, yFoldBottom - kulak));
|
|
4787
|
+
cut.push(line8(0, 0, totalWidth, 0));
|
|
4788
|
+
cut.push(line8(totalWidth, 0, totalWidth, yFoldBottom));
|
|
4789
|
+
cut.push(line8(0, yFoldBottom - kulak, kulak, yFoldBottom));
|
|
4790
|
+
const boundaries = [xFront, xSide1, xBack, xSide2, xEnd];
|
|
4791
|
+
for (let i = 0; i < boundaries.length; i++) {
|
|
4792
|
+
const xb = boundaries[i];
|
|
4793
|
+
const isFirst = i === 0;
|
|
4794
|
+
const isLast = i === boundaries.length - 1;
|
|
4795
|
+
if (!isFirst) {
|
|
4796
|
+
cut.push(line8(xb - NOTCH_X2, yNotchStart, xb - NOTCH_X2, totalHeight));
|
|
4797
|
+
cut.push(line8(xb - NOTCH_X2, yNotchStart, xb, yFoldBottom));
|
|
4798
|
+
}
|
|
4799
|
+
if (!isLast) {
|
|
4800
|
+
cut.push(line8(xb + NOTCH_X2, yNotchStart, xb + NOTCH_X2, totalHeight));
|
|
4801
|
+
cut.push(line8(xb + NOTCH_X2, yNotchStart, xb, yFoldBottom));
|
|
4802
|
+
}
|
|
4803
|
+
}
|
|
4804
|
+
cut.push(line8(xFront + NOTCH_X2, totalHeight, xSide1 - NOTCH_X2, totalHeight));
|
|
4805
|
+
cut.push(line8(xSide1 + NOTCH_X2, totalHeight, xBack - NOTCH_X2, totalHeight));
|
|
4806
|
+
cut.push(line8(xBack + NOTCH_X2, totalHeight, xSide2 - NOTCH_X2, totalHeight));
|
|
4807
|
+
cut.push(line8(xSide2 + NOTCH_X2, totalHeight, xEnd - NOTCH_X2, totalHeight));
|
|
4808
|
+
const frontCx = kulak + A / 2;
|
|
4809
|
+
const backCx = kulak + A + B + A / 2;
|
|
4810
|
+
const yRibbonTop = yFoldTop - RIBBON_DY2 / 2;
|
|
4811
|
+
const yRibbonBot = yFoldTop + RIBBON_DY2 / 2;
|
|
4812
|
+
function addRibbonNotch(cx) {
|
|
4813
|
+
cut.push(line8(cx - RIBBON_HALF_W2, yRibbonBot, cx + RIBBON_HALF_W2, yRibbonBot));
|
|
4814
|
+
cut.push(line8(cx - RIBBON_HALF_W2 - RIBBON_DX2, yRibbonTop, cx - RIBBON_HALF_W2, yRibbonBot));
|
|
4815
|
+
cut.push(line8(cx + RIBBON_HALF_W2 + RIBBON_DX2, yRibbonTop, cx + RIBBON_HALF_W2, yRibbonBot));
|
|
4816
|
+
}
|
|
4817
|
+
addRibbonNotch(frontCx - X / 2);
|
|
4818
|
+
addRibbonNotch(frontCx + X / 2);
|
|
4819
|
+
addRibbonNotch(backCx - X / 2);
|
|
4820
|
+
addRibbonNotch(backCx + X / 2);
|
|
4821
|
+
crease.push(line8(0, yFoldTop, totalWidth, yFoldTop));
|
|
4822
|
+
crease.push(line8(0, yFoldBottomStart, totalWidth, yFoldBottomStart));
|
|
4823
|
+
crease.push(line8(kulak, yFoldBottom, xEnd, yFoldBottom));
|
|
4824
|
+
crease.push(line8(xFront, 0, xFront, yFoldBottom));
|
|
4825
|
+
crease.push(line8(xSide1, 0, xSide1, yFoldBottom));
|
|
4826
|
+
crease.push(line8(xBack, 0, xBack, yFoldBottom));
|
|
4827
|
+
crease.push(line8(xSide2, 0, xSide2, yFoldBottom));
|
|
4828
|
+
crease.push(line8(xSide1Mid, 0, xSide1Mid, totalHeight));
|
|
4829
|
+
crease.push(line8(xSide2Mid, 0, xSide2Mid, totalHeight));
|
|
4830
|
+
crease.push(line8(xBack, yFoldBottom, xSide1Mid, yFoldBottomStart));
|
|
4831
|
+
crease.push(line8(xSide1Mid, yFoldBottomStart, xSide1, yFoldBottom));
|
|
4832
|
+
crease.push(line8(xSide2Mid, yFoldBottomStart, xSide2, yFoldBottom));
|
|
4833
|
+
crease.push(line8(xSide2Mid, yFoldBottomStart, xEnd, D + C - 2));
|
|
4834
|
+
return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
|
|
4835
|
+
}
|
|
4836
|
+
function generateOuterContour8(attr) {
|
|
4837
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
4838
|
+
const D = calcD4(C, B);
|
|
4839
|
+
const kulak = glueArea ?? calcKulak4(B);
|
|
4840
|
+
const xFront = kulak;
|
|
4841
|
+
const xSide1 = kulak + A;
|
|
4842
|
+
const xBack = kulak + A + B;
|
|
4843
|
+
const xSide2 = kulak + 2 * A + B;
|
|
4844
|
+
const xEnd = kulak + 2 * A + 2 * B - 2;
|
|
4845
|
+
const yFoldBottom = D + C;
|
|
4846
|
+
const yNotchStart = yFoldBottom + NOTCH_Y2;
|
|
4847
|
+
const yEnd = D + C + B / 2 + DIP4;
|
|
4848
|
+
return [
|
|
4849
|
+
{ x: 0, y: 0 },
|
|
4850
|
+
{ x: xEnd, y: 0 },
|
|
4851
|
+
{ x: xEnd, y: yFoldBottom },
|
|
4852
|
+
{ x: xEnd - NOTCH_X2, y: yNotchStart },
|
|
4853
|
+
{ x: xEnd - NOTCH_X2, y: yEnd },
|
|
4854
|
+
{ x: xSide2 + NOTCH_X2, y: yEnd },
|
|
4855
|
+
{ x: xSide2 + NOTCH_X2, y: yNotchStart },
|
|
4856
|
+
{ x: xSide2, y: yFoldBottom },
|
|
4857
|
+
{ x: xSide2 - NOTCH_X2, y: yNotchStart },
|
|
4858
|
+
{ x: xSide2 - NOTCH_X2, y: yEnd },
|
|
4859
|
+
{ x: xBack + NOTCH_X2, y: yEnd },
|
|
4860
|
+
{ x: xBack + NOTCH_X2, y: yNotchStart },
|
|
4861
|
+
{ x: xBack, y: yFoldBottom },
|
|
4862
|
+
{ x: xBack - NOTCH_X2, y: yNotchStart },
|
|
4863
|
+
{ x: xBack - NOTCH_X2, y: yEnd },
|
|
4864
|
+
{ x: xSide1 + NOTCH_X2, y: yEnd },
|
|
4865
|
+
{ x: xSide1 + NOTCH_X2, y: yNotchStart },
|
|
4866
|
+
{ x: xSide1, y: yFoldBottom },
|
|
4867
|
+
{ x: xSide1 - NOTCH_X2, y: yNotchStart },
|
|
4868
|
+
{ x: xSide1 - NOTCH_X2, y: yEnd },
|
|
4869
|
+
{ x: xFront + NOTCH_X2, y: yEnd },
|
|
4870
|
+
{ x: xFront + NOTCH_X2, y: yNotchStart },
|
|
4871
|
+
{ x: xFront, y: yFoldBottom },
|
|
4872
|
+
{ x: 0, y: yFoldBottom - kulak }
|
|
4873
|
+
];
|
|
4874
|
+
}
|
|
4875
|
+
function offsetContour8(points, distance) {
|
|
4876
|
+
const n = points.length;
|
|
4877
|
+
const result = [];
|
|
4878
|
+
for (let i = 0; i < n; i++) {
|
|
4879
|
+
const prev = points[(i - 1 + n) % n];
|
|
4880
|
+
const curr = points[i];
|
|
4881
|
+
const next = points[(i + 1) % n];
|
|
4882
|
+
const e1x = curr.x - prev.x;
|
|
4883
|
+
const e1y = curr.y - prev.y;
|
|
4884
|
+
const e2x = next.x - curr.x;
|
|
4885
|
+
const e2y = next.y - curr.y;
|
|
4886
|
+
const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
|
|
4887
|
+
const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
|
|
4888
|
+
if (len1 === 0 || len2 === 0) {
|
|
4889
|
+
result.push(curr);
|
|
4890
|
+
continue;
|
|
4891
|
+
}
|
|
4892
|
+
const n1x = e1y / len1;
|
|
4893
|
+
const n1y = -e1x / len1;
|
|
4894
|
+
const n2x = e2y / len2;
|
|
4895
|
+
const n2y = -e2x / len2;
|
|
4896
|
+
const ax = n1x + n2x;
|
|
4897
|
+
const ay = n1y + n2y;
|
|
4898
|
+
const aLen = Math.sqrt(ax * ax + ay * ay);
|
|
4899
|
+
if (aLen < 1e-3) {
|
|
4900
|
+
result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
|
|
4901
|
+
continue;
|
|
4902
|
+
}
|
|
4903
|
+
const nx = ax / aLen;
|
|
4904
|
+
const ny = ay / aLen;
|
|
4905
|
+
const dot = n1x * nx + n1y * ny;
|
|
4906
|
+
const d = distance / Math.max(dot, 0.1);
|
|
4907
|
+
result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
|
|
4908
|
+
}
|
|
4909
|
+
return result;
|
|
4910
|
+
}
|
|
4911
|
+
function contourToPath8(points) {
|
|
4912
|
+
if (points.length === 0) return "";
|
|
4913
|
+
let d = `M${points[0].x} ${points[0].y}`;
|
|
4914
|
+
for (let i = 1; i < points.length; i++) {
|
|
4915
|
+
d += ` L${points[i].x} ${points[i].y}`;
|
|
4916
|
+
}
|
|
4917
|
+
d += " Z";
|
|
4918
|
+
return d;
|
|
4919
|
+
}
|
|
4920
|
+
function generateDimensions8(attr, unit) {
|
|
4921
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
4922
|
+
const D = calcD4(C, B);
|
|
4923
|
+
const kulak = glueArea ?? calcKulak4(B);
|
|
4924
|
+
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
4925
|
+
const suffix = unit;
|
|
4926
|
+
const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
|
|
4927
|
+
const xFront = kulak;
|
|
4928
|
+
const xSide1 = kulak + A;
|
|
4929
|
+
const xBack = kulak + A + B;
|
|
4930
|
+
const yFoldTop = D;
|
|
4931
|
+
const yFoldBottom = D + C;
|
|
4932
|
+
const yEnd = D + C + B / 2 + DIP4;
|
|
4933
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
4934
|
+
const totalHeight = yEnd;
|
|
4935
|
+
const bottomSection = B / 2 + DIP4;
|
|
4936
|
+
return [
|
|
4937
|
+
{
|
|
4938
|
+
x1: 0,
|
|
4939
|
+
y1: 0,
|
|
4940
|
+
x2: totalWidth,
|
|
4941
|
+
y2: 0,
|
|
4942
|
+
label: `Overall Width : ${fmt(totalWidth)}`,
|
|
4943
|
+
orientation: "horizontal",
|
|
4944
|
+
offset: -12
|
|
4945
|
+
},
|
|
4946
|
+
{
|
|
4947
|
+
x1: 0,
|
|
4948
|
+
y1: 0,
|
|
4949
|
+
x2: 0,
|
|
4950
|
+
y2: totalHeight,
|
|
4951
|
+
label: `Overall Height : ${fmt(totalHeight)}`,
|
|
4952
|
+
orientation: "vertical",
|
|
4953
|
+
offset: -12
|
|
4954
|
+
},
|
|
4955
|
+
{
|
|
4956
|
+
x1: xBack + A * 0.6,
|
|
4957
|
+
y1: yFoldTop,
|
|
4958
|
+
x2: xBack + A * 0.6,
|
|
4959
|
+
y2: yFoldBottom,
|
|
4960
|
+
label: fmt(C),
|
|
4961
|
+
orientation: "vertical",
|
|
4962
|
+
offset: -10
|
|
4963
|
+
},
|
|
4964
|
+
{
|
|
4965
|
+
x1: xBack + A * 0.6,
|
|
4966
|
+
y1: 0,
|
|
4967
|
+
x2: xBack + A * 0.6,
|
|
4968
|
+
y2: yFoldTop,
|
|
4969
|
+
label: fmt(D),
|
|
4970
|
+
orientation: "vertical",
|
|
4971
|
+
offset: -10
|
|
4972
|
+
},
|
|
4973
|
+
{
|
|
4974
|
+
x1: xBack + A * 0.6,
|
|
4975
|
+
y1: yFoldBottom,
|
|
4976
|
+
x2: xBack + A * 0.6,
|
|
4977
|
+
y2: yEnd,
|
|
4978
|
+
label: fmt(bottomSection),
|
|
4979
|
+
orientation: "vertical",
|
|
4980
|
+
offset: -10
|
|
4981
|
+
},
|
|
4982
|
+
{
|
|
4983
|
+
x1: xFront,
|
|
4984
|
+
y1: yFoldTop + C * 0.65,
|
|
4985
|
+
x2: xSide1,
|
|
4986
|
+
y2: yFoldTop + C * 0.65,
|
|
4987
|
+
label: fmt(A),
|
|
4988
|
+
orientation: "horizontal",
|
|
4989
|
+
offset: -20
|
|
4990
|
+
},
|
|
4991
|
+
{
|
|
4992
|
+
x1: xSide1,
|
|
4993
|
+
y1: yFoldTop + C * 0.65,
|
|
4994
|
+
x2: xBack,
|
|
4995
|
+
y2: yFoldTop + C * 0.65,
|
|
4996
|
+
label: fmt(B),
|
|
4997
|
+
orientation: "horizontal",
|
|
4998
|
+
offset: -20
|
|
4999
|
+
},
|
|
5000
|
+
{
|
|
5001
|
+
x1: 0,
|
|
5002
|
+
y1: yFoldTop + C * 0.65,
|
|
5003
|
+
x2: xFront,
|
|
5004
|
+
y2: yFoldTop + C * 0.65,
|
|
5005
|
+
label: fmt(kulak),
|
|
5006
|
+
orientation: "horizontal",
|
|
5007
|
+
offset: -20
|
|
5008
|
+
}
|
|
5009
|
+
];
|
|
5010
|
+
}
|
|
5011
|
+
var MODEL_ID8 = "BECF-C-12109";
|
|
5012
|
+
var UNIT_FACTOR8 = {
|
|
5013
|
+
mm: 1,
|
|
5014
|
+
cm: 0.1,
|
|
5015
|
+
in: 1 / 25.4
|
|
5016
|
+
};
|
|
5017
|
+
var PX_PER_MM8 = 96 / 25.4;
|
|
5018
|
+
function renderDimension8(dim, i, fs) {
|
|
5019
|
+
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
5020
|
+
const tick = 1.5;
|
|
5021
|
+
if (orientation === "horizontal") {
|
|
5022
|
+
const y = y1 + offset;
|
|
5023
|
+
const midX = (x1 + x2) / 2;
|
|
5024
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
5025
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
|
|
5026
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
5027
|
+
/* @__PURE__ */ jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
5028
|
+
/* @__PURE__ */ jsx(
|
|
5029
|
+
"text",
|
|
5030
|
+
{
|
|
5031
|
+
x: midX,
|
|
5032
|
+
y: y - 1.5,
|
|
5033
|
+
textAnchor: "middle",
|
|
5034
|
+
fontSize: fs,
|
|
5035
|
+
fontFamily: "sans-serif",
|
|
5036
|
+
fill: "#000",
|
|
5037
|
+
children: label
|
|
5038
|
+
}
|
|
5039
|
+
)
|
|
5040
|
+
] }, `dim-${i}`);
|
|
5041
|
+
}
|
|
5042
|
+
const x = x1 + offset;
|
|
5043
|
+
const midY = (y1 + y2) / 2;
|
|
5044
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
5045
|
+
/* @__PURE__ */ jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
|
|
5046
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
|
|
5047
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
|
|
5048
|
+
/* @__PURE__ */ jsx(
|
|
5049
|
+
"text",
|
|
5050
|
+
{
|
|
5051
|
+
x: x - 1.5,
|
|
5052
|
+
y: midY - 1,
|
|
5053
|
+
textAnchor: "middle",
|
|
5054
|
+
dominantBaseline: "central",
|
|
5055
|
+
fontSize: fs,
|
|
5056
|
+
fontFamily: "sans-serif",
|
|
5057
|
+
fill: "#000",
|
|
5058
|
+
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
5059
|
+
children: label
|
|
5060
|
+
}
|
|
5061
|
+
)
|
|
5062
|
+
] }, `dim-${i}`);
|
|
5063
|
+
}
|
|
5064
|
+
var DIE_LINE_BECF_C_12109 = forwardRef(
|
|
5065
|
+
({
|
|
5066
|
+
attributes,
|
|
5067
|
+
unit = "mm",
|
|
5068
|
+
isShowDimensions = false,
|
|
5069
|
+
renderAs = "svg"
|
|
5070
|
+
}, ref) => {
|
|
5071
|
+
const theme = useMemo(
|
|
5072
|
+
() => getModelTheme(),
|
|
5073
|
+
[]
|
|
5074
|
+
);
|
|
5075
|
+
const svgRef = useRef(null);
|
|
5076
|
+
const dieline = useMemo(() => generateBecfC12109(attributes), [attributes]);
|
|
5077
|
+
const dimensions = useMemo(
|
|
5078
|
+
() => generateDimensions8(attributes, unit),
|
|
5079
|
+
[attributes, unit]
|
|
5080
|
+
);
|
|
5081
|
+
const factor = UNIT_FACTOR8[unit] ?? 1;
|
|
5082
|
+
const serializeSvg = useCallback(
|
|
5083
|
+
(showDimensions) => {
|
|
5084
|
+
const svg = svgRef.current;
|
|
5085
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
5086
|
+
const clone = svg.cloneNode(true);
|
|
5087
|
+
if (!showDimensions) {
|
|
5088
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
5089
|
+
dimGroup?.remove();
|
|
5090
|
+
}
|
|
5091
|
+
return new XMLSerializer().serializeToString(clone);
|
|
5092
|
+
},
|
|
5093
|
+
[]
|
|
5094
|
+
);
|
|
5095
|
+
useImperativeHandle(
|
|
5096
|
+
ref,
|
|
5097
|
+
() => {
|
|
5098
|
+
const auto = getAutoCalcValues4(attributes);
|
|
5099
|
+
return {
|
|
5100
|
+
getAttributes: () => ({
|
|
5101
|
+
modelId: MODEL_ID8,
|
|
5102
|
+
overallWidth: dieline.viewBox.width * factor,
|
|
5103
|
+
overallHeight: dieline.viewBox.height * factor,
|
|
5104
|
+
length: attributes.length * factor,
|
|
5105
|
+
width: attributes.width * factor,
|
|
5106
|
+
height: attributes.height * factor,
|
|
5107
|
+
glueArea: auto.kulak * factor,
|
|
5108
|
+
d: auto.d * factor,
|
|
5109
|
+
kulak: auto.kulak * factor,
|
|
5110
|
+
dip: auto.dip * factor,
|
|
5111
|
+
ribbonHW: auto.ribbonHW * factor,
|
|
5112
|
+
ribbonDX: auto.ribbonDX * factor,
|
|
5113
|
+
ribbonDY: auto.ribbonDY * factor,
|
|
5114
|
+
ribbonX: auto.ribbonX * factor
|
|
5115
|
+
}),
|
|
5116
|
+
exportImage: async (options) => {
|
|
5117
|
+
const svgStr = serializeSvg(options.isShowDimension);
|
|
5118
|
+
const blob = new Blob([svgStr], {
|
|
5119
|
+
type: "image/svg+xml;charset=utf-8"
|
|
5120
|
+
});
|
|
5121
|
+
const url = URL.createObjectURL(blob);
|
|
5122
|
+
const img = new Image();
|
|
5123
|
+
await new Promise((resolve, reject) => {
|
|
5124
|
+
img.onload = () => resolve();
|
|
5125
|
+
img.onerror = reject;
|
|
5126
|
+
img.src = url;
|
|
5127
|
+
});
|
|
5128
|
+
const canvas = document.createElement("canvas");
|
|
5129
|
+
if (options.originalSize) {
|
|
5130
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM8);
|
|
5131
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM8);
|
|
5132
|
+
} else {
|
|
5133
|
+
canvas.width = 1920;
|
|
5134
|
+
canvas.height = 1080;
|
|
5135
|
+
}
|
|
5136
|
+
const ctx = canvas.getContext("2d");
|
|
5137
|
+
ctx.fillStyle = "#ffffff";
|
|
5138
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
5139
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
5140
|
+
URL.revokeObjectURL(url);
|
|
5141
|
+
return new Promise((resolve, reject) => {
|
|
5142
|
+
canvas.toBlob(
|
|
5143
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
5144
|
+
"image/png"
|
|
5145
|
+
);
|
|
5146
|
+
});
|
|
5147
|
+
},
|
|
5148
|
+
exportDimension: async () => {
|
|
5149
|
+
const dimData = generateDimensions8(attributes, unit);
|
|
5150
|
+
return exportDimensionPdf({
|
|
5151
|
+
modelId: MODEL_ID8,
|
|
5152
|
+
dieline,
|
|
5153
|
+
dimensions: dimData,
|
|
5154
|
+
attributes,
|
|
5155
|
+
unit,
|
|
5156
|
+
factor,
|
|
5157
|
+
theme
|
|
5158
|
+
});
|
|
5159
|
+
}
|
|
5160
|
+
};
|
|
5161
|
+
},
|
|
5162
|
+
[attributes, dieline, factor, unit, serializeSvg, theme]
|
|
5163
|
+
);
|
|
5164
|
+
const padding = isShowDimensions ? 15 : 0;
|
|
5165
|
+
const vbX = -padding;
|
|
5166
|
+
const vbY = -padding;
|
|
5167
|
+
const vbW = dieline.viewBox.width + padding * 2;
|
|
5168
|
+
const vbH = dieline.viewBox.height + padding * 2;
|
|
5169
|
+
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5170
|
+
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
5171
|
+
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
5172
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension8(d, i, getFontDimensionSize())) })
|
|
5173
|
+
] });
|
|
5174
|
+
if (renderAs === "group") {
|
|
5175
|
+
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
5176
|
+
}
|
|
5177
|
+
return /* @__PURE__ */ jsx(
|
|
5178
|
+
"svg",
|
|
5179
|
+
{
|
|
5180
|
+
ref: svgRef,
|
|
5181
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5182
|
+
viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`,
|
|
5183
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
5184
|
+
style: { backgroundColor: theme.colorBackground },
|
|
5185
|
+
children: svgChildren
|
|
5186
|
+
}
|
|
5187
|
+
);
|
|
5188
|
+
}
|
|
5189
|
+
);
|
|
5190
|
+
var CANVAS_BECF_C_12109 = forwardRef(
|
|
5191
|
+
(props, ref) => {
|
|
5192
|
+
const dieLineRef = useRef(null);
|
|
5193
|
+
const canvasRef = useRef(null);
|
|
5194
|
+
const {
|
|
5195
|
+
attributes
|
|
5196
|
+
} = props;
|
|
5197
|
+
const theme = useMemo(
|
|
5198
|
+
() => getModelTheme(),
|
|
5199
|
+
[]
|
|
5200
|
+
);
|
|
5201
|
+
const dieline = useMemo(() => generateBecfC12109(attributes), [attributes]);
|
|
5202
|
+
const stablePadding = 15;
|
|
5203
|
+
const viewBox = useMemo(
|
|
5204
|
+
() => ({
|
|
5205
|
+
x: -stablePadding,
|
|
5206
|
+
y: -stablePadding,
|
|
5207
|
+
width: dieline.viewBox.width + stablePadding * 2,
|
|
5208
|
+
height: dieline.viewBox.height + stablePadding * 2
|
|
5209
|
+
}),
|
|
5210
|
+
[dieline.viewBox.width, dieline.viewBox.height]
|
|
5211
|
+
);
|
|
5212
|
+
const serializeCanvasSvg = useCallback((showDimensions) => {
|
|
5213
|
+
const svg = canvasRef.current?.getSvgElement();
|
|
5214
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
5215
|
+
const clone = svg.cloneNode(true);
|
|
5216
|
+
if (!showDimensions) {
|
|
5217
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
5218
|
+
dimGroup?.remove();
|
|
5219
|
+
}
|
|
5220
|
+
return new XMLSerializer().serializeToString(clone);
|
|
5221
|
+
}, []);
|
|
5222
|
+
useImperativeHandle(ref, () => ({
|
|
5223
|
+
getAttributes: () => dieLineRef.current.getAttributes(),
|
|
5224
|
+
exportImage: async (options) => {
|
|
5225
|
+
const svgStr = serializeCanvasSvg(options.isShowDimension);
|
|
5226
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
5227
|
+
const url = URL.createObjectURL(blob);
|
|
5228
|
+
const img = new Image();
|
|
5229
|
+
await new Promise((resolve, reject) => {
|
|
5230
|
+
img.onload = () => resolve();
|
|
5231
|
+
img.onerror = reject;
|
|
5232
|
+
img.src = url;
|
|
5233
|
+
});
|
|
5234
|
+
const canvas = document.createElement("canvas");
|
|
5235
|
+
if (options.originalSize) {
|
|
5236
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM8);
|
|
5237
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM8);
|
|
5238
|
+
} else {
|
|
5239
|
+
canvas.width = 1920;
|
|
5240
|
+
canvas.height = 1080;
|
|
5241
|
+
}
|
|
5242
|
+
const ctx = canvas.getContext("2d");
|
|
5243
|
+
ctx.fillStyle = "#ffffff";
|
|
5244
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
5245
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
5246
|
+
URL.revokeObjectURL(url);
|
|
5247
|
+
return new Promise((resolve, reject) => {
|
|
5248
|
+
canvas.toBlob(
|
|
5249
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
5250
|
+
"image/png"
|
|
5251
|
+
);
|
|
5252
|
+
});
|
|
5253
|
+
},
|
|
5254
|
+
exportDimension: () => dieLineRef.current.exportDimension(),
|
|
5255
|
+
resetView: () => canvasRef.current?.resetView(),
|
|
5256
|
+
fitView: () => canvasRef.current?.fitView()
|
|
5257
|
+
}), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
|
|
5258
|
+
return /* @__PURE__ */ jsx(
|
|
5259
|
+
BaseCanvas,
|
|
5260
|
+
{
|
|
5261
|
+
ref: canvasRef,
|
|
5262
|
+
viewBox,
|
|
5263
|
+
backgroundColor: theme.colorBackground,
|
|
5264
|
+
children: /* @__PURE__ */ jsx(DIE_LINE_BECF_C_12109, { ref: dieLineRef, ...props, renderAs: "group" })
|
|
5265
|
+
}
|
|
5266
|
+
);
|
|
5267
|
+
}
|
|
5268
|
+
);
|
|
5269
|
+
var MODEL_BECF_C_12109 = forwardRef(
|
|
5270
|
+
({ mode = "DIE_LINE", ...props }, ref) => {
|
|
5271
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (() => {
|
|
5272
|
+
switch (mode) {
|
|
5273
|
+
case "DIE_LINE":
|
|
5274
|
+
return /* @__PURE__ */ jsx(CANVAS_BECF_C_12109, { ref, ...props });
|
|
5275
|
+
case "3D":
|
|
5276
|
+
return null;
|
|
5277
|
+
case "AUTO_LAYOUT":
|
|
5278
|
+
return /* @__PURE__ */ jsx(DIE_LINE_BECF_C_12109, { ref, ...props });
|
|
5279
|
+
default:
|
|
5280
|
+
return null;
|
|
5281
|
+
}
|
|
5282
|
+
})() });
|
|
5283
|
+
}
|
|
5284
|
+
);
|
|
5285
|
+
|
|
5286
|
+
// src/utils/autoLayout/rasterize.ts
|
|
5287
|
+
function rasterizePolygon(points, resolution) {
|
|
5288
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
5289
|
+
for (const p of points) {
|
|
5290
|
+
if (p.x < minX) minX = p.x;
|
|
5291
|
+
if (p.y < minY) minY = p.y;
|
|
5292
|
+
if (p.x > maxX) maxX = p.x;
|
|
5293
|
+
if (p.y > maxY) maxY = p.y;
|
|
5294
|
+
}
|
|
5295
|
+
const offsetX = Math.floor(minX / resolution);
|
|
5296
|
+
const offsetY = Math.floor(minY / resolution);
|
|
5297
|
+
const w = Math.ceil((maxX - offsetX * resolution) / resolution) + 1;
|
|
5298
|
+
const h = Math.ceil((maxY - offsetY * resolution) / resolution) + 1;
|
|
5299
|
+
const data = new Uint8Array(w * h);
|
|
5300
|
+
for (let gy = 0; gy < h; gy++) {
|
|
5301
|
+
const worldY = (offsetY + gy) * resolution + resolution / 2;
|
|
5302
|
+
const crossings = [];
|
|
5303
|
+
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
|
|
5304
|
+
const yi = points[i].y, yj = points[j].y;
|
|
5305
|
+
if (yi <= worldY && yj > worldY || yj <= worldY && yi > worldY) {
|
|
5306
|
+
const t = (worldY - yi) / (yj - yi);
|
|
5307
|
+
crossings.push(points[i].x + t * (points[j].x - points[i].x));
|
|
5308
|
+
}
|
|
5309
|
+
}
|
|
5310
|
+
crossings.sort((a, b) => a - b);
|
|
5311
|
+
for (let c = 0; c < crossings.length - 1; c += 2) {
|
|
5312
|
+
const startGx = Math.max(0, Math.floor((crossings[c] - offsetX * resolution) / resolution));
|
|
5313
|
+
const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
|
|
5314
|
+
for (let gx = startGx; gx <= endGx; gx++) {
|
|
5315
|
+
data[gy * w + gx] = 1;
|
|
5316
|
+
}
|
|
5317
|
+
}
|
|
5318
|
+
}
|
|
5319
|
+
return { data, width: w, height: h, offsetX, offsetY };
|
|
5320
|
+
}
|
|
5321
|
+
function canPlace(paperGrid, paperW, paperH, piece, px, py) {
|
|
5322
|
+
for (let y = 0; y < piece.height; y++) {
|
|
5323
|
+
const paperY = py + y;
|
|
5324
|
+
if (paperY < 0 || paperY >= paperH) {
|
|
5325
|
+
for (let x = 0; x < piece.width; x++) {
|
|
5326
|
+
if (piece.data[y * piece.width + x]) return false;
|
|
5327
|
+
}
|
|
5328
|
+
continue;
|
|
5329
|
+
}
|
|
5330
|
+
for (let x = 0; x < piece.width; x++) {
|
|
5331
|
+
if (!piece.data[y * piece.width + x]) continue;
|
|
5332
|
+
const paperX = px + x;
|
|
5333
|
+
if (paperX < 0 || paperX >= paperW) return false;
|
|
5334
|
+
if (paperGrid[paperY * paperW + paperX]) return false;
|
|
5335
|
+
}
|
|
5336
|
+
}
|
|
5337
|
+
return true;
|
|
5338
|
+
}
|
|
5339
|
+
function placePiece(paperGrid, paperW, piece, px, py) {
|
|
5340
|
+
for (let y = 0; y < piece.height; y++) {
|
|
5341
|
+
for (let x = 0; x < piece.width; x++) {
|
|
5342
|
+
if (piece.data[y * piece.width + x]) {
|
|
5343
|
+
paperGrid[(py + y) * paperW + (px + x)] = 1;
|
|
5344
|
+
}
|
|
5345
|
+
}
|
|
5346
|
+
}
|
|
5347
|
+
}
|
|
5348
|
+
|
|
5349
|
+
// src/utils/autoLayout/calculate/shared.ts
|
|
5350
|
+
var RESOLUTION = 1;
|
|
5351
|
+
function resolveGripperSide(paperWidth, paperHeight) {
|
|
5352
|
+
if (paperWidth >= paperHeight) return "bottom";
|
|
5353
|
+
return "left";
|
|
5354
|
+
}
|
|
5355
|
+
function computeUsableBounds(paperWidth, paperHeight, gripperSide, spacing, griper, colorbarDepth) {
|
|
5356
|
+
switch (gripperSide) {
|
|
5357
|
+
case "bottom":
|
|
5358
|
+
return {
|
|
5359
|
+
top: colorbarDepth + spacing,
|
|
5360
|
+
bottom: paperHeight - griper,
|
|
5361
|
+
left: spacing,
|
|
5362
|
+
right: paperWidth - spacing
|
|
5363
|
+
};
|
|
5364
|
+
case "top":
|
|
5365
|
+
return {
|
|
5366
|
+
top: griper,
|
|
5367
|
+
bottom: paperHeight - colorbarDepth - spacing,
|
|
5368
|
+
left: spacing,
|
|
5369
|
+
right: paperWidth - spacing
|
|
5370
|
+
};
|
|
5371
|
+
case "left":
|
|
5372
|
+
return {
|
|
5373
|
+
top: spacing,
|
|
5374
|
+
bottom: paperHeight - spacing,
|
|
5375
|
+
left: griper,
|
|
5376
|
+
right: paperWidth - colorbarDepth - spacing
|
|
5377
|
+
};
|
|
5378
|
+
case "right":
|
|
5379
|
+
return {
|
|
5380
|
+
top: spacing,
|
|
5381
|
+
bottom: paperHeight - spacing,
|
|
5382
|
+
left: colorbarDepth + spacing,
|
|
5383
|
+
right: paperWidth - griper
|
|
5384
|
+
};
|
|
5385
|
+
}
|
|
5386
|
+
}
|
|
5387
|
+
function normalizePoints(points, degrees) {
|
|
5388
|
+
const rad = degrees * Math.PI / 180;
|
|
5389
|
+
const cos = Math.cos(rad);
|
|
5390
|
+
const sin = Math.sin(rad);
|
|
5391
|
+
const rotated = points.map((p) => ({
|
|
5392
|
+
x: p.x * cos - p.y * sin,
|
|
5393
|
+
y: p.x * sin + p.y * cos
|
|
5394
|
+
}));
|
|
5395
|
+
let minX = Infinity, minY = Infinity;
|
|
5396
|
+
for (const p of rotated) {
|
|
5397
|
+
if (p.x < minX) minX = p.x;
|
|
5398
|
+
if (p.y < minY) minY = p.y;
|
|
5399
|
+
}
|
|
5400
|
+
return rotated.map((p) => ({ x: p.x - minX, y: p.y - minY }));
|
|
5401
|
+
}
|
|
5402
|
+
function computeDielineBBOffset(offsetContourPoints, dielineW, dielineH, degrees) {
|
|
5403
|
+
const rad = degrees * Math.PI / 180;
|
|
5404
|
+
const cos = Math.cos(rad);
|
|
5405
|
+
const sin = Math.sin(rad);
|
|
5406
|
+
let ocMinX = Infinity, ocMinY = Infinity;
|
|
5407
|
+
for (const p of offsetContourPoints) {
|
|
5408
|
+
const rx = p.x * cos - p.y * sin;
|
|
5409
|
+
const ry = p.x * sin + p.y * cos;
|
|
5410
|
+
if (rx < ocMinX) ocMinX = rx;
|
|
5411
|
+
if (ry < ocMinY) ocMinY = ry;
|
|
5412
|
+
}
|
|
5413
|
+
const corners = [[0, 0], [dielineW, 0], [0, dielineH], [dielineW, dielineH]];
|
|
5414
|
+
let dlMinX = Infinity, dlMinY = Infinity;
|
|
5415
|
+
for (const [cx, cy] of corners) {
|
|
5416
|
+
const rx = cx * cos - cy * sin;
|
|
5417
|
+
const ry = cx * sin + cy * cos;
|
|
5418
|
+
if (rx < dlMinX) dlMinX = rx;
|
|
5419
|
+
if (ry < dlMinY) dlMinY = ry;
|
|
5420
|
+
}
|
|
5421
|
+
return { dx: dlMinX - ocMinX, dy: dlMinY - ocMinY };
|
|
5422
|
+
}
|
|
5423
|
+
function computeLayoutForPaperDefault(contourPoints, dielineW, dielineH, paperWidth, paperHeight, bounds) {
|
|
5424
|
+
const usableLeft = Math.ceil(bounds.left / RESOLUTION);
|
|
5425
|
+
const usableTop = Math.ceil(bounds.top / RESOLUTION);
|
|
5426
|
+
const usableRight = Math.floor(bounds.right / RESOLUTION);
|
|
5427
|
+
const usableBottom = Math.floor(bounds.bottom / RESOLUTION);
|
|
5428
|
+
const paperW = Math.floor(paperWidth / RESOLUTION);
|
|
5429
|
+
const paperH = Math.floor(paperHeight / RESOLUTION);
|
|
5430
|
+
let bestCandidate = { rotation: 0, placements: [], producedPerSheet: 0 };
|
|
5431
|
+
let bestGridPositions = [];
|
|
5432
|
+
let bestBitmapW = 0;
|
|
5433
|
+
let bestBitmapH = 0;
|
|
5434
|
+
for (const deg of [0, 90, 180, 270]) {
|
|
5435
|
+
const rotatedContour = normalizePoints(contourPoints, deg);
|
|
5436
|
+
const pieceBitmap = rasterizePolygon(rotatedContour, RESOLUTION);
|
|
5437
|
+
const bbOffset = computeDielineBBOffset(contourPoints, dielineW, dielineH, deg);
|
|
5438
|
+
const paperGrid = new Uint8Array(paperW * paperH);
|
|
5439
|
+
const placements = [];
|
|
5440
|
+
const gridPositions = [];
|
|
5441
|
+
for (let py = usableTop; py <= usableBottom - pieceBitmap.height; py++) {
|
|
5442
|
+
for (let px = usableLeft; px <= usableRight - pieceBitmap.width; px++) {
|
|
5443
|
+
if (canPlace(paperGrid, paperW, paperH, pieceBitmap, px, py)) {
|
|
5444
|
+
placePiece(paperGrid, paperW, pieceBitmap, px, py);
|
|
5445
|
+
gridPositions.push({ px, py });
|
|
5446
|
+
placements.push({
|
|
5447
|
+
x: px * RESOLUTION + bbOffset.dx,
|
|
5448
|
+
y: py * RESOLUTION + bbOffset.dy,
|
|
5449
|
+
rotation: deg
|
|
5450
|
+
});
|
|
5451
|
+
}
|
|
5452
|
+
}
|
|
5453
|
+
}
|
|
5454
|
+
if (placements.length > bestCandidate.producedPerSheet) {
|
|
5455
|
+
bestCandidate = { rotation: deg, placements, producedPerSheet: placements.length };
|
|
5456
|
+
bestGridPositions = gridPositions;
|
|
5457
|
+
bestBitmapW = pieceBitmap.width;
|
|
5458
|
+
bestBitmapH = pieceBitmap.height;
|
|
5459
|
+
}
|
|
5460
|
+
}
|
|
5461
|
+
if (bestCandidate.placements.length > 0) {
|
|
5462
|
+
let gridMinX = Infinity;
|
|
5463
|
+
let gridMinY = Infinity;
|
|
5464
|
+
let gridMaxX = -Infinity;
|
|
5465
|
+
let gridMaxY = -Infinity;
|
|
5466
|
+
for (const { px, py } of bestGridPositions) {
|
|
5467
|
+
if (px < gridMinX) gridMinX = px;
|
|
5468
|
+
if (py < gridMinY) gridMinY = py;
|
|
5469
|
+
if (px + bestBitmapW > gridMaxX) gridMaxX = px + bestBitmapW;
|
|
5470
|
+
if (py + bestBitmapH > gridMaxY) gridMaxY = py + bestBitmapH;
|
|
5471
|
+
}
|
|
5472
|
+
const groupW = gridMaxX - gridMinX;
|
|
5473
|
+
const groupH = gridMaxY - gridMinY;
|
|
4376
5474
|
const usableW = usableRight - usableLeft;
|
|
4377
5475
|
const usableH = usableBottom - usableTop;
|
|
4378
5476
|
const offsetX = ((usableW - groupW) / 2 - (gridMinX - usableLeft)) * RESOLUTION;
|
|
@@ -4382,52 +5480,378 @@ function computeLayoutForPaperDefault(contourPoints, dielineW, dielineH, paperWi
|
|
|
4382
5480
|
p.y += offsetY;
|
|
4383
5481
|
}
|
|
4384
5482
|
}
|
|
4385
|
-
return bestCandidate;
|
|
5483
|
+
return bestCandidate;
|
|
5484
|
+
}
|
|
5485
|
+
|
|
5486
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1010a/index.ts
|
|
5487
|
+
var SAMPLE_STEP = 0.1;
|
|
5488
|
+
function buildProfile(points) {
|
|
5489
|
+
let maxX = 0, maxY = 0;
|
|
5490
|
+
for (const p of points) {
|
|
5491
|
+
if (p.x > maxX) maxX = p.x;
|
|
5492
|
+
if (p.y > maxY) maxY = p.y;
|
|
5493
|
+
}
|
|
5494
|
+
const width = maxX, height = maxY;
|
|
5495
|
+
const nY = Math.ceil(height / SAMPLE_STEP) + 1;
|
|
5496
|
+
const nX = Math.ceil(width / SAMPLE_STEP) + 1;
|
|
5497
|
+
const rightX = new Float64Array(nY).fill(-Infinity);
|
|
5498
|
+
const leftX = new Float64Array(nY).fill(Infinity);
|
|
5499
|
+
const bottomY = new Float64Array(nX).fill(-Infinity);
|
|
5500
|
+
const topY = new Float64Array(nX).fill(Infinity);
|
|
5501
|
+
const nPts = points.length;
|
|
5502
|
+
for (let iy = 0; iy < nY; iy++) {
|
|
5503
|
+
const y = iy * SAMPLE_STEP;
|
|
5504
|
+
for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
|
|
5505
|
+
const yj = points[j].y, yk = points[k].y;
|
|
5506
|
+
if (yj <= y && yk > y || yk <= y && yj > y) {
|
|
5507
|
+
const t = (y - yj) / (yk - yj);
|
|
5508
|
+
const x = points[j].x + t * (points[k].x - points[j].x);
|
|
5509
|
+
if (x > rightX[iy]) rightX[iy] = x;
|
|
5510
|
+
if (x < leftX[iy]) leftX[iy] = x;
|
|
5511
|
+
}
|
|
5512
|
+
}
|
|
5513
|
+
}
|
|
5514
|
+
for (let ix = 0; ix < nX; ix++) {
|
|
5515
|
+
const x = ix * SAMPLE_STEP;
|
|
5516
|
+
for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
|
|
5517
|
+
const xj = points[j].x, xk = points[k].x;
|
|
5518
|
+
if (xj <= x && xk > x || xk <= x && xj > x) {
|
|
5519
|
+
const t = (x - xj) / (xk - xj);
|
|
5520
|
+
const y = points[j].y + t * (points[k].y - points[j].y);
|
|
5521
|
+
if (y > bottomY[ix]) bottomY[ix] = y;
|
|
5522
|
+
if (y < topY[ix]) topY[ix] = y;
|
|
5523
|
+
}
|
|
5524
|
+
}
|
|
5525
|
+
}
|
|
5526
|
+
return { width, height, nY, nX, rightX, leftX, bottomY, topY };
|
|
5527
|
+
}
|
|
5528
|
+
function prepareRotation(contourPoints, dielineW, dielineH, deg) {
|
|
5529
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
5530
|
+
return {
|
|
5531
|
+
profile: buildProfile(rotated),
|
|
5532
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
5533
|
+
deg
|
|
5534
|
+
};
|
|
5535
|
+
}
|
|
5536
|
+
function findMinStepX(a, b, dyMm) {
|
|
5537
|
+
const dySamples = Math.round(dyMm / SAMPLE_STEP);
|
|
5538
|
+
let maxOverlap = -Infinity;
|
|
5539
|
+
for (let ia = 0; ia < a.nY; ia++) {
|
|
5540
|
+
const ib = ia - dySamples;
|
|
5541
|
+
if (ib < 0 || ib >= b.nY) continue;
|
|
5542
|
+
if (a.rightX[ia] === -Infinity || b.leftX[ib] === Infinity) continue;
|
|
5543
|
+
const overlap = a.rightX[ia] - b.leftX[ib];
|
|
5544
|
+
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
5545
|
+
}
|
|
5546
|
+
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
5547
|
+
}
|
|
5548
|
+
function findMinStepY(a, b, dxMm) {
|
|
5549
|
+
const dxSamples = Math.round(dxMm / SAMPLE_STEP);
|
|
5550
|
+
let maxOverlap = -Infinity;
|
|
5551
|
+
for (let ia = 0; ia < a.nX; ia++) {
|
|
5552
|
+
const ib = ia - dxSamples;
|
|
5553
|
+
if (ib < 0 || ib >= b.nX) continue;
|
|
5554
|
+
if (a.bottomY[ia] === -Infinity || b.topY[ib] === Infinity) continue;
|
|
5555
|
+
const overlap = a.bottomY[ia] - b.topY[ib];
|
|
5556
|
+
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
5557
|
+
}
|
|
5558
|
+
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
5559
|
+
}
|
|
5560
|
+
function findMinStepY_multi(profA, stepX_A, profB, offsetX) {
|
|
5561
|
+
const reach = Math.max(profA.width, profB.width);
|
|
5562
|
+
let maxStep = 0;
|
|
5563
|
+
const nMin = Math.floor((offsetX - reach) / stepX_A);
|
|
5564
|
+
const nMax = Math.ceil((offsetX + reach) / stepX_A);
|
|
5565
|
+
for (let n = nMin; n <= nMax; n++) {
|
|
5566
|
+
const s = findMinStepY(profA, profB, offsetX - n * stepX_A);
|
|
5567
|
+
if (s > maxStep) maxStep = s;
|
|
5568
|
+
}
|
|
5569
|
+
return maxStep;
|
|
5570
|
+
}
|
|
5571
|
+
function emptyResult() {
|
|
5572
|
+
return { placements: [], count: 0, minX: 0, minY: 0, maxX: 0, maxY: 0 };
|
|
5573
|
+
}
|
|
5574
|
+
function singleRotGrid(rd, bounds) {
|
|
5575
|
+
const p = rd.profile;
|
|
5576
|
+
const stepX = findMinStepX(p, p, 0);
|
|
5577
|
+
const stepY = findMinStepY(p, p, 0);
|
|
5578
|
+
if (stepX <= 0 || stepY <= 0) return emptyResult();
|
|
5579
|
+
const cols = Math.max(0, Math.floor((bounds.right - bounds.left - p.width) / stepX) + 1);
|
|
5580
|
+
const rows = Math.max(0, Math.floor((bounds.bottom - bounds.top - p.height) / stepY) + 1);
|
|
5581
|
+
if (cols === 0 || rows === 0) return emptyResult();
|
|
5582
|
+
const placements = [];
|
|
5583
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
5584
|
+
for (let r = 0; r < rows; r++) {
|
|
5585
|
+
for (let c = 0; c < cols; c++) {
|
|
5586
|
+
const ox = bounds.left + c * stepX;
|
|
5587
|
+
const oy = bounds.top + r * stepY;
|
|
5588
|
+
placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
|
|
5589
|
+
if (ox < minX) minX = ox;
|
|
5590
|
+
if (oy < minY) minY = oy;
|
|
5591
|
+
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
5592
|
+
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
5593
|
+
}
|
|
5594
|
+
}
|
|
5595
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5596
|
+
}
|
|
5597
|
+
function dualRotGrid(rdA, rdB, offsetX, bounds) {
|
|
5598
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
5599
|
+
const stepX_A = findMinStepX(pA, pA, 0);
|
|
5600
|
+
const stepX_B = findMinStepX(pB, pB, 0);
|
|
5601
|
+
if (stepX_A <= 0 || stepX_B <= 0) return emptyResult();
|
|
5602
|
+
let stepY_AB = findMinStepY_multi(pA, stepX_A, pB, offsetX);
|
|
5603
|
+
let stepY_BA = findMinStepY_multi(pB, stepX_B, pA, -offsetX);
|
|
5604
|
+
if (stepY_AB + stepY_BA <= 0) return emptyResult();
|
|
5605
|
+
const minAA = findMinStepY_multi(pA, stepX_A, pA, 0);
|
|
5606
|
+
const minBB = findMinStepY_multi(pB, stepX_B, pB, 0);
|
|
5607
|
+
const cycle = stepY_AB + stepY_BA;
|
|
5608
|
+
const neededCycle = Math.max(cycle, minAA, minBB);
|
|
5609
|
+
if (neededCycle > cycle) {
|
|
5610
|
+
const scale = neededCycle / cycle;
|
|
5611
|
+
stepY_AB *= scale;
|
|
5612
|
+
stepY_BA *= scale;
|
|
5613
|
+
}
|
|
5614
|
+
const placements = [];
|
|
5615
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
5616
|
+
let oy = bounds.top;
|
|
5617
|
+
let isRowA = true;
|
|
5618
|
+
while (true) {
|
|
5619
|
+
const rd = isRowA ? rdA : rdB;
|
|
5620
|
+
const p = rd.profile;
|
|
5621
|
+
const stepX = isRowA ? stepX_A : stepX_B;
|
|
5622
|
+
if (oy + p.height > bounds.bottom) break;
|
|
5623
|
+
let sx = isRowA ? bounds.left : bounds.left + offsetX;
|
|
5624
|
+
if (sx < bounds.left) sx += stepX * Math.ceil((bounds.left - sx) / stepX);
|
|
5625
|
+
for (let ox = sx; ox + p.width <= bounds.right; ox += stepX) {
|
|
5626
|
+
placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
|
|
5627
|
+
if (ox < minX) minX = ox;
|
|
5628
|
+
if (oy < minY) minY = oy;
|
|
5629
|
+
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
5630
|
+
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
5631
|
+
}
|
|
5632
|
+
oy += isRowA ? stepY_AB : stepY_BA;
|
|
5633
|
+
isRowA = !isRowA;
|
|
5634
|
+
}
|
|
5635
|
+
if (placements.length === 0) return emptyResult();
|
|
5636
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5637
|
+
}
|
|
5638
|
+
function centerLayout(result, bounds) {
|
|
5639
|
+
if (result.count === 0) return;
|
|
5640
|
+
const offX = (bounds.right - bounds.left - (result.maxX - result.minX)) / 2 - (result.minX - bounds.left);
|
|
5641
|
+
const offY = (bounds.bottom - bounds.top - (result.maxY - result.minY)) / 2 - (result.minY - bounds.top);
|
|
5642
|
+
for (const p of result.placements) {
|
|
5643
|
+
p.x += offX;
|
|
5644
|
+
p.y += offY;
|
|
5645
|
+
}
|
|
5646
|
+
}
|
|
5647
|
+
function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
5648
|
+
const rots = [0, 90, 180, 270];
|
|
5649
|
+
const rd = /* @__PURE__ */ new Map();
|
|
5650
|
+
for (const deg of rots) {
|
|
5651
|
+
rd.set(deg, prepareRotation(contourPoints, dielineW, dielineH, deg));
|
|
5652
|
+
}
|
|
5653
|
+
const results = [];
|
|
5654
|
+
for (const deg of rots) {
|
|
5655
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
5656
|
+
}
|
|
5657
|
+
const pairs = [
|
|
5658
|
+
[0, 180],
|
|
5659
|
+
[90, 270],
|
|
5660
|
+
[0, 90],
|
|
5661
|
+
[0, 270],
|
|
5662
|
+
[90, 180],
|
|
5663
|
+
[180, 270]
|
|
5664
|
+
];
|
|
5665
|
+
for (const [a, b] of pairs) {
|
|
5666
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
5667
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
5668
|
+
if (stepA <= 0) continue;
|
|
5669
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
5670
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
5671
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
5672
|
+
}
|
|
5673
|
+
}
|
|
5674
|
+
let best = results[0];
|
|
5675
|
+
for (const r of results) {
|
|
5676
|
+
if (r.count > best.count) best = r;
|
|
5677
|
+
}
|
|
5678
|
+
centerLayout(best, bounds);
|
|
5679
|
+
return {
|
|
5680
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
5681
|
+
placements: best.placements,
|
|
5682
|
+
producedPerSheet: best.count
|
|
5683
|
+
};
|
|
4386
5684
|
}
|
|
4387
5685
|
|
|
4388
|
-
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
5686
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1030a/index.ts
|
|
5687
|
+
function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
|
|
5688
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
5689
|
+
return {
|
|
5690
|
+
profile: buildProfile(rotated),
|
|
5691
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
5692
|
+
deg
|
|
5693
|
+
};
|
|
5694
|
+
}
|
|
5695
|
+
function findPairRowStepY(pA, pB, gapAB, pairStepX) {
|
|
5696
|
+
const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
|
|
5697
|
+
const nMin = Math.floor(-reach / pairStepX) - 1;
|
|
5698
|
+
const nMax = Math.ceil(reach / pairStepX) + 1;
|
|
5699
|
+
let maxStep = 0;
|
|
5700
|
+
for (let n = nMin; n <= nMax; n++) {
|
|
5701
|
+
const dx = n * pairStepX;
|
|
5702
|
+
const s1 = findMinStepY(pA, pA, dx);
|
|
5703
|
+
if (s1 > maxStep) maxStep = s1;
|
|
5704
|
+
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
5705
|
+
if (s2 > maxStep) maxStep = s2;
|
|
5706
|
+
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
5707
|
+
if (s3 > maxStep) maxStep = s3;
|
|
5708
|
+
const s4 = findMinStepY(pB, pB, dx);
|
|
5709
|
+
if (s4 > maxStep) maxStep = s4;
|
|
4395
5710
|
}
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
const
|
|
4400
|
-
const
|
|
4401
|
-
|
|
4402
|
-
const
|
|
4403
|
-
const
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
5711
|
+
return maxStep;
|
|
5712
|
+
}
|
|
5713
|
+
function pairGrid(rdA, rdB, bounds) {
|
|
5714
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
5715
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
5716
|
+
if (gapAB <= 0) return emptyResult();
|
|
5717
|
+
const pairW = gapAB + pB.width;
|
|
5718
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
5719
|
+
const pairStepX = Math.max(
|
|
5720
|
+
gapAB + findMinStepX(pB, pA, 0),
|
|
5721
|
+
findMinStepX(pA, pA, 0),
|
|
5722
|
+
findMinStepX(pB, pB, 0)
|
|
5723
|
+
);
|
|
5724
|
+
const pairStepY = findPairRowStepY(pA, pB, gapAB, pairStepX);
|
|
5725
|
+
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
5726
|
+
const usableW = bounds.right - bounds.left;
|
|
5727
|
+
const usableH = bounds.bottom - bounds.top;
|
|
5728
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
5729
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
5730
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
5731
|
+
const placements = [];
|
|
5732
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
5733
|
+
for (let r = 0; r < pairRows; r++) {
|
|
5734
|
+
for (let c = 0; c < pairCols; c++) {
|
|
5735
|
+
const baseX = bounds.left + c * pairStepX;
|
|
5736
|
+
const baseY = bounds.top + r * pairStepY;
|
|
5737
|
+
const oxA = baseX;
|
|
5738
|
+
const oyA = baseY;
|
|
5739
|
+
placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
5740
|
+
if (oxA < minX) minX = oxA;
|
|
5741
|
+
if (oyA < minY) minY = oyA;
|
|
5742
|
+
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
5743
|
+
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
5744
|
+
const oxB = baseX + gapAB;
|
|
5745
|
+
const oyB = baseY;
|
|
5746
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
5747
|
+
if (oxB < minX) minX = oxB;
|
|
5748
|
+
if (oyB < minY) minY = oyB;
|
|
5749
|
+
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
5750
|
+
if (oyB + pB.height > maxY) maxY = oyB + pB.height;
|
|
5751
|
+
}
|
|
5752
|
+
}
|
|
5753
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
5754
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
5755
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
5756
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
5757
|
+
const extraRotations = [rdA, rdB];
|
|
5758
|
+
for (const rdExtra of extraRotations) {
|
|
5759
|
+
const pe = rdExtra.profile;
|
|
5760
|
+
if (pe.width <= gapRight) {
|
|
5761
|
+
for (let r = 0; r < pairRows; r++) {
|
|
5762
|
+
const ox = pairsRightEdge;
|
|
5763
|
+
const oy = bounds.top + r * pairStepY;
|
|
5764
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
5765
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
5766
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
5767
|
+
}
|
|
4413
5768
|
}
|
|
5769
|
+
break;
|
|
4414
5770
|
}
|
|
4415
5771
|
}
|
|
4416
|
-
for (
|
|
4417
|
-
const
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
const
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
5772
|
+
for (const rdExtra of extraRotations) {
|
|
5773
|
+
const pe = rdExtra.profile;
|
|
5774
|
+
if (pe.height <= gapBottom) {
|
|
5775
|
+
for (let c = 0; c < pairCols; c++) {
|
|
5776
|
+
const oxA = bounds.left + c * pairStepX;
|
|
5777
|
+
const oy = pairsBottomEdge;
|
|
5778
|
+
if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
5779
|
+
placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
5780
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
5781
|
+
}
|
|
5782
|
+
}
|
|
5783
|
+
break;
|
|
5784
|
+
}
|
|
5785
|
+
}
|
|
5786
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5787
|
+
}
|
|
5788
|
+
function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
5789
|
+
const rots = [0, 90, 180, 270];
|
|
5790
|
+
const rd = /* @__PURE__ */ new Map();
|
|
5791
|
+
for (const deg of rots) {
|
|
5792
|
+
rd.set(deg, prepareRotation2(contourPoints, dielineW, dielineH, deg));
|
|
5793
|
+
}
|
|
5794
|
+
const results = [];
|
|
5795
|
+
for (const deg of rots) {
|
|
5796
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
5797
|
+
}
|
|
5798
|
+
const allPairs = [
|
|
5799
|
+
[0, 180],
|
|
5800
|
+
[90, 270],
|
|
5801
|
+
[0, 90],
|
|
5802
|
+
[0, 270],
|
|
5803
|
+
[90, 180],
|
|
5804
|
+
[180, 270]
|
|
5805
|
+
];
|
|
5806
|
+
for (const [a, b] of allPairs) {
|
|
5807
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
5808
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
5809
|
+
if (stepA <= 0) continue;
|
|
5810
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
5811
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
5812
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
5813
|
+
}
|
|
5814
|
+
}
|
|
5815
|
+
for (const [a, b] of allPairs) {
|
|
5816
|
+
results.push(pairGrid(rd.get(a), rd.get(b), bounds));
|
|
5817
|
+
results.push(pairGrid(rd.get(b), rd.get(a), bounds));
|
|
5818
|
+
}
|
|
5819
|
+
const singleResults = [];
|
|
5820
|
+
const multiResults = [];
|
|
5821
|
+
for (const r of results) {
|
|
5822
|
+
if (r.count === 0) continue;
|
|
5823
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
5824
|
+
if (rotations.size > 1) {
|
|
5825
|
+
multiResults.push(r);
|
|
5826
|
+
} else {
|
|
5827
|
+
singleResults.push(r);
|
|
5828
|
+
}
|
|
5829
|
+
}
|
|
5830
|
+
function pickBest(arr) {
|
|
5831
|
+
let b = arr[0] ?? emptyResult();
|
|
5832
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
5833
|
+
for (const r of arr) {
|
|
5834
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
5835
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
5836
|
+
b = r;
|
|
5837
|
+
bArea = area;
|
|
4425
5838
|
}
|
|
4426
5839
|
}
|
|
5840
|
+
return b;
|
|
4427
5841
|
}
|
|
4428
|
-
|
|
5842
|
+
const bestSingle = pickBest(singleResults);
|
|
5843
|
+
const bestMulti = pickBest(multiResults);
|
|
5844
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
5845
|
+
centerLayout(best, bounds);
|
|
5846
|
+
return {
|
|
5847
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
5848
|
+
placements: best.placements,
|
|
5849
|
+
producedPerSheet: best.count
|
|
5850
|
+
};
|
|
4429
5851
|
}
|
|
4430
|
-
|
|
5852
|
+
|
|
5853
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1040a/index.ts
|
|
5854
|
+
function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
|
|
4431
5855
|
const rotated = normalizePoints(contourPoints, deg);
|
|
4432
5856
|
return {
|
|
4433
5857
|
profile: buildProfile(rotated),
|
|
@@ -4435,119 +5859,176 @@ function prepareRotation(contourPoints, dielineW, dielineH, deg) {
|
|
|
4435
5859
|
deg
|
|
4436
5860
|
};
|
|
4437
5861
|
}
|
|
4438
|
-
function
|
|
4439
|
-
const
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
const ib = ia - dySamples;
|
|
4443
|
-
if (ib < 0 || ib >= b.nY) continue;
|
|
4444
|
-
if (a.rightX[ia] === -Infinity || b.leftX[ib] === Infinity) continue;
|
|
4445
|
-
const overlap = a.rightX[ia] - b.leftX[ib];
|
|
4446
|
-
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
4447
|
-
}
|
|
4448
|
-
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
4449
|
-
}
|
|
4450
|
-
function findMinStepY(a, b, dxMm) {
|
|
4451
|
-
const dxSamples = Math.round(dxMm / SAMPLE_STEP);
|
|
4452
|
-
let maxOverlap = -Infinity;
|
|
4453
|
-
for (let ia = 0; ia < a.nX; ia++) {
|
|
4454
|
-
const ib = ia - dxSamples;
|
|
4455
|
-
if (ib < 0 || ib >= b.nX) continue;
|
|
4456
|
-
if (a.bottomY[ia] === -Infinity || b.topY[ib] === Infinity) continue;
|
|
4457
|
-
const overlap = a.bottomY[ia] - b.topY[ib];
|
|
4458
|
-
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
4459
|
-
}
|
|
4460
|
-
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
4461
|
-
}
|
|
4462
|
-
function findMinStepY_multi(profA, stepX_A, profB, offsetX) {
|
|
4463
|
-
const reach = Math.max(profA.width, profB.width);
|
|
5862
|
+
function findPairRowStepY2(pA, pB, gapAB, pairStepX) {
|
|
5863
|
+
const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
|
|
5864
|
+
const nMin = Math.floor(-reach / pairStepX) - 1;
|
|
5865
|
+
const nMax = Math.ceil(reach / pairStepX) + 1;
|
|
4464
5866
|
let maxStep = 0;
|
|
4465
|
-
const nMin = Math.floor((offsetX - reach) / stepX_A);
|
|
4466
|
-
const nMax = Math.ceil((offsetX + reach) / stepX_A);
|
|
4467
5867
|
for (let n = nMin; n <= nMax; n++) {
|
|
4468
|
-
const
|
|
4469
|
-
|
|
5868
|
+
const dx = n * pairStepX;
|
|
5869
|
+
const s1 = findMinStepY(pA, pA, dx);
|
|
5870
|
+
if (s1 > maxStep) maxStep = s1;
|
|
5871
|
+
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
5872
|
+
if (s2 > maxStep) maxStep = s2;
|
|
5873
|
+
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
5874
|
+
if (s3 > maxStep) maxStep = s3;
|
|
5875
|
+
const s4 = findMinStepY(pB, pB, dx);
|
|
5876
|
+
if (s4 > maxStep) maxStep = s4;
|
|
4470
5877
|
}
|
|
4471
5878
|
return maxStep;
|
|
4472
5879
|
}
|
|
4473
|
-
function
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
const
|
|
4478
|
-
const
|
|
4479
|
-
const
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
5880
|
+
function pairGrid2(rdA, rdB, bounds) {
|
|
5881
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
5882
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
5883
|
+
if (gapAB <= 0) return emptyResult();
|
|
5884
|
+
const pairW = gapAB + pB.width;
|
|
5885
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
5886
|
+
const pairStepX = Math.max(
|
|
5887
|
+
gapAB + findMinStepX(pB, pA, 0),
|
|
5888
|
+
findMinStepX(pA, pA, 0),
|
|
5889
|
+
findMinStepX(pB, pB, 0)
|
|
5890
|
+
);
|
|
5891
|
+
if (pairStepX <= 0) return emptyResult();
|
|
5892
|
+
const pairStepY = findPairRowStepY2(pA, pB, gapAB, pairStepX);
|
|
5893
|
+
if (pairStepY <= 0) return emptyResult();
|
|
5894
|
+
const usableW = bounds.right - bounds.left;
|
|
5895
|
+
const usableH = bounds.bottom - bounds.top;
|
|
5896
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
5897
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
5898
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
4484
5899
|
const placements = [];
|
|
4485
5900
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4486
|
-
for (let r = 0; r <
|
|
4487
|
-
for (let c = 0; c <
|
|
4488
|
-
const
|
|
4489
|
-
const
|
|
4490
|
-
placements.push({ x:
|
|
4491
|
-
if (
|
|
4492
|
-
if (
|
|
4493
|
-
if (
|
|
4494
|
-
if (
|
|
5901
|
+
for (let r = 0; r < pairRows; r++) {
|
|
5902
|
+
for (let c = 0; c < pairCols; c++) {
|
|
5903
|
+
const baseX = bounds.left + c * pairStepX;
|
|
5904
|
+
const baseY = bounds.top + r * pairStepY;
|
|
5905
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
5906
|
+
if (baseX < minX) minX = baseX;
|
|
5907
|
+
if (baseY < minY) minY = baseY;
|
|
5908
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
5909
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
5910
|
+
const bx = baseX + gapAB;
|
|
5911
|
+
placements.push({ x: bx + rdB.bbOffset.dx, y: baseY + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
5912
|
+
if (bx < minX) minX = bx;
|
|
5913
|
+
if (bx + pB.width > maxX) maxX = bx + pB.width;
|
|
5914
|
+
if (baseY + pB.height > maxY) maxY = baseY + pB.height;
|
|
5915
|
+
}
|
|
5916
|
+
}
|
|
5917
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
5918
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
5919
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
5920
|
+
const pe = rdExtra.profile;
|
|
5921
|
+
if (pe.width > gapRight) continue;
|
|
5922
|
+
const dxFromB = pairsRightEdge - (bounds.left + (pairCols - 1) * pairStepX + gapAB);
|
|
5923
|
+
const dxFromA = pairsRightEdge - bounds.left - (pairCols - 1) * pairStepX;
|
|
5924
|
+
const extraStepY = Math.max(
|
|
5925
|
+
findMinStepY(pA, pe, dxFromA),
|
|
5926
|
+
findMinStepY(pB, pe, dxFromB),
|
|
5927
|
+
findMinStepY(pe, pe, 0)
|
|
5928
|
+
);
|
|
5929
|
+
if (extraStepY <= 0) continue;
|
|
5930
|
+
const effectiveStepY = Math.max(pairStepY, extraStepY);
|
|
5931
|
+
const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
|
|
5932
|
+
for (let r = 0; r < extraRows; r++) {
|
|
5933
|
+
const ox = pairsRightEdge;
|
|
5934
|
+
const oy = bounds.top + r * effectiveStepY;
|
|
5935
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
5936
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
5937
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
5938
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
5939
|
+
}
|
|
5940
|
+
}
|
|
5941
|
+
break;
|
|
5942
|
+
}
|
|
5943
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
5944
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
5945
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
5946
|
+
const pe = rdExtra.profile;
|
|
5947
|
+
if (pe.height > gapBottom) continue;
|
|
5948
|
+
const extraStepX = findMinStepX(pe, pe, 0);
|
|
5949
|
+
if (extraStepX <= 0) continue;
|
|
5950
|
+
const dyFromPairRow = pairsBottomEdge - (bounds.top + (pairRows - 1) * pairStepY);
|
|
5951
|
+
const stepFromA = findMinStepY(pA, pe, 0);
|
|
5952
|
+
const stepFromB = findMinStepY(pB, pe, gapAB);
|
|
5953
|
+
if (dyFromPairRow < stepFromA || dyFromPairRow < stepFromB) continue;
|
|
5954
|
+
const extraCols = Math.max(0, Math.floor((usableW - pe.width) / extraStepX) + 1);
|
|
5955
|
+
for (let c = 0; c < extraCols; c++) {
|
|
5956
|
+
const ox = bounds.left + c * extraStepX;
|
|
5957
|
+
const oy = pairsBottomEdge;
|
|
5958
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
5959
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
5960
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
5961
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
5962
|
+
}
|
|
4495
5963
|
}
|
|
5964
|
+
break;
|
|
4496
5965
|
}
|
|
4497
5966
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4498
5967
|
}
|
|
4499
|
-
function
|
|
5968
|
+
function verticalPairGrid(rdA, rdB, bounds) {
|
|
4500
5969
|
const pA = rdA.profile, pB = rdB.profile;
|
|
4501
|
-
const
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
const
|
|
4505
|
-
const
|
|
4506
|
-
|
|
5970
|
+
const gapAB_Y = findMinStepY(pA, pB, 0);
|
|
5971
|
+
if (gapAB_Y <= 0) return emptyResult();
|
|
5972
|
+
const vpairH = gapAB_Y + pB.height;
|
|
5973
|
+
const vpairW = Math.max(pA.width, pB.width);
|
|
5974
|
+
const stepXAA = findMinStepX(pA, pA, 0);
|
|
5975
|
+
const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
|
|
5976
|
+
const stepXBA = findMinStepX(pB, pA, gapAB_Y);
|
|
5977
|
+
const stepXBB = findMinStepX(pB, pB, 0);
|
|
5978
|
+
const vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
|
|
5979
|
+
if (vpairStepX <= 0) return emptyResult();
|
|
5980
|
+
let vpairStepY = 0;
|
|
5981
|
+
{
|
|
5982
|
+
const reach = Math.max(pA.width, pB.width);
|
|
5983
|
+
const nMin = Math.floor(-reach / vpairStepX) - 1;
|
|
5984
|
+
const nMax = Math.ceil(reach / vpairStepX) + 1;
|
|
5985
|
+
for (let n = nMin; n <= nMax; n++) {
|
|
5986
|
+
const dx = n * vpairStepX;
|
|
5987
|
+
const sAA = findMinStepY(pA, pA, dx);
|
|
5988
|
+
if (sAA > vpairStepY) vpairStepY = sAA;
|
|
5989
|
+
const sAB = findMinStepY(pA, pB, dx) - gapAB_Y;
|
|
5990
|
+
if (sAB > vpairStepY) vpairStepY = sAB;
|
|
5991
|
+
const sBA = findMinStepY(pB, pA, dx) + gapAB_Y;
|
|
5992
|
+
if (sBA > vpairStepY) vpairStepY = sBA;
|
|
5993
|
+
const sBB = findMinStepY(pB, pB, dx);
|
|
5994
|
+
if (sBB > vpairStepY) vpairStepY = sBB;
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5997
|
+
if (vpairStepY <= 0) return emptyResult();
|
|
5998
|
+
const usableW = bounds.right - bounds.left;
|
|
5999
|
+
const usableH = bounds.bottom - bounds.top;
|
|
6000
|
+
const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
|
|
6001
|
+
const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
|
|
6002
|
+
if (cols === 0 || rows === 0) return emptyResult();
|
|
4507
6003
|
const placements = [];
|
|
4508
6004
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4509
|
-
let
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
placements.push({ x:
|
|
4520
|
-
if (
|
|
4521
|
-
if (oy < minY) minY = oy;
|
|
4522
|
-
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
4523
|
-
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
6005
|
+
for (let r = 0; r < rows; r++) {
|
|
6006
|
+
for (let c = 0; c < cols; c++) {
|
|
6007
|
+
const baseX = bounds.left + c * vpairStepX;
|
|
6008
|
+
const baseY = bounds.top + r * vpairStepY;
|
|
6009
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
6010
|
+
if (baseX < minX) minX = baseX;
|
|
6011
|
+
if (baseY < minY) minY = baseY;
|
|
6012
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
6013
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
6014
|
+
const by = baseY + gapAB_Y;
|
|
6015
|
+
placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
6016
|
+
if (by + pB.height > maxY) maxY = by + pB.height;
|
|
4524
6017
|
}
|
|
4525
|
-
oy += isRowA ? stepY_AB : stepY_BA;
|
|
4526
|
-
isRowA = !isRowA;
|
|
4527
6018
|
}
|
|
4528
|
-
if (placements.length === 0) return emptyResult();
|
|
4529
6019
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4530
6020
|
}
|
|
4531
|
-
function
|
|
4532
|
-
if (result.count === 0) return;
|
|
4533
|
-
const offX = (bounds.right - bounds.left - (result.maxX - result.minX)) / 2 - (result.minX - bounds.left);
|
|
4534
|
-
const offY = (bounds.bottom - bounds.top - (result.maxY - result.minY)) / 2 - (result.minY - bounds.top);
|
|
4535
|
-
for (const p of result.placements) {
|
|
4536
|
-
p.x += offX;
|
|
4537
|
-
p.y += offY;
|
|
4538
|
-
}
|
|
4539
|
-
}
|
|
4540
|
-
function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
6021
|
+
function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4541
6022
|
const rots = [0, 90, 180, 270];
|
|
4542
6023
|
const rd = /* @__PURE__ */ new Map();
|
|
4543
6024
|
for (const deg of rots) {
|
|
4544
|
-
rd.set(deg,
|
|
6025
|
+
rd.set(deg, prepareRotation3(contourPoints, dielineW, dielineH, deg));
|
|
4545
6026
|
}
|
|
4546
6027
|
const results = [];
|
|
4547
6028
|
for (const deg of rots) {
|
|
4548
6029
|
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
4549
6030
|
}
|
|
4550
|
-
const
|
|
6031
|
+
const allPairs = [
|
|
4551
6032
|
[0, 180],
|
|
4552
6033
|
[90, 270],
|
|
4553
6034
|
[0, 90],
|
|
@@ -4555,7 +6036,7 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
4555
6036
|
[90, 180],
|
|
4556
6037
|
[180, 270]
|
|
4557
6038
|
];
|
|
4558
|
-
for (const [a, b] of
|
|
6039
|
+
for (const [a, b] of allPairs) {
|
|
4559
6040
|
const rdA = rd.get(a), rdB = rd.get(b);
|
|
4560
6041
|
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
4561
6042
|
if (stepA <= 0) continue;
|
|
@@ -4564,10 +6045,40 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
4564
6045
|
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
4565
6046
|
}
|
|
4566
6047
|
}
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
}
|
|
6048
|
+
for (const [a, b] of allPairs) {
|
|
6049
|
+
results.push(pairGrid2(rd.get(a), rd.get(b), bounds));
|
|
6050
|
+
results.push(pairGrid2(rd.get(b), rd.get(a), bounds));
|
|
6051
|
+
}
|
|
6052
|
+
for (const [a, b] of allPairs) {
|
|
6053
|
+
results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
|
|
6054
|
+
results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
|
|
6055
|
+
}
|
|
6056
|
+
const singleResults = [];
|
|
6057
|
+
const multiResults = [];
|
|
6058
|
+
for (const r of results) {
|
|
6059
|
+
if (r.count === 0) continue;
|
|
6060
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
6061
|
+
if (rotations.size > 1) {
|
|
6062
|
+
multiResults.push(r);
|
|
6063
|
+
} else {
|
|
6064
|
+
singleResults.push(r);
|
|
6065
|
+
}
|
|
6066
|
+
}
|
|
6067
|
+
function pickBest(arr) {
|
|
6068
|
+
let b = arr[0] ?? emptyResult();
|
|
6069
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
6070
|
+
for (const r of arr) {
|
|
6071
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
6072
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
6073
|
+
b = r;
|
|
6074
|
+
bArea = area;
|
|
6075
|
+
}
|
|
6076
|
+
}
|
|
6077
|
+
return b;
|
|
6078
|
+
}
|
|
6079
|
+
const bestSingle = pickBest(singleResults);
|
|
6080
|
+
const bestMulti = pickBest(multiResults);
|
|
6081
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
4571
6082
|
centerLayout(best, bounds);
|
|
4572
6083
|
return {
|
|
4573
6084
|
rotation: best.placements[0]?.rotation ?? 0,
|
|
@@ -4576,8 +6087,8 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
4576
6087
|
};
|
|
4577
6088
|
}
|
|
4578
6089
|
|
|
4579
|
-
// src/utils/autoLayout/calculate/
|
|
4580
|
-
function
|
|
6090
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-12101/index.ts
|
|
6091
|
+
function prepareRotation4(contourPoints, dielineW, dielineH, deg) {
|
|
4581
6092
|
const rotated = normalizePoints(contourPoints, deg);
|
|
4582
6093
|
return {
|
|
4583
6094
|
profile: buildProfile(rotated),
|
|
@@ -4585,7 +6096,7 @@ function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
|
|
|
4585
6096
|
deg
|
|
4586
6097
|
};
|
|
4587
6098
|
}
|
|
4588
|
-
function
|
|
6099
|
+
function pairGrid3(rdA, rdB, bounds) {
|
|
4589
6100
|
const pA = rdA.profile, pB = rdB.profile;
|
|
4590
6101
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
4591
6102
|
if (gapAB <= 0) return emptyResult();
|
|
@@ -4661,11 +6172,11 @@ function pairGrid(rdA, rdB, bounds) {
|
|
|
4661
6172
|
}
|
|
4662
6173
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4663
6174
|
}
|
|
4664
|
-
function
|
|
6175
|
+
function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4665
6176
|
const rots = [0, 90, 180, 270];
|
|
4666
6177
|
const rd = /* @__PURE__ */ new Map();
|
|
4667
6178
|
for (const deg of rots) {
|
|
4668
|
-
rd.set(deg,
|
|
6179
|
+
rd.set(deg, prepareRotation4(contourPoints, dielineW, dielineH, deg));
|
|
4669
6180
|
}
|
|
4670
6181
|
const results = [];
|
|
4671
6182
|
for (const deg of rots) {
|
|
@@ -4689,8 +6200,8 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
4689
6200
|
}
|
|
4690
6201
|
}
|
|
4691
6202
|
for (const [a, b] of allPairs) {
|
|
4692
|
-
results.push(
|
|
4693
|
-
results.push(
|
|
6203
|
+
results.push(pairGrid3(rd.get(a), rd.get(b), bounds));
|
|
6204
|
+
results.push(pairGrid3(rd.get(b), rd.get(a), bounds));
|
|
4694
6205
|
}
|
|
4695
6206
|
const singleResults = [];
|
|
4696
6207
|
const multiResults = [];
|
|
@@ -4726,8 +6237,8 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
4726
6237
|
};
|
|
4727
6238
|
}
|
|
4728
6239
|
|
|
4729
|
-
// src/utils/autoLayout/calculate/
|
|
4730
|
-
function
|
|
6240
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-12109/index.ts
|
|
6241
|
+
function prepareRotation5(contourPoints, dielineW, dielineH, deg) {
|
|
4731
6242
|
const rotated = normalizePoints(contourPoints, deg);
|
|
4732
6243
|
return {
|
|
4733
6244
|
profile: buildProfile(rotated),
|
|
@@ -4735,34 +6246,20 @@ function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
|
|
|
4735
6246
|
deg
|
|
4736
6247
|
};
|
|
4737
6248
|
}
|
|
4738
|
-
function
|
|
4739
|
-
const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
|
|
4740
|
-
const nMin = Math.floor(-reach / pairStepX) - 1;
|
|
4741
|
-
const nMax = Math.ceil(reach / pairStepX) + 1;
|
|
4742
|
-
let maxStep = 0;
|
|
4743
|
-
for (let n = nMin; n <= nMax; n++) {
|
|
4744
|
-
const dx = n * pairStepX;
|
|
4745
|
-
const s1 = findMinStepY(pA, pA, dx);
|
|
4746
|
-
if (s1 > maxStep) maxStep = s1;
|
|
4747
|
-
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
4748
|
-
if (s2 > maxStep) maxStep = s2;
|
|
4749
|
-
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
4750
|
-
if (s3 > maxStep) maxStep = s3;
|
|
4751
|
-
const s4 = findMinStepY(pB, pB, dx);
|
|
4752
|
-
if (s4 > maxStep) maxStep = s4;
|
|
4753
|
-
}
|
|
4754
|
-
return maxStep;
|
|
4755
|
-
}
|
|
4756
|
-
function pairGrid2(rdA, rdB, bounds) {
|
|
6249
|
+
function pairGrid4(rdA, rdB, bounds) {
|
|
4757
6250
|
const pA = rdA.profile, pB = rdB.profile;
|
|
4758
6251
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
4759
6252
|
if (gapAB <= 0) return emptyResult();
|
|
4760
6253
|
const pairW = gapAB + pB.width;
|
|
4761
6254
|
const pairH = Math.max(pA.height, pB.height);
|
|
4762
6255
|
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
6256
|
+
const pairStepY = Math.max(
|
|
6257
|
+
findMinStepY(pA, pA, 0),
|
|
6258
|
+
findMinStepY(pA, pB, gapAB),
|
|
6259
|
+
findMinStepY(pB, pA, -gapAB),
|
|
6260
|
+
findMinStepY(pB, pB, 0)
|
|
6261
|
+
);
|
|
6262
|
+
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
4766
6263
|
const usableW = bounds.right - bounds.left;
|
|
4767
6264
|
const usableH = bounds.bottom - bounds.top;
|
|
4768
6265
|
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
@@ -4774,115 +6271,62 @@ function pairGrid2(rdA, rdB, bounds) {
|
|
|
4774
6271
|
for (let c = 0; c < pairCols; c++) {
|
|
4775
6272
|
const baseX = bounds.left + c * pairStepX;
|
|
4776
6273
|
const baseY = bounds.top + r * pairStepY;
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
if (
|
|
4781
|
-
if (
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
6274
|
+
const oxA = baseX;
|
|
6275
|
+
const oyA = baseY;
|
|
6276
|
+
placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
6277
|
+
if (oxA < minX) minX = oxA;
|
|
6278
|
+
if (oyA < minY) minY = oyA;
|
|
6279
|
+
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
6280
|
+
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
6281
|
+
const oxB = baseX + gapAB;
|
|
6282
|
+
const oyB = baseY;
|
|
6283
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
6284
|
+
if (oxB < minX) minX = oxB;
|
|
6285
|
+
if (oyB < minY) minY = oyB;
|
|
6286
|
+
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
6287
|
+
if (oyB + pB.height > maxY) maxY = oyB + pB.height;
|
|
4787
6288
|
}
|
|
4788
6289
|
}
|
|
4789
6290
|
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
6291
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
4790
6292
|
const gapRight = bounds.right - pairsRightEdge;
|
|
4791
|
-
|
|
6293
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
6294
|
+
const extraRotations = [rdA, rdB];
|
|
6295
|
+
for (const rdExtra of extraRotations) {
|
|
4792
6296
|
const pe = rdExtra.profile;
|
|
4793
|
-
if (pe.width
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
if (extraStepY <= 0) continue;
|
|
4802
|
-
const effectiveStepY = Math.max(pairStepY, extraStepY);
|
|
4803
|
-
const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
|
|
4804
|
-
for (let r = 0; r < extraRows; r++) {
|
|
4805
|
-
const ox = pairsRightEdge;
|
|
4806
|
-
const oy = bounds.top + r * effectiveStepY;
|
|
4807
|
-
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4808
|
-
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4809
|
-
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
4810
|
-
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
6297
|
+
if (pe.width <= gapRight) {
|
|
6298
|
+
for (let r = 0; r < pairRows; r++) {
|
|
6299
|
+
const ox = pairsRightEdge;
|
|
6300
|
+
const oy = bounds.top + r * pairStepY;
|
|
6301
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
6302
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
6303
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
6304
|
+
}
|
|
4811
6305
|
}
|
|
6306
|
+
break;
|
|
4812
6307
|
}
|
|
4813
|
-
break;
|
|
4814
6308
|
}
|
|
4815
|
-
const
|
|
4816
|
-
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
4817
|
-
for (const rdExtra of [rdA, rdB]) {
|
|
6309
|
+
for (const rdExtra of extraRotations) {
|
|
4818
6310
|
const pe = rdExtra.profile;
|
|
4819
|
-
if (pe.height
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
for (let c = 0; c < extraCols; c++) {
|
|
4828
|
-
const ox = bounds.left + c * extraStepX;
|
|
4829
|
-
const oy = pairsBottomEdge;
|
|
4830
|
-
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4831
|
-
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4832
|
-
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
4833
|
-
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
6311
|
+
if (pe.height <= gapBottom) {
|
|
6312
|
+
for (let c = 0; c < pairCols; c++) {
|
|
6313
|
+
const oxA = bounds.left + c * pairStepX;
|
|
6314
|
+
const oy = pairsBottomEdge;
|
|
6315
|
+
if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
6316
|
+
placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
6317
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
6318
|
+
}
|
|
4834
6319
|
}
|
|
4835
|
-
|
|
4836
|
-
break;
|
|
4837
|
-
}
|
|
4838
|
-
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4839
|
-
}
|
|
4840
|
-
function verticalPairGrid(rdA, rdB, bounds) {
|
|
4841
|
-
const pA = rdA.profile, pB = rdB.profile;
|
|
4842
|
-
const gapAB_Y = findMinStepY(pA, pB, 0);
|
|
4843
|
-
if (gapAB_Y <= 0) return emptyResult();
|
|
4844
|
-
const vpairH = gapAB_Y + pB.height;
|
|
4845
|
-
const vpairW = Math.max(pA.width, pB.width);
|
|
4846
|
-
Math.max(pA.height, pB.height) + Math.abs(gapAB_Y);
|
|
4847
|
-
let vpairStepX = 0;
|
|
4848
|
-
{
|
|
4849
|
-
const stepXAA = findMinStepX(pA, pA, 0);
|
|
4850
|
-
const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
|
|
4851
|
-
const stepXBA = findMinStepX(pB, pA, gapAB_Y);
|
|
4852
|
-
const stepXBB = findMinStepX(pB, pB, 0);
|
|
4853
|
-
vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
|
|
4854
|
-
}
|
|
4855
|
-
if (vpairStepX <= 0) return emptyResult();
|
|
4856
|
-
const vpairStepY = gapAB_Y + findMinStepY(pB, pA, 0);
|
|
4857
|
-
if (vpairStepY <= 0) return emptyResult();
|
|
4858
|
-
const usableW = bounds.right - bounds.left;
|
|
4859
|
-
const usableH = bounds.bottom - bounds.top;
|
|
4860
|
-
const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
|
|
4861
|
-
const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
|
|
4862
|
-
if (cols === 0 || rows === 0) return emptyResult();
|
|
4863
|
-
const placements = [];
|
|
4864
|
-
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4865
|
-
for (let r = 0; r < rows; r++) {
|
|
4866
|
-
for (let c = 0; c < cols; c++) {
|
|
4867
|
-
const baseX = bounds.left + c * vpairStepX;
|
|
4868
|
-
const baseY = bounds.top + r * vpairStepY;
|
|
4869
|
-
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
4870
|
-
if (baseX < minX) minX = baseX;
|
|
4871
|
-
if (baseY < minY) minY = baseY;
|
|
4872
|
-
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
4873
|
-
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
4874
|
-
const by = baseY + gapAB_Y;
|
|
4875
|
-
placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
4876
|
-
if (by + pB.height > maxY) maxY = by + pB.height;
|
|
6320
|
+
break;
|
|
4877
6321
|
}
|
|
4878
6322
|
}
|
|
4879
6323
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4880
6324
|
}
|
|
4881
|
-
function
|
|
6325
|
+
function computeLayoutForPaper5(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4882
6326
|
const rots = [0, 90, 180, 270];
|
|
4883
6327
|
const rd = /* @__PURE__ */ new Map();
|
|
4884
6328
|
for (const deg of rots) {
|
|
4885
|
-
rd.set(deg,
|
|
6329
|
+
rd.set(deg, prepareRotation5(contourPoints, dielineW, dielineH, deg));
|
|
4886
6330
|
}
|
|
4887
6331
|
const results = [];
|
|
4888
6332
|
for (const deg of rots) {
|
|
@@ -4906,12 +6350,8 @@ function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
4906
6350
|
}
|
|
4907
6351
|
}
|
|
4908
6352
|
for (const [a, b] of allPairs) {
|
|
4909
|
-
results.push(
|
|
4910
|
-
results.push(
|
|
4911
|
-
}
|
|
4912
|
-
for (const [a, b] of allPairs) {
|
|
4913
|
-
results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
|
|
4914
|
-
results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
|
|
6353
|
+
results.push(pairGrid4(rd.get(a), rd.get(b), bounds));
|
|
6354
|
+
results.push(pairGrid4(rd.get(b), rd.get(a), bounds));
|
|
4915
6355
|
}
|
|
4916
6356
|
const singleResults = [];
|
|
4917
6357
|
const multiResults = [];
|
|
@@ -4947,8 +6387,8 @@ function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
4947
6387
|
};
|
|
4948
6388
|
}
|
|
4949
6389
|
|
|
4950
|
-
// src/utils/autoLayout/calculate/bags-pillows/becf-12101/index.ts
|
|
4951
|
-
function
|
|
6390
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-c-12101/index.ts
|
|
6391
|
+
function prepareRotation6(contourPoints, dielineW, dielineH, deg) {
|
|
4952
6392
|
const rotated = normalizePoints(contourPoints, deg);
|
|
4953
6393
|
return {
|
|
4954
6394
|
profile: buildProfile(rotated),
|
|
@@ -4956,7 +6396,7 @@ function prepareRotation4(contourPoints, dielineW, dielineH, deg) {
|
|
|
4956
6396
|
deg
|
|
4957
6397
|
};
|
|
4958
6398
|
}
|
|
4959
|
-
function
|
|
6399
|
+
function pairGrid5(rdA, rdB, bounds) {
|
|
4960
6400
|
const pA = rdA.profile, pB = rdB.profile;
|
|
4961
6401
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
4962
6402
|
if (gapAB <= 0) return emptyResult();
|
|
@@ -5032,11 +6472,11 @@ function pairGrid3(rdA, rdB, bounds) {
|
|
|
5032
6472
|
}
|
|
5033
6473
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5034
6474
|
}
|
|
5035
|
-
function
|
|
6475
|
+
function computeLayoutForPaper6(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
5036
6476
|
const rots = [0, 90, 180, 270];
|
|
5037
6477
|
const rd = /* @__PURE__ */ new Map();
|
|
5038
6478
|
for (const deg of rots) {
|
|
5039
|
-
rd.set(deg,
|
|
6479
|
+
rd.set(deg, prepareRotation6(contourPoints, dielineW, dielineH, deg));
|
|
5040
6480
|
}
|
|
5041
6481
|
const results = [];
|
|
5042
6482
|
for (const deg of rots) {
|
|
@@ -5060,8 +6500,8 @@ function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
5060
6500
|
}
|
|
5061
6501
|
}
|
|
5062
6502
|
for (const [a, b] of allPairs) {
|
|
5063
|
-
results.push(
|
|
5064
|
-
results.push(
|
|
6503
|
+
results.push(pairGrid5(rd.get(a), rd.get(b), bounds));
|
|
6504
|
+
results.push(pairGrid5(rd.get(b), rd.get(a), bounds));
|
|
5065
6505
|
}
|
|
5066
6506
|
const singleResults = [];
|
|
5067
6507
|
const multiResults = [];
|
|
@@ -5097,8 +6537,8 @@ function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
5097
6537
|
};
|
|
5098
6538
|
}
|
|
5099
6539
|
|
|
5100
|
-
// src/utils/autoLayout/calculate/bags-pillows/becf-12109/index.ts
|
|
5101
|
-
function
|
|
6540
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-c-12109/index.ts
|
|
6541
|
+
function prepareRotation7(contourPoints, dielineW, dielineH, deg) {
|
|
5102
6542
|
const rotated = normalizePoints(contourPoints, deg);
|
|
5103
6543
|
return {
|
|
5104
6544
|
profile: buildProfile(rotated),
|
|
@@ -5106,7 +6546,7 @@ function prepareRotation5(contourPoints, dielineW, dielineH, deg) {
|
|
|
5106
6546
|
deg
|
|
5107
6547
|
};
|
|
5108
6548
|
}
|
|
5109
|
-
function
|
|
6549
|
+
function pairGrid6(rdA, rdB, bounds) {
|
|
5110
6550
|
const pA = rdA.profile, pB = rdB.profile;
|
|
5111
6551
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
5112
6552
|
if (gapAB <= 0) return emptyResult();
|
|
@@ -5182,11 +6622,11 @@ function pairGrid4(rdA, rdB, bounds) {
|
|
|
5182
6622
|
}
|
|
5183
6623
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5184
6624
|
}
|
|
5185
|
-
function
|
|
6625
|
+
function computeLayoutForPaper7(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
5186
6626
|
const rots = [0, 90, 180, 270];
|
|
5187
6627
|
const rd = /* @__PURE__ */ new Map();
|
|
5188
6628
|
for (const deg of rots) {
|
|
5189
|
-
rd.set(deg,
|
|
6629
|
+
rd.set(deg, prepareRotation7(contourPoints, dielineW, dielineH, deg));
|
|
5190
6630
|
}
|
|
5191
6631
|
const results = [];
|
|
5192
6632
|
for (const deg of rots) {
|
|
@@ -5210,8 +6650,8 @@ function computeLayoutForPaper5(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
5210
6650
|
}
|
|
5211
6651
|
}
|
|
5212
6652
|
for (const [a, b] of allPairs) {
|
|
5213
|
-
results.push(
|
|
5214
|
-
results.push(
|
|
6653
|
+
results.push(pairGrid6(rd.get(a), rd.get(b), bounds));
|
|
6654
|
+
results.push(pairGrid6(rd.get(b), rd.get(a), bounds));
|
|
5215
6655
|
}
|
|
5216
6656
|
const singleResults = [];
|
|
5217
6657
|
const multiResults = [];
|
|
@@ -5290,6 +6730,22 @@ function resolveModelFunctions(modelId, attrs) {
|
|
|
5290
6730
|
offsetContour: offsetContour6
|
|
5291
6731
|
};
|
|
5292
6732
|
}
|
|
6733
|
+
case "BECF-C-12101": {
|
|
6734
|
+
const a = attrs;
|
|
6735
|
+
return {
|
|
6736
|
+
contour: generateOuterContour7(a),
|
|
6737
|
+
dieline: generateBecfC12101(a),
|
|
6738
|
+
offsetContour: offsetContour7
|
|
6739
|
+
};
|
|
6740
|
+
}
|
|
6741
|
+
case "BECF-C-12109": {
|
|
6742
|
+
const a = attrs;
|
|
6743
|
+
return {
|
|
6744
|
+
contour: generateOuterContour8(a),
|
|
6745
|
+
dieline: generateBecfC12109(a),
|
|
6746
|
+
offsetContour: offsetContour8
|
|
6747
|
+
};
|
|
6748
|
+
}
|
|
5293
6749
|
case "BECF-1010A":
|
|
5294
6750
|
default: {
|
|
5295
6751
|
const a = attrs;
|
|
@@ -5313,6 +6769,10 @@ function resolveLayoutCalculator(modelId) {
|
|
|
5313
6769
|
return computeLayoutForPaper4;
|
|
5314
6770
|
case "BECF-12109":
|
|
5315
6771
|
return computeLayoutForPaper5;
|
|
6772
|
+
case "BECF-C-12101":
|
|
6773
|
+
return computeLayoutForPaper6;
|
|
6774
|
+
case "BECF-C-12109":
|
|
6775
|
+
return computeLayoutForPaper7;
|
|
5316
6776
|
default:
|
|
5317
6777
|
return computeLayoutForPaperDefault;
|
|
5318
6778
|
}
|
|
@@ -5326,11 +6786,11 @@ function calculateAutoLayout(rawConfig) {
|
|
|
5326
6786
|
colorbarHeight: rawConfig.colorbarHeight ?? 5,
|
|
5327
6787
|
isShowColorbar: rawConfig.isShowColorbar ?? true
|
|
5328
6788
|
};
|
|
5329
|
-
const { contour, dieline, offsetContour:
|
|
6789
|
+
const { contour, dieline, offsetContour: offsetContour9 } = resolveModelFunctions(
|
|
5330
6790
|
config.model.modelId,
|
|
5331
6791
|
config.model.attributes
|
|
5332
6792
|
);
|
|
5333
|
-
const offsetContourPoints = config.layoutDistance > 0 ?
|
|
6793
|
+
const offsetContourPoints = config.layoutDistance > 0 ? offsetContour9(contour, config.layoutDistance / 2) : contour;
|
|
5334
6794
|
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
5335
6795
|
const computeLayout = resolveLayoutCalculator(config.model.modelId);
|
|
5336
6796
|
const paperResults = [];
|
|
@@ -6281,6 +7741,28 @@ function resolveModel(modelId, attrs, layoutDistance) {
|
|
|
6281
7741
|
generateContour: (a) => generateOuterContour6(a)
|
|
6282
7742
|
};
|
|
6283
7743
|
}
|
|
7744
|
+
case "BECF-C-12101": {
|
|
7745
|
+
const typedAttrs = attrs;
|
|
7746
|
+
const contour = generateOuterContour7(typedAttrs);
|
|
7747
|
+
return {
|
|
7748
|
+
dieline: generateBecfC12101(typedAttrs),
|
|
7749
|
+
contourPath: contourToPath7(contour),
|
|
7750
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour7(contour, layoutDistance / 2) : contour,
|
|
7751
|
+
generate: (a) => generateBecfC12101(a),
|
|
7752
|
+
generateContour: (a) => generateOuterContour7(a)
|
|
7753
|
+
};
|
|
7754
|
+
}
|
|
7755
|
+
case "BECF-C-12109": {
|
|
7756
|
+
const typedAttrs = attrs;
|
|
7757
|
+
const contour = generateOuterContour8(typedAttrs);
|
|
7758
|
+
return {
|
|
7759
|
+
dieline: generateBecfC12109(typedAttrs),
|
|
7760
|
+
contourPath: contourToPath8(contour),
|
|
7761
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour8(contour, layoutDistance / 2) : contour,
|
|
7762
|
+
generate: (a) => generateBecfC12109(a),
|
|
7763
|
+
generateContour: (a) => generateOuterContour8(a)
|
|
7764
|
+
};
|
|
7765
|
+
}
|
|
6284
7766
|
case "BECF-1010A":
|
|
6285
7767
|
default: {
|
|
6286
7768
|
const typedAttrs = attrs;
|
|
@@ -6338,6 +7820,22 @@ function renderDieLine2(modelId, attrs) {
|
|
|
6338
7820
|
renderAs: "group"
|
|
6339
7821
|
}
|
|
6340
7822
|
);
|
|
7823
|
+
case "BECF-C-12101":
|
|
7824
|
+
return /* @__PURE__ */ jsx(
|
|
7825
|
+
DIE_LINE_BECF_C_12101,
|
|
7826
|
+
{
|
|
7827
|
+
attributes: attrs,
|
|
7828
|
+
renderAs: "group"
|
|
7829
|
+
}
|
|
7830
|
+
);
|
|
7831
|
+
case "BECF-C-12109":
|
|
7832
|
+
return /* @__PURE__ */ jsx(
|
|
7833
|
+
DIE_LINE_BECF_C_12109,
|
|
7834
|
+
{
|
|
7835
|
+
attributes: attrs,
|
|
7836
|
+
renderAs: "group"
|
|
7837
|
+
}
|
|
7838
|
+
);
|
|
6341
7839
|
case "BECF-1010A":
|
|
6342
7840
|
default:
|
|
6343
7841
|
return /* @__PURE__ */ jsx(
|
|
@@ -6351,7 +7849,7 @@ function renderDieLine2(modelId, attrs) {
|
|
|
6351
7849
|
})();
|
|
6352
7850
|
}
|
|
6353
7851
|
var PAPER_GAP = 20;
|
|
6354
|
-
var
|
|
7852
|
+
var PX_PER_MM9 = 96 / 25.4;
|
|
6355
7853
|
var RESULT_PANEL_HEIGHT = 55;
|
|
6356
7854
|
var RESULT_GAP = 5;
|
|
6357
7855
|
function getOpposite2(side) {
|
|
@@ -6528,8 +8026,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
6528
8026
|
const svg = document.createElementNS(svgNs, "svg");
|
|
6529
8027
|
svg.setAttribute("xmlns", svgNs);
|
|
6530
8028
|
svg.setAttribute("viewBox", `0 0 ${vw} ${vh}`);
|
|
6531
|
-
svg.setAttribute("width", String(Math.round(vw *
|
|
6532
|
-
svg.setAttribute("height", String(Math.round(vh *
|
|
8029
|
+
svg.setAttribute("width", String(Math.round(vw * PX_PER_MM9)));
|
|
8030
|
+
svg.setAttribute("height", String(Math.round(vh * PX_PER_MM9)));
|
|
6533
8031
|
const bg = document.createElementNS(svgNs, "rect");
|
|
6534
8032
|
bg.setAttribute("width", String(vw));
|
|
6535
8033
|
bg.setAttribute("height", String(vh));
|
|
@@ -6562,8 +8060,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
6562
8060
|
img.src = url;
|
|
6563
8061
|
});
|
|
6564
8062
|
const canvas = document.createElement("canvas");
|
|
6565
|
-
canvas.width = Math.round(vw *
|
|
6566
|
-
canvas.height = Math.round(vh *
|
|
8063
|
+
canvas.width = Math.round(vw * PX_PER_MM9);
|
|
8064
|
+
canvas.height = Math.round(vh * PX_PER_MM9);
|
|
6567
8065
|
const ctx = canvas.getContext("2d");
|
|
6568
8066
|
ctx.fillStyle = "#ffffff";
|
|
6569
8067
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -6587,8 +8085,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
6587
8085
|
const svg = document.createElementNS(svgNs, "svg");
|
|
6588
8086
|
svg.setAttribute("xmlns", svgNs);
|
|
6589
8087
|
svg.setAttribute("viewBox", `0 0 ${paperResult.paperWidth} ${paperResult.paperHeight}`);
|
|
6590
|
-
svg.setAttribute("width", String(Math.round(paperResult.paperWidth *
|
|
6591
|
-
svg.setAttribute("height", String(Math.round(paperResult.paperHeight *
|
|
8088
|
+
svg.setAttribute("width", String(Math.round(paperResult.paperWidth * PX_PER_MM9)));
|
|
8089
|
+
svg.setAttribute("height", String(Math.round(paperResult.paperHeight * PX_PER_MM9)));
|
|
6592
8090
|
const bg = document.createElementNS(svgNs, "rect");
|
|
6593
8091
|
bg.setAttribute("width", String(paperResult.paperWidth));
|
|
6594
8092
|
bg.setAttribute("height", String(paperResult.paperHeight));
|
|
@@ -6692,8 +8190,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
6692
8190
|
img.src = url;
|
|
6693
8191
|
});
|
|
6694
8192
|
const canvas = document.createElement("canvas");
|
|
6695
|
-
canvas.width = Math.round(paperResult.paperWidth *
|
|
6696
|
-
canvas.height = Math.round(paperResult.paperHeight *
|
|
8193
|
+
canvas.width = Math.round(paperResult.paperWidth * PX_PER_MM9);
|
|
8194
|
+
canvas.height = Math.round(paperResult.paperHeight * PX_PER_MM9);
|
|
6697
8195
|
const ctx = canvas.getContext("2d");
|
|
6698
8196
|
ctx.fillStyle = theme.colorPaperFill;
|
|
6699
8197
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -7254,6 +8752,22 @@ var BECF_12109_DEFAULT_ATTRIBUTES = {
|
|
|
7254
8752
|
glueArea: 13
|
|
7255
8753
|
};
|
|
7256
8754
|
|
|
8755
|
+
// src/statics/bags-pillows/becf-c-12101/DEFAULT_ATTRIBUTES.ts
|
|
8756
|
+
var BECF_C_12101_DEFAULT_ATTRIBUTES = {
|
|
8757
|
+
length: 100,
|
|
8758
|
+
width: 50,
|
|
8759
|
+
height: 150,
|
|
8760
|
+
glueArea: 13
|
|
8761
|
+
};
|
|
8762
|
+
|
|
8763
|
+
// src/statics/bags-pillows/becf-c-12109/DEFAULT_ATTRIBUTES.ts
|
|
8764
|
+
var BECF_C_12109_DEFAULT_ATTRIBUTES = {
|
|
8765
|
+
length: 100,
|
|
8766
|
+
width: 50,
|
|
8767
|
+
height: 150,
|
|
8768
|
+
glueArea: 13
|
|
8769
|
+
};
|
|
8770
|
+
|
|
7257
8771
|
// src/statics/modelList.ts
|
|
7258
8772
|
var modelList = [
|
|
7259
8773
|
{
|
|
@@ -7293,10 +8807,24 @@ var modelList = [
|
|
|
7293
8807
|
},
|
|
7294
8808
|
{
|
|
7295
8809
|
id: "BECF-12109",
|
|
7296
|
-
nameEN: "SHOPPING BAGS TYPE
|
|
7297
|
-
nameTH: "\u0E16\u0E38\u0E07\u0E23\u0E49\u0E2D\u0E22\u0E40\u0E0A\u0E37\u0E2D\u0E01\u0E40\u0E1B\u0E35\u0E22 \u0E21\u0E31\u0E14\u0E1B\u0E21
|
|
8810
|
+
nameEN: "SHOPPING BAGS TYPE A1",
|
|
8811
|
+
nameTH: "\u0E16\u0E38\u0E07\u0E23\u0E49\u0E2D\u0E22\u0E40\u0E0A\u0E37\u0E2D\u0E01\u0E40\u0E1B\u0E35\u0E22 \u0E21\u0E31\u0E14\u0E1B\u0E21 A1",
|
|
7298
8812
|
dimension: ["DIE_LINE"],
|
|
7299
8813
|
attributes: { ...BECF_12109_DEFAULT_ATTRIBUTES }
|
|
8814
|
+
},
|
|
8815
|
+
{
|
|
8816
|
+
id: "BECF-C-12101",
|
|
8817
|
+
nameEN: "SHOPPING BAGS TYPE C",
|
|
8818
|
+
nameTH: "\u0E16\u0E38\u0E07\u0E2B\u0E39\u0E23\u0E34\u0E1A\u0E1A\u0E34\u0E49\u0E19 C",
|
|
8819
|
+
dimension: ["DIE_LINE"],
|
|
8820
|
+
attributes: { ...BECF_C_12101_DEFAULT_ATTRIBUTES }
|
|
8821
|
+
},
|
|
8822
|
+
{
|
|
8823
|
+
id: "BECF-C-12109",
|
|
8824
|
+
nameEN: "SHOPPING BAGS TYPE C1",
|
|
8825
|
+
nameTH: "\u0E16\u0E38\u0E07\u0E2B\u0E39\u0E23\u0E34\u0E1A\u0E1A\u0E34\u0E49\u0E19 C1",
|
|
8826
|
+
dimension: ["DIE_LINE"],
|
|
8827
|
+
attributes: { ...BECF_C_12109_DEFAULT_ATTRIBUTES }
|
|
7300
8828
|
}
|
|
7301
8829
|
];
|
|
7302
8830
|
|
|
@@ -7309,6 +8837,6 @@ var BECF_11D01_DEFAULT_ATTRIBUTES = {
|
|
|
7309
8837
|
glueArea: 13
|
|
7310
8838
|
};
|
|
7311
8839
|
|
|
7312
|
-
export { AUTO_LAYOUT, AUTO_LAYOUT_THEME_CONFIG, BECF_1010A_DEFAULT_ATTRIBUTES, BECF_1030A_DEFAULT_ATTRIBUTES, BECF_1040A_DEFAULT_ATTRIBUTES, BECF_11D01_DEFAULT_ATTRIBUTES, BECF_12101_DEFAULT_ATTRIBUTES, BECF_12109_DEFAULT_ATTRIBUTES, Colorbar, DIE_LINE_LAYOUT, Gripper, MODEL_BECF_1010A, MODEL_BECF_1030A, MODEL_BECF_1040A, MODEL_BECF_11D01, MODEL_BECF_12101, MODEL_BECF_12109, MODEL_THEME_CONFIG, appendColorbarToSvg, appendGripperToSvg, calculateAutoLayout, configurePackaging, modelList };
|
|
8840
|
+
export { AUTO_LAYOUT, AUTO_LAYOUT_THEME_CONFIG, BECF_1010A_DEFAULT_ATTRIBUTES, BECF_1030A_DEFAULT_ATTRIBUTES, BECF_1040A_DEFAULT_ATTRIBUTES, BECF_11D01_DEFAULT_ATTRIBUTES, BECF_12101_DEFAULT_ATTRIBUTES, BECF_12109_DEFAULT_ATTRIBUTES, BECF_C_12101_DEFAULT_ATTRIBUTES, BECF_C_12109_DEFAULT_ATTRIBUTES, Colorbar, DIE_LINE_LAYOUT, Gripper, MODEL_BECF_1010A, MODEL_BECF_1030A, MODEL_BECF_1040A, MODEL_BECF_11D01, MODEL_BECF_12101, MODEL_BECF_12109, MODEL_BECF_C_12101, MODEL_BECF_C_12109, MODEL_THEME_CONFIG, appendColorbarToSvg, appendGripperToSvg, calculateAutoLayout, configurePackaging, modelList };
|
|
7313
8841
|
//# sourceMappingURL=index.mjs.map
|
|
7314
8842
|
//# sourceMappingURL=index.mjs.map
|