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