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