@tscircuit/cli 0.1.2303 → 0.1.2304
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/cli/build/build.worker.js +420 -118
- package/dist/cli/main.js +2 -2
- package/dist/lib/index.js +2 -2
- package/package.json +2 -2
|
@@ -35079,15 +35079,20 @@ var fmtNum2 = (n) => Number.isInteger(n) ? `${n}.` : `${n}`;
|
|
|
35079
35079
|
var Repository2 = class {
|
|
35080
35080
|
map = /* @__PURE__ */ new Map;
|
|
35081
35081
|
order = [];
|
|
35082
|
+
maxId = 0;
|
|
35082
35083
|
schema = "AP214";
|
|
35083
35084
|
units = { length: "MM", angle: "RAD", solidAngle: "SR" };
|
|
35084
35085
|
set(id, e) {
|
|
35085
|
-
if (!this.map.has(id))
|
|
35086
|
+
if (!this.map.has(id)) {
|
|
35086
35087
|
this.order.push(id);
|
|
35088
|
+
if (id > this.maxId)
|
|
35089
|
+
this.maxId = id;
|
|
35090
|
+
}
|
|
35087
35091
|
this.map.set(id, e);
|
|
35088
35092
|
}
|
|
35089
35093
|
add(e) {
|
|
35090
|
-
|
|
35094
|
+
this.maxId++;
|
|
35095
|
+
const id = eid2(this.maxId);
|
|
35091
35096
|
this.set(id, e);
|
|
35092
35097
|
return new Ref2(id);
|
|
35093
35098
|
}
|
|
@@ -35295,6 +35300,103 @@ var Vector2 = class _Vector extends Entity2 {
|
|
|
35295
35300
|
}
|
|
35296
35301
|
};
|
|
35297
35302
|
register2("VECTOR", Vector2.parse.bind(Vector2));
|
|
35303
|
+
var Ellipse2 = class _Ellipse extends Entity2 {
|
|
35304
|
+
constructor(name, placement, semiAxis1, semiAxis2) {
|
|
35305
|
+
super();
|
|
35306
|
+
this.name = name;
|
|
35307
|
+
this.placement = placement;
|
|
35308
|
+
this.semiAxis1 = semiAxis1;
|
|
35309
|
+
this.semiAxis2 = semiAxis2;
|
|
35310
|
+
}
|
|
35311
|
+
type = "ELLIPSE";
|
|
35312
|
+
static parse(a, ctx) {
|
|
35313
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
35314
|
+
const placement = ctx.parseRef(a[1]);
|
|
35315
|
+
const semiAxis1 = ctx.parseNumber(a[2]);
|
|
35316
|
+
const semiAxis2 = ctx.parseNumber(a[3]);
|
|
35317
|
+
return new _Ellipse(name, placement, semiAxis1, semiAxis2);
|
|
35318
|
+
}
|
|
35319
|
+
toStep() {
|
|
35320
|
+
return `ELLIPSE(${stepStr2(this.name)},${this.placement},${fmtNum2(this.semiAxis1)},${fmtNum2(this.semiAxis2)})`;
|
|
35321
|
+
}
|
|
35322
|
+
};
|
|
35323
|
+
register2("ELLIPSE", Ellipse2.parse.bind(Ellipse2));
|
|
35324
|
+
var ConicalSurface2 = class _ConicalSurface extends Entity2 {
|
|
35325
|
+
constructor(name, position, radius, semiAngle) {
|
|
35326
|
+
super();
|
|
35327
|
+
this.name = name;
|
|
35328
|
+
this.position = position;
|
|
35329
|
+
this.radius = radius;
|
|
35330
|
+
this.semiAngle = semiAngle;
|
|
35331
|
+
}
|
|
35332
|
+
type = "CONICAL_SURFACE";
|
|
35333
|
+
static parse(a, ctx) {
|
|
35334
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
35335
|
+
const position = ctx.parseRef(a[1]);
|
|
35336
|
+
const radius = ctx.parseNumber(a[2]);
|
|
35337
|
+
const semiAngle = ctx.parseNumber(a[3]);
|
|
35338
|
+
return new _ConicalSurface(name, position, radius, semiAngle);
|
|
35339
|
+
}
|
|
35340
|
+
toStep() {
|
|
35341
|
+
return `CONICAL_SURFACE(${stepStr2(this.name)},${this.position},${fmtNum2(this.radius)},${fmtNum2(this.semiAngle)})`;
|
|
35342
|
+
}
|
|
35343
|
+
};
|
|
35344
|
+
register2("CONICAL_SURFACE", ConicalSurface2.parse.bind(ConicalSurface2));
|
|
35345
|
+
var SphericalSurface2 = class _SphericalSurface extends Entity2 {
|
|
35346
|
+
constructor(name, position, radius) {
|
|
35347
|
+
super();
|
|
35348
|
+
this.name = name;
|
|
35349
|
+
this.position = position;
|
|
35350
|
+
this.radius = radius;
|
|
35351
|
+
}
|
|
35352
|
+
type = "SPHERICAL_SURFACE";
|
|
35353
|
+
static parse(a, ctx) {
|
|
35354
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
35355
|
+
const position = ctx.parseRef(a[1]);
|
|
35356
|
+
const radius = ctx.parseNumber(a[2]);
|
|
35357
|
+
return new _SphericalSurface(name, position, radius);
|
|
35358
|
+
}
|
|
35359
|
+
toStep() {
|
|
35360
|
+
return `SPHERICAL_SURFACE(${stepStr2(this.name)},${this.position},${fmtNum2(this.radius)})`;
|
|
35361
|
+
}
|
|
35362
|
+
};
|
|
35363
|
+
register2("SPHERICAL_SURFACE", SphericalSurface2.parse.bind(SphericalSurface2));
|
|
35364
|
+
var BSplineCurveWithKnots2 = class _BSplineCurveWithKnots extends Entity2 {
|
|
35365
|
+
constructor(name, degree, controlPointsList, curveForm, closedCurve, selfIntersect, knotMultiplicities, knots, knotSpec) {
|
|
35366
|
+
super();
|
|
35367
|
+
this.name = name;
|
|
35368
|
+
this.degree = degree;
|
|
35369
|
+
this.controlPointsList = controlPointsList;
|
|
35370
|
+
this.curveForm = curveForm;
|
|
35371
|
+
this.closedCurve = closedCurve;
|
|
35372
|
+
this.selfIntersect = selfIntersect;
|
|
35373
|
+
this.knotMultiplicities = knotMultiplicities;
|
|
35374
|
+
this.knots = knots;
|
|
35375
|
+
this.knotSpec = knotSpec;
|
|
35376
|
+
}
|
|
35377
|
+
type = "B_SPLINE_CURVE_WITH_KNOTS";
|
|
35378
|
+
static parse(a, ctx) {
|
|
35379
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
35380
|
+
const degree = ctx.parseNumber(a[1]);
|
|
35381
|
+
const controlPoints = a[2].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
|
|
35382
|
+
const curveForm = a[3].trim();
|
|
35383
|
+
const closedCurve = a[4].trim() === ".T.";
|
|
35384
|
+
const selfIntersect = a[5].trim() === ".T.";
|
|
35385
|
+
const knotMults = a[6].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseNumber(tok.trim()));
|
|
35386
|
+
const knots = a[7].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseNumber(tok.trim()));
|
|
35387
|
+
const knotSpec = a[8].trim();
|
|
35388
|
+
return new _BSplineCurveWithKnots(name, degree, controlPoints, curveForm, closedCurve, selfIntersect, knotMults, knots, knotSpec);
|
|
35389
|
+
}
|
|
35390
|
+
toStep() {
|
|
35391
|
+
const cps = `(${this.controlPointsList.join(",")})`;
|
|
35392
|
+
const kms = `(${this.knotMultiplicities.map(fmtNum2).join(",")})`;
|
|
35393
|
+
const ks = `(${this.knots.map(fmtNum2).join(",")})`;
|
|
35394
|
+
const closed = this.closedCurve ? ".T." : ".F.";
|
|
35395
|
+
const self = this.selfIntersect ? ".T." : ".F.";
|
|
35396
|
+
return `B_SPLINE_CURVE_WITH_KNOTS(${stepStr2(this.name)},${this.degree},${cps},${this.curveForm},${closed},${self},${kms},${ks},${this.knotSpec})`;
|
|
35397
|
+
}
|
|
35398
|
+
};
|
|
35399
|
+
register2("B_SPLINE_CURVE_WITH_KNOTS", BSplineCurveWithKnots2.parse.bind(BSplineCurveWithKnots2));
|
|
35298
35400
|
var ColourRgb2 = class _ColourRgb extends Entity2 {
|
|
35299
35401
|
constructor(name, r, g, b) {
|
|
35300
35402
|
super();
|
|
@@ -35569,9 +35671,9 @@ var Product2 = class _Product extends Entity2 {
|
|
|
35569
35671
|
}
|
|
35570
35672
|
type = "PRODUCT";
|
|
35571
35673
|
static parse(a, ctx) {
|
|
35572
|
-
const name = ctx.parseString(a[0]);
|
|
35573
|
-
const id = ctx.parseString(a[1]);
|
|
35574
|
-
const description = ctx.parseString(a[2]);
|
|
35674
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
35675
|
+
const id = a[1] === "$" ? "" : ctx.parseString(a[1]);
|
|
35676
|
+
const description = a[2] === "$" ? "" : ctx.parseString(a[2]);
|
|
35575
35677
|
const refs = a[3].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
|
|
35576
35678
|
return new _Product(name, id, description, refs);
|
|
35577
35679
|
}
|
|
@@ -35925,9 +36027,9 @@ var __commonJS2 = (cb, mod) => function __require() {
|
|
|
35925
36027
|
};
|
|
35926
36028
|
var __copyProps = (to, from, except, desc) => {
|
|
35927
36029
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
35928
|
-
for (let
|
|
35929
|
-
if (!__hasOwnProp2.call(to,
|
|
35930
|
-
__defProp2(to,
|
|
36030
|
+
for (let key2 of __getOwnPropNames2(from))
|
|
36031
|
+
if (!__hasOwnProp2.call(to, key2) && key2 !== except)
|
|
36032
|
+
__defProp2(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
35931
36033
|
}
|
|
35932
36034
|
return to;
|
|
35933
36035
|
};
|
|
@@ -36319,13 +36421,13 @@ var require_add2 = __commonJS2({
|
|
|
36319
36421
|
});
|
|
36320
36422
|
var require_dot = __commonJS2({
|
|
36321
36423
|
"node_modules/@jscad/modeling/src/maths/vec3/dot.js"(exports, module) {
|
|
36322
|
-
var
|
|
36323
|
-
module.exports =
|
|
36424
|
+
var dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
36425
|
+
module.exports = dot3;
|
|
36324
36426
|
}
|
|
36325
36427
|
});
|
|
36326
36428
|
var require_angle = __commonJS2({
|
|
36327
36429
|
"node_modules/@jscad/modeling/src/maths/vec3/angle.js"(exports, module) {
|
|
36328
|
-
var
|
|
36430
|
+
var dot3 = require_dot();
|
|
36329
36431
|
var angle = (a, b) => {
|
|
36330
36432
|
const ax = a[0];
|
|
36331
36433
|
const ay = a[1];
|
|
@@ -36336,7 +36438,7 @@ var require_angle = __commonJS2({
|
|
|
36336
36438
|
const mag1 = Math.sqrt(ax * ax + ay * ay + az * az);
|
|
36337
36439
|
const mag2 = Math.sqrt(bx * bx + by * by + bz * bz);
|
|
36338
36440
|
const mag = mag1 * mag2;
|
|
36339
|
-
const cosine = mag &&
|
|
36441
|
+
const cosine = mag && dot3(a, b) / mag;
|
|
36340
36442
|
return Math.acos(Math.min(Math.max(cosine, -1), 1));
|
|
36341
36443
|
};
|
|
36342
36444
|
module.exports = angle;
|
|
@@ -36374,7 +36476,7 @@ var require_copy2 = __commonJS2({
|
|
|
36374
36476
|
});
|
|
36375
36477
|
var require_cross = __commonJS2({
|
|
36376
36478
|
"node_modules/@jscad/modeling/src/maths/vec3/cross.js"(exports, module) {
|
|
36377
|
-
var
|
|
36479
|
+
var cross3 = (out, a, b) => {
|
|
36378
36480
|
const ax = a[0];
|
|
36379
36481
|
const ay = a[1];
|
|
36380
36482
|
const az = a[2];
|
|
@@ -36386,7 +36488,7 @@ var require_cross = __commonJS2({
|
|
|
36386
36488
|
out[2] = ax * by - ay * bx;
|
|
36387
36489
|
return out;
|
|
36388
36490
|
};
|
|
36389
|
-
module.exports =
|
|
36491
|
+
module.exports = cross3;
|
|
36390
36492
|
}
|
|
36391
36493
|
});
|
|
36392
36494
|
var require_distance = __commonJS2({
|
|
@@ -36540,13 +36642,13 @@ var require_orthogonal = __commonJS2({
|
|
|
36540
36642
|
"node_modules/@jscad/modeling/src/maths/vec3/orthogonal.js"(exports, module) {
|
|
36541
36643
|
var abs = require_abs();
|
|
36542
36644
|
var create = require_create2();
|
|
36543
|
-
var
|
|
36645
|
+
var cross3 = require_cross();
|
|
36544
36646
|
var orthogonal = (out, vector) => {
|
|
36545
36647
|
const bV = abs(create(), vector);
|
|
36546
36648
|
const b0 = 0 + (bV[0] < bV[1] && bV[0] < bV[2]);
|
|
36547
36649
|
const b1 = 0 + (bV[1] <= bV[0] && bV[1] < bV[2]);
|
|
36548
36650
|
const b2 = 0 + (bV[2] <= bV[0] && bV[2] <= bV[1]);
|
|
36549
|
-
return
|
|
36651
|
+
return cross3(out, vector, [b0, b1, b2]);
|
|
36550
36652
|
};
|
|
36551
36653
|
module.exports = orthogonal;
|
|
36552
36654
|
}
|
|
@@ -37347,13 +37449,13 @@ var require_copy3 = __commonJS2({
|
|
|
37347
37449
|
});
|
|
37348
37450
|
var require_cross2 = __commonJS2({
|
|
37349
37451
|
"node_modules/@jscad/modeling/src/maths/vec2/cross.js"(exports, module) {
|
|
37350
|
-
var
|
|
37452
|
+
var cross3 = (out, a, b) => {
|
|
37351
37453
|
out[0] = 0;
|
|
37352
37454
|
out[1] = 0;
|
|
37353
37455
|
out[2] = a[0] * b[1] - a[1] * b[0];
|
|
37354
37456
|
return out;
|
|
37355
37457
|
};
|
|
37356
|
-
module.exports =
|
|
37458
|
+
module.exports = cross3;
|
|
37357
37459
|
}
|
|
37358
37460
|
});
|
|
37359
37461
|
var require_distance2 = __commonJS2({
|
|
@@ -37378,8 +37480,8 @@ var require_divide2 = __commonJS2({
|
|
|
37378
37480
|
});
|
|
37379
37481
|
var require_dot2 = __commonJS2({
|
|
37380
37482
|
"node_modules/@jscad/modeling/src/maths/vec2/dot.js"(exports, module) {
|
|
37381
|
-
var
|
|
37382
|
-
module.exports =
|
|
37483
|
+
var dot3 = (a, b) => a[0] * b[0] + a[1] * b[1];
|
|
37484
|
+
module.exports = dot3;
|
|
37383
37485
|
}
|
|
37384
37486
|
});
|
|
37385
37487
|
var require_equals3 = __commonJS2({
|
|
@@ -37741,11 +37843,11 @@ var require_toOutlines = __commonJS2({
|
|
|
37741
37843
|
var toSharedVertices = (sides) => {
|
|
37742
37844
|
const unique = /* @__PURE__ */ new Map;
|
|
37743
37845
|
const getUniqueVertex = (vertex) => {
|
|
37744
|
-
const
|
|
37745
|
-
if (unique.has(
|
|
37746
|
-
return unique.get(
|
|
37846
|
+
const key2 = vertex.toString();
|
|
37847
|
+
if (unique.has(key2)) {
|
|
37848
|
+
return unique.get(key2);
|
|
37747
37849
|
} else {
|
|
37748
|
-
unique.set(
|
|
37850
|
+
unique.set(key2, vertex);
|
|
37749
37851
|
return vertex;
|
|
37750
37852
|
}
|
|
37751
37853
|
};
|
|
@@ -37987,7 +38089,7 @@ var require_create5 = __commonJS2({
|
|
|
37987
38089
|
});
|
|
37988
38090
|
var require_point_line_distance = __commonJS2({
|
|
37989
38091
|
"node_modules/@jscad/modeling/src/operations/hulls/quickhull/point-line-distance.js"(exports, module) {
|
|
37990
|
-
var
|
|
38092
|
+
var cross3 = require_cross();
|
|
37991
38093
|
var subtract2 = require_subtract();
|
|
37992
38094
|
var squaredLength = require_squaredLength();
|
|
37993
38095
|
var distanceSquared = (p, a, b) => {
|
|
@@ -37996,7 +38098,7 @@ var require_point_line_distance = __commonJS2({
|
|
|
37996
38098
|
const cr = [];
|
|
37997
38099
|
subtract2(ab, b, a);
|
|
37998
38100
|
subtract2(ap, p, a);
|
|
37999
|
-
const area = squaredLength(
|
|
38101
|
+
const area = squaredLength(cross3(cr, ap, ab));
|
|
38000
38102
|
const s = squaredLength(ab);
|
|
38001
38103
|
if (s === 0) {
|
|
38002
38104
|
throw Error("a and b are the same point");
|
|
@@ -38009,14 +38111,14 @@ var require_point_line_distance = __commonJS2({
|
|
|
38009
38111
|
});
|
|
38010
38112
|
var require_get_plane_normal = __commonJS2({
|
|
38011
38113
|
"node_modules/@jscad/modeling/src/operations/hulls/quickhull/get-plane-normal.js"(exports, module) {
|
|
38012
|
-
var
|
|
38114
|
+
var cross3 = require_cross();
|
|
38013
38115
|
var normalize2 = require_normalize();
|
|
38014
38116
|
var subtract2 = require_subtract();
|
|
38015
38117
|
var planeNormal = (out, point1, point2, point3) => {
|
|
38016
38118
|
const tmp = [0, 0, 0];
|
|
38017
38119
|
subtract2(out, point1, point2);
|
|
38018
38120
|
subtract2(tmp, point2, point3);
|
|
38019
|
-
|
|
38121
|
+
cross3(out, out, tmp);
|
|
38020
38122
|
return normalize2(out, out);
|
|
38021
38123
|
};
|
|
38022
38124
|
module.exports = planeNormal;
|
|
@@ -38164,8 +38266,8 @@ var require_Face = __commonJS2({
|
|
|
38164
38266
|
"node_modules/@jscad/modeling/src/operations/hulls/quickhull/Face.js"(exports, module) {
|
|
38165
38267
|
var add = require_add2();
|
|
38166
38268
|
var copy = require_copy2();
|
|
38167
|
-
var
|
|
38168
|
-
var
|
|
38269
|
+
var cross3 = require_cross();
|
|
38270
|
+
var dot3 = require_dot();
|
|
38169
38271
|
var length = require_length();
|
|
38170
38272
|
var normalize2 = require_normalize();
|
|
38171
38273
|
var scale = require_scale();
|
|
@@ -38211,7 +38313,7 @@ var require_Face = __commonJS2({
|
|
|
38211
38313
|
while (e2 !== e0) {
|
|
38212
38314
|
copy(v1, v2);
|
|
38213
38315
|
subtract2(v2, e2.head().point, e0.head().point);
|
|
38214
|
-
add(this.normal, this.normal,
|
|
38316
|
+
add(this.normal, this.normal, cross3(t, v1, v2));
|
|
38215
38317
|
e2 = e2.next;
|
|
38216
38318
|
this.nVertices += 1;
|
|
38217
38319
|
}
|
|
@@ -38237,7 +38339,7 @@ var require_Face = __commonJS2({
|
|
|
38237
38339
|
const maxVector = subtract2([], p2, p1);
|
|
38238
38340
|
const maxLength = Math.sqrt(maxSquaredLength);
|
|
38239
38341
|
scale(maxVector, maxVector, 1 / maxLength);
|
|
38240
|
-
const maxProjection =
|
|
38342
|
+
const maxProjection = dot3(this.normal, maxVector);
|
|
38241
38343
|
scale(maxVector, maxVector, -maxProjection);
|
|
38242
38344
|
add(this.normal, this.normal, maxVector);
|
|
38243
38345
|
normalize2(this.normal, this.normal);
|
|
@@ -38259,10 +38361,10 @@ var require_Face = __commonJS2({
|
|
|
38259
38361
|
this.computeNormal();
|
|
38260
38362
|
}
|
|
38261
38363
|
this.computeCentroid();
|
|
38262
|
-
this.offset =
|
|
38364
|
+
this.offset = dot3(this.normal, this.centroid);
|
|
38263
38365
|
}
|
|
38264
38366
|
distanceToPlane(point) {
|
|
38265
|
-
return
|
|
38367
|
+
return dot3(this.normal, point) - this.offset;
|
|
38266
38368
|
}
|
|
38267
38369
|
connectHalfEdges(prev, next) {
|
|
38268
38370
|
let discardedFace;
|
|
@@ -38360,7 +38462,7 @@ var require_Face = __commonJS2({
|
|
|
38360
38462
|
});
|
|
38361
38463
|
var require_QuickHull = __commonJS2({
|
|
38362
38464
|
"node_modules/@jscad/modeling/src/operations/hulls/quickhull/QuickHull.js"(exports, module) {
|
|
38363
|
-
var
|
|
38465
|
+
var dot3 = require_dot();
|
|
38364
38466
|
var pointLineDistance = require_point_line_distance();
|
|
38365
38467
|
var getPlaneNormal = require_get_plane_normal();
|
|
38366
38468
|
var VertexList = require_VertexList();
|
|
@@ -38522,12 +38624,12 @@ var require_QuickHull = __commonJS2({
|
|
|
38522
38624
|
}
|
|
38523
38625
|
}
|
|
38524
38626
|
const normal = getPlaneNormal([], v0.point, v1.point, v2.point);
|
|
38525
|
-
const distPO =
|
|
38627
|
+
const distPO = dot3(v0.point, normal);
|
|
38526
38628
|
maxDistance = -1;
|
|
38527
38629
|
for (i = 0;i < this.vertices.length; i += 1) {
|
|
38528
38630
|
const vertex = this.vertices[i];
|
|
38529
38631
|
if (vertex !== v0 && vertex !== v1 && vertex !== v2) {
|
|
38530
|
-
const distance = Math.abs(
|
|
38632
|
+
const distance = Math.abs(dot3(normal, vertex.point) - distPO);
|
|
38531
38633
|
if (distance > maxDistance) {
|
|
38532
38634
|
maxDistance = distance;
|
|
38533
38635
|
v3 = vertex;
|
|
@@ -38535,7 +38637,7 @@ var require_QuickHull = __commonJS2({
|
|
|
38535
38637
|
}
|
|
38536
38638
|
}
|
|
38537
38639
|
const faces = [];
|
|
38538
|
-
if (
|
|
38640
|
+
if (dot3(v3.point, normal) - distPO < 0) {
|
|
38539
38641
|
faces.push(Face.createTriangle(v0, v1, v2), Face.createTriangle(v3, v1, v0), Face.createTriangle(v3, v2, v1), Face.createTriangle(v3, v0, v2));
|
|
38540
38642
|
for (i = 0;i < 3; i += 1) {
|
|
38541
38643
|
const j2 = (i + 1) % 3;
|
|
@@ -39237,8 +39339,8 @@ var require_measureBoundingBox = __commonJS2({
|
|
|
39237
39339
|
});
|
|
39238
39340
|
var require_dot3 = __commonJS2({
|
|
39239
39341
|
"node_modules/@jscad/modeling/src/maths/vec4/dot.js"(exports, module) {
|
|
39240
|
-
var
|
|
39241
|
-
module.exports =
|
|
39342
|
+
var dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
|
|
39343
|
+
module.exports = dot3;
|
|
39242
39344
|
}
|
|
39243
39345
|
});
|
|
39244
39346
|
var require_fromScalar3 = __commonJS2({
|
|
@@ -39337,10 +39439,10 @@ var require_measureSignedVolume = __commonJS2({
|
|
|
39337
39439
|
var measureSignedVolume = (polygon) => {
|
|
39338
39440
|
let signedVolume = 0;
|
|
39339
39441
|
const vertices = polygon.vertices;
|
|
39340
|
-
const
|
|
39442
|
+
const cross3 = vec3.create();
|
|
39341
39443
|
for (let i = 0;i < vertices.length - 2; i++) {
|
|
39342
|
-
vec3.cross(
|
|
39343
|
-
signedVolume += vec3.dot(vertices[0],
|
|
39444
|
+
vec3.cross(cross3, vertices[i + 1], vertices[i + 2]);
|
|
39445
|
+
signedVolume += vec3.dot(vertices[0], cross3);
|
|
39344
39446
|
}
|
|
39345
39447
|
signedVolume /= 6;
|
|
39346
39448
|
return signedVolume;
|
|
@@ -39589,9 +39691,9 @@ var require_isConvex2 = __commonJS2({
|
|
|
39589
39691
|
const verts = polygons[i].vertices;
|
|
39590
39692
|
for (let j = 0;j < verts.length; j++) {
|
|
39591
39693
|
const v = verts[j];
|
|
39592
|
-
const
|
|
39593
|
-
if (!found.has(
|
|
39594
|
-
found.add(
|
|
39694
|
+
const key2 = `${v[0]},${v[1]},${v[2]}`;
|
|
39695
|
+
if (!found.has(key2)) {
|
|
39696
|
+
found.add(key2);
|
|
39595
39697
|
vertices.push(v);
|
|
39596
39698
|
}
|
|
39597
39699
|
}
|
|
@@ -46327,9 +46429,9 @@ var require_minkowskiSum = __commonJS2({
|
|
|
46327
46429
|
const vertices = polygons[i].vertices;
|
|
46328
46430
|
for (let j = 0;j < vertices.length; j++) {
|
|
46329
46431
|
const v = vertices[j];
|
|
46330
|
-
const
|
|
46331
|
-
if (!found.has(
|
|
46332
|
-
found.add(
|
|
46432
|
+
const key2 = `${v[0]},${v[1]},${v[2]}`;
|
|
46433
|
+
if (!found.has(key2)) {
|
|
46434
|
+
found.add(key2);
|
|
46333
46435
|
unique.push(v);
|
|
46334
46436
|
}
|
|
46335
46437
|
}
|
|
@@ -46346,17 +46448,17 @@ var require_scissionGeom3 = __commonJS2({
|
|
|
46346
46448
|
var geom3 = require_geom3();
|
|
46347
46449
|
var sortNb = (array) => array.sort((a, b) => a - b).filter((item, pos, ary) => !pos || item !== ary[pos - 1]);
|
|
46348
46450
|
var insertMapping = (map, point, index) => {
|
|
46349
|
-
const
|
|
46350
|
-
const mapping = map.get(
|
|
46451
|
+
const key2 = `${point}`;
|
|
46452
|
+
const mapping = map.get(key2);
|
|
46351
46453
|
if (mapping === undefined) {
|
|
46352
|
-
map.set(
|
|
46454
|
+
map.set(key2, [index]);
|
|
46353
46455
|
} else {
|
|
46354
46456
|
mapping.push(index);
|
|
46355
46457
|
}
|
|
46356
46458
|
};
|
|
46357
46459
|
var findMapping = (map, point) => {
|
|
46358
|
-
const
|
|
46359
|
-
return map.get(
|
|
46460
|
+
const key2 = `${point}`;
|
|
46461
|
+
return map.get(key2);
|
|
46360
46462
|
};
|
|
46361
46463
|
var scissionGeom3 = (geometry) => {
|
|
46362
46464
|
const eps = measureEpsilon(geometry);
|
|
@@ -46777,24 +46879,24 @@ var require_expandShell = __commonJS2({
|
|
|
46777
46879
|
var unionGeom3Sub = require_unionGeom3Sub();
|
|
46778
46880
|
var extrudePolygon = require_extrudePolygon();
|
|
46779
46881
|
var mapPlaneToVertex = (map, vertex, plane) => {
|
|
46780
|
-
const
|
|
46781
|
-
if (!map.has(
|
|
46882
|
+
const key2 = vertex.toString();
|
|
46883
|
+
if (!map.has(key2)) {
|
|
46782
46884
|
const entry = [vertex, [plane]];
|
|
46783
|
-
map.set(
|
|
46885
|
+
map.set(key2, entry);
|
|
46784
46886
|
} else {
|
|
46785
|
-
const planes = map.get(
|
|
46887
|
+
const planes = map.get(key2)[1];
|
|
46786
46888
|
planes.push(plane);
|
|
46787
46889
|
}
|
|
46788
46890
|
};
|
|
46789
46891
|
var mapPlaneToEdge = (map, edge, plane) => {
|
|
46790
46892
|
const key0 = edge[0].toString();
|
|
46791
46893
|
const key1 = edge[1].toString();
|
|
46792
|
-
const
|
|
46793
|
-
if (!map.has(
|
|
46894
|
+
const key2 = key0 < key1 ? `${key0},${key1}` : `${key1},${key0}`;
|
|
46895
|
+
if (!map.has(key2)) {
|
|
46794
46896
|
const entry = [edge, [plane]];
|
|
46795
|
-
map.set(
|
|
46897
|
+
map.set(key2, entry);
|
|
46796
46898
|
} else {
|
|
46797
|
-
const planes = map.get(
|
|
46899
|
+
const planes = map.get(key2)[1];
|
|
46798
46900
|
planes.push(plane);
|
|
46799
46901
|
}
|
|
46800
46902
|
};
|
|
@@ -46903,8 +47005,8 @@ var require_expandShell = __commonJS2({
|
|
|
46903
47005
|
let bestzaxisorthogonality = 0;
|
|
46904
47006
|
for (let i = 1;i < planes.length; i++) {
|
|
46905
47007
|
const normal = planes[i];
|
|
46906
|
-
const
|
|
46907
|
-
const crosslength = vec3.length(
|
|
47008
|
+
const cross3 = vec3.cross(v1, xaxis, normal);
|
|
47009
|
+
const crosslength = vec3.length(cross3);
|
|
46908
47010
|
if (crosslength > 0.05) {
|
|
46909
47011
|
if (crosslength > bestzaxisorthogonality) {
|
|
46910
47012
|
bestzaxisorthogonality = crosslength;
|
|
@@ -47498,10 +47600,10 @@ var require_toUniquePoints = __commonJS2({
|
|
|
47498
47600
|
const found = /* @__PURE__ */ new Set;
|
|
47499
47601
|
const uniquePoints = [];
|
|
47500
47602
|
const addPoint = (point) => {
|
|
47501
|
-
const
|
|
47502
|
-
if (!found.has(
|
|
47603
|
+
const key2 = point.toString();
|
|
47604
|
+
if (!found.has(key2)) {
|
|
47503
47605
|
uniquePoints.push(point);
|
|
47504
|
-
found.add(
|
|
47606
|
+
found.add(key2);
|
|
47505
47607
|
}
|
|
47506
47608
|
};
|
|
47507
47609
|
geometries.forEach((geometry) => {
|
|
@@ -47683,16 +47785,16 @@ var require_mergePolygons = __commonJS2({
|
|
|
47683
47785
|
return edges;
|
|
47684
47786
|
};
|
|
47685
47787
|
var insertEdge = (edges, edge) => {
|
|
47686
|
-
const
|
|
47687
|
-
edges.set(
|
|
47788
|
+
const key2 = `${edge.v1}:${edge.v2}`;
|
|
47789
|
+
edges.set(key2, edge);
|
|
47688
47790
|
};
|
|
47689
47791
|
var deleteEdge = (edges, edge) => {
|
|
47690
|
-
const
|
|
47691
|
-
edges.delete(
|
|
47792
|
+
const key2 = `${edge.v1}:${edge.v2}`;
|
|
47793
|
+
edges.delete(key2);
|
|
47692
47794
|
};
|
|
47693
47795
|
var findOppositeEdge = (edges, edge) => {
|
|
47694
|
-
const
|
|
47695
|
-
return edges.get(
|
|
47796
|
+
const key2 = `${edge.v2}:${edge.v1}`;
|
|
47797
|
+
return edges.get(key2);
|
|
47696
47798
|
};
|
|
47697
47799
|
var calculateAnglesBetween = (current, opposite, normal) => {
|
|
47698
47800
|
let v0 = current.prev.v1;
|
|
@@ -48544,6 +48646,194 @@ var newellNormal = (vertices) => {
|
|
|
48544
48646
|
var EPS = 0.0000000001;
|
|
48545
48647
|
var snap = (n) => Math.abs(n) < EPS ? 0 : n;
|
|
48546
48648
|
var cleanVec3 = (v) => [snap(v[0]), snap(v[1]), snap(v[2])];
|
|
48649
|
+
function simpleBoundaries(loops, points, normal) {
|
|
48650
|
+
const drop = normal.map(Math.abs).indexOf(Math.max(...normal.map(Math.abs)));
|
|
48651
|
+
const axes = [0, 1, 2].filter((axis) => axis !== drop);
|
|
48652
|
+
const project = (id) => [
|
|
48653
|
+
points[id][axes[0]],
|
|
48654
|
+
points[id][axes[1]]
|
|
48655
|
+
];
|
|
48656
|
+
const distance = (p, a, b) => {
|
|
48657
|
+
const dx = b[0] - a[0], dy = b[1] - a[1];
|
|
48658
|
+
const t = Math.max(0, Math.min(1, ((p[0] - a[0]) * dx + (p[1] - a[1]) * dy) / (dx * dx + dy * dy)));
|
|
48659
|
+
return Math.hypot(p[0] - a[0] - t * dx, p[1] - a[1] - t * dy);
|
|
48660
|
+
};
|
|
48661
|
+
const orient = (a, b, c) => (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
|
|
48662
|
+
const edges = loops.flatMap((loop, ring) => loop.map((id, index) => ({
|
|
48663
|
+
a: project(id),
|
|
48664
|
+
b: project(loop[(index + 1) % loop.length]),
|
|
48665
|
+
ring,
|
|
48666
|
+
index,
|
|
48667
|
+
count: loop.length
|
|
48668
|
+
})));
|
|
48669
|
+
for (let i = 0;i < edges.length; i++) {
|
|
48670
|
+
const e = edges[i];
|
|
48671
|
+
for (let j = i + 1;j < edges.length; j++) {
|
|
48672
|
+
const f = edges[j];
|
|
48673
|
+
if (e.ring === f.ring && (j === i + 1 || f.index - e.index === e.count - 1))
|
|
48674
|
+
continue;
|
|
48675
|
+
if ([0, 1].some((axis) => Math.max(e.a[axis], e.b[axis]) + 0.000000001 < Math.min(f.a[axis], f.b[axis]) || Math.max(f.a[axis], f.b[axis]) + 0.000000001 < Math.min(e.a[axis], e.b[axis])))
|
|
48676
|
+
continue;
|
|
48677
|
+
if (orient(e.a, e.b, f.a) * orient(e.a, e.b, f.b) < 0 && orient(f.a, f.b, e.a) * orient(f.a, f.b, e.b) < 0)
|
|
48678
|
+
return false;
|
|
48679
|
+
if (Math.min(distance(e.a, f.a, f.b), distance(e.b, f.a, f.b), distance(f.a, e.a, e.b), distance(f.b, e.a, e.b)) <= 0.000000001)
|
|
48680
|
+
return false;
|
|
48681
|
+
}
|
|
48682
|
+
}
|
|
48683
|
+
return true;
|
|
48684
|
+
}
|
|
48685
|
+
function mergeCoplanarFaces(polygons, enabled = true) {
|
|
48686
|
+
if (!enabled)
|
|
48687
|
+
return polygons.map((polygon) => ({
|
|
48688
|
+
loops: [polygon],
|
|
48689
|
+
normal: newellNormal(polygon)
|
|
48690
|
+
}));
|
|
48691
|
+
const points = [];
|
|
48692
|
+
const ids = /* @__PURE__ */ new Map;
|
|
48693
|
+
const cycles = polygons.map((polygon) => polygon.map((point) => {
|
|
48694
|
+
const k = vertexKey(point);
|
|
48695
|
+
let id = ids.get(k);
|
|
48696
|
+
if (id === undefined) {
|
|
48697
|
+
id = points.length;
|
|
48698
|
+
ids.set(k, id);
|
|
48699
|
+
points.push(point);
|
|
48700
|
+
}
|
|
48701
|
+
return id;
|
|
48702
|
+
}));
|
|
48703
|
+
const metres = points.map((p) => p.map((v) => v * 0.001));
|
|
48704
|
+
return mergeCoplanarRegions(metres, cycles).map((region) => ({
|
|
48705
|
+
loops: region.loops.map((loop) => loop.map((id) => points[id])),
|
|
48706
|
+
normal: region.normal
|
|
48707
|
+
}));
|
|
48708
|
+
}
|
|
48709
|
+
var sub = (a, b) => a.map((v, i) => v - b[i]);
|
|
48710
|
+
var dot22 = (a, b) => a.reduce((s, v, i) => s + v * b[i], 0);
|
|
48711
|
+
var cross2 = (a, b) => [
|
|
48712
|
+
a[1] * b[2] - a[2] * b[1],
|
|
48713
|
+
a[2] * b[0] - a[0] * b[2],
|
|
48714
|
+
a[0] * b[1] - a[1] * b[0]
|
|
48715
|
+
];
|
|
48716
|
+
var key = (a, b) => a < b ? `${a},${b}` : `${b},${a}`;
|
|
48717
|
+
function areaVector(loop, points) {
|
|
48718
|
+
const origin = points[loop[0]];
|
|
48719
|
+
const area = [0, 0, 0];
|
|
48720
|
+
for (let i = 1;i < loop.length - 1; i++) {
|
|
48721
|
+
const c = cross2(sub(points[loop[i]], origin), sub(points[loop[i + 1]], origin));
|
|
48722
|
+
for (let axis = 0;axis < 3; axis++)
|
|
48723
|
+
area[axis] += c[axis];
|
|
48724
|
+
}
|
|
48725
|
+
return area;
|
|
48726
|
+
}
|
|
48727
|
+
function mergeCoplanarRegions(points, cycles) {
|
|
48728
|
+
const normals = cycles.map((cycle) => {
|
|
48729
|
+
const area = areaVector(cycle, points);
|
|
48730
|
+
const magnitude = Math.hypot(...area);
|
|
48731
|
+
return magnitude ? area.map((v) => v / magnitude) : [0, 0, 0];
|
|
48732
|
+
});
|
|
48733
|
+
const uses = /* @__PURE__ */ new Map;
|
|
48734
|
+
cycles.forEach((cycle, face) => cycle.forEach((a, i) => {
|
|
48735
|
+
const k = key(a, cycle[(i + 1) % cycle.length]);
|
|
48736
|
+
const list = uses.get(k) ?? [];
|
|
48737
|
+
list.push(face);
|
|
48738
|
+
uses.set(k, list);
|
|
48739
|
+
}));
|
|
48740
|
+
const visited = /* @__PURE__ */ new Set;
|
|
48741
|
+
const regions = [];
|
|
48742
|
+
for (let seed = 0;seed < cycles.length; seed++) {
|
|
48743
|
+
if (visited.has(seed))
|
|
48744
|
+
continue;
|
|
48745
|
+
const normal = normals[seed];
|
|
48746
|
+
const origin = points[cycles[seed][0]];
|
|
48747
|
+
const matches = (face) => {
|
|
48748
|
+
return dot22(normal, normals[face]) > 0 && Math.hypot(...cross2(normal, normals[face])) <= 0.0000000001 && cycles[face].every((id) => Math.abs(dot22(sub(points[id], origin), normal)) <= 0.000000001);
|
|
48749
|
+
};
|
|
48750
|
+
const group = [seed];
|
|
48751
|
+
visited.add(seed);
|
|
48752
|
+
for (let i = 0;i < group.length; i++) {
|
|
48753
|
+
const cycle = cycles[group[i]];
|
|
48754
|
+
cycle.forEach((a, j) => {
|
|
48755
|
+
const neighbours = uses.get(key(a, cycle[(j + 1) % cycle.length]));
|
|
48756
|
+
if (neighbours.length !== 2)
|
|
48757
|
+
return;
|
|
48758
|
+
for (const other of neighbours) {
|
|
48759
|
+
if (visited.has(other) || !matches(other))
|
|
48760
|
+
continue;
|
|
48761
|
+
visited.add(other);
|
|
48762
|
+
group.push(other);
|
|
48763
|
+
}
|
|
48764
|
+
});
|
|
48765
|
+
}
|
|
48766
|
+
if (group.length === 1) {
|
|
48767
|
+
regions.push({
|
|
48768
|
+
loops: [cycles[seed]],
|
|
48769
|
+
normal: newellNormal(cycles[seed].map((id) => points[id]))
|
|
48770
|
+
});
|
|
48771
|
+
continue;
|
|
48772
|
+
}
|
|
48773
|
+
const members = new Set(group);
|
|
48774
|
+
const boundary = /* @__PURE__ */ new Map;
|
|
48775
|
+
let ambiguous = false;
|
|
48776
|
+
for (const face of group) {
|
|
48777
|
+
const cycle = cycles[face];
|
|
48778
|
+
cycle.forEach((a, j) => {
|
|
48779
|
+
const b = cycle[(j + 1) % cycle.length];
|
|
48780
|
+
const incident = uses.get(key(a, b));
|
|
48781
|
+
if (incident.length > 2)
|
|
48782
|
+
ambiguous = true;
|
|
48783
|
+
if (incident.length === 2 && incident.every((other) => members.has(other))) {
|
|
48784
|
+
const other = cycles[incident.find((id) => id !== face)];
|
|
48785
|
+
if (!other?.some((v, i) => v === b && other[(i + 1) % other.length] === a))
|
|
48786
|
+
ambiguous = true;
|
|
48787
|
+
return;
|
|
48788
|
+
}
|
|
48789
|
+
if (boundary.has(a))
|
|
48790
|
+
ambiguous = true;
|
|
48791
|
+
boundary.set(a, b);
|
|
48792
|
+
});
|
|
48793
|
+
}
|
|
48794
|
+
const loops = [];
|
|
48795
|
+
while (!ambiguous && boundary.size) {
|
|
48796
|
+
const start = boundary.keys().next().value;
|
|
48797
|
+
const loop = [];
|
|
48798
|
+
let current = start;
|
|
48799
|
+
do {
|
|
48800
|
+
const next = boundary.get(current);
|
|
48801
|
+
if (next === undefined) {
|
|
48802
|
+
ambiguous = true;
|
|
48803
|
+
break;
|
|
48804
|
+
}
|
|
48805
|
+
loop.push(current);
|
|
48806
|
+
boundary.delete(current);
|
|
48807
|
+
current = next;
|
|
48808
|
+
} while (current !== start);
|
|
48809
|
+
if (loop.length < 3)
|
|
48810
|
+
ambiguous = true;
|
|
48811
|
+
loops.push(loop);
|
|
48812
|
+
}
|
|
48813
|
+
if (ambiguous || loops.length === 0) {
|
|
48814
|
+
for (const face of group)
|
|
48815
|
+
regions.push({
|
|
48816
|
+
loops: [cycles[face]],
|
|
48817
|
+
normal: normals[face]
|
|
48818
|
+
});
|
|
48819
|
+
continue;
|
|
48820
|
+
}
|
|
48821
|
+
const outer = loops.filter((loop) => dot22(areaVector(loop, points), normal) > 0);
|
|
48822
|
+
if (outer.length !== 1 || !simpleBoundaries(loops, points, normal)) {
|
|
48823
|
+
for (const face of group)
|
|
48824
|
+
regions.push({
|
|
48825
|
+
loops: [cycles[face]],
|
|
48826
|
+
normal: normals[face]
|
|
48827
|
+
});
|
|
48828
|
+
continue;
|
|
48829
|
+
}
|
|
48830
|
+
regions.push({
|
|
48831
|
+
loops: [outer[0], ...loops.filter((loop) => loop !== outer[0])],
|
|
48832
|
+
normal
|
|
48833
|
+
});
|
|
48834
|
+
}
|
|
48835
|
+
return regions;
|
|
48836
|
+
}
|
|
48547
48837
|
function extractPosition(vertex) {
|
|
48548
48838
|
if (Array.isArray(vertex) && vertex.length >= 3) {
|
|
48549
48839
|
return [
|
|
@@ -48624,17 +48914,17 @@ function splitTJunctions(polygons) {
|
|
|
48624
48914
|
}
|
|
48625
48915
|
return result;
|
|
48626
48916
|
}
|
|
48627
|
-
function geom3ToBrep(repo, geom) {
|
|
48917
|
+
function geom3ToBrep(repo, geom, mergeCoplanar = true) {
|
|
48628
48918
|
const vertexMap = /* @__PURE__ */ new Map;
|
|
48629
48919
|
const edgeMap = /* @__PURE__ */ new Map;
|
|
48630
48920
|
function getOrCreateVertex(pos) {
|
|
48631
|
-
const
|
|
48632
|
-
let ref = vertexMap.get(
|
|
48921
|
+
const key2 = vertexKey(pos);
|
|
48922
|
+
let ref = vertexMap.get(key2);
|
|
48633
48923
|
if (!ref) {
|
|
48634
48924
|
const clean = cleanVec3(pos);
|
|
48635
48925
|
const pt = repo.add(new CartesianPoint2("", clean[0], clean[1], clean[2]));
|
|
48636
48926
|
ref = repo.add(new VertexPoint2("", pt));
|
|
48637
|
-
vertexMap.set(
|
|
48927
|
+
vertexMap.set(key2, ref);
|
|
48638
48928
|
}
|
|
48639
48929
|
return ref;
|
|
48640
48930
|
}
|
|
@@ -48674,32 +48964,19 @@ function geom3ToBrep(repo, geom) {
|
|
|
48674
48964
|
}
|
|
48675
48965
|
rawPolygons = splitTJunctions(rawPolygons);
|
|
48676
48966
|
const faces = [];
|
|
48677
|
-
|
|
48678
|
-
|
|
48679
|
-
|
|
48680
|
-
|
|
48681
|
-
const
|
|
48682
|
-
|
|
48683
|
-
|
|
48684
|
-
|
|
48685
|
-
|
|
48686
|
-
|
|
48687
|
-
|
|
48688
|
-
const
|
|
48689
|
-
const
|
|
48690
|
-
for (let i = 0;i < uniquePositions.length; i++) {
|
|
48691
|
-
const aPos = uniquePositions[i];
|
|
48692
|
-
const bPos = uniquePositions[(i + 1) % uniquePositions.length];
|
|
48693
|
-
const aRef = vertexRefs[i];
|
|
48694
|
-
const bRef = vertexRefs[(i + 1) % uniquePositions.length];
|
|
48695
|
-
if (vertexKey(aPos) === vertexKey(bPos))
|
|
48696
|
-
continue;
|
|
48697
|
-
const { edgeRef, sameDirection } = getOrCreateEdge(aPos, bPos, aRef, bRef);
|
|
48698
|
-
orientedEdges.push(repo.add(new OrientedEdge2("", edgeRef, sameDirection)));
|
|
48699
|
-
}
|
|
48700
|
-
if (orientedEdges.length < 3)
|
|
48701
|
-
continue;
|
|
48702
|
-
const normal = cleanVec3(newellNormal(uniquePositions));
|
|
48967
|
+
rawPolygons = rawPolygons.map((positions) => positions.filter((pos, i) => vertexKey(pos) !== vertexKey(positions[(i + positions.length - 1) % positions.length]))).filter((positions) => positions.length >= 3);
|
|
48968
|
+
function createLoop(positions) {
|
|
48969
|
+
const vertexRefs = positions.map((pos) => getOrCreateVertex(pos));
|
|
48970
|
+
const orientedEdges = positions.map((aPos, i) => {
|
|
48971
|
+
const next = (i + 1) % positions.length;
|
|
48972
|
+
const { edgeRef, sameDirection } = getOrCreateEdge(aPos, positions[next], vertexRefs[i], vertexRefs[next]);
|
|
48973
|
+
return repo.add(new OrientedEdge2("", edgeRef, sameDirection));
|
|
48974
|
+
});
|
|
48975
|
+
return repo.add(new EdgeLoop2("", orientedEdges));
|
|
48976
|
+
}
|
|
48977
|
+
for (const region of mergeCoplanarFaces(rawPolygons, mergeCoplanar)) {
|
|
48978
|
+
const uniquePositions = region.loops[0];
|
|
48979
|
+
const normal = cleanVec3(region.normal);
|
|
48703
48980
|
const v0 = uniquePositions[0];
|
|
48704
48981
|
const cleanV0 = cleanVec3(v0);
|
|
48705
48982
|
const planeOrigin = repo.add(new CartesianPoint2("", cleanV0[0], cleanV0[1], cleanV0[2]));
|
|
@@ -48716,9 +48993,11 @@ function geom3ToBrep(repo, geom) {
|
|
|
48716
48993
|
const refDir = repo.add(new Direction2("", edge0Dir[0], edge0Dir[1], edge0Dir[2]));
|
|
48717
48994
|
const placement = repo.add(new Axis2Placement3D2("", planeOrigin, planeNormal, refDir));
|
|
48718
48995
|
const plane = repo.add(new Plane2("", placement));
|
|
48719
|
-
const
|
|
48720
|
-
|
|
48721
|
-
|
|
48996
|
+
const bounds = region.loops.map((loop, index) => {
|
|
48997
|
+
const edgeLoop = createLoop(loop);
|
|
48998
|
+
return index === 0 ? repo.add(new FaceOuterBound2("", edgeLoop, true)) : repo.add(new FaceBound2("", edgeLoop, true));
|
|
48999
|
+
});
|
|
49000
|
+
const face = repo.add(new AdvancedFace2("", bounds, plane, true));
|
|
48722
49001
|
faces.push(face);
|
|
48723
49002
|
}
|
|
48724
49003
|
return faces;
|
|
@@ -48822,7 +49101,7 @@ function resolveGeometries(input) {
|
|
|
48822
49101
|
const result = executeJscadOperations(import_modeling.default, input);
|
|
48823
49102
|
return Array.isArray(result) ? result : [result];
|
|
48824
49103
|
}
|
|
48825
|
-
function jscadToStep(operation) {
|
|
49104
|
+
function jscadToStep(operation, options = {}) {
|
|
48826
49105
|
const repo = new Repository2;
|
|
48827
49106
|
const geometries = resolveGeometries(operation);
|
|
48828
49107
|
const appContext = repo.add(new ApplicationContext2("core data for automotive mechanical design processes"));
|
|
@@ -48861,7 +49140,7 @@ function jscadToStep(operation) {
|
|
|
48861
49140
|
if (!geom?.polygons || geom.polygons.length === 0)
|
|
48862
49141
|
continue;
|
|
48863
49142
|
const { color: _color, ...brepGeom } = geom;
|
|
48864
|
-
const faces = geom3ToBrep(repo, brepGeom);
|
|
49143
|
+
const faces = geom3ToBrep(repo, brepGeom, options.mergeCoplanarFaces ?? true);
|
|
48865
49144
|
if (faces.length === 0)
|
|
48866
49145
|
continue;
|
|
48867
49146
|
const shell = repo.add(new ClosedShell2("", faces));
|
|
@@ -49567,7 +49846,7 @@ function normalizeStepNumericExponents(stepText) {
|
|
|
49567
49846
|
var package_default = {
|
|
49568
49847
|
name: "circuit-json-to-step",
|
|
49569
49848
|
main: "dist/index.js",
|
|
49570
|
-
version: "0.0.
|
|
49849
|
+
version: "0.0.47",
|
|
49571
49850
|
repository: {
|
|
49572
49851
|
type: "git",
|
|
49573
49852
|
url: "https://github.com/tscircuit/circuit-json-to-step.git"
|
|
@@ -49581,20 +49860,21 @@ var package_default = {
|
|
|
49581
49860
|
format: "biome format --write .",
|
|
49582
49861
|
"format:check": "biome format .",
|
|
49583
49862
|
start: "bun site/index.html",
|
|
49584
|
-
"build:site": "bun build site/index.html --outdir=site-export"
|
|
49863
|
+
"build:site": "bun build site/index.html --outdir=site-export",
|
|
49864
|
+
prepare: "bun install --frozen-lockfile --ignore-scripts && bun run build"
|
|
49585
49865
|
},
|
|
49586
49866
|
devDependencies: {
|
|
49587
49867
|
"@biomejs/biome": "^2.3.8",
|
|
49588
|
-
"circuit-to-svg": "^0.0.356",
|
|
49589
49868
|
"@resvg/resvg-js": "^2.6.2",
|
|
49590
49869
|
"@resvg/resvg-wasm": "^2.6.2",
|
|
49591
49870
|
"@tscircuit/circuit-json-util": "^0.0.75",
|
|
49592
49871
|
"@types/bun": "latest",
|
|
49593
49872
|
"circuit-json": "^0.0.525",
|
|
49873
|
+
"circuit-to-svg": "^0.0.356",
|
|
49594
49874
|
"looks-same": "^10.0.1",
|
|
49595
49875
|
"occt-import-js": "^0.0.23",
|
|
49596
|
-
"schematic-symbols": "^0.0.221",
|
|
49597
49876
|
poppygl: "^0.0.24",
|
|
49877
|
+
"schematic-symbols": "^0.0.221",
|
|
49598
49878
|
tsup: "^8.5.0"
|
|
49599
49879
|
},
|
|
49600
49880
|
peerDependencies: {
|
|
@@ -49605,7 +49885,7 @@ var package_default = {
|
|
|
49605
49885
|
dependencies: {
|
|
49606
49886
|
"circuit-json-to-connectivity-map": "^0.0.22",
|
|
49607
49887
|
"circuit-json-to-gltf": "^0.0.106",
|
|
49608
|
-
"jscad-to-step": "0.0.
|
|
49888
|
+
"jscad-to-step": "^0.0.11",
|
|
49609
49889
|
stepts: "^0.0.4"
|
|
49610
49890
|
}
|
|
49611
49891
|
};
|
|
@@ -49789,8 +50069,11 @@ function createPillHoleGeometry(repo, hole, zMin, zMax, zDir) {
|
|
|
49789
50069
|
}
|
|
49790
50070
|
return { bottomLoop, topLoop, wallFaces };
|
|
49791
50071
|
}
|
|
49792
|
-
function circuitJsonToAssemblyStep(circuitJson, {
|
|
49793
|
-
|
|
50072
|
+
function circuitJsonToAssemblyStep(circuitJson, {
|
|
50073
|
+
productName = "Combined Assembly",
|
|
50074
|
+
sourceComponentId
|
|
50075
|
+
} = {}) {
|
|
50076
|
+
const parts = circuitJson.filter((item) => item.type === "source_component").filter((item) => item.ftype === "printedpart").filter((item) => sourceComponentId === undefined || item.source_component_id === sourceComponentId);
|
|
49794
50077
|
if (parts.length === 0) {
|
|
49795
50078
|
throw new Error("No assembly.printedpart elements found to export");
|
|
49796
50079
|
}
|
|
@@ -49876,9 +50159,27 @@ function circuitJsonToAssemblyStep(circuitJson, { productName = "Combined Assemb
|
|
|
49876
50159
|
}
|
|
49877
50160
|
async function circuitJsonToStep(circuitJson, options = {}) {
|
|
49878
50161
|
const hasBoard = circuitJson.some((item) => item.type === "pcb_board");
|
|
49879
|
-
const
|
|
49880
|
-
if (options.exportMode === "assembly" || options.exportMode === undefined && !hasBoard && !options.boardWidth && !options.boardHeight &&
|
|
49881
|
-
|
|
50162
|
+
const printedParts = circuitJson.filter((item) => item.type === "source_component" && item.ftype === "printedpart");
|
|
50163
|
+
if (options.exportMode === "assembly" || options.exportMode === undefined && !hasBoard && !options.boardWidth && !options.boardHeight && printedParts.length > 0) {
|
|
50164
|
+
if (printedParts.length === 0) {
|
|
50165
|
+
throw new Error("No assembly.printedpart elements found to export");
|
|
50166
|
+
}
|
|
50167
|
+
const files = {};
|
|
50168
|
+
const usedNames = /* @__PURE__ */ new Set;
|
|
50169
|
+
for (const part of printedParts) {
|
|
50170
|
+
const baseName = part.name.replace(/[^a-zA-Z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "printed-part";
|
|
50171
|
+
let fileName = `${baseName}.step`;
|
|
50172
|
+
let suffix = 2;
|
|
50173
|
+
while (usedNames.has(fileName.toLowerCase())) {
|
|
50174
|
+
fileName = `${baseName}-${suffix++}.step`;
|
|
50175
|
+
}
|
|
50176
|
+
usedNames.add(fileName.toLowerCase());
|
|
50177
|
+
files[fileName] = circuitJsonToAssemblyStep(circuitJson, {
|
|
50178
|
+
productName: options.productName ?? part.name,
|
|
50179
|
+
sourceComponentId: part.source_component_id
|
|
50180
|
+
});
|
|
50181
|
+
}
|
|
50182
|
+
return files;
|
|
49882
50183
|
}
|
|
49883
50184
|
const repo = new Repository;
|
|
49884
50185
|
const pcbBoard = circuitJson.find((item) => item.type === "pcb_board");
|
|
@@ -51767,6 +52068,7 @@ var writeGlbFromCircuitJson = async (circuitJson, glbOutputPath) => {
|
|
|
51767
52068
|
};
|
|
51768
52069
|
var writeStepFromCircuitJson = async (circuitJson, stepOutputPath) => {
|
|
51769
52070
|
const stepContent = await circuitJsonToStep(circuitJson, {
|
|
52071
|
+
exportMode: "pcb",
|
|
51770
52072
|
includeComponents: true,
|
|
51771
52073
|
includeExternalMeshes: true,
|
|
51772
52074
|
fsMap: await loadLocalStepModelFsMap(circuitJson)
|
package/dist/cli/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/dist/cli/main.js
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 46820988 bytes
|
|
4
|
+
sha256: fd367510807bb619d2b456da0a1c787933fd081760a4ac9c388f2cef60d843d0
|
package/dist/lib/index.js
CHANGED
|
@@ -69121,7 +69121,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
69121
69121
|
}));
|
|
69122
69122
|
};
|
|
69123
69123
|
// package.json
|
|
69124
|
-
var version = "0.1.
|
|
69124
|
+
var version = "0.1.2303";
|
|
69125
69125
|
var package_default = {
|
|
69126
69126
|
name: "@tscircuit/cli",
|
|
69127
69127
|
version,
|
|
@@ -69179,7 +69179,7 @@ var package_default = {
|
|
|
69179
69179
|
"circuit-json-to-pnp-csv": "^0.0.18",
|
|
69180
69180
|
"circuit-json-to-readable-netlist": "^0.0.15",
|
|
69181
69181
|
"circuit-json-to-spice": "^0.0.45",
|
|
69182
|
-
"circuit-json-to-step": "^0.0.
|
|
69182
|
+
"circuit-json-to-step": "^0.0.47",
|
|
69183
69183
|
"circuit-json-to-tscircuit": "^0.0.50",
|
|
69184
69184
|
"circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8",
|
|
69185
69185
|
"circuit-to-canvas": "^0.0.123",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2304",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/tscircuit/cli"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"circuit-json-to-pnp-csv": "^0.0.18",
|
|
56
56
|
"circuit-json-to-readable-netlist": "^0.0.15",
|
|
57
57
|
"circuit-json-to-spice": "^0.0.45",
|
|
58
|
-
"circuit-json-to-step": "^0.0.
|
|
58
|
+
"circuit-json-to-step": "^0.0.47",
|
|
59
59
|
"circuit-json-to-tscircuit": "^0.0.50",
|
|
60
60
|
"circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8",
|
|
61
61
|
"circuit-to-canvas": "^0.0.123",
|