@lucablockltd/ultimate-packaging 1.1.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/AGENTS_README.md +299 -30
- package/dist/index.d.mts +129 -25
- package/dist/index.d.ts +129 -25
- package/dist/index.js +2212 -443
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2209 -444
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3757,6 +3757,99 @@ function generateBecf12109(attr) {
|
|
|
3757
3757
|
crease.push(line6(xSide2Mid, yFoldBottomStart, xEnd, D + C - 2));
|
|
3758
3758
|
return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
|
|
3759
3759
|
}
|
|
3760
|
+
function generateOuterContour6(attr) {
|
|
3761
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3762
|
+
const D = calcD2(C, B);
|
|
3763
|
+
const kulak = glueArea ?? calcKulak2(B);
|
|
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;
|
|
3772
|
+
return [
|
|
3773
|
+
// Top edge
|
|
3774
|
+
{ x: 0, y: 0 },
|
|
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
|
|
3806
|
+
];
|
|
3807
|
+
}
|
|
3808
|
+
function offsetContour6(points, distance) {
|
|
3809
|
+
const n = points.length;
|
|
3810
|
+
const result = [];
|
|
3811
|
+
for (let i = 0; i < n; i++) {
|
|
3812
|
+
const prev = points[(i - 1 + n) % n];
|
|
3813
|
+
const curr = points[i];
|
|
3814
|
+
const next = points[(i + 1) % n];
|
|
3815
|
+
const e1x = curr.x - prev.x;
|
|
3816
|
+
const e1y = curr.y - prev.y;
|
|
3817
|
+
const e2x = next.x - curr.x;
|
|
3818
|
+
const e2y = next.y - curr.y;
|
|
3819
|
+
const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
|
|
3820
|
+
const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
|
|
3821
|
+
if (len1 === 0 || len2 === 0) {
|
|
3822
|
+
result.push(curr);
|
|
3823
|
+
continue;
|
|
3824
|
+
}
|
|
3825
|
+
const n1x = e1y / len1;
|
|
3826
|
+
const n1y = -e1x / len1;
|
|
3827
|
+
const n2x = e2y / len2;
|
|
3828
|
+
const n2y = -e2x / len2;
|
|
3829
|
+
const ax = n1x + n2x;
|
|
3830
|
+
const ay = n1y + n2y;
|
|
3831
|
+
const aLen = Math.sqrt(ax * ax + ay * ay);
|
|
3832
|
+
if (aLen < 1e-3) {
|
|
3833
|
+
result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
|
|
3834
|
+
continue;
|
|
3835
|
+
}
|
|
3836
|
+
const nx = ax / aLen;
|
|
3837
|
+
const ny = ay / aLen;
|
|
3838
|
+
const dot = n1x * nx + n1y * ny;
|
|
3839
|
+
const d = distance / Math.max(dot, 0.1);
|
|
3840
|
+
result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
|
|
3841
|
+
}
|
|
3842
|
+
return result;
|
|
3843
|
+
}
|
|
3844
|
+
function contourToPath6(points) {
|
|
3845
|
+
if (points.length === 0) return "";
|
|
3846
|
+
let d = `M${points[0].x} ${points[0].y}`;
|
|
3847
|
+
for (let i = 1; i < points.length; i++) {
|
|
3848
|
+
d += ` L${points[i].x} ${points[i].y}`;
|
|
3849
|
+
}
|
|
3850
|
+
d += " Z";
|
|
3851
|
+
return d;
|
|
3852
|
+
}
|
|
3760
3853
|
function generateDimensions6(attr, unit) {
|
|
3761
3854
|
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3762
3855
|
const D = calcD2(C, B);
|
|
@@ -4129,144 +4222,1207 @@ var MODEL_BECF_12109 = react.forwardRef(
|
|
|
4129
4222
|
}
|
|
4130
4223
|
);
|
|
4131
4224
|
|
|
4132
|
-
// src/
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
const worldY = (offsetY + gy) * resolution + resolution / 2;
|
|
4148
|
-
const crossings = [];
|
|
4149
|
-
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
|
|
4150
|
-
const yi = points[i].y, yj = points[j].y;
|
|
4151
|
-
if (yi <= worldY && yj > worldY || yj <= worldY && yi > worldY) {
|
|
4152
|
-
const t = (worldY - yi) / (yj - yi);
|
|
4153
|
-
crossings.push(points[i].x + t * (points[j].x - points[i].x));
|
|
4154
|
-
}
|
|
4155
|
-
}
|
|
4156
|
-
crossings.sort((a, b) => a - b);
|
|
4157
|
-
for (let c = 0; c < crossings.length - 1; c += 2) {
|
|
4158
|
-
const startGx = Math.max(0, Math.floor((crossings[c] - offsetX * resolution) / resolution));
|
|
4159
|
-
const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
|
|
4160
|
-
for (let gx = startGx; gx <= endGx; gx++) {
|
|
4161
|
-
data[gy * w + gx] = 1;
|
|
4162
|
-
}
|
|
4163
|
-
}
|
|
4164
|
-
}
|
|
4165
|
-
return { data, width: w, height: h, offsetX, offsetY };
|
|
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;
|
|
4166
4240
|
}
|
|
4167
|
-
function
|
|
4168
|
-
|
|
4169
|
-
const paperY = py + y;
|
|
4170
|
-
if (paperY < 0 || paperY >= paperH) {
|
|
4171
|
-
for (let x = 0; x < piece.width; x++) {
|
|
4172
|
-
if (piece.data[y * piece.width + x]) return false;
|
|
4173
|
-
}
|
|
4174
|
-
continue;
|
|
4175
|
-
}
|
|
4176
|
-
for (let x = 0; x < piece.width; x++) {
|
|
4177
|
-
if (!piece.data[y * piece.width + x]) continue;
|
|
4178
|
-
const paperX = px + x;
|
|
4179
|
-
if (paperX < 0 || paperX >= paperW) return false;
|
|
4180
|
-
if (paperGrid[paperY * paperW + paperX]) return false;
|
|
4181
|
-
}
|
|
4182
|
-
}
|
|
4183
|
-
return true;
|
|
4241
|
+
function calcX3(a) {
|
|
4242
|
+
return Math.min(a / 2, 110);
|
|
4184
4243
|
}
|
|
4185
|
-
function
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
}
|
|
4192
|
-
}
|
|
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 };
|
|
4193
4250
|
}
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
var RESOLUTION = 1;
|
|
4197
|
-
function resolveGripperSide(paperWidth, paperHeight) {
|
|
4198
|
-
if (paperWidth >= paperHeight) return "bottom";
|
|
4199
|
-
return "left";
|
|
4251
|
+
function line7(x1, y1, x2, y2) {
|
|
4252
|
+
return `M${x1} ${y1} L${x2} ${y2}`;
|
|
4200
4253
|
}
|
|
4201
|
-
function
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
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 } };
|
|
4232
4311
|
}
|
|
4233
|
-
function
|
|
4234
|
-
const
|
|
4235
|
-
const
|
|
4236
|
-
const
|
|
4237
|
-
const
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
}
|
|
4246
|
-
return rotated.map((p) => ({ x: p.x - minX, y: p.y - minY }));
|
|
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
|
+
];
|
|
4247
4324
|
}
|
|
4248
|
-
function
|
|
4249
|
-
const
|
|
4250
|
-
const
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
const
|
|
4255
|
-
const
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
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;
|
|
4341
|
+
}
|
|
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;
|
|
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 });
|
|
4266
4358
|
}
|
|
4267
|
-
return
|
|
4359
|
+
return result;
|
|
4268
4360
|
}
|
|
4269
|
-
function
|
|
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) {
|
|
4270
5426
|
const usableLeft = Math.ceil(bounds.left / RESOLUTION);
|
|
4271
5427
|
const usableTop = Math.ceil(bounds.top / RESOLUTION);
|
|
4272
5428
|
const usableRight = Math.floor(bounds.right / RESOLUTION);
|
|
@@ -4297,81 +5453,644 @@ function computeLayoutForPaperDefault(contourPoints, dielineW, dielineH, paperWi
|
|
|
4297
5453
|
}
|
|
4298
5454
|
}
|
|
4299
5455
|
}
|
|
4300
|
-
if (placements.length > bestCandidate.producedPerSheet) {
|
|
4301
|
-
bestCandidate = { rotation: deg, placements, producedPerSheet: placements.length };
|
|
4302
|
-
bestGridPositions = gridPositions;
|
|
4303
|
-
bestBitmapW = pieceBitmap.width;
|
|
4304
|
-
bestBitmapH = pieceBitmap.height;
|
|
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;
|
|
5476
|
+
const usableW = usableRight - usableLeft;
|
|
5477
|
+
const usableH = usableBottom - usableTop;
|
|
5478
|
+
const offsetX = ((usableW - groupW) / 2 - (gridMinX - usableLeft)) * RESOLUTION;
|
|
5479
|
+
const offsetY = ((usableH - groupH) / 2 - (gridMinY - usableTop)) * RESOLUTION;
|
|
5480
|
+
for (const p of bestCandidate.placements) {
|
|
5481
|
+
p.x += offsetX;
|
|
5482
|
+
p.y += offsetY;
|
|
5483
|
+
}
|
|
5484
|
+
}
|
|
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
|
+
};
|
|
5686
|
+
}
|
|
5687
|
+
|
|
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;
|
|
5712
|
+
}
|
|
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
|
+
}
|
|
5770
|
+
}
|
|
5771
|
+
break;
|
|
5772
|
+
}
|
|
5773
|
+
}
|
|
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));
|
|
4305
5815
|
}
|
|
4306
5816
|
}
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
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);
|
|
4317
5830
|
}
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
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;
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
return b;
|
|
5843
|
+
}
|
|
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
|
+
};
|
|
5853
|
+
}
|
|
5854
|
+
|
|
5855
|
+
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1040a/index.ts
|
|
5856
|
+
function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
|
|
5857
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
5858
|
+
return {
|
|
5859
|
+
profile: buildProfile(rotated),
|
|
5860
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
5861
|
+
deg
|
|
5862
|
+
};
|
|
5863
|
+
}
|
|
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;
|
|
5868
|
+
let maxStep = 0;
|
|
5869
|
+
for (let n = nMin; n <= nMax; n++) {
|
|
5870
|
+
const dx = n * pairStepX;
|
|
5871
|
+
const s1 = findMinStepY(pA, pA, dx);
|
|
5872
|
+
if (s1 > maxStep) maxStep = s1;
|
|
5873
|
+
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
5874
|
+
if (s2 > maxStep) maxStep = s2;
|
|
5875
|
+
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
5876
|
+
if (s3 > maxStep) maxStep = s3;
|
|
5877
|
+
const s4 = findMinStepY(pB, pB, dx);
|
|
5878
|
+
if (s4 > maxStep) maxStep = s4;
|
|
5879
|
+
}
|
|
5880
|
+
return maxStep;
|
|
5881
|
+
}
|
|
5882
|
+
function pairGrid2(rdA, rdB, bounds) {
|
|
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();
|
|
5901
|
+
const placements = [];
|
|
5902
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
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
|
+
}
|
|
5965
|
+
}
|
|
5966
|
+
break;
|
|
5967
|
+
}
|
|
5968
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5969
|
+
}
|
|
5970
|
+
function verticalPairGrid(rdA, rdB, bounds) {
|
|
5971
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
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();
|
|
6005
|
+
const placements = [];
|
|
6006
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
6007
|
+
for (let r = 0; r < rows; r++) {
|
|
6008
|
+
for (let c = 0; c < cols; c++) {
|
|
6009
|
+
const baseX = bounds.left + c * vpairStepX;
|
|
6010
|
+
const baseY = bounds.top + r * vpairStepY;
|
|
6011
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
6012
|
+
if (baseX < minX) minX = baseX;
|
|
6013
|
+
if (baseY < minY) minY = baseY;
|
|
6014
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
6015
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
6016
|
+
const by = baseY + gapAB_Y;
|
|
6017
|
+
placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
6018
|
+
if (by + pB.height > maxY) maxY = by + pB.height;
|
|
6019
|
+
}
|
|
6020
|
+
}
|
|
6021
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
6022
|
+
}
|
|
6023
|
+
function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
6024
|
+
const rots = [0, 90, 180, 270];
|
|
6025
|
+
const rd = /* @__PURE__ */ new Map();
|
|
6026
|
+
for (const deg of rots) {
|
|
6027
|
+
rd.set(deg, prepareRotation3(contourPoints, dielineW, dielineH, deg));
|
|
6028
|
+
}
|
|
6029
|
+
const results = [];
|
|
6030
|
+
for (const deg of rots) {
|
|
6031
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
6032
|
+
}
|
|
6033
|
+
const allPairs = [
|
|
6034
|
+
[0, 180],
|
|
6035
|
+
[90, 270],
|
|
6036
|
+
[0, 90],
|
|
6037
|
+
[0, 270],
|
|
6038
|
+
[90, 180],
|
|
6039
|
+
[180, 270]
|
|
6040
|
+
];
|
|
6041
|
+
for (const [a, b] of allPairs) {
|
|
6042
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
6043
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
6044
|
+
if (stepA <= 0) continue;
|
|
6045
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
6046
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
6047
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
4327
6048
|
}
|
|
4328
6049
|
}
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
// src/utils/autoLayout/calculate/tuck-end-boxes/becf-1010a/index.ts
|
|
4333
|
-
var SAMPLE_STEP = 0.1;
|
|
4334
|
-
function buildProfile(points) {
|
|
4335
|
-
let maxX = 0, maxY = 0;
|
|
4336
|
-
for (const p of points) {
|
|
4337
|
-
if (p.x > maxX) maxX = p.x;
|
|
4338
|
-
if (p.y > maxY) maxY = p.y;
|
|
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));
|
|
4339
6053
|
}
|
|
4340
|
-
const
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
const
|
|
4345
|
-
const
|
|
4346
|
-
const
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
const t = (y - yj) / (yk - yj);
|
|
4354
|
-
const x = points[j].x + t * (points[k].x - points[j].x);
|
|
4355
|
-
if (x > rightX[iy]) rightX[iy] = x;
|
|
4356
|
-
if (x < leftX[iy]) leftX[iy] = x;
|
|
4357
|
-
}
|
|
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);
|
|
4358
6067
|
}
|
|
4359
6068
|
}
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
if (y < topY[ix]) topY[ix] = y;
|
|
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;
|
|
4369
6077
|
}
|
|
4370
6078
|
}
|
|
6079
|
+
return b;
|
|
4371
6080
|
}
|
|
4372
|
-
|
|
6081
|
+
const bestSingle = pickBest(singleResults);
|
|
6082
|
+
const bestMulti = pickBest(multiResults);
|
|
6083
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
6084
|
+
centerLayout(best, bounds);
|
|
6085
|
+
return {
|
|
6086
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
6087
|
+
placements: best.placements,
|
|
6088
|
+
producedPerSheet: best.count
|
|
6089
|
+
};
|
|
4373
6090
|
}
|
|
4374
|
-
|
|
6091
|
+
|
|
6092
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-12101/index.ts
|
|
6093
|
+
function prepareRotation4(contourPoints, dielineW, dielineH, deg) {
|
|
4375
6094
|
const rotated = normalizePoints(contourPoints, deg);
|
|
4376
6095
|
return {
|
|
4377
6096
|
profile: buildProfile(rotated),
|
|
@@ -4379,119 +6098,93 @@ function prepareRotation(contourPoints, dielineW, dielineH, deg) {
|
|
|
4379
6098
|
deg
|
|
4380
6099
|
};
|
|
4381
6100
|
}
|
|
4382
|
-
function
|
|
4383
|
-
const
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
const overlap = a.bottomY[ia] - b.topY[ib];
|
|
4402
|
-
if (overlap > maxOverlap) maxOverlap = overlap;
|
|
4403
|
-
}
|
|
4404
|
-
return maxOverlap <= -Infinity ? 0 : maxOverlap;
|
|
4405
|
-
}
|
|
4406
|
-
function findMinStepY_multi(profA, stepX_A, profB, offsetX) {
|
|
4407
|
-
const reach = Math.max(profA.width, profB.width);
|
|
4408
|
-
let maxStep = 0;
|
|
4409
|
-
const nMin = Math.floor((offsetX - reach) / stepX_A);
|
|
4410
|
-
const nMax = Math.ceil((offsetX + reach) / stepX_A);
|
|
4411
|
-
for (let n = nMin; n <= nMax; n++) {
|
|
4412
|
-
const s = findMinStepY(profA, profB, offsetX - n * stepX_A);
|
|
4413
|
-
if (s > maxStep) maxStep = s;
|
|
4414
|
-
}
|
|
4415
|
-
return maxStep;
|
|
4416
|
-
}
|
|
4417
|
-
function emptyResult() {
|
|
4418
|
-
return { placements: [], count: 0, minX: 0, minY: 0, maxX: 0, maxY: 0 };
|
|
4419
|
-
}
|
|
4420
|
-
function singleRotGrid(rd, bounds) {
|
|
4421
|
-
const p = rd.profile;
|
|
4422
|
-
const stepX = findMinStepX(p, p, 0);
|
|
4423
|
-
const stepY = findMinStepY(p, p, 0);
|
|
4424
|
-
if (stepX <= 0 || stepY <= 0) return emptyResult();
|
|
4425
|
-
const cols = Math.max(0, Math.floor((bounds.right - bounds.left - p.width) / stepX) + 1);
|
|
4426
|
-
const rows = Math.max(0, Math.floor((bounds.bottom - bounds.top - p.height) / stepY) + 1);
|
|
4427
|
-
if (cols === 0 || rows === 0) return emptyResult();
|
|
6101
|
+
function pairGrid3(rdA, rdB, bounds) {
|
|
6102
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
6103
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
6104
|
+
if (gapAB <= 0) return emptyResult();
|
|
6105
|
+
const pairW = gapAB + pB.width;
|
|
6106
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
6107
|
+
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
6108
|
+
const pairStepY = Math.max(
|
|
6109
|
+
findMinStepY(pA, pA, 0),
|
|
6110
|
+
findMinStepY(pA, pB, gapAB),
|
|
6111
|
+
findMinStepY(pB, pA, -gapAB),
|
|
6112
|
+
findMinStepY(pB, pB, 0)
|
|
6113
|
+
);
|
|
6114
|
+
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
6115
|
+
const usableW = bounds.right - bounds.left;
|
|
6116
|
+
const usableH = bounds.bottom - bounds.top;
|
|
6117
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
6118
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
6119
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
4428
6120
|
const placements = [];
|
|
4429
6121
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4430
|
-
for (let r = 0; r <
|
|
4431
|
-
for (let c = 0; c <
|
|
4432
|
-
const
|
|
4433
|
-
const
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
if (
|
|
4438
|
-
if (
|
|
6122
|
+
for (let r = 0; r < pairRows; r++) {
|
|
6123
|
+
for (let c = 0; c < pairCols; c++) {
|
|
6124
|
+
const baseX = bounds.left + c * pairStepX;
|
|
6125
|
+
const baseY = bounds.top + r * pairStepY;
|
|
6126
|
+
const oxA = baseX;
|
|
6127
|
+
const oyA = baseY;
|
|
6128
|
+
placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
6129
|
+
if (oxA < minX) minX = oxA;
|
|
6130
|
+
if (oyA < minY) minY = oyA;
|
|
6131
|
+
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
6132
|
+
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
6133
|
+
const oxB = baseX + gapAB;
|
|
6134
|
+
const oyB = baseY;
|
|
6135
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
6136
|
+
if (oxB < minX) minX = oxB;
|
|
6137
|
+
if (oyB < minY) minY = oyB;
|
|
6138
|
+
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
6139
|
+
if (oyB + pB.height > maxY) maxY = oyB + pB.height;
|
|
4439
6140
|
}
|
|
4440
6141
|
}
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
const
|
|
4445
|
-
const
|
|
4446
|
-
const
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
const stepX = isRowA ? stepX_A : stepX_B;
|
|
4459
|
-
if (oy + p.height > bounds.bottom) break;
|
|
4460
|
-
let sx = isRowA ? bounds.left : bounds.left + offsetX;
|
|
4461
|
-
if (sx < bounds.left) sx += stepX * Math.ceil((bounds.left - sx) / stepX);
|
|
4462
|
-
for (let ox = sx; ox + p.width <= bounds.right; ox += stepX) {
|
|
4463
|
-
placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
|
|
4464
|
-
if (ox < minX) minX = ox;
|
|
4465
|
-
if (oy < minY) minY = oy;
|
|
4466
|
-
if (ox + p.width > maxX) maxX = ox + p.width;
|
|
4467
|
-
if (oy + p.height > maxY) maxY = oy + p.height;
|
|
6142
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
6143
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
6144
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
6145
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
6146
|
+
const extraRotations = [rdA, rdB];
|
|
6147
|
+
for (const rdExtra of extraRotations) {
|
|
6148
|
+
const pe = rdExtra.profile;
|
|
6149
|
+
if (pe.width <= gapRight) {
|
|
6150
|
+
for (let r = 0; r < pairRows; r++) {
|
|
6151
|
+
const ox = pairsRightEdge;
|
|
6152
|
+
const oy = bounds.top + r * pairStepY;
|
|
6153
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
6154
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
6155
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
6156
|
+
}
|
|
6157
|
+
}
|
|
6158
|
+
break;
|
|
4468
6159
|
}
|
|
4469
|
-
oy += isRowA ? stepY_AB : stepY_BA;
|
|
4470
|
-
isRowA = !isRowA;
|
|
4471
6160
|
}
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
6161
|
+
for (const rdExtra of extraRotations) {
|
|
6162
|
+
const pe = rdExtra.profile;
|
|
6163
|
+
if (pe.height <= gapBottom) {
|
|
6164
|
+
for (let c = 0; c < pairCols; c++) {
|
|
6165
|
+
const oxA = bounds.left + c * pairStepX;
|
|
6166
|
+
const oy = pairsBottomEdge;
|
|
6167
|
+
if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
6168
|
+
placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
6169
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
6170
|
+
}
|
|
6171
|
+
}
|
|
6172
|
+
break;
|
|
6173
|
+
}
|
|
4482
6174
|
}
|
|
6175
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4483
6176
|
}
|
|
4484
|
-
function
|
|
6177
|
+
function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4485
6178
|
const rots = [0, 90, 180, 270];
|
|
4486
6179
|
const rd = /* @__PURE__ */ new Map();
|
|
4487
6180
|
for (const deg of rots) {
|
|
4488
|
-
rd.set(deg,
|
|
6181
|
+
rd.set(deg, prepareRotation4(contourPoints, dielineW, dielineH, deg));
|
|
4489
6182
|
}
|
|
4490
6183
|
const results = [];
|
|
4491
6184
|
for (const deg of rots) {
|
|
4492
6185
|
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
4493
6186
|
}
|
|
4494
|
-
const
|
|
6187
|
+
const allPairs = [
|
|
4495
6188
|
[0, 180],
|
|
4496
6189
|
[90, 270],
|
|
4497
6190
|
[0, 90],
|
|
@@ -4499,7 +6192,7 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
4499
6192
|
[90, 180],
|
|
4500
6193
|
[180, 270]
|
|
4501
6194
|
];
|
|
4502
|
-
for (const [a, b] of
|
|
6195
|
+
for (const [a, b] of allPairs) {
|
|
4503
6196
|
const rdA = rd.get(a), rdB = rd.get(b);
|
|
4504
6197
|
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
4505
6198
|
if (stepA <= 0) continue;
|
|
@@ -4508,10 +6201,36 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
4508
6201
|
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
4509
6202
|
}
|
|
4510
6203
|
}
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
6204
|
+
for (const [a, b] of allPairs) {
|
|
6205
|
+
results.push(pairGrid3(rd.get(a), rd.get(b), bounds));
|
|
6206
|
+
results.push(pairGrid3(rd.get(b), rd.get(a), bounds));
|
|
6207
|
+
}
|
|
6208
|
+
const singleResults = [];
|
|
6209
|
+
const multiResults = [];
|
|
6210
|
+
for (const r of results) {
|
|
6211
|
+
if (r.count === 0) continue;
|
|
6212
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
6213
|
+
if (rotations.size > 1) {
|
|
6214
|
+
multiResults.push(r);
|
|
6215
|
+
} else {
|
|
6216
|
+
singleResults.push(r);
|
|
6217
|
+
}
|
|
6218
|
+
}
|
|
6219
|
+
function pickBest(arr) {
|
|
6220
|
+
let b = arr[0] ?? emptyResult();
|
|
6221
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
6222
|
+
for (const r of arr) {
|
|
6223
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
6224
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
6225
|
+
b = r;
|
|
6226
|
+
bArea = area;
|
|
6227
|
+
}
|
|
6228
|
+
}
|
|
6229
|
+
return b;
|
|
4514
6230
|
}
|
|
6231
|
+
const bestSingle = pickBest(singleResults);
|
|
6232
|
+
const bestMulti = pickBest(multiResults);
|
|
6233
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
4515
6234
|
centerLayout(best, bounds);
|
|
4516
6235
|
return {
|
|
4517
6236
|
rotation: best.placements[0]?.rotation ?? 0,
|
|
@@ -4520,8 +6239,8 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
|
|
|
4520
6239
|
};
|
|
4521
6240
|
}
|
|
4522
6241
|
|
|
4523
|
-
// src/utils/autoLayout/calculate/
|
|
4524
|
-
function
|
|
6242
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-12109/index.ts
|
|
6243
|
+
function prepareRotation5(contourPoints, dielineW, dielineH, deg) {
|
|
4525
6244
|
const rotated = normalizePoints(contourPoints, deg);
|
|
4526
6245
|
return {
|
|
4527
6246
|
profile: buildProfile(rotated),
|
|
@@ -4529,7 +6248,7 @@ function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
|
|
|
4529
6248
|
deg
|
|
4530
6249
|
};
|
|
4531
6250
|
}
|
|
4532
|
-
function
|
|
6251
|
+
function pairGrid4(rdA, rdB, bounds) {
|
|
4533
6252
|
const pA = rdA.profile, pB = rdB.profile;
|
|
4534
6253
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
4535
6254
|
if (gapAB <= 0) return emptyResult();
|
|
@@ -4605,11 +6324,11 @@ function pairGrid(rdA, rdB, bounds) {
|
|
|
4605
6324
|
}
|
|
4606
6325
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4607
6326
|
}
|
|
4608
|
-
function
|
|
6327
|
+
function computeLayoutForPaper5(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4609
6328
|
const rots = [0, 90, 180, 270];
|
|
4610
6329
|
const rd = /* @__PURE__ */ new Map();
|
|
4611
6330
|
for (const deg of rots) {
|
|
4612
|
-
rd.set(deg,
|
|
6331
|
+
rd.set(deg, prepareRotation5(contourPoints, dielineW, dielineH, deg));
|
|
4613
6332
|
}
|
|
4614
6333
|
const results = [];
|
|
4615
6334
|
for (const deg of rots) {
|
|
@@ -4633,8 +6352,8 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
4633
6352
|
}
|
|
4634
6353
|
}
|
|
4635
6354
|
for (const [a, b] of allPairs) {
|
|
4636
|
-
results.push(
|
|
4637
|
-
results.push(
|
|
6355
|
+
results.push(pairGrid4(rd.get(a), rd.get(b), bounds));
|
|
6356
|
+
results.push(pairGrid4(rd.get(b), rd.get(a), bounds));
|
|
4638
6357
|
}
|
|
4639
6358
|
const singleResults = [];
|
|
4640
6359
|
const multiResults = [];
|
|
@@ -4670,8 +6389,8 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
4670
6389
|
};
|
|
4671
6390
|
}
|
|
4672
6391
|
|
|
4673
|
-
// src/utils/autoLayout/calculate/
|
|
4674
|
-
function
|
|
6392
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-c-12101/index.ts
|
|
6393
|
+
function prepareRotation6(contourPoints, dielineW, dielineH, deg) {
|
|
4675
6394
|
const rotated = normalizePoints(contourPoints, deg);
|
|
4676
6395
|
return {
|
|
4677
6396
|
profile: buildProfile(rotated),
|
|
@@ -4679,34 +6398,20 @@ function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
|
|
|
4679
6398
|
deg
|
|
4680
6399
|
};
|
|
4681
6400
|
}
|
|
4682
|
-
function
|
|
4683
|
-
const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
|
|
4684
|
-
const nMin = Math.floor(-reach / pairStepX) - 1;
|
|
4685
|
-
const nMax = Math.ceil(reach / pairStepX) + 1;
|
|
4686
|
-
let maxStep = 0;
|
|
4687
|
-
for (let n = nMin; n <= nMax; n++) {
|
|
4688
|
-
const dx = n * pairStepX;
|
|
4689
|
-
const s1 = findMinStepY(pA, pA, dx);
|
|
4690
|
-
if (s1 > maxStep) maxStep = s1;
|
|
4691
|
-
const s2 = findMinStepY(pA, pB, dx + gapAB);
|
|
4692
|
-
if (s2 > maxStep) maxStep = s2;
|
|
4693
|
-
const s3 = findMinStepY(pB, pA, dx - gapAB);
|
|
4694
|
-
if (s3 > maxStep) maxStep = s3;
|
|
4695
|
-
const s4 = findMinStepY(pB, pB, dx);
|
|
4696
|
-
if (s4 > maxStep) maxStep = s4;
|
|
4697
|
-
}
|
|
4698
|
-
return maxStep;
|
|
4699
|
-
}
|
|
4700
|
-
function pairGrid2(rdA, rdB, bounds) {
|
|
6401
|
+
function pairGrid5(rdA, rdB, bounds) {
|
|
4701
6402
|
const pA = rdA.profile, pB = rdB.profile;
|
|
4702
6403
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
4703
6404
|
if (gapAB <= 0) return emptyResult();
|
|
4704
6405
|
const pairW = gapAB + pB.width;
|
|
4705
6406
|
const pairH = Math.max(pA.height, pB.height);
|
|
4706
6407
|
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
6408
|
+
const pairStepY = Math.max(
|
|
6409
|
+
findMinStepY(pA, pA, 0),
|
|
6410
|
+
findMinStepY(pA, pB, gapAB),
|
|
6411
|
+
findMinStepY(pB, pA, -gapAB),
|
|
6412
|
+
findMinStepY(pB, pB, 0)
|
|
6413
|
+
);
|
|
6414
|
+
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
4710
6415
|
const usableW = bounds.right - bounds.left;
|
|
4711
6416
|
const usableH = bounds.bottom - bounds.top;
|
|
4712
6417
|
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
@@ -4718,115 +6423,62 @@ function pairGrid2(rdA, rdB, bounds) {
|
|
|
4718
6423
|
for (let c = 0; c < pairCols; c++) {
|
|
4719
6424
|
const baseX = bounds.left + c * pairStepX;
|
|
4720
6425
|
const baseY = bounds.top + r * pairStepY;
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
if (
|
|
4725
|
-
if (
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
6426
|
+
const oxA = baseX;
|
|
6427
|
+
const oyA = baseY;
|
|
6428
|
+
placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
6429
|
+
if (oxA < minX) minX = oxA;
|
|
6430
|
+
if (oyA < minY) minY = oyA;
|
|
6431
|
+
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
6432
|
+
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
6433
|
+
const oxB = baseX + gapAB;
|
|
6434
|
+
const oyB = baseY;
|
|
6435
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
6436
|
+
if (oxB < minX) minX = oxB;
|
|
6437
|
+
if (oyB < minY) minY = oyB;
|
|
6438
|
+
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
6439
|
+
if (oyB + pB.height > maxY) maxY = oyB + pB.height;
|
|
4731
6440
|
}
|
|
4732
6441
|
}
|
|
4733
6442
|
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
6443
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
4734
6444
|
const gapRight = bounds.right - pairsRightEdge;
|
|
4735
|
-
|
|
6445
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
6446
|
+
const extraRotations = [rdA, rdB];
|
|
6447
|
+
for (const rdExtra of extraRotations) {
|
|
4736
6448
|
const pe = rdExtra.profile;
|
|
4737
|
-
if (pe.width
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
if (extraStepY <= 0) continue;
|
|
4746
|
-
const effectiveStepY = Math.max(pairStepY, extraStepY);
|
|
4747
|
-
const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
|
|
4748
|
-
for (let r = 0; r < extraRows; r++) {
|
|
4749
|
-
const ox = pairsRightEdge;
|
|
4750
|
-
const oy = bounds.top + r * effectiveStepY;
|
|
4751
|
-
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4752
|
-
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4753
|
-
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
4754
|
-
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
6449
|
+
if (pe.width <= gapRight) {
|
|
6450
|
+
for (let r = 0; r < pairRows; r++) {
|
|
6451
|
+
const ox = pairsRightEdge;
|
|
6452
|
+
const oy = bounds.top + r * pairStepY;
|
|
6453
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
6454
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
6455
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
6456
|
+
}
|
|
4755
6457
|
}
|
|
6458
|
+
break;
|
|
4756
6459
|
}
|
|
4757
|
-
break;
|
|
4758
6460
|
}
|
|
4759
|
-
const
|
|
4760
|
-
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
4761
|
-
for (const rdExtra of [rdA, rdB]) {
|
|
6461
|
+
for (const rdExtra of extraRotations) {
|
|
4762
6462
|
const pe = rdExtra.profile;
|
|
4763
|
-
if (pe.height
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
for (let c = 0; c < extraCols; c++) {
|
|
4772
|
-
const ox = bounds.left + c * extraStepX;
|
|
4773
|
-
const oy = pairsBottomEdge;
|
|
4774
|
-
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4775
|
-
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4776
|
-
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
4777
|
-
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
6463
|
+
if (pe.height <= gapBottom) {
|
|
6464
|
+
for (let c = 0; c < pairCols; c++) {
|
|
6465
|
+
const oxA = bounds.left + c * pairStepX;
|
|
6466
|
+
const oy = pairsBottomEdge;
|
|
6467
|
+
if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
6468
|
+
placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
6469
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
6470
|
+
}
|
|
4778
6471
|
}
|
|
4779
|
-
|
|
4780
|
-
break;
|
|
4781
|
-
}
|
|
4782
|
-
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4783
|
-
}
|
|
4784
|
-
function verticalPairGrid(rdA, rdB, bounds) {
|
|
4785
|
-
const pA = rdA.profile, pB = rdB.profile;
|
|
4786
|
-
const gapAB_Y = findMinStepY(pA, pB, 0);
|
|
4787
|
-
if (gapAB_Y <= 0) return emptyResult();
|
|
4788
|
-
const vpairH = gapAB_Y + pB.height;
|
|
4789
|
-
const vpairW = Math.max(pA.width, pB.width);
|
|
4790
|
-
Math.max(pA.height, pB.height) + Math.abs(gapAB_Y);
|
|
4791
|
-
let vpairStepX = 0;
|
|
4792
|
-
{
|
|
4793
|
-
const stepXAA = findMinStepX(pA, pA, 0);
|
|
4794
|
-
const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
|
|
4795
|
-
const stepXBA = findMinStepX(pB, pA, gapAB_Y);
|
|
4796
|
-
const stepXBB = findMinStepX(pB, pB, 0);
|
|
4797
|
-
vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
|
|
4798
|
-
}
|
|
4799
|
-
if (vpairStepX <= 0) return emptyResult();
|
|
4800
|
-
const vpairStepY = gapAB_Y + findMinStepY(pB, pA, 0);
|
|
4801
|
-
if (vpairStepY <= 0) return emptyResult();
|
|
4802
|
-
const usableW = bounds.right - bounds.left;
|
|
4803
|
-
const usableH = bounds.bottom - bounds.top;
|
|
4804
|
-
const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
|
|
4805
|
-
const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
|
|
4806
|
-
if (cols === 0 || rows === 0) return emptyResult();
|
|
4807
|
-
const placements = [];
|
|
4808
|
-
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4809
|
-
for (let r = 0; r < rows; r++) {
|
|
4810
|
-
for (let c = 0; c < cols; c++) {
|
|
4811
|
-
const baseX = bounds.left + c * vpairStepX;
|
|
4812
|
-
const baseY = bounds.top + r * vpairStepY;
|
|
4813
|
-
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
4814
|
-
if (baseX < minX) minX = baseX;
|
|
4815
|
-
if (baseY < minY) minY = baseY;
|
|
4816
|
-
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
4817
|
-
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
4818
|
-
const by = baseY + gapAB_Y;
|
|
4819
|
-
placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
4820
|
-
if (by + pB.height > maxY) maxY = by + pB.height;
|
|
6472
|
+
break;
|
|
4821
6473
|
}
|
|
4822
6474
|
}
|
|
4823
6475
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4824
6476
|
}
|
|
4825
|
-
function
|
|
6477
|
+
function computeLayoutForPaper6(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4826
6478
|
const rots = [0, 90, 180, 270];
|
|
4827
6479
|
const rd = /* @__PURE__ */ new Map();
|
|
4828
6480
|
for (const deg of rots) {
|
|
4829
|
-
rd.set(deg,
|
|
6481
|
+
rd.set(deg, prepareRotation6(contourPoints, dielineW, dielineH, deg));
|
|
4830
6482
|
}
|
|
4831
6483
|
const results = [];
|
|
4832
6484
|
for (const deg of rots) {
|
|
@@ -4850,12 +6502,8 @@ function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
4850
6502
|
}
|
|
4851
6503
|
}
|
|
4852
6504
|
for (const [a, b] of allPairs) {
|
|
4853
|
-
results.push(
|
|
4854
|
-
results.push(
|
|
4855
|
-
}
|
|
4856
|
-
for (const [a, b] of allPairs) {
|
|
4857
|
-
results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
|
|
4858
|
-
results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
|
|
6505
|
+
results.push(pairGrid5(rd.get(a), rd.get(b), bounds));
|
|
6506
|
+
results.push(pairGrid5(rd.get(b), rd.get(a), bounds));
|
|
4859
6507
|
}
|
|
4860
6508
|
const singleResults = [];
|
|
4861
6509
|
const multiResults = [];
|
|
@@ -4891,8 +6539,8 @@ function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
4891
6539
|
};
|
|
4892
6540
|
}
|
|
4893
6541
|
|
|
4894
|
-
// src/utils/autoLayout/calculate/bags-pillows/becf-
|
|
4895
|
-
function
|
|
6542
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-c-12109/index.ts
|
|
6543
|
+
function prepareRotation7(contourPoints, dielineW, dielineH, deg) {
|
|
4896
6544
|
const rotated = normalizePoints(contourPoints, deg);
|
|
4897
6545
|
return {
|
|
4898
6546
|
profile: buildProfile(rotated),
|
|
@@ -4900,7 +6548,7 @@ function prepareRotation4(contourPoints, dielineW, dielineH, deg) {
|
|
|
4900
6548
|
deg
|
|
4901
6549
|
};
|
|
4902
6550
|
}
|
|
4903
|
-
function
|
|
6551
|
+
function pairGrid6(rdA, rdB, bounds) {
|
|
4904
6552
|
const pA = rdA.profile, pB = rdB.profile;
|
|
4905
6553
|
const gapAB = findMinStepX(pA, pB, 0);
|
|
4906
6554
|
if (gapAB <= 0) return emptyResult();
|
|
@@ -4976,11 +6624,11 @@ function pairGrid3(rdA, rdB, bounds) {
|
|
|
4976
6624
|
}
|
|
4977
6625
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4978
6626
|
}
|
|
4979
|
-
function
|
|
6627
|
+
function computeLayoutForPaper7(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4980
6628
|
const rots = [0, 90, 180, 270];
|
|
4981
6629
|
const rd = /* @__PURE__ */ new Map();
|
|
4982
6630
|
for (const deg of rots) {
|
|
4983
|
-
rd.set(deg,
|
|
6631
|
+
rd.set(deg, prepareRotation7(contourPoints, dielineW, dielineH, deg));
|
|
4984
6632
|
}
|
|
4985
6633
|
const results = [];
|
|
4986
6634
|
for (const deg of rots) {
|
|
@@ -5004,8 +6652,8 @@ function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
5004
6652
|
}
|
|
5005
6653
|
}
|
|
5006
6654
|
for (const [a, b] of allPairs) {
|
|
5007
|
-
results.push(
|
|
5008
|
-
results.push(
|
|
6655
|
+
results.push(pairGrid6(rd.get(a), rd.get(b), bounds));
|
|
6656
|
+
results.push(pairGrid6(rd.get(b), rd.get(a), bounds));
|
|
5009
6657
|
}
|
|
5010
6658
|
const singleResults = [];
|
|
5011
6659
|
const multiResults = [];
|
|
@@ -5076,6 +6724,30 @@ function resolveModelFunctions(modelId, attrs) {
|
|
|
5076
6724
|
offsetContour: offsetContour5
|
|
5077
6725
|
};
|
|
5078
6726
|
}
|
|
6727
|
+
case "BECF-12109": {
|
|
6728
|
+
const a = attrs;
|
|
6729
|
+
return {
|
|
6730
|
+
contour: generateOuterContour6(a),
|
|
6731
|
+
dieline: generateBecf12109(a),
|
|
6732
|
+
offsetContour: offsetContour6
|
|
6733
|
+
};
|
|
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
|
+
}
|
|
5079
6751
|
case "BECF-1010A":
|
|
5080
6752
|
default: {
|
|
5081
6753
|
const a = attrs;
|
|
@@ -5097,6 +6769,12 @@ function resolveLayoutCalculator(modelId) {
|
|
|
5097
6769
|
return computeLayoutForPaper3;
|
|
5098
6770
|
case "BECF-12101":
|
|
5099
6771
|
return computeLayoutForPaper4;
|
|
6772
|
+
case "BECF-12109":
|
|
6773
|
+
return computeLayoutForPaper5;
|
|
6774
|
+
case "BECF-C-12101":
|
|
6775
|
+
return computeLayoutForPaper6;
|
|
6776
|
+
case "BECF-C-12109":
|
|
6777
|
+
return computeLayoutForPaper7;
|
|
5100
6778
|
default:
|
|
5101
6779
|
return computeLayoutForPaperDefault;
|
|
5102
6780
|
}
|
|
@@ -5110,11 +6788,11 @@ function calculateAutoLayout(rawConfig) {
|
|
|
5110
6788
|
colorbarHeight: rawConfig.colorbarHeight ?? 5,
|
|
5111
6789
|
isShowColorbar: rawConfig.isShowColorbar ?? true
|
|
5112
6790
|
};
|
|
5113
|
-
const { contour, dieline, offsetContour:
|
|
6791
|
+
const { contour, dieline, offsetContour: offsetContour9 } = resolveModelFunctions(
|
|
5114
6792
|
config.model.modelId,
|
|
5115
6793
|
config.model.attributes
|
|
5116
6794
|
);
|
|
5117
|
-
const offsetContourPoints = config.layoutDistance > 0 ?
|
|
6795
|
+
const offsetContourPoints = config.layoutDistance > 0 ? offsetContour9(contour, config.layoutDistance / 2) : contour;
|
|
5118
6796
|
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
5119
6797
|
const computeLayout = resolveLayoutCalculator(config.model.modelId);
|
|
5120
6798
|
const paperResults = [];
|
|
@@ -6054,6 +7732,39 @@ function resolveModel(modelId, attrs, layoutDistance) {
|
|
|
6054
7732
|
generateContour: (a) => generateOuterContour5(a)
|
|
6055
7733
|
};
|
|
6056
7734
|
}
|
|
7735
|
+
case "BECF-12109": {
|
|
7736
|
+
const typedAttrs = attrs;
|
|
7737
|
+
const contour = generateOuterContour6(typedAttrs);
|
|
7738
|
+
return {
|
|
7739
|
+
dieline: generateBecf12109(typedAttrs),
|
|
7740
|
+
contourPath: contourToPath6(contour),
|
|
7741
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour6(contour, layoutDistance / 2) : contour,
|
|
7742
|
+
generate: (a) => generateBecf12109(a),
|
|
7743
|
+
generateContour: (a) => generateOuterContour6(a)
|
|
7744
|
+
};
|
|
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
|
+
}
|
|
6057
7768
|
case "BECF-1010A":
|
|
6058
7769
|
default: {
|
|
6059
7770
|
const typedAttrs = attrs;
|
|
@@ -6103,6 +7814,30 @@ function renderDieLine2(modelId, attrs) {
|
|
|
6103
7814
|
renderAs: "group"
|
|
6104
7815
|
}
|
|
6105
7816
|
);
|
|
7817
|
+
case "BECF-12109":
|
|
7818
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7819
|
+
DIE_LINE_BECF_12109,
|
|
7820
|
+
{
|
|
7821
|
+
attributes: attrs,
|
|
7822
|
+
renderAs: "group"
|
|
7823
|
+
}
|
|
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
|
+
);
|
|
6106
7841
|
case "BECF-1010A":
|
|
6107
7842
|
default:
|
|
6108
7843
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6116,7 +7851,7 @@ function renderDieLine2(modelId, attrs) {
|
|
|
6116
7851
|
})();
|
|
6117
7852
|
}
|
|
6118
7853
|
var PAPER_GAP = 20;
|
|
6119
|
-
var
|
|
7854
|
+
var PX_PER_MM9 = 96 / 25.4;
|
|
6120
7855
|
var RESULT_PANEL_HEIGHT = 55;
|
|
6121
7856
|
var RESULT_GAP = 5;
|
|
6122
7857
|
function getOpposite2(side) {
|
|
@@ -6293,8 +8028,8 @@ var AUTO_LAYOUT = react.forwardRef(
|
|
|
6293
8028
|
const svg = document.createElementNS(svgNs, "svg");
|
|
6294
8029
|
svg.setAttribute("xmlns", svgNs);
|
|
6295
8030
|
svg.setAttribute("viewBox", `0 0 ${vw} ${vh}`);
|
|
6296
|
-
svg.setAttribute("width", String(Math.round(vw *
|
|
6297
|
-
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)));
|
|
6298
8033
|
const bg = document.createElementNS(svgNs, "rect");
|
|
6299
8034
|
bg.setAttribute("width", String(vw));
|
|
6300
8035
|
bg.setAttribute("height", String(vh));
|
|
@@ -6327,8 +8062,8 @@ var AUTO_LAYOUT = react.forwardRef(
|
|
|
6327
8062
|
img.src = url;
|
|
6328
8063
|
});
|
|
6329
8064
|
const canvas = document.createElement("canvas");
|
|
6330
|
-
canvas.width = Math.round(vw *
|
|
6331
|
-
canvas.height = Math.round(vh *
|
|
8065
|
+
canvas.width = Math.round(vw * PX_PER_MM9);
|
|
8066
|
+
canvas.height = Math.round(vh * PX_PER_MM9);
|
|
6332
8067
|
const ctx = canvas.getContext("2d");
|
|
6333
8068
|
ctx.fillStyle = "#ffffff";
|
|
6334
8069
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -6352,8 +8087,8 @@ var AUTO_LAYOUT = react.forwardRef(
|
|
|
6352
8087
|
const svg = document.createElementNS(svgNs, "svg");
|
|
6353
8088
|
svg.setAttribute("xmlns", svgNs);
|
|
6354
8089
|
svg.setAttribute("viewBox", `0 0 ${paperResult.paperWidth} ${paperResult.paperHeight}`);
|
|
6355
|
-
svg.setAttribute("width", String(Math.round(paperResult.paperWidth *
|
|
6356
|
-
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)));
|
|
6357
8092
|
const bg = document.createElementNS(svgNs, "rect");
|
|
6358
8093
|
bg.setAttribute("width", String(paperResult.paperWidth));
|
|
6359
8094
|
bg.setAttribute("height", String(paperResult.paperHeight));
|
|
@@ -6457,8 +8192,8 @@ var AUTO_LAYOUT = react.forwardRef(
|
|
|
6457
8192
|
img.src = url;
|
|
6458
8193
|
});
|
|
6459
8194
|
const canvas = document.createElement("canvas");
|
|
6460
|
-
canvas.width = Math.round(paperResult.paperWidth *
|
|
6461
|
-
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);
|
|
6462
8197
|
const ctx = canvas.getContext("2d");
|
|
6463
8198
|
ctx.fillStyle = theme.colorPaperFill;
|
|
6464
8199
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -7019,6 +8754,22 @@ var BECF_12109_DEFAULT_ATTRIBUTES = {
|
|
|
7019
8754
|
glueArea: 13
|
|
7020
8755
|
};
|
|
7021
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
|
+
|
|
7022
8773
|
// src/statics/modelList.ts
|
|
7023
8774
|
var modelList = [
|
|
7024
8775
|
{
|
|
@@ -7058,10 +8809,24 @@ var modelList = [
|
|
|
7058
8809
|
},
|
|
7059
8810
|
{
|
|
7060
8811
|
id: "BECF-12109",
|
|
7061
|
-
nameEN: "SHOPPING BAGS TYPE
|
|
7062
|
-
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",
|
|
7063
8814
|
dimension: ["DIE_LINE"],
|
|
7064
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 }
|
|
7065
8830
|
}
|
|
7066
8831
|
];
|
|
7067
8832
|
|
|
@@ -7082,6 +8847,8 @@ exports.BECF_1040A_DEFAULT_ATTRIBUTES = BECF_1040A_DEFAULT_ATTRIBUTES;
|
|
|
7082
8847
|
exports.BECF_11D01_DEFAULT_ATTRIBUTES = BECF_11D01_DEFAULT_ATTRIBUTES;
|
|
7083
8848
|
exports.BECF_12101_DEFAULT_ATTRIBUTES = BECF_12101_DEFAULT_ATTRIBUTES;
|
|
7084
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;
|
|
7085
8852
|
exports.Colorbar = Colorbar;
|
|
7086
8853
|
exports.DIE_LINE_LAYOUT = DIE_LINE_LAYOUT;
|
|
7087
8854
|
exports.Gripper = Gripper;
|
|
@@ -7091,6 +8858,8 @@ exports.MODEL_BECF_1040A = MODEL_BECF_1040A;
|
|
|
7091
8858
|
exports.MODEL_BECF_11D01 = MODEL_BECF_11D01;
|
|
7092
8859
|
exports.MODEL_BECF_12101 = MODEL_BECF_12101;
|
|
7093
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;
|
|
7094
8863
|
exports.MODEL_THEME_CONFIG = MODEL_THEME_CONFIG;
|
|
7095
8864
|
exports.appendColorbarToSvg = appendColorbarToSvg;
|
|
7096
8865
|
exports.appendGripperToSvg = appendGripperToSvg;
|