@tscircuit/cli 0.1.1371 → 0.1.1372
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 +2364 -15
- package/dist/cli/main.js +1015 -914
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
|
@@ -11504,7 +11504,7 @@ import { parentPort } from "node:worker_threads";
|
|
|
11504
11504
|
|
|
11505
11505
|
// cli/build/worker-build-handlers.ts
|
|
11506
11506
|
import fs10 from "node:fs";
|
|
11507
|
-
import
|
|
11507
|
+
import path14 from "node:path";
|
|
11508
11508
|
|
|
11509
11509
|
// lib/shared/circuit-json-diagnostics.ts
|
|
11510
11510
|
function analyzeCircuitJson(circuitJson) {
|
|
@@ -12005,7 +12005,2307 @@ var resolveImageFormatSelection = (options) => {
|
|
|
12005
12005
|
|
|
12006
12006
|
// cli/build/worker-output-generators.ts
|
|
12007
12007
|
import fs9 from "node:fs";
|
|
12008
|
-
import
|
|
12008
|
+
import path13 from "node:path";
|
|
12009
|
+
|
|
12010
|
+
// node_modules/circuit-json-to-step/node_modules/stepts/dist/index.js
|
|
12011
|
+
var Entity = class {
|
|
12012
|
+
static parse(_a, _ctx) {
|
|
12013
|
+
throw new Error("not implemented");
|
|
12014
|
+
}
|
|
12015
|
+
};
|
|
12016
|
+
var eid = (n) => n;
|
|
12017
|
+
var Ref = class {
|
|
12018
|
+
constructor(id) {
|
|
12019
|
+
this.id = id;
|
|
12020
|
+
}
|
|
12021
|
+
resolve(repo) {
|
|
12022
|
+
const e = repo.get(this.id);
|
|
12023
|
+
if (!e)
|
|
12024
|
+
throw new Error(`Unresolved #${this.id}`);
|
|
12025
|
+
return e;
|
|
12026
|
+
}
|
|
12027
|
+
toString() {
|
|
12028
|
+
return `#${this.id}`;
|
|
12029
|
+
}
|
|
12030
|
+
};
|
|
12031
|
+
var stepStr = (s) => `'${s.replace(/'/g, "''")}'`;
|
|
12032
|
+
var fmtNum = (n) => Number.isInteger(n) ? `${n}.` : `${n}`;
|
|
12033
|
+
var Repository = class {
|
|
12034
|
+
map = /* @__PURE__ */ new Map;
|
|
12035
|
+
order = [];
|
|
12036
|
+
maxId = 0;
|
|
12037
|
+
schema = "AP214";
|
|
12038
|
+
units = { length: "MM", angle: "RAD", solidAngle: "SR" };
|
|
12039
|
+
set(id, e) {
|
|
12040
|
+
if (!this.map.has(id)) {
|
|
12041
|
+
this.order.push(id);
|
|
12042
|
+
if (id > this.maxId)
|
|
12043
|
+
this.maxId = id;
|
|
12044
|
+
}
|
|
12045
|
+
this.map.set(id, e);
|
|
12046
|
+
}
|
|
12047
|
+
add(e) {
|
|
12048
|
+
this.maxId++;
|
|
12049
|
+
const id = eid(this.maxId);
|
|
12050
|
+
this.set(id, e);
|
|
12051
|
+
return new Ref(id);
|
|
12052
|
+
}
|
|
12053
|
+
get(id) {
|
|
12054
|
+
return this.map.get(id);
|
|
12055
|
+
}
|
|
12056
|
+
entries() {
|
|
12057
|
+
return this.order.map((id) => [id, this.map.get(id)]);
|
|
12058
|
+
}
|
|
12059
|
+
toPartFile(meta) {
|
|
12060
|
+
const now = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "-");
|
|
12061
|
+
const hdr = [
|
|
12062
|
+
"ISO-10303-21;",
|
|
12063
|
+
"HEADER;",
|
|
12064
|
+
`FILE_DESCRIPTION((${stepStr(meta.name)}),'2;1');`,
|
|
12065
|
+
`FILE_NAME(${stepStr(meta.name)},${stepStr(now)},(${stepStr(meta.author ?? "tscircuit")}),(${stepStr(meta.org ?? "tscircuit")}),${stepStr("generator")},${stepStr("")},${stepStr("")});`,
|
|
12066
|
+
`FILE_SCHEMA(('${this.schema === "AP214" ? "AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }" : "AP242_MANAGED_MODEL_BASED_3D_ENGINEERING"}'));`,
|
|
12067
|
+
"ENDSEC;",
|
|
12068
|
+
"DATA;"
|
|
12069
|
+
];
|
|
12070
|
+
const data = this.entries().map(([id, e]) => `#${id} = ${e.toStep(this)};`);
|
|
12071
|
+
const ftr = ["ENDSEC;", "END-ISO-10303-21;"];
|
|
12072
|
+
return [...hdr, ...data, ...ftr].join(`
|
|
12073
|
+
`);
|
|
12074
|
+
}
|
|
12075
|
+
};
|
|
12076
|
+
var registry = /* @__PURE__ */ new Map;
|
|
12077
|
+
function register(type, parser) {
|
|
12078
|
+
registry.set(type, parser);
|
|
12079
|
+
}
|
|
12080
|
+
function getParser(type) {
|
|
12081
|
+
return registry.get(type);
|
|
12082
|
+
}
|
|
12083
|
+
var Axis2Placement3D = class _Axis2Placement3D extends Entity {
|
|
12084
|
+
constructor(name, location, axis, refDirection) {
|
|
12085
|
+
super();
|
|
12086
|
+
this.name = name;
|
|
12087
|
+
this.location = location;
|
|
12088
|
+
this.axis = axis;
|
|
12089
|
+
this.refDirection = refDirection;
|
|
12090
|
+
}
|
|
12091
|
+
type = "AXIS2_PLACEMENT_3D";
|
|
12092
|
+
static parse(a, ctx) {
|
|
12093
|
+
const name = ctx.parseString(a[0]);
|
|
12094
|
+
const loc = ctx.parseRef(a[1]);
|
|
12095
|
+
const axis = a[2] !== "$" ? ctx.parseRef(a[2]) : undefined;
|
|
12096
|
+
const refd = a[3] !== "$" ? ctx.parseRef(a[3]) : undefined;
|
|
12097
|
+
return new _Axis2Placement3D(name, loc, axis, refd);
|
|
12098
|
+
}
|
|
12099
|
+
toStep() {
|
|
12100
|
+
const A = this.axis ? this.axis.toString() : "$";
|
|
12101
|
+
const R = this.refDirection ? this.refDirection.toString() : "$";
|
|
12102
|
+
return `AXIS2_PLACEMENT_3D(${stepStr(this.name)},${this.location},${A},${R})`;
|
|
12103
|
+
}
|
|
12104
|
+
};
|
|
12105
|
+
register("AXIS2_PLACEMENT_3D", Axis2Placement3D.parse.bind(Axis2Placement3D));
|
|
12106
|
+
var CartesianPoint = class _CartesianPoint extends Entity {
|
|
12107
|
+
constructor(name, x, y, z) {
|
|
12108
|
+
super();
|
|
12109
|
+
this.name = name;
|
|
12110
|
+
this.x = x;
|
|
12111
|
+
this.y = y;
|
|
12112
|
+
this.z = z;
|
|
12113
|
+
}
|
|
12114
|
+
type = "CARTESIAN_POINT";
|
|
12115
|
+
static parse(a, ctx) {
|
|
12116
|
+
const name = ctx.parseString(a[0]);
|
|
12117
|
+
const coords = a[1].replace(/^\(|\)$/g, "").split(",").map(ctx.parseNumber);
|
|
12118
|
+
return new _CartesianPoint(name, coords[0], coords[1], coords[2] ?? 0);
|
|
12119
|
+
}
|
|
12120
|
+
toStep() {
|
|
12121
|
+
return `CARTESIAN_POINT(${stepStr(this.name)},(${fmtNum(this.x)},${fmtNum(this.y)},${fmtNum(this.z)}))`;
|
|
12122
|
+
}
|
|
12123
|
+
};
|
|
12124
|
+
register("CARTESIAN_POINT", CartesianPoint.parse.bind(CartesianPoint));
|
|
12125
|
+
var Circle = class _Circle extends Entity {
|
|
12126
|
+
constructor(name, placement, radius) {
|
|
12127
|
+
super();
|
|
12128
|
+
this.name = name;
|
|
12129
|
+
this.placement = placement;
|
|
12130
|
+
this.radius = radius;
|
|
12131
|
+
}
|
|
12132
|
+
type = "CIRCLE";
|
|
12133
|
+
static parse(a, ctx) {
|
|
12134
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12135
|
+
const pl = ctx.parseRef(a[1]);
|
|
12136
|
+
const r = ctx.parseNumber(a[2]);
|
|
12137
|
+
return new _Circle(name, pl, r);
|
|
12138
|
+
}
|
|
12139
|
+
toStep() {
|
|
12140
|
+
return `CIRCLE(${this.name ? `'${this.name}'` : "''"},${this.placement},${fmtNum(this.radius)})`;
|
|
12141
|
+
}
|
|
12142
|
+
};
|
|
12143
|
+
register("CIRCLE", Circle.parse.bind(Circle));
|
|
12144
|
+
var CylindricalSurface = class _CylindricalSurface extends Entity {
|
|
12145
|
+
constructor(name, position, radius) {
|
|
12146
|
+
super();
|
|
12147
|
+
this.name = name;
|
|
12148
|
+
this.position = position;
|
|
12149
|
+
this.radius = radius;
|
|
12150
|
+
}
|
|
12151
|
+
type = "CYLINDRICAL_SURFACE";
|
|
12152
|
+
static parse(a, ctx) {
|
|
12153
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12154
|
+
const position = ctx.parseRef(a[1]);
|
|
12155
|
+
const radius = ctx.parseNumber(a[2]);
|
|
12156
|
+
return new _CylindricalSurface(name, position, radius);
|
|
12157
|
+
}
|
|
12158
|
+
toStep() {
|
|
12159
|
+
return `CYLINDRICAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.radius)})`;
|
|
12160
|
+
}
|
|
12161
|
+
};
|
|
12162
|
+
register("CYLINDRICAL_SURFACE", CylindricalSurface.parse.bind(CylindricalSurface));
|
|
12163
|
+
var Direction = class _Direction extends Entity {
|
|
12164
|
+
constructor(name, dx, dy, dz) {
|
|
12165
|
+
super();
|
|
12166
|
+
this.name = name;
|
|
12167
|
+
this.dx = dx;
|
|
12168
|
+
this.dy = dy;
|
|
12169
|
+
this.dz = dz;
|
|
12170
|
+
}
|
|
12171
|
+
type = "DIRECTION";
|
|
12172
|
+
static parse(a, ctx) {
|
|
12173
|
+
const name = ctx.parseString(a[0]);
|
|
12174
|
+
const comps = a[1].replace(/^\(|\)$/g, "").split(",").map(ctx.parseNumber);
|
|
12175
|
+
return new _Direction(name, comps[0], comps[1], comps[2] ?? 0);
|
|
12176
|
+
}
|
|
12177
|
+
toStep() {
|
|
12178
|
+
return `DIRECTION(${stepStr(this.name)},(${fmtNum(this.dx)},${fmtNum(this.dy)},${fmtNum(this.dz)}))`;
|
|
12179
|
+
}
|
|
12180
|
+
};
|
|
12181
|
+
register("DIRECTION", Direction.parse.bind(Direction));
|
|
12182
|
+
var Line = class _Line extends Entity {
|
|
12183
|
+
constructor(name, pnt, dir) {
|
|
12184
|
+
super();
|
|
12185
|
+
this.name = name;
|
|
12186
|
+
this.pnt = pnt;
|
|
12187
|
+
this.dir = dir;
|
|
12188
|
+
}
|
|
12189
|
+
type = "LINE";
|
|
12190
|
+
static parse(a, ctx) {
|
|
12191
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12192
|
+
const p = ctx.parseRef(a[1]);
|
|
12193
|
+
const vecTok = a[2];
|
|
12194
|
+
if (vecTok.startsWith("VECTOR(")) {
|
|
12195
|
+
throw new Error("Inline VECTOR in LINE is not supported - VECTOR should be a separate entity");
|
|
12196
|
+
}
|
|
12197
|
+
const vec = ctx.parseRef(vecTok);
|
|
12198
|
+
return new _Line(name, p, vec);
|
|
12199
|
+
}
|
|
12200
|
+
toStep() {
|
|
12201
|
+
return `LINE(${this.name ? `'${this.name}'` : "''"},${this.pnt},${this.dir})`;
|
|
12202
|
+
}
|
|
12203
|
+
};
|
|
12204
|
+
register("LINE", Line.parse.bind(Line));
|
|
12205
|
+
var Plane = class _Plane extends Entity {
|
|
12206
|
+
constructor(name, placement) {
|
|
12207
|
+
super();
|
|
12208
|
+
this.name = name;
|
|
12209
|
+
this.placement = placement;
|
|
12210
|
+
}
|
|
12211
|
+
type = "PLANE";
|
|
12212
|
+
static parse(a, ctx) {
|
|
12213
|
+
return new _Plane(ctx.parseString(a[0]), ctx.parseRef(a[1]));
|
|
12214
|
+
}
|
|
12215
|
+
toStep() {
|
|
12216
|
+
return `PLANE(${stepStr(this.name)},${this.placement})`;
|
|
12217
|
+
}
|
|
12218
|
+
};
|
|
12219
|
+
register("PLANE", Plane.parse.bind(Plane));
|
|
12220
|
+
var ToroidalSurface = class _ToroidalSurface extends Entity {
|
|
12221
|
+
constructor(name, position, majorRadius, minorRadius) {
|
|
12222
|
+
super();
|
|
12223
|
+
this.name = name;
|
|
12224
|
+
this.position = position;
|
|
12225
|
+
this.majorRadius = majorRadius;
|
|
12226
|
+
this.minorRadius = minorRadius;
|
|
12227
|
+
}
|
|
12228
|
+
type = "TOROIDAL_SURFACE";
|
|
12229
|
+
static parse(a, ctx) {
|
|
12230
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12231
|
+
const position = ctx.parseRef(a[1]);
|
|
12232
|
+
const majorRadius = ctx.parseNumber(a[2]);
|
|
12233
|
+
const minorRadius = ctx.parseNumber(a[3]);
|
|
12234
|
+
return new _ToroidalSurface(name, position, majorRadius, minorRadius);
|
|
12235
|
+
}
|
|
12236
|
+
toStep() {
|
|
12237
|
+
return `TOROIDAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.majorRadius)},${fmtNum(this.minorRadius)})`;
|
|
12238
|
+
}
|
|
12239
|
+
};
|
|
12240
|
+
register("TOROIDAL_SURFACE", ToroidalSurface.parse.bind(ToroidalSurface));
|
|
12241
|
+
var Vector = class _Vector extends Entity {
|
|
12242
|
+
constructor(name, orientation, magnitude) {
|
|
12243
|
+
super();
|
|
12244
|
+
this.name = name;
|
|
12245
|
+
this.orientation = orientation;
|
|
12246
|
+
this.magnitude = magnitude;
|
|
12247
|
+
}
|
|
12248
|
+
type = "VECTOR";
|
|
12249
|
+
static parse(a, ctx) {
|
|
12250
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12251
|
+
const orientation = ctx.parseRef(a[1]);
|
|
12252
|
+
const magnitude = ctx.parseNumber(a[2]);
|
|
12253
|
+
return new _Vector(name, orientation, magnitude);
|
|
12254
|
+
}
|
|
12255
|
+
toStep() {
|
|
12256
|
+
return `VECTOR(${stepStr(this.name)},${this.orientation},${fmtNum(this.magnitude)})`;
|
|
12257
|
+
}
|
|
12258
|
+
};
|
|
12259
|
+
register("VECTOR", Vector.parse.bind(Vector));
|
|
12260
|
+
var Ellipse = class _Ellipse extends Entity {
|
|
12261
|
+
constructor(name, placement, semiAxis1, semiAxis2) {
|
|
12262
|
+
super();
|
|
12263
|
+
this.name = name;
|
|
12264
|
+
this.placement = placement;
|
|
12265
|
+
this.semiAxis1 = semiAxis1;
|
|
12266
|
+
this.semiAxis2 = semiAxis2;
|
|
12267
|
+
}
|
|
12268
|
+
type = "ELLIPSE";
|
|
12269
|
+
static parse(a, ctx) {
|
|
12270
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12271
|
+
const placement = ctx.parseRef(a[1]);
|
|
12272
|
+
const semiAxis1 = ctx.parseNumber(a[2]);
|
|
12273
|
+
const semiAxis2 = ctx.parseNumber(a[3]);
|
|
12274
|
+
return new _Ellipse(name, placement, semiAxis1, semiAxis2);
|
|
12275
|
+
}
|
|
12276
|
+
toStep() {
|
|
12277
|
+
return `ELLIPSE(${stepStr(this.name)},${this.placement},${fmtNum(this.semiAxis1)},${fmtNum(this.semiAxis2)})`;
|
|
12278
|
+
}
|
|
12279
|
+
};
|
|
12280
|
+
register("ELLIPSE", Ellipse.parse.bind(Ellipse));
|
|
12281
|
+
var ConicalSurface = class _ConicalSurface extends Entity {
|
|
12282
|
+
constructor(name, position, radius, semiAngle) {
|
|
12283
|
+
super();
|
|
12284
|
+
this.name = name;
|
|
12285
|
+
this.position = position;
|
|
12286
|
+
this.radius = radius;
|
|
12287
|
+
this.semiAngle = semiAngle;
|
|
12288
|
+
}
|
|
12289
|
+
type = "CONICAL_SURFACE";
|
|
12290
|
+
static parse(a, ctx) {
|
|
12291
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12292
|
+
const position = ctx.parseRef(a[1]);
|
|
12293
|
+
const radius = ctx.parseNumber(a[2]);
|
|
12294
|
+
const semiAngle = ctx.parseNumber(a[3]);
|
|
12295
|
+
return new _ConicalSurface(name, position, radius, semiAngle);
|
|
12296
|
+
}
|
|
12297
|
+
toStep() {
|
|
12298
|
+
return `CONICAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.radius)},${fmtNum(this.semiAngle)})`;
|
|
12299
|
+
}
|
|
12300
|
+
};
|
|
12301
|
+
register("CONICAL_SURFACE", ConicalSurface.parse.bind(ConicalSurface));
|
|
12302
|
+
var SphericalSurface = class _SphericalSurface extends Entity {
|
|
12303
|
+
constructor(name, position, radius) {
|
|
12304
|
+
super();
|
|
12305
|
+
this.name = name;
|
|
12306
|
+
this.position = position;
|
|
12307
|
+
this.radius = radius;
|
|
12308
|
+
}
|
|
12309
|
+
type = "SPHERICAL_SURFACE";
|
|
12310
|
+
static parse(a, ctx) {
|
|
12311
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12312
|
+
const position = ctx.parseRef(a[1]);
|
|
12313
|
+
const radius = ctx.parseNumber(a[2]);
|
|
12314
|
+
return new _SphericalSurface(name, position, radius);
|
|
12315
|
+
}
|
|
12316
|
+
toStep() {
|
|
12317
|
+
return `SPHERICAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.radius)})`;
|
|
12318
|
+
}
|
|
12319
|
+
};
|
|
12320
|
+
register("SPHERICAL_SURFACE", SphericalSurface.parse.bind(SphericalSurface));
|
|
12321
|
+
var BSplineCurveWithKnots = class _BSplineCurveWithKnots extends Entity {
|
|
12322
|
+
constructor(name, degree, controlPointsList, curveForm, closedCurve, selfIntersect, knotMultiplicities, knots, knotSpec) {
|
|
12323
|
+
super();
|
|
12324
|
+
this.name = name;
|
|
12325
|
+
this.degree = degree;
|
|
12326
|
+
this.controlPointsList = controlPointsList;
|
|
12327
|
+
this.curveForm = curveForm;
|
|
12328
|
+
this.closedCurve = closedCurve;
|
|
12329
|
+
this.selfIntersect = selfIntersect;
|
|
12330
|
+
this.knotMultiplicities = knotMultiplicities;
|
|
12331
|
+
this.knots = knots;
|
|
12332
|
+
this.knotSpec = knotSpec;
|
|
12333
|
+
}
|
|
12334
|
+
type = "B_SPLINE_CURVE_WITH_KNOTS";
|
|
12335
|
+
static parse(a, ctx) {
|
|
12336
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12337
|
+
const degree = ctx.parseNumber(a[1]);
|
|
12338
|
+
const controlPoints = a[2].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
|
|
12339
|
+
const curveForm = a[3].trim();
|
|
12340
|
+
const closedCurve = a[4].trim() === ".T.";
|
|
12341
|
+
const selfIntersect = a[5].trim() === ".T.";
|
|
12342
|
+
const knotMults = a[6].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseNumber(tok.trim()));
|
|
12343
|
+
const knots = a[7].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseNumber(tok.trim()));
|
|
12344
|
+
const knotSpec = a[8].trim();
|
|
12345
|
+
return new _BSplineCurveWithKnots(name, degree, controlPoints, curveForm, closedCurve, selfIntersect, knotMults, knots, knotSpec);
|
|
12346
|
+
}
|
|
12347
|
+
toStep() {
|
|
12348
|
+
const cps = `(${this.controlPointsList.join(",")})`;
|
|
12349
|
+
const kms = `(${this.knotMultiplicities.map(fmtNum).join(",")})`;
|
|
12350
|
+
const ks = `(${this.knots.map(fmtNum).join(",")})`;
|
|
12351
|
+
const closed = this.closedCurve ? ".T." : ".F.";
|
|
12352
|
+
const self = this.selfIntersect ? ".T." : ".F.";
|
|
12353
|
+
return `B_SPLINE_CURVE_WITH_KNOTS(${stepStr(this.name)},${this.degree},${cps},${this.curveForm},${closed},${self},${kms},${ks},${this.knotSpec})`;
|
|
12354
|
+
}
|
|
12355
|
+
};
|
|
12356
|
+
register("B_SPLINE_CURVE_WITH_KNOTS", BSplineCurveWithKnots.parse.bind(BSplineCurveWithKnots));
|
|
12357
|
+
var ColourRgb = class _ColourRgb extends Entity {
|
|
12358
|
+
constructor(name, r, g, b) {
|
|
12359
|
+
super();
|
|
12360
|
+
this.name = name;
|
|
12361
|
+
this.r = r;
|
|
12362
|
+
this.g = g;
|
|
12363
|
+
this.b = b;
|
|
12364
|
+
}
|
|
12365
|
+
type = "COLOUR_RGB";
|
|
12366
|
+
static parse(a, ctx) {
|
|
12367
|
+
return new _ColourRgb(ctx.parseString(a[0]), ctx.parseNumber(a[1]), ctx.parseNumber(a[2]), ctx.parseNumber(a[3]));
|
|
12368
|
+
}
|
|
12369
|
+
toStep() {
|
|
12370
|
+
return `COLOUR_RGB(${stepStr(this.name)},${this.r},${this.g},${this.b})`;
|
|
12371
|
+
}
|
|
12372
|
+
};
|
|
12373
|
+
register("COLOUR_RGB", ColourRgb.parse.bind(ColourRgb));
|
|
12374
|
+
var FillAreaStyle = class _FillAreaStyle extends Entity {
|
|
12375
|
+
constructor(name, items) {
|
|
12376
|
+
super();
|
|
12377
|
+
this.name = name;
|
|
12378
|
+
this.items = items;
|
|
12379
|
+
}
|
|
12380
|
+
type = "FILL_AREA_STYLE";
|
|
12381
|
+
static parse(a, ctx) {
|
|
12382
|
+
const items = a[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
12383
|
+
return new _FillAreaStyle(a[0] === "$" ? "" : ctx.parseString(a[0]), items);
|
|
12384
|
+
}
|
|
12385
|
+
toStep() {
|
|
12386
|
+
return `FILL_AREA_STYLE(${stepStr(this.name)},(${this.items.join(",")}))`;
|
|
12387
|
+
}
|
|
12388
|
+
};
|
|
12389
|
+
register("FILL_AREA_STYLE", FillAreaStyle.parse.bind(FillAreaStyle));
|
|
12390
|
+
var FillAreaStyleColour = class _FillAreaStyleColour extends Entity {
|
|
12391
|
+
constructor(name, colour) {
|
|
12392
|
+
super();
|
|
12393
|
+
this.name = name;
|
|
12394
|
+
this.colour = colour;
|
|
12395
|
+
}
|
|
12396
|
+
type = "FILL_AREA_STYLE_COLOUR";
|
|
12397
|
+
static parse(a, ctx) {
|
|
12398
|
+
return new _FillAreaStyleColour(ctx.parseString(a[0]), ctx.parseRef(a[1]));
|
|
12399
|
+
}
|
|
12400
|
+
toStep() {
|
|
12401
|
+
return `FILL_AREA_STYLE_COLOUR(${stepStr(this.name)},${this.colour})`;
|
|
12402
|
+
}
|
|
12403
|
+
};
|
|
12404
|
+
register("FILL_AREA_STYLE_COLOUR", FillAreaStyleColour.parse.bind(FillAreaStyleColour));
|
|
12405
|
+
var MechanicalDesignGeometricPresentationRepresentation = class _MechanicalDesignGeometricPresentationRepresentation extends Entity {
|
|
12406
|
+
constructor(name, items, contextOfItems) {
|
|
12407
|
+
super();
|
|
12408
|
+
this.name = name;
|
|
12409
|
+
this.items = items;
|
|
12410
|
+
this.contextOfItems = contextOfItems;
|
|
12411
|
+
}
|
|
12412
|
+
type = "MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION";
|
|
12413
|
+
static parse(a, ctx) {
|
|
12414
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12415
|
+
const items = a[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
12416
|
+
const contextOfItems = ctx.parseRef(a[2]);
|
|
12417
|
+
return new _MechanicalDesignGeometricPresentationRepresentation(name, items, contextOfItems);
|
|
12418
|
+
}
|
|
12419
|
+
toStep() {
|
|
12420
|
+
return `MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION(${stepStr(this.name)},(${this.items.join(",")}),${this.contextOfItems})`;
|
|
12421
|
+
}
|
|
12422
|
+
};
|
|
12423
|
+
register("MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION", MechanicalDesignGeometricPresentationRepresentation.parse.bind(MechanicalDesignGeometricPresentationRepresentation));
|
|
12424
|
+
var PresentationStyleAssignment = class _PresentationStyleAssignment extends Entity {
|
|
12425
|
+
constructor(items) {
|
|
12426
|
+
super();
|
|
12427
|
+
this.items = items;
|
|
12428
|
+
}
|
|
12429
|
+
type = "PRESENTATION_STYLE_ASSIGNMENT";
|
|
12430
|
+
static parse(a, ctx) {
|
|
12431
|
+
const list = a[0].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
12432
|
+
return new _PresentationStyleAssignment(list);
|
|
12433
|
+
}
|
|
12434
|
+
toStep() {
|
|
12435
|
+
return `PRESENTATION_STYLE_ASSIGNMENT((${this.items.join(",")}))`;
|
|
12436
|
+
}
|
|
12437
|
+
};
|
|
12438
|
+
register("PRESENTATION_STYLE_ASSIGNMENT", PresentationStyleAssignment.parse.bind(PresentationStyleAssignment));
|
|
12439
|
+
var StyledItem = class _StyledItem extends Entity {
|
|
12440
|
+
constructor(name, styles, item) {
|
|
12441
|
+
super();
|
|
12442
|
+
this.name = name;
|
|
12443
|
+
this.styles = styles;
|
|
12444
|
+
this.item = item;
|
|
12445
|
+
}
|
|
12446
|
+
type = "STYLED_ITEM";
|
|
12447
|
+
static parse(a, ctx) {
|
|
12448
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12449
|
+
const styles = a[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
12450
|
+
const item = ctx.parseRef(a[2]);
|
|
12451
|
+
return new _StyledItem(name, styles, item);
|
|
12452
|
+
}
|
|
12453
|
+
toStep() {
|
|
12454
|
+
return `STYLED_ITEM(${stepStr(this.name)},(${this.styles.join(",")}),${this.item})`;
|
|
12455
|
+
}
|
|
12456
|
+
};
|
|
12457
|
+
register("STYLED_ITEM", StyledItem.parse.bind(StyledItem));
|
|
12458
|
+
var SurfaceSideStyle = class _SurfaceSideStyle extends Entity {
|
|
12459
|
+
constructor(name, styles) {
|
|
12460
|
+
super();
|
|
12461
|
+
this.name = name;
|
|
12462
|
+
this.styles = styles;
|
|
12463
|
+
}
|
|
12464
|
+
type = "SURFACE_SIDE_STYLE";
|
|
12465
|
+
static parse(a, ctx) {
|
|
12466
|
+
const list = a[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
12467
|
+
return new _SurfaceSideStyle(a[0] === "$" ? "" : ctx.parseString(a[0]), list);
|
|
12468
|
+
}
|
|
12469
|
+
toStep() {
|
|
12470
|
+
return `SURFACE_SIDE_STYLE(${stepStr(this.name)},(${this.styles.join(",")}))`;
|
|
12471
|
+
}
|
|
12472
|
+
};
|
|
12473
|
+
register("SURFACE_SIDE_STYLE", SurfaceSideStyle.parse.bind(SurfaceSideStyle));
|
|
12474
|
+
var SurfaceStyleFillArea = class _SurfaceStyleFillArea extends Entity {
|
|
12475
|
+
constructor(style) {
|
|
12476
|
+
super();
|
|
12477
|
+
this.style = style;
|
|
12478
|
+
}
|
|
12479
|
+
type = "SURFACE_STYLE_FILL_AREA";
|
|
12480
|
+
static parse(a, ctx) {
|
|
12481
|
+
return new _SurfaceStyleFillArea(ctx.parseRef(a[0]));
|
|
12482
|
+
}
|
|
12483
|
+
toStep() {
|
|
12484
|
+
return `SURFACE_STYLE_FILL_AREA(${this.style})`;
|
|
12485
|
+
}
|
|
12486
|
+
};
|
|
12487
|
+
register("SURFACE_STYLE_FILL_AREA", SurfaceStyleFillArea.parse.bind(SurfaceStyleFillArea));
|
|
12488
|
+
var SurfaceStyleUsage = class _SurfaceStyleUsage extends Entity {
|
|
12489
|
+
constructor(side, style) {
|
|
12490
|
+
super();
|
|
12491
|
+
this.side = side;
|
|
12492
|
+
this.style = style;
|
|
12493
|
+
}
|
|
12494
|
+
type = "SURFACE_STYLE_USAGE";
|
|
12495
|
+
static parse(a, ctx) {
|
|
12496
|
+
return new _SurfaceStyleUsage(a[0].trim(), ctx.parseRef(a[1]));
|
|
12497
|
+
}
|
|
12498
|
+
toStep() {
|
|
12499
|
+
return `SURFACE_STYLE_USAGE(${this.side},${this.style})`;
|
|
12500
|
+
}
|
|
12501
|
+
};
|
|
12502
|
+
register("SURFACE_STYLE_USAGE", SurfaceStyleUsage.parse.bind(SurfaceStyleUsage));
|
|
12503
|
+
var AdvancedBrepShapeRepresentation = class _AdvancedBrepShapeRepresentation extends Entity {
|
|
12504
|
+
constructor(name, items, context) {
|
|
12505
|
+
super();
|
|
12506
|
+
this.name = name;
|
|
12507
|
+
this.items = items;
|
|
12508
|
+
this.context = context;
|
|
12509
|
+
}
|
|
12510
|
+
type = "ADVANCED_BREP_SHAPE_REPRESENTATION";
|
|
12511
|
+
static parse(a, ctx) {
|
|
12512
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12513
|
+
const items = a[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
12514
|
+
const c = ctx.parseRef(a[2]);
|
|
12515
|
+
return new _AdvancedBrepShapeRepresentation(name, items, c);
|
|
12516
|
+
}
|
|
12517
|
+
toStep() {
|
|
12518
|
+
return `ADVANCED_BREP_SHAPE_REPRESENTATION(${stepStr(this.name)},(${this.items.join(",")}),${this.context})`;
|
|
12519
|
+
}
|
|
12520
|
+
};
|
|
12521
|
+
register("ADVANCED_BREP_SHAPE_REPRESENTATION", AdvancedBrepShapeRepresentation.parse.bind(AdvancedBrepShapeRepresentation));
|
|
12522
|
+
var ApplicationContext = class _ApplicationContext extends Entity {
|
|
12523
|
+
constructor(application) {
|
|
12524
|
+
super();
|
|
12525
|
+
this.application = application;
|
|
12526
|
+
}
|
|
12527
|
+
type = "APPLICATION_CONTEXT";
|
|
12528
|
+
static parse(a, ctx) {
|
|
12529
|
+
const application = ctx.parseString(a[0]);
|
|
12530
|
+
return new _ApplicationContext(application);
|
|
12531
|
+
}
|
|
12532
|
+
toStep() {
|
|
12533
|
+
return `APPLICATION_CONTEXT(${stepStr(this.application)})`;
|
|
12534
|
+
}
|
|
12535
|
+
};
|
|
12536
|
+
register("APPLICATION_CONTEXT", ApplicationContext.parse.bind(ApplicationContext));
|
|
12537
|
+
var ApplicationProtocolDefinition = class _ApplicationProtocolDefinition extends Entity {
|
|
12538
|
+
constructor(status, applicationInterpretedModelSchemaName, applicationProtocolYear, application) {
|
|
12539
|
+
super();
|
|
12540
|
+
this.status = status;
|
|
12541
|
+
this.applicationInterpretedModelSchemaName = applicationInterpretedModelSchemaName;
|
|
12542
|
+
this.applicationProtocolYear = applicationProtocolYear;
|
|
12543
|
+
this.application = application;
|
|
12544
|
+
}
|
|
12545
|
+
type = "APPLICATION_PROTOCOL_DEFINITION";
|
|
12546
|
+
static parse(a, ctx) {
|
|
12547
|
+
const status = ctx.parseString(a[0]);
|
|
12548
|
+
const schemaName = ctx.parseString(a[1]);
|
|
12549
|
+
const year = ctx.parseNumber(a[2]);
|
|
12550
|
+
const application = ctx.parseRef(a[3]);
|
|
12551
|
+
return new _ApplicationProtocolDefinition(status, schemaName, year, application);
|
|
12552
|
+
}
|
|
12553
|
+
toStep() {
|
|
12554
|
+
return `APPLICATION_PROTOCOL_DEFINITION(${stepStr(this.status)},${stepStr(this.applicationInterpretedModelSchemaName)},${this.applicationProtocolYear},${this.application})`;
|
|
12555
|
+
}
|
|
12556
|
+
};
|
|
12557
|
+
register("APPLICATION_PROTOCOL_DEFINITION", ApplicationProtocolDefinition.parse.bind(ApplicationProtocolDefinition));
|
|
12558
|
+
var ContextDependentShapeRepresentation = class _ContextDependentShapeRepresentation extends Entity {
|
|
12559
|
+
constructor(representationRelation, representedProductRelation) {
|
|
12560
|
+
super();
|
|
12561
|
+
this.representationRelation = representationRelation;
|
|
12562
|
+
this.representedProductRelation = representedProductRelation;
|
|
12563
|
+
}
|
|
12564
|
+
type = "CONTEXT_DEPENDENT_SHAPE_REPRESENTATION";
|
|
12565
|
+
static parse(a, ctx) {
|
|
12566
|
+
const representationRelation = ctx.parseRef(a[0]);
|
|
12567
|
+
const representedProductRelation = ctx.parseRef(a[1]);
|
|
12568
|
+
return new _ContextDependentShapeRepresentation(representationRelation, representedProductRelation);
|
|
12569
|
+
}
|
|
12570
|
+
toStep() {
|
|
12571
|
+
return `CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(${this.representationRelation},${this.representedProductRelation})`;
|
|
12572
|
+
}
|
|
12573
|
+
};
|
|
12574
|
+
register("CONTEXT_DEPENDENT_SHAPE_REPRESENTATION", ContextDependentShapeRepresentation.parse.bind(ContextDependentShapeRepresentation));
|
|
12575
|
+
var ItemDefinedTransformation = class _ItemDefinedTransformation extends Entity {
|
|
12576
|
+
constructor(name, description, transformItem1, transformItem2) {
|
|
12577
|
+
super();
|
|
12578
|
+
this.name = name;
|
|
12579
|
+
this.description = description;
|
|
12580
|
+
this.transformItem1 = transformItem1;
|
|
12581
|
+
this.transformItem2 = transformItem2;
|
|
12582
|
+
}
|
|
12583
|
+
type = "ITEM_DEFINED_TRANSFORMATION";
|
|
12584
|
+
static parse(a, ctx) {
|
|
12585
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12586
|
+
const description = a[1] === "$" ? "" : ctx.parseString(a[1]);
|
|
12587
|
+
const item1 = ctx.parseRef(a[2]);
|
|
12588
|
+
const item2 = ctx.parseRef(a[3]);
|
|
12589
|
+
return new _ItemDefinedTransformation(name, description, item1, item2);
|
|
12590
|
+
}
|
|
12591
|
+
toStep() {
|
|
12592
|
+
return `ITEM_DEFINED_TRANSFORMATION(${stepStr(this.name)},${stepStr(this.description)},${this.transformItem1},${this.transformItem2})`;
|
|
12593
|
+
}
|
|
12594
|
+
};
|
|
12595
|
+
register("ITEM_DEFINED_TRANSFORMATION", ItemDefinedTransformation.parse.bind(ItemDefinedTransformation));
|
|
12596
|
+
var NextAssemblyUsageOccurrence = class _NextAssemblyUsageOccurrence extends Entity {
|
|
12597
|
+
constructor(id, name, description, relatingProductDefinition, relatedProductDefinition, referenceDesignator) {
|
|
12598
|
+
super();
|
|
12599
|
+
this.id = id;
|
|
12600
|
+
this.name = name;
|
|
12601
|
+
this.description = description;
|
|
12602
|
+
this.relatingProductDefinition = relatingProductDefinition;
|
|
12603
|
+
this.relatedProductDefinition = relatedProductDefinition;
|
|
12604
|
+
this.referenceDesignator = referenceDesignator;
|
|
12605
|
+
}
|
|
12606
|
+
type = "NEXT_ASSEMBLY_USAGE_OCCURRENCE";
|
|
12607
|
+
static parse(a, ctx) {
|
|
12608
|
+
const id = ctx.parseString(a[0]);
|
|
12609
|
+
const name = ctx.parseString(a[1]);
|
|
12610
|
+
const description = a[2] === "$" ? "" : ctx.parseString(a[2]);
|
|
12611
|
+
const relating = ctx.parseRef(a[3]);
|
|
12612
|
+
const related = ctx.parseRef(a[4]);
|
|
12613
|
+
const designator = a[5] === "$" ? "" : ctx.parseString(a[5]);
|
|
12614
|
+
return new _NextAssemblyUsageOccurrence(id, name, description, relating, related, designator);
|
|
12615
|
+
}
|
|
12616
|
+
toStep() {
|
|
12617
|
+
return `NEXT_ASSEMBLY_USAGE_OCCURRENCE(${stepStr(this.id)},${stepStr(this.name)},${this.description ? stepStr(this.description) : "$"},${this.relatingProductDefinition},${this.relatedProductDefinition},${this.referenceDesignator ? stepStr(this.referenceDesignator) : "$"})`;
|
|
12618
|
+
}
|
|
12619
|
+
};
|
|
12620
|
+
register("NEXT_ASSEMBLY_USAGE_OCCURRENCE", NextAssemblyUsageOccurrence.parse.bind(NextAssemblyUsageOccurrence));
|
|
12621
|
+
var Product = class _Product extends Entity {
|
|
12622
|
+
constructor(name, id, description, frameOfReference) {
|
|
12623
|
+
super();
|
|
12624
|
+
this.name = name;
|
|
12625
|
+
this.id = id;
|
|
12626
|
+
this.description = description;
|
|
12627
|
+
this.frameOfReference = frameOfReference;
|
|
12628
|
+
}
|
|
12629
|
+
type = "PRODUCT";
|
|
12630
|
+
static parse(a, ctx) {
|
|
12631
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12632
|
+
const id = a[1] === "$" ? "" : ctx.parseString(a[1]);
|
|
12633
|
+
const description = a[2] === "$" ? "" : ctx.parseString(a[2]);
|
|
12634
|
+
const refs = a[3].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
|
|
12635
|
+
return new _Product(name, id, description, refs);
|
|
12636
|
+
}
|
|
12637
|
+
toStep() {
|
|
12638
|
+
return `PRODUCT(${stepStr(this.name)},${stepStr(this.id)},${stepStr(this.description)},(${this.frameOfReference.join(",")}))`;
|
|
12639
|
+
}
|
|
12640
|
+
};
|
|
12641
|
+
register("PRODUCT", Product.parse.bind(Product));
|
|
12642
|
+
var ProductContext = class _ProductContext extends Entity {
|
|
12643
|
+
constructor(name, frameOfReference, disciplineType) {
|
|
12644
|
+
super();
|
|
12645
|
+
this.name = name;
|
|
12646
|
+
this.frameOfReference = frameOfReference;
|
|
12647
|
+
this.disciplineType = disciplineType;
|
|
12648
|
+
}
|
|
12649
|
+
type = "PRODUCT_CONTEXT";
|
|
12650
|
+
static parse(a, ctx) {
|
|
12651
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12652
|
+
const frameOfReference = ctx.parseRef(a[1]);
|
|
12653
|
+
const disciplineType = ctx.parseString(a[2]);
|
|
12654
|
+
return new _ProductContext(name, frameOfReference, disciplineType);
|
|
12655
|
+
}
|
|
12656
|
+
toStep() {
|
|
12657
|
+
return `PRODUCT_CONTEXT(${stepStr(this.name)},${this.frameOfReference},${stepStr(this.disciplineType)})`;
|
|
12658
|
+
}
|
|
12659
|
+
};
|
|
12660
|
+
register("PRODUCT_CONTEXT", ProductContext.parse.bind(ProductContext));
|
|
12661
|
+
var ProductDefinition = class _ProductDefinition extends Entity {
|
|
12662
|
+
constructor(id, description, formation, frameOfReference) {
|
|
12663
|
+
super();
|
|
12664
|
+
this.id = id;
|
|
12665
|
+
this.description = description;
|
|
12666
|
+
this.formation = formation;
|
|
12667
|
+
this.frameOfReference = frameOfReference;
|
|
12668
|
+
}
|
|
12669
|
+
type = "PRODUCT_DEFINITION";
|
|
12670
|
+
static parse(a, ctx) {
|
|
12671
|
+
const id = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12672
|
+
const description = a[1] === "$" ? "" : ctx.parseString(a[1]);
|
|
12673
|
+
const formation = ctx.parseRef(a[2]);
|
|
12674
|
+
const frameOfReference = ctx.parseRef(a[3]);
|
|
12675
|
+
return new _ProductDefinition(id, description, formation, frameOfReference);
|
|
12676
|
+
}
|
|
12677
|
+
toStep() {
|
|
12678
|
+
return `PRODUCT_DEFINITION(${stepStr(this.id)},${stepStr(this.description)},${this.formation},${this.frameOfReference})`;
|
|
12679
|
+
}
|
|
12680
|
+
};
|
|
12681
|
+
register("PRODUCT_DEFINITION", ProductDefinition.parse.bind(ProductDefinition));
|
|
12682
|
+
var ProductDefinitionContext = class _ProductDefinitionContext extends Entity {
|
|
12683
|
+
constructor(name, frameOfReference, lifecycleStage) {
|
|
12684
|
+
super();
|
|
12685
|
+
this.name = name;
|
|
12686
|
+
this.frameOfReference = frameOfReference;
|
|
12687
|
+
this.lifecycleStage = lifecycleStage;
|
|
12688
|
+
}
|
|
12689
|
+
type = "PRODUCT_DEFINITION_CONTEXT";
|
|
12690
|
+
static parse(a, ctx) {
|
|
12691
|
+
const name = ctx.parseString(a[0]);
|
|
12692
|
+
const frameOfReference = ctx.parseRef(a[1]);
|
|
12693
|
+
const lifecycleStage = ctx.parseString(a[2]);
|
|
12694
|
+
return new _ProductDefinitionContext(name, frameOfReference, lifecycleStage);
|
|
12695
|
+
}
|
|
12696
|
+
toStep() {
|
|
12697
|
+
return `PRODUCT_DEFINITION_CONTEXT(${stepStr(this.name)},${this.frameOfReference},${stepStr(this.lifecycleStage)})`;
|
|
12698
|
+
}
|
|
12699
|
+
};
|
|
12700
|
+
register("PRODUCT_DEFINITION_CONTEXT", ProductDefinitionContext.parse.bind(ProductDefinitionContext));
|
|
12701
|
+
var ProductDefinitionFormation = class _ProductDefinitionFormation extends Entity {
|
|
12702
|
+
constructor(id, description, ofProduct) {
|
|
12703
|
+
super();
|
|
12704
|
+
this.id = id;
|
|
12705
|
+
this.description = description;
|
|
12706
|
+
this.ofProduct = ofProduct;
|
|
12707
|
+
}
|
|
12708
|
+
type = "PRODUCT_DEFINITION_FORMATION";
|
|
12709
|
+
static parse(a, ctx) {
|
|
12710
|
+
const id = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12711
|
+
const description = a[1] === "$" ? "" : ctx.parseString(a[1]);
|
|
12712
|
+
const ofProduct = ctx.parseRef(a[2]);
|
|
12713
|
+
return new _ProductDefinitionFormation(id, description, ofProduct);
|
|
12714
|
+
}
|
|
12715
|
+
toStep() {
|
|
12716
|
+
return `PRODUCT_DEFINITION_FORMATION(${stepStr(this.id)},${stepStr(this.description)},${this.ofProduct})`;
|
|
12717
|
+
}
|
|
12718
|
+
};
|
|
12719
|
+
register("PRODUCT_DEFINITION_FORMATION", ProductDefinitionFormation.parse.bind(ProductDefinitionFormation));
|
|
12720
|
+
var ProductDefinitionShape = class _ProductDefinitionShape extends Entity {
|
|
12721
|
+
constructor(name, description, definition) {
|
|
12722
|
+
super();
|
|
12723
|
+
this.name = name;
|
|
12724
|
+
this.description = description;
|
|
12725
|
+
this.definition = definition;
|
|
12726
|
+
}
|
|
12727
|
+
type = "PRODUCT_DEFINITION_SHAPE";
|
|
12728
|
+
static parse(a, ctx) {
|
|
12729
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12730
|
+
const description = a[1] === "$" ? "" : ctx.parseString(a[1]);
|
|
12731
|
+
const definition = ctx.parseRef(a[2]);
|
|
12732
|
+
return new _ProductDefinitionShape(name, description, definition);
|
|
12733
|
+
}
|
|
12734
|
+
toStep() {
|
|
12735
|
+
return `PRODUCT_DEFINITION_SHAPE(${stepStr(this.name)},${stepStr(this.description)},${this.definition})`;
|
|
12736
|
+
}
|
|
12737
|
+
};
|
|
12738
|
+
register("PRODUCT_DEFINITION_SHAPE", ProductDefinitionShape.parse.bind(ProductDefinitionShape));
|
|
12739
|
+
var ProductRelatedProductCategory = class _ProductRelatedProductCategory extends Entity {
|
|
12740
|
+
constructor(name, description, products) {
|
|
12741
|
+
super();
|
|
12742
|
+
this.name = name;
|
|
12743
|
+
this.description = description;
|
|
12744
|
+
this.products = products;
|
|
12745
|
+
}
|
|
12746
|
+
type = "PRODUCT_RELATED_PRODUCT_CATEGORY";
|
|
12747
|
+
static parse(a, ctx) {
|
|
12748
|
+
const name = ctx.parseString(a[0]);
|
|
12749
|
+
const description = a[1] === "$" ? "" : ctx.parseString(a[1]);
|
|
12750
|
+
const products = a[2].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
12751
|
+
return new _ProductRelatedProductCategory(name, description, products);
|
|
12752
|
+
}
|
|
12753
|
+
toStep() {
|
|
12754
|
+
return `PRODUCT_RELATED_PRODUCT_CATEGORY(${stepStr(this.name)},${this.description ? stepStr(this.description) : "$"},(${this.products.join(",")}))`;
|
|
12755
|
+
}
|
|
12756
|
+
};
|
|
12757
|
+
register("PRODUCT_RELATED_PRODUCT_CATEGORY", ProductRelatedProductCategory.parse.bind(ProductRelatedProductCategory));
|
|
12758
|
+
var ShapeDefinitionRepresentation = class _ShapeDefinitionRepresentation extends Entity {
|
|
12759
|
+
constructor(definition, usedRepresentation) {
|
|
12760
|
+
super();
|
|
12761
|
+
this.definition = definition;
|
|
12762
|
+
this.usedRepresentation = usedRepresentation;
|
|
12763
|
+
}
|
|
12764
|
+
type = "SHAPE_DEFINITION_REPRESENTATION";
|
|
12765
|
+
static parse(a, ctx) {
|
|
12766
|
+
const definition = ctx.parseRef(a[0]);
|
|
12767
|
+
const usedRepresentation = ctx.parseRef(a[1]);
|
|
12768
|
+
return new _ShapeDefinitionRepresentation(definition, usedRepresentation);
|
|
12769
|
+
}
|
|
12770
|
+
toStep() {
|
|
12771
|
+
return `SHAPE_DEFINITION_REPRESENTATION(${this.definition},${this.usedRepresentation})`;
|
|
12772
|
+
}
|
|
12773
|
+
};
|
|
12774
|
+
register("SHAPE_DEFINITION_REPRESENTATION", ShapeDefinitionRepresentation.parse.bind(ShapeDefinitionRepresentation));
|
|
12775
|
+
var ShapeRepresentation = class _ShapeRepresentation extends Entity {
|
|
12776
|
+
constructor(name, items, contextOfItems) {
|
|
12777
|
+
super();
|
|
12778
|
+
this.name = name;
|
|
12779
|
+
this.items = items;
|
|
12780
|
+
this.contextOfItems = contextOfItems;
|
|
12781
|
+
}
|
|
12782
|
+
type = "SHAPE_REPRESENTATION";
|
|
12783
|
+
static parse(a, ctx) {
|
|
12784
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12785
|
+
const items = a[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
12786
|
+
const contextOfItems = ctx.parseRef(a[2]);
|
|
12787
|
+
return new _ShapeRepresentation(name, items, contextOfItems);
|
|
12788
|
+
}
|
|
12789
|
+
toStep() {
|
|
12790
|
+
return `SHAPE_REPRESENTATION(${stepStr(this.name)},(${this.items.join(",")}),${this.contextOfItems})`;
|
|
12791
|
+
}
|
|
12792
|
+
};
|
|
12793
|
+
register("SHAPE_REPRESENTATION", ShapeRepresentation.parse.bind(ShapeRepresentation));
|
|
12794
|
+
var AdvancedFace = class _AdvancedFace extends Entity {
|
|
12795
|
+
constructor(name, bounds, surface, sameSense) {
|
|
12796
|
+
super();
|
|
12797
|
+
this.name = name;
|
|
12798
|
+
this.bounds = bounds;
|
|
12799
|
+
this.surface = surface;
|
|
12800
|
+
this.sameSense = sameSense;
|
|
12801
|
+
}
|
|
12802
|
+
type = "ADVANCED_FACE";
|
|
12803
|
+
static parse(a, ctx) {
|
|
12804
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12805
|
+
const bounds = a[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
|
|
12806
|
+
const surf = ctx.parseRef(a[2]);
|
|
12807
|
+
const ss = a[3].trim() === ".T.";
|
|
12808
|
+
return new _AdvancedFace(name, bounds, surf, ss);
|
|
12809
|
+
}
|
|
12810
|
+
toStep() {
|
|
12811
|
+
return `ADVANCED_FACE(${this.name ? `'${this.name}'` : "''"},(${this.bounds.join(",")}),${this.surface},${this.sameSense ? ".T." : ".F."})`;
|
|
12812
|
+
}
|
|
12813
|
+
};
|
|
12814
|
+
register("ADVANCED_FACE", AdvancedFace.parse.bind(AdvancedFace));
|
|
12815
|
+
var ClosedShell = class _ClosedShell extends Entity {
|
|
12816
|
+
constructor(name, faces) {
|
|
12817
|
+
super();
|
|
12818
|
+
this.name = name;
|
|
12819
|
+
this.faces = faces;
|
|
12820
|
+
}
|
|
12821
|
+
type = "CLOSED_SHELL";
|
|
12822
|
+
static parse(a, ctx) {
|
|
12823
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12824
|
+
const faces = a[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
|
|
12825
|
+
return new _ClosedShell(name, faces);
|
|
12826
|
+
}
|
|
12827
|
+
toStep() {
|
|
12828
|
+
return `CLOSED_SHELL(${this.name ? `'${this.name}'` : "''"},(${this.faces.join(",")}))`;
|
|
12829
|
+
}
|
|
12830
|
+
};
|
|
12831
|
+
register("CLOSED_SHELL", ClosedShell.parse.bind(ClosedShell));
|
|
12832
|
+
var EdgeCurve = class _EdgeCurve extends Entity {
|
|
12833
|
+
constructor(name, start, end, curve, sameSense) {
|
|
12834
|
+
super();
|
|
12835
|
+
this.name = name;
|
|
12836
|
+
this.start = start;
|
|
12837
|
+
this.end = end;
|
|
12838
|
+
this.curve = curve;
|
|
12839
|
+
this.sameSense = sameSense;
|
|
12840
|
+
}
|
|
12841
|
+
type = "EDGE_CURVE";
|
|
12842
|
+
static parse(a, ctx) {
|
|
12843
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12844
|
+
const s = ctx.parseRef(a[1]);
|
|
12845
|
+
const e = ctx.parseRef(a[2]);
|
|
12846
|
+
const c = ctx.parseRef(a[3]);
|
|
12847
|
+
const same = a[4].trim() === ".T.";
|
|
12848
|
+
return new _EdgeCurve(name, s, e, c, same);
|
|
12849
|
+
}
|
|
12850
|
+
toStep() {
|
|
12851
|
+
return `EDGE_CURVE(${this.name ? `'${this.name}'` : "''"},${this.start},${this.end},${this.curve},${this.sameSense ? ".T." : ".F."})`;
|
|
12852
|
+
}
|
|
12853
|
+
};
|
|
12854
|
+
register("EDGE_CURVE", EdgeCurve.parse.bind(EdgeCurve));
|
|
12855
|
+
var EdgeLoop = class _EdgeLoop extends Entity {
|
|
12856
|
+
constructor(name, edges) {
|
|
12857
|
+
super();
|
|
12858
|
+
this.name = name;
|
|
12859
|
+
this.edges = edges;
|
|
12860
|
+
}
|
|
12861
|
+
type = "EDGE_LOOP";
|
|
12862
|
+
static parse(a, ctx) {
|
|
12863
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12864
|
+
const list = a[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
12865
|
+
return new _EdgeLoop(name, list);
|
|
12866
|
+
}
|
|
12867
|
+
toStep() {
|
|
12868
|
+
return `EDGE_LOOP(${stepStr(this.name)},(${this.edges.join(",")}))`;
|
|
12869
|
+
}
|
|
12870
|
+
};
|
|
12871
|
+
register("EDGE_LOOP", EdgeLoop.parse.bind(EdgeLoop));
|
|
12872
|
+
var FaceBound = class _FaceBound extends Entity {
|
|
12873
|
+
constructor(name, bound, sameSense) {
|
|
12874
|
+
super();
|
|
12875
|
+
this.name = name;
|
|
12876
|
+
this.bound = bound;
|
|
12877
|
+
this.sameSense = sameSense;
|
|
12878
|
+
}
|
|
12879
|
+
type = "FACE_BOUND";
|
|
12880
|
+
static parse(a, ctx) {
|
|
12881
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12882
|
+
return new _FaceBound(name, ctx.parseRef(a[1]), a[2].trim() === ".T.");
|
|
12883
|
+
}
|
|
12884
|
+
toStep() {
|
|
12885
|
+
return `FACE_BOUND(${stepStr(this.name)},${this.bound},${this.sameSense ? ".T." : ".F."})`;
|
|
12886
|
+
}
|
|
12887
|
+
};
|
|
12888
|
+
register("FACE_BOUND", FaceBound.parse.bind(FaceBound));
|
|
12889
|
+
var FaceOuterBound = class _FaceOuterBound extends Entity {
|
|
12890
|
+
constructor(name, bound, sameSense) {
|
|
12891
|
+
super();
|
|
12892
|
+
this.name = name;
|
|
12893
|
+
this.bound = bound;
|
|
12894
|
+
this.sameSense = sameSense;
|
|
12895
|
+
}
|
|
12896
|
+
type = "FACE_OUTER_BOUND";
|
|
12897
|
+
static parse(a, ctx) {
|
|
12898
|
+
return new _FaceOuterBound(ctx.parseString(a[0]), ctx.parseRef(a[1]), a[2].trim() === ".T.");
|
|
12899
|
+
}
|
|
12900
|
+
toStep() {
|
|
12901
|
+
return `FACE_OUTER_BOUND('${this.name}',${this.bound},${this.sameSense ? ".T." : ".F."})`;
|
|
12902
|
+
}
|
|
12903
|
+
};
|
|
12904
|
+
register("FACE_OUTER_BOUND", FaceOuterBound.parse.bind(FaceOuterBound));
|
|
12905
|
+
var ManifoldSolidBrep = class _ManifoldSolidBrep extends Entity {
|
|
12906
|
+
constructor(name, outer) {
|
|
12907
|
+
super();
|
|
12908
|
+
this.name = name;
|
|
12909
|
+
this.outer = outer;
|
|
12910
|
+
}
|
|
12911
|
+
type = "MANIFOLD_SOLID_BREP";
|
|
12912
|
+
static parse(a, ctx) {
|
|
12913
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12914
|
+
return new _ManifoldSolidBrep(name, ctx.parseRef(a[1]));
|
|
12915
|
+
}
|
|
12916
|
+
toStep() {
|
|
12917
|
+
return `MANIFOLD_SOLID_BREP(${stepStr(this.name)},${this.outer})`;
|
|
12918
|
+
}
|
|
12919
|
+
};
|
|
12920
|
+
register("MANIFOLD_SOLID_BREP", ManifoldSolidBrep.parse.bind(ManifoldSolidBrep));
|
|
12921
|
+
var OrientedEdge = class _OrientedEdge extends Entity {
|
|
12922
|
+
constructor(name, edge, orientation) {
|
|
12923
|
+
super();
|
|
12924
|
+
this.name = name;
|
|
12925
|
+
this.edge = edge;
|
|
12926
|
+
this.orientation = orientation;
|
|
12927
|
+
}
|
|
12928
|
+
type = "ORIENTED_EDGE";
|
|
12929
|
+
static parse(a, ctx) {
|
|
12930
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12931
|
+
const edge = ctx.parseRef(a[3]);
|
|
12932
|
+
const orient = a[4]?.trim?.() === ".T." || a[2]?.trim?.() === ".T.";
|
|
12933
|
+
return new _OrientedEdge(name, edge, orient);
|
|
12934
|
+
}
|
|
12935
|
+
toStep() {
|
|
12936
|
+
return `ORIENTED_EDGE(${stepStr(this.name)},*,*,${this.edge},${this.orientation ? ".T." : ".F."})`;
|
|
12937
|
+
}
|
|
12938
|
+
};
|
|
12939
|
+
register("ORIENTED_EDGE", OrientedEdge.parse.bind(OrientedEdge));
|
|
12940
|
+
var VertexPoint = class _VertexPoint extends Entity {
|
|
12941
|
+
constructor(name, pnt) {
|
|
12942
|
+
super();
|
|
12943
|
+
this.name = name;
|
|
12944
|
+
this.pnt = pnt;
|
|
12945
|
+
}
|
|
12946
|
+
type = "VERTEX_POINT";
|
|
12947
|
+
static parse(a, ctx) {
|
|
12948
|
+
const name = a[0] === "$" ? "" : ctx.parseString(a[0]);
|
|
12949
|
+
return new _VertexPoint(name, ctx.parseRef(a[1]));
|
|
12950
|
+
}
|
|
12951
|
+
toStep() {
|
|
12952
|
+
return `VERTEX_POINT(${this.name ? `'${this.name}'` : "''"},${this.pnt})`;
|
|
12953
|
+
}
|
|
12954
|
+
};
|
|
12955
|
+
register("VERTEX_POINT", VertexPoint.parse.bind(VertexPoint));
|
|
12956
|
+
var Unknown = class extends Entity {
|
|
12957
|
+
constructor(type, args) {
|
|
12958
|
+
super();
|
|
12959
|
+
this.type = type;
|
|
12960
|
+
this.args = args;
|
|
12961
|
+
}
|
|
12962
|
+
toStep() {
|
|
12963
|
+
if (this.args.length === 1 && this.args[0].startsWith("( ")) {
|
|
12964
|
+
const content = this.args[0].slice(2, -2).trim();
|
|
12965
|
+
const parts = content.split(/\s+(?=[A-Z_])/g);
|
|
12966
|
+
return `(
|
|
12967
|
+
${parts.join(`
|
|
12968
|
+
`)}
|
|
12969
|
+
)`;
|
|
12970
|
+
}
|
|
12971
|
+
return `${this.type}(${this.args.join(",")})`;
|
|
12972
|
+
}
|
|
12973
|
+
};
|
|
12974
|
+
function tokenizeSTEP(data) {
|
|
12975
|
+
const entities = [];
|
|
12976
|
+
const dataStart = data.indexOf("DATA;");
|
|
12977
|
+
const dataEnd = data.indexOf("ENDSEC;", dataStart);
|
|
12978
|
+
if (dataStart === -1 || dataEnd === -1) {
|
|
12979
|
+
throw new Error("Could not find DATA section in STEP file");
|
|
12980
|
+
}
|
|
12981
|
+
const dataSection = data.substring(dataStart + 5, dataEnd);
|
|
12982
|
+
const entityPattern = /#(\d+)\s*=\s*/g;
|
|
12983
|
+
let match;
|
|
12984
|
+
const entityStarts = [];
|
|
12985
|
+
while ((match = entityPattern.exec(dataSection)) !== null) {
|
|
12986
|
+
entityStarts.push({
|
|
12987
|
+
index: match.index,
|
|
12988
|
+
id: parseInt(match[1], 10)
|
|
12989
|
+
});
|
|
12990
|
+
}
|
|
12991
|
+
for (let i = 0;i < entityStarts.length; i++) {
|
|
12992
|
+
const start = entityStarts[i];
|
|
12993
|
+
const nextStart = i + 1 < entityStarts.length ? entityStarts[i + 1].index : dataSection.length;
|
|
12994
|
+
const entityText = dataSection.substring(start.index, nextStart);
|
|
12995
|
+
const semiIndex = entityText.indexOf(";");
|
|
12996
|
+
if (semiIndex === -1) {
|
|
12997
|
+
throw new Error(`Could not find closing semicolon for entity #${start.id}`);
|
|
12998
|
+
}
|
|
12999
|
+
const fullEntity = entityText.substring(0, semiIndex + 1);
|
|
13000
|
+
if (fullEntity.match(/#\d+\s*=\s*\(/)) {
|
|
13001
|
+
const complexMatch = fullEntity.match(/#\d+\s*=\s*\(([\s\S]*)\);/);
|
|
13002
|
+
if (!complexMatch) {
|
|
13003
|
+
throw new Error(`Could not parse complex entity: ${fullEntity.substring(0, 100)}`);
|
|
13004
|
+
}
|
|
13005
|
+
entities.push({
|
|
13006
|
+
id: eid(start.id),
|
|
13007
|
+
type: "Unknown",
|
|
13008
|
+
args: [`( ${complexMatch[1].trim()} )`]
|
|
13009
|
+
});
|
|
13010
|
+
} else {
|
|
13011
|
+
const match2 = fullEntity.match(/#\d+\s*=\s*([A-Z0-9_]+)\s*\(([\s\S]*)\);/);
|
|
13012
|
+
if (!match2) {
|
|
13013
|
+
throw new Error(`Could not parse entity: ${fullEntity.substring(0, 100)}`);
|
|
13014
|
+
}
|
|
13015
|
+
const type = match2[1].trim();
|
|
13016
|
+
const argsBody = match2[2].trim();
|
|
13017
|
+
const args = splitArgs(argsBody);
|
|
13018
|
+
entities.push({ id: eid(start.id), type, args });
|
|
13019
|
+
}
|
|
13020
|
+
}
|
|
13021
|
+
return entities;
|
|
13022
|
+
}
|
|
13023
|
+
function splitArgs(s) {
|
|
13024
|
+
const out = [];
|
|
13025
|
+
let buf = "";
|
|
13026
|
+
let depth = 0;
|
|
13027
|
+
let inStr = false;
|
|
13028
|
+
for (let i = 0;i < s.length; i++) {
|
|
13029
|
+
const c = s[i];
|
|
13030
|
+
if (c === "'" && s[i - 1] !== "\\")
|
|
13031
|
+
inStr = !inStr;
|
|
13032
|
+
if (!inStr) {
|
|
13033
|
+
if (c === "(")
|
|
13034
|
+
depth++;
|
|
13035
|
+
if (c === ")")
|
|
13036
|
+
depth--;
|
|
13037
|
+
if (c === "," && depth === 0) {
|
|
13038
|
+
out.push(buf.trim());
|
|
13039
|
+
buf = "";
|
|
13040
|
+
continue;
|
|
13041
|
+
}
|
|
13042
|
+
}
|
|
13043
|
+
buf += c;
|
|
13044
|
+
}
|
|
13045
|
+
if (buf.trim())
|
|
13046
|
+
out.push(buf.trim());
|
|
13047
|
+
return out;
|
|
13048
|
+
}
|
|
13049
|
+
function parseRepository(data) {
|
|
13050
|
+
const repo = new Repository;
|
|
13051
|
+
const ctx = {
|
|
13052
|
+
repo,
|
|
13053
|
+
parseRef(_tok) {
|
|
13054
|
+
const n = +_tok.replace("#", "").trim();
|
|
13055
|
+
return new Ref(eid(n));
|
|
13056
|
+
},
|
|
13057
|
+
parseNumber(tok) {
|
|
13058
|
+
return Number(tok);
|
|
13059
|
+
},
|
|
13060
|
+
parseString(tok) {
|
|
13061
|
+
const m = tok.match(/^'(.*)'$/);
|
|
13062
|
+
if (!m)
|
|
13063
|
+
throw new Error(`Expected string: ${tok}`);
|
|
13064
|
+
return m[1].replace(/''/g, "'");
|
|
13065
|
+
}
|
|
13066
|
+
};
|
|
13067
|
+
for (const row of tokenizeSTEP(data)) {
|
|
13068
|
+
const parser = getParser(row.type);
|
|
13069
|
+
if (!parser) {
|
|
13070
|
+
repo.set(row.id, new Unknown(row.type, row.args));
|
|
13071
|
+
continue;
|
|
13072
|
+
}
|
|
13073
|
+
const entity = parser(row.args, ctx);
|
|
13074
|
+
repo.set(row.id, entity);
|
|
13075
|
+
}
|
|
13076
|
+
return repo;
|
|
13077
|
+
}
|
|
13078
|
+
|
|
13079
|
+
// node_modules/circuit-json-to-step/dist/index.js
|
|
13080
|
+
var getCircuitJsonToGltfModule = async () => {
|
|
13081
|
+
try {
|
|
13082
|
+
return await import("circuit-json-to-gltf");
|
|
13083
|
+
} catch (error) {
|
|
13084
|
+
const dynamicGlobal = globalThis.tscircuitDynamicModules?.["circuit-json-to-gltf"];
|
|
13085
|
+
if (dynamicGlobal)
|
|
13086
|
+
return dynamicGlobal;
|
|
13087
|
+
throw new Error('Unable to load "circuit-json-to-gltf" from import() or globalThis.tscircuitDynamicModules.', { cause: error });
|
|
13088
|
+
}
|
|
13089
|
+
};
|
|
13090
|
+
function createStyleCache() {
|
|
13091
|
+
return /* @__PURE__ */ new Map;
|
|
13092
|
+
}
|
|
13093
|
+
function createStyledItem(repo, options) {
|
|
13094
|
+
const { itemRef, rgb, styleCache, name = "color" } = options;
|
|
13095
|
+
const key = rgb.map((value) => value.toFixed(6)).join(",");
|
|
13096
|
+
let presStyle = styleCache.get(key);
|
|
13097
|
+
if (!presStyle) {
|
|
13098
|
+
const color = repo.add(new ColourRgb("", rgb[0], rgb[1], rgb[2]));
|
|
13099
|
+
const fillColor = repo.add(new FillAreaStyleColour("", color));
|
|
13100
|
+
const fillStyle = repo.add(new FillAreaStyle("", [fillColor]));
|
|
13101
|
+
const surfaceFill = repo.add(new SurfaceStyleFillArea(fillStyle));
|
|
13102
|
+
const surfaceSide = repo.add(new SurfaceSideStyle("", [surfaceFill]));
|
|
13103
|
+
const surfaceUsage = repo.add(new SurfaceStyleUsage(".BOTH.", surfaceSide));
|
|
13104
|
+
presStyle = repo.add(new PresentationStyleAssignment([surfaceUsage]));
|
|
13105
|
+
styleCache.set(key, presStyle);
|
|
13106
|
+
}
|
|
13107
|
+
return repo.add(new StyledItem(name, [presStyle], itemRef));
|
|
13108
|
+
}
|
|
13109
|
+
function createStyledItems(repo, options) {
|
|
13110
|
+
const { itemRefs, rgb, styleCache, name } = options;
|
|
13111
|
+
return itemRefs.map((itemRef) => createStyledItem(repo, { itemRef, rgb, styleCache, name }));
|
|
13112
|
+
}
|
|
13113
|
+
function rotatePoint3(point, rotation) {
|
|
13114
|
+
if (!rotation)
|
|
13115
|
+
return point;
|
|
13116
|
+
let { x, y, z } = point;
|
|
13117
|
+
if (rotation.x) {
|
|
13118
|
+
const cos = Math.cos(rotation.x);
|
|
13119
|
+
const sin = Math.sin(rotation.x);
|
|
13120
|
+
const nextY = y * cos - z * sin;
|
|
13121
|
+
const nextZ = y * sin + z * cos;
|
|
13122
|
+
y = nextY;
|
|
13123
|
+
z = nextZ;
|
|
13124
|
+
}
|
|
13125
|
+
if (rotation.y) {
|
|
13126
|
+
const cos = Math.cos(rotation.y);
|
|
13127
|
+
const sin = Math.sin(rotation.y);
|
|
13128
|
+
const nextX = x * cos + z * sin;
|
|
13129
|
+
const nextZ = -x * sin + z * cos;
|
|
13130
|
+
x = nextX;
|
|
13131
|
+
z = nextZ;
|
|
13132
|
+
}
|
|
13133
|
+
if (rotation.z) {
|
|
13134
|
+
const cos = Math.cos(rotation.z);
|
|
13135
|
+
const sin = Math.sin(rotation.z);
|
|
13136
|
+
const nextX = x * cos - y * sin;
|
|
13137
|
+
const nextY = x * sin + y * cos;
|
|
13138
|
+
x = nextX;
|
|
13139
|
+
y = nextY;
|
|
13140
|
+
}
|
|
13141
|
+
return { x, y, z };
|
|
13142
|
+
}
|
|
13143
|
+
function createVertex(repo, point) {
|
|
13144
|
+
return repo.add(new VertexPoint("", repo.add(new CartesianPoint("", point.x, point.y, point.z))));
|
|
13145
|
+
}
|
|
13146
|
+
function createEdge(repo, vStart, vEnd) {
|
|
13147
|
+
const pStart = vStart.resolve(repo).pnt.resolve(repo);
|
|
13148
|
+
const pEnd = vEnd.resolve(repo).pnt.resolve(repo);
|
|
13149
|
+
const dx = pEnd.x - pStart.x;
|
|
13150
|
+
const dy = pEnd.y - pStart.y;
|
|
13151
|
+
const dz = pEnd.z - pStart.z;
|
|
13152
|
+
const length = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
13153
|
+
if (length < 0.0000000001) {
|
|
13154
|
+
const dir2 = repo.add(new Direction("", 1, 0, 0));
|
|
13155
|
+
const vec2 = repo.add(new Vector("", dir2, 0.0000000001));
|
|
13156
|
+
const line2 = repo.add(new Line("", vStart.resolve(repo).pnt, vec2));
|
|
13157
|
+
return repo.add(new EdgeCurve("", vStart, vEnd, line2, true));
|
|
13158
|
+
}
|
|
13159
|
+
const dir = repo.add(new Direction("", dx / length, dy / length, dz / length));
|
|
13160
|
+
const vec = repo.add(new Vector("", dir, length));
|
|
13161
|
+
const line = repo.add(new Line("", vStart.resolve(repo).pnt, vec));
|
|
13162
|
+
return repo.add(new EdgeCurve("", vStart, vEnd, line, true));
|
|
13163
|
+
}
|
|
13164
|
+
function createFaceFromVertices(repo, vertices) {
|
|
13165
|
+
const edges = vertices.map((vertex, index) => createEdge(repo, vertex, vertices[(index + 1) % vertices.length]));
|
|
13166
|
+
const edgeLoop = repo.add(new EdgeLoop("", edges.map((edge) => repo.add(new OrientedEdge("", edge, true)))));
|
|
13167
|
+
const p1 = vertices[0].resolve(repo).pnt.resolve(repo);
|
|
13168
|
+
const p2 = vertices[1].resolve(repo).pnt.resolve(repo);
|
|
13169
|
+
const p3 = vertices[2].resolve(repo).pnt.resolve(repo);
|
|
13170
|
+
const ux = p2.x - p1.x;
|
|
13171
|
+
const uy = p2.y - p1.y;
|
|
13172
|
+
const uz = p2.z - p1.z;
|
|
13173
|
+
const vx = p3.x - p1.x;
|
|
13174
|
+
const vy = p3.y - p1.y;
|
|
13175
|
+
const vz = p3.z - p1.z;
|
|
13176
|
+
const nx = uy * vz - uz * vy;
|
|
13177
|
+
const ny = uz * vx - ux * vz;
|
|
13178
|
+
const nz = ux * vy - uy * vx;
|
|
13179
|
+
const normalLength = Math.sqrt(nx * nx + ny * ny + nz * nz);
|
|
13180
|
+
const normal = normalLength < 0.0000000001 ? repo.add(new Direction("", 0, 0, 1)) : repo.add(new Direction("", nx / normalLength, ny / normalLength, nz / normalLength));
|
|
13181
|
+
const refLength = Math.sqrt(ux * ux + uy * uy + uz * uz);
|
|
13182
|
+
const refDir = refLength < 0.0000000001 ? repo.add(new Direction("", 1, 0, 0)) : repo.add(new Direction("", ux / refLength, uy / refLength, uz / refLength));
|
|
13183
|
+
const placement = repo.add(new Axis2Placement3D("", vertices[0].resolve(repo).pnt, normal, refDir));
|
|
13184
|
+
const plane = repo.add(new Plane("", placement));
|
|
13185
|
+
return repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", edgeLoop, true))], plane, true));
|
|
13186
|
+
}
|
|
13187
|
+
function createSceneBoxSolid(repo, box) {
|
|
13188
|
+
if (box.mesh?.triangles?.length) {
|
|
13189
|
+
return createSceneMeshSolid(repo, box);
|
|
13190
|
+
}
|
|
13191
|
+
const localBounds = box.mesh?.boundingBox ? {
|
|
13192
|
+
min: box.mesh.boundingBox.min,
|
|
13193
|
+
max: box.mesh.boundingBox.max
|
|
13194
|
+
} : {
|
|
13195
|
+
min: {
|
|
13196
|
+
x: -box.size.x / 2,
|
|
13197
|
+
y: -box.size.y / 2,
|
|
13198
|
+
z: -box.size.z / 2
|
|
13199
|
+
},
|
|
13200
|
+
max: {
|
|
13201
|
+
x: box.size.x / 2,
|
|
13202
|
+
y: box.size.y / 2,
|
|
13203
|
+
z: box.size.z / 2
|
|
13204
|
+
}
|
|
13205
|
+
};
|
|
13206
|
+
const corners = [
|
|
13207
|
+
{ x: localBounds.min.x, y: localBounds.min.y, z: localBounds.min.z },
|
|
13208
|
+
{ x: localBounds.max.x, y: localBounds.min.y, z: localBounds.min.z },
|
|
13209
|
+
{ x: localBounds.max.x, y: localBounds.max.y, z: localBounds.min.z },
|
|
13210
|
+
{ x: localBounds.min.x, y: localBounds.max.y, z: localBounds.min.z },
|
|
13211
|
+
{ x: localBounds.min.x, y: localBounds.min.y, z: localBounds.max.z },
|
|
13212
|
+
{ x: localBounds.max.x, y: localBounds.min.y, z: localBounds.max.z },
|
|
13213
|
+
{ x: localBounds.max.x, y: localBounds.max.y, z: localBounds.max.z },
|
|
13214
|
+
{ x: localBounds.min.x, y: localBounds.max.y, z: localBounds.max.z }
|
|
13215
|
+
].map((corner) => {
|
|
13216
|
+
const rotated = rotatePoint3(corner, box.rotation);
|
|
13217
|
+
return {
|
|
13218
|
+
x: rotated.x + box.center.x,
|
|
13219
|
+
y: rotated.y + box.center.y,
|
|
13220
|
+
z: rotated.z + box.center.z
|
|
13221
|
+
};
|
|
13222
|
+
});
|
|
13223
|
+
const stepCorners = corners.map((corner) => ({
|
|
13224
|
+
x: corner.x,
|
|
13225
|
+
y: corner.z,
|
|
13226
|
+
z: corner.y
|
|
13227
|
+
}));
|
|
13228
|
+
const vertices = stepCorners.map((corner) => createVertex(repo, corner));
|
|
13229
|
+
const faces = [
|
|
13230
|
+
[vertices[0], vertices[1], vertices[2], vertices[3]],
|
|
13231
|
+
[vertices[4], vertices[7], vertices[6], vertices[5]],
|
|
13232
|
+
[vertices[0], vertices[4], vertices[5], vertices[1]],
|
|
13233
|
+
[vertices[1], vertices[5], vertices[6], vertices[2]],
|
|
13234
|
+
[vertices[2], vertices[6], vertices[7], vertices[3]],
|
|
13235
|
+
[vertices[3], vertices[7], vertices[4], vertices[0]]
|
|
13236
|
+
].map((faceVertices) => createFaceFromVertices(repo, faceVertices));
|
|
13237
|
+
const shell = repo.add(new ClosedShell("", faces));
|
|
13238
|
+
return {
|
|
13239
|
+
solid: repo.add(new ManifoldSolidBrep(box.label ?? "Component", shell)),
|
|
13240
|
+
styledItems: [],
|
|
13241
|
+
usesIntrinsicFaceStyles: false,
|
|
13242
|
+
styleTargets: faces
|
|
13243
|
+
};
|
|
13244
|
+
}
|
|
13245
|
+
function createSceneMeshSolid(repo, box) {
|
|
13246
|
+
const styleCache = createStyleCache();
|
|
13247
|
+
const styledItems = [];
|
|
13248
|
+
const faces = box.mesh.triangles.map((triangle) => {
|
|
13249
|
+
const vertices = triangle.vertices.map((vertex) => {
|
|
13250
|
+
const rotated = rotatePoint3(vertex, box.rotation);
|
|
13251
|
+
const translated = {
|
|
13252
|
+
x: rotated.x + box.center.x,
|
|
13253
|
+
y: rotated.z + box.center.z,
|
|
13254
|
+
z: rotated.y + box.center.y
|
|
13255
|
+
};
|
|
13256
|
+
return createVertex(repo, translated);
|
|
13257
|
+
});
|
|
13258
|
+
const face = createFaceFromVertices(repo, vertices);
|
|
13259
|
+
const faceColor = normalizeTriangleColor(triangle.color);
|
|
13260
|
+
if (faceColor) {
|
|
13261
|
+
styledItems.push(createStyledItem(repo, {
|
|
13262
|
+
itemRef: face,
|
|
13263
|
+
rgb: faceColor,
|
|
13264
|
+
styleCache
|
|
13265
|
+
}));
|
|
13266
|
+
}
|
|
13267
|
+
return face;
|
|
13268
|
+
});
|
|
13269
|
+
const shell = repo.add(new ClosedShell("", faces));
|
|
13270
|
+
return {
|
|
13271
|
+
solid: repo.add(new ManifoldSolidBrep(box.label ?? "Component", shell)),
|
|
13272
|
+
styledItems,
|
|
13273
|
+
usesIntrinsicFaceStyles: faces.length > 0 && styledItems.length === faces.length,
|
|
13274
|
+
styleTargets: []
|
|
13275
|
+
};
|
|
13276
|
+
}
|
|
13277
|
+
function normalizeTriangleColor(color) {
|
|
13278
|
+
if (!Array.isArray(color) || color.length < 3)
|
|
13279
|
+
return null;
|
|
13280
|
+
const scale = color.some((value) => value > 1) ? 255 : 1;
|
|
13281
|
+
return [
|
|
13282
|
+
clampColorChannel(color[0] / scale),
|
|
13283
|
+
clampColorChannel(color[1] / scale),
|
|
13284
|
+
clampColorChannel(color[2] / scale)
|
|
13285
|
+
];
|
|
13286
|
+
}
|
|
13287
|
+
function clampColorChannel(value) {
|
|
13288
|
+
return Math.max(0, Math.min(1, value));
|
|
13289
|
+
}
|
|
13290
|
+
async function generateComponentMeshes(options) {
|
|
13291
|
+
const {
|
|
13292
|
+
repo,
|
|
13293
|
+
circuitJson,
|
|
13294
|
+
boardThickness,
|
|
13295
|
+
includeExternalMeshes = false,
|
|
13296
|
+
excludeCadComponentIds,
|
|
13297
|
+
excludePcbComponentIds,
|
|
13298
|
+
pcbComponentIdsWithStepUrl
|
|
13299
|
+
} = options;
|
|
13300
|
+
const solids = [];
|
|
13301
|
+
try {
|
|
13302
|
+
const filteredCircuitJson = circuitJson.filter((element) => {
|
|
13303
|
+
if (element.type === "pcb_board")
|
|
13304
|
+
return false;
|
|
13305
|
+
if (element.type === "cad_component" && element.cad_component_id && excludeCadComponentIds?.has(element.cad_component_id)) {
|
|
13306
|
+
return false;
|
|
13307
|
+
}
|
|
13308
|
+
if (element.type === "pcb_component" && element.pcb_component_id && excludePcbComponentIds?.has(element.pcb_component_id)) {
|
|
13309
|
+
return false;
|
|
13310
|
+
}
|
|
13311
|
+
if (element.type === "cad_component" && element.model_step_url) {
|
|
13312
|
+
return false;
|
|
13313
|
+
}
|
|
13314
|
+
if (element.type === "cad_component" && element.pcb_component_id && pcbComponentIdsWithStepUrl?.has(element.pcb_component_id)) {
|
|
13315
|
+
return false;
|
|
13316
|
+
}
|
|
13317
|
+
return true;
|
|
13318
|
+
}).map((element) => {
|
|
13319
|
+
if (!includeExternalMeshes && element.type === "cad_component") {
|
|
13320
|
+
return {
|
|
13321
|
+
...element,
|
|
13322
|
+
model_3mf_url: undefined,
|
|
13323
|
+
model_obj_url: undefined,
|
|
13324
|
+
model_stl_url: undefined,
|
|
13325
|
+
model_glb_url: undefined,
|
|
13326
|
+
model_gltf_url: undefined
|
|
13327
|
+
};
|
|
13328
|
+
}
|
|
13329
|
+
return element;
|
|
13330
|
+
});
|
|
13331
|
+
const { convertCircuitJsonTo3D } = await getCircuitJsonToGltfModule();
|
|
13332
|
+
const scene3d = await convertCircuitJsonTo3D(filteredCircuitJson, {
|
|
13333
|
+
boardThickness,
|
|
13334
|
+
renderBoardTextures: false
|
|
13335
|
+
});
|
|
13336
|
+
for (const box of scene3d.boxes) {
|
|
13337
|
+
solids.push(createSceneBoxSolid(repo, box));
|
|
13338
|
+
}
|
|
13339
|
+
} catch (error) {
|
|
13340
|
+
console.warn("Failed to generate component mesh:", error);
|
|
13341
|
+
}
|
|
13342
|
+
return solids;
|
|
13343
|
+
}
|
|
13344
|
+
var EXCLUDED_ENTITY_TYPES = /* @__PURE__ */ new Set([
|
|
13345
|
+
"APPLICATION_CONTEXT",
|
|
13346
|
+
"APPLICATION_PROTOCOL_DEFINITION",
|
|
13347
|
+
"PRODUCT",
|
|
13348
|
+
"PRODUCT_CONTEXT",
|
|
13349
|
+
"PRODUCT_DEFINITION",
|
|
13350
|
+
"PRODUCT_DEFINITION_FORMATION",
|
|
13351
|
+
"PRODUCT_DEFINITION_CONTEXT",
|
|
13352
|
+
"PRODUCT_DEFINITION_SHAPE",
|
|
13353
|
+
"SHAPE_DEFINITION_REPRESENTATION",
|
|
13354
|
+
"ADVANCED_BREP_SHAPE_REPRESENTATION",
|
|
13355
|
+
"PRODUCT_RELATED_PRODUCT_CATEGORY",
|
|
13356
|
+
"NEXT_ASSEMBLY_USAGE_OCCURRENCE",
|
|
13357
|
+
"CONTEXT_DEPENDENT_SHAPE_REPRESENTATION",
|
|
13358
|
+
"ITEM_DEFINED_TRANSFORMATION"
|
|
13359
|
+
]);
|
|
13360
|
+
function asVector3(value) {
|
|
13361
|
+
return {
|
|
13362
|
+
x: value?.x ?? 0,
|
|
13363
|
+
y: value?.y ?? 0,
|
|
13364
|
+
z: value?.z ?? 0
|
|
13365
|
+
};
|
|
13366
|
+
}
|
|
13367
|
+
function toRadians(rotation) {
|
|
13368
|
+
const factor = Math.PI / 180;
|
|
13369
|
+
return {
|
|
13370
|
+
x: rotation.x * factor,
|
|
13371
|
+
y: rotation.y * factor,
|
|
13372
|
+
z: rotation.z * factor
|
|
13373
|
+
};
|
|
13374
|
+
}
|
|
13375
|
+
function transformPoint(point, rotation, translation) {
|
|
13376
|
+
const rotated = rotateVector(point, rotation);
|
|
13377
|
+
return [
|
|
13378
|
+
rotated[0] + translation.x,
|
|
13379
|
+
rotated[1] + translation.y,
|
|
13380
|
+
rotated[2] + translation.z
|
|
13381
|
+
];
|
|
13382
|
+
}
|
|
13383
|
+
function transformDirection(vector, rotation) {
|
|
13384
|
+
return rotateVector(vector, rotation);
|
|
13385
|
+
}
|
|
13386
|
+
function rotateVector(vector, rotation) {
|
|
13387
|
+
let [x, y, z] = vector;
|
|
13388
|
+
if (rotation.x !== 0) {
|
|
13389
|
+
const cosX = Math.cos(rotation.x);
|
|
13390
|
+
const sinX = Math.sin(rotation.x);
|
|
13391
|
+
const y1 = y * cosX - z * sinX;
|
|
13392
|
+
const z1 = y * sinX + z * cosX;
|
|
13393
|
+
y = y1;
|
|
13394
|
+
z = z1;
|
|
13395
|
+
}
|
|
13396
|
+
if (rotation.y !== 0) {
|
|
13397
|
+
const cosY = Math.cos(rotation.y);
|
|
13398
|
+
const sinY = Math.sin(rotation.y);
|
|
13399
|
+
const x1 = x * cosY + z * sinY;
|
|
13400
|
+
const z1 = -x * sinY + z * cosY;
|
|
13401
|
+
x = x1;
|
|
13402
|
+
z = z1;
|
|
13403
|
+
}
|
|
13404
|
+
if (rotation.z !== 0) {
|
|
13405
|
+
const cosZ = Math.cos(rotation.z);
|
|
13406
|
+
const sinZ = Math.sin(rotation.z);
|
|
13407
|
+
const x1 = x * cosZ - y * sinZ;
|
|
13408
|
+
const y1 = x * sinZ + y * cosZ;
|
|
13409
|
+
x = x1;
|
|
13410
|
+
y = y1;
|
|
13411
|
+
}
|
|
13412
|
+
return [x, y, z];
|
|
13413
|
+
}
|
|
13414
|
+
async function readStepFile(modelUrl) {
|
|
13415
|
+
if (!/^https?:\/\//i.test(modelUrl)) {
|
|
13416
|
+
throw new Error(`Only HTTP(S) URLs are supported. For local files, read the file content and pass it directly. Received: ${modelUrl}`);
|
|
13417
|
+
}
|
|
13418
|
+
const globalFetch = globalThis.fetch;
|
|
13419
|
+
if (!globalFetch) {
|
|
13420
|
+
throw new Error("fetch is not available in this environment");
|
|
13421
|
+
}
|
|
13422
|
+
const res = await globalFetch(modelUrl);
|
|
13423
|
+
if (!res.ok) {
|
|
13424
|
+
throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
13425
|
+
}
|
|
13426
|
+
return await res.text();
|
|
13427
|
+
}
|
|
13428
|
+
async function mergeExternalStepModels(options) {
|
|
13429
|
+
const { repo, circuitJson, boardThickness, fsMap } = options;
|
|
13430
|
+
const cadComponents = circuitJson.filter((item) => item?.type === "cad_component" && typeof item.model_step_url === "string");
|
|
13431
|
+
const pcbComponentMap = /* @__PURE__ */ new Map;
|
|
13432
|
+
for (const item of circuitJson) {
|
|
13433
|
+
if (item?.type === "pcb_component" && item.pcb_component_id) {
|
|
13434
|
+
pcbComponentMap.set(item.pcb_component_id, item);
|
|
13435
|
+
}
|
|
13436
|
+
}
|
|
13437
|
+
const solids = [];
|
|
13438
|
+
const handledComponentIds = /* @__PURE__ */ new Set;
|
|
13439
|
+
const handledPcbComponentIds = /* @__PURE__ */ new Set;
|
|
13440
|
+
for (const component of cadComponents) {
|
|
13441
|
+
const componentId = component.cad_component_id ?? "";
|
|
13442
|
+
const stepUrl = component.model_step_url;
|
|
13443
|
+
try {
|
|
13444
|
+
const stepText = fsMap?.[stepUrl] ?? await readStepFile(stepUrl);
|
|
13445
|
+
if (!stepText.trim()) {
|
|
13446
|
+
throw new Error("STEP file is empty");
|
|
13447
|
+
}
|
|
13448
|
+
const pcbComponent = component.pcb_component_id ? pcbComponentMap.get(component.pcb_component_id) : undefined;
|
|
13449
|
+
const layer = pcbComponent?.layer?.toLowerCase();
|
|
13450
|
+
const transform = {
|
|
13451
|
+
translation: asVector3(component.position),
|
|
13452
|
+
rotation: asVector3(component.rotation)
|
|
13453
|
+
};
|
|
13454
|
+
const componentSolids = mergeSingleStepModel(repo, stepText, transform, {
|
|
13455
|
+
layer,
|
|
13456
|
+
boardThickness
|
|
13457
|
+
});
|
|
13458
|
+
if (componentSolids.length > 0) {
|
|
13459
|
+
if (componentId) {
|
|
13460
|
+
handledComponentIds.add(componentId);
|
|
13461
|
+
}
|
|
13462
|
+
const pcbComponentId = component.pcb_component_id;
|
|
13463
|
+
if (pcbComponentId) {
|
|
13464
|
+
handledPcbComponentIds.add(pcbComponentId);
|
|
13465
|
+
}
|
|
13466
|
+
}
|
|
13467
|
+
solids.push(...componentSolids);
|
|
13468
|
+
} catch (error) {
|
|
13469
|
+
console.warn(`Failed to merge STEP model from ${stepUrl}:`, error);
|
|
13470
|
+
}
|
|
13471
|
+
}
|
|
13472
|
+
return { solids, handledComponentIds, handledPcbComponentIds };
|
|
13473
|
+
}
|
|
13474
|
+
function mergeSingleStepModel(targetRepo, stepText, transform, placement) {
|
|
13475
|
+
const sourceRepo = parseRepository(stepText);
|
|
13476
|
+
let entries = sourceRepo.entries().map(([id, entity]) => [Number(id), entity]).filter(([, entity]) => !EXCLUDED_ENTITY_TYPES.has(entity.type));
|
|
13477
|
+
entries = pruneInvalidEntries(entries);
|
|
13478
|
+
adjustTransformForPlacement(entries, transform, placement);
|
|
13479
|
+
applyTransform(entries, transform);
|
|
13480
|
+
const idMapping = allocateIds(targetRepo, entries);
|
|
13481
|
+
remapReferences(entries, idMapping);
|
|
13482
|
+
for (const [oldId, entity] of entries) {
|
|
13483
|
+
const mappedId = idMapping.get(oldId);
|
|
13484
|
+
if (mappedId === undefined)
|
|
13485
|
+
continue;
|
|
13486
|
+
targetRepo.set(eid(mappedId), entity);
|
|
13487
|
+
}
|
|
13488
|
+
const solids = [];
|
|
13489
|
+
for (const [oldId, entity] of entries) {
|
|
13490
|
+
if (entity instanceof ManifoldSolidBrep) {
|
|
13491
|
+
const mappedId = idMapping.get(oldId);
|
|
13492
|
+
if (mappedId !== undefined) {
|
|
13493
|
+
solids.push(new Ref(eid(mappedId)));
|
|
13494
|
+
}
|
|
13495
|
+
}
|
|
13496
|
+
}
|
|
13497
|
+
return solids;
|
|
13498
|
+
}
|
|
13499
|
+
function adjustTransformForPlacement(entries, transform, placement) {
|
|
13500
|
+
if (!placement)
|
|
13501
|
+
return;
|
|
13502
|
+
const points = [];
|
|
13503
|
+
for (const [, entity] of entries) {
|
|
13504
|
+
if (entity instanceof CartesianPoint) {
|
|
13505
|
+
points.push([entity.x, entity.y, entity.z]);
|
|
13506
|
+
}
|
|
13507
|
+
}
|
|
13508
|
+
if (!points.length)
|
|
13509
|
+
return;
|
|
13510
|
+
const rotationRadians = toRadians(transform.rotation);
|
|
13511
|
+
let minX = Infinity;
|
|
13512
|
+
let minY = Infinity;
|
|
13513
|
+
let minZ = Infinity;
|
|
13514
|
+
let maxX = -Infinity;
|
|
13515
|
+
let maxY = -Infinity;
|
|
13516
|
+
let maxZ = -Infinity;
|
|
13517
|
+
for (const point of points) {
|
|
13518
|
+
const [x, y, z] = rotateVector(point, rotationRadians);
|
|
13519
|
+
if (x < minX)
|
|
13520
|
+
minX = x;
|
|
13521
|
+
if (y < minY)
|
|
13522
|
+
minY = y;
|
|
13523
|
+
if (z < minZ)
|
|
13524
|
+
minZ = z;
|
|
13525
|
+
if (x > maxX)
|
|
13526
|
+
maxX = x;
|
|
13527
|
+
if (y > maxY)
|
|
13528
|
+
maxY = y;
|
|
13529
|
+
if (z > maxZ)
|
|
13530
|
+
maxZ = z;
|
|
13531
|
+
}
|
|
13532
|
+
if (!Number.isFinite(minX))
|
|
13533
|
+
return;
|
|
13534
|
+
const center = {
|
|
13535
|
+
x: (minX + maxX) / 2,
|
|
13536
|
+
y: (minY + maxY) / 2,
|
|
13537
|
+
z: (minZ + maxZ) / 2
|
|
13538
|
+
};
|
|
13539
|
+
const normalizedLayer = placement.layer?.toLowerCase() === "bottom" ? "bottom" : "top";
|
|
13540
|
+
const boardThickness = placement.boardThickness ?? 0;
|
|
13541
|
+
const targetX = transform.translation.x;
|
|
13542
|
+
const targetY = transform.translation.y;
|
|
13543
|
+
const targetZ = transform.translation.z;
|
|
13544
|
+
const THROUGH_HOLE_Z_TOLERANCE = 0.001;
|
|
13545
|
+
const isThroughHoleComponent = minZ < -THROUGH_HOLE_Z_TOLERANCE && maxZ > THROUGH_HOLE_Z_TOLERANCE;
|
|
13546
|
+
transform.translation.x = targetX - center.x;
|
|
13547
|
+
transform.translation.y = targetY - center.y;
|
|
13548
|
+
if (isThroughHoleComponent) {
|
|
13549
|
+
transform.translation.z = boardThickness / 2;
|
|
13550
|
+
}
|
|
13551
|
+
if (!isThroughHoleComponent && boardThickness > 0) {
|
|
13552
|
+
const halfThickness = boardThickness / 2;
|
|
13553
|
+
const offsetZ = targetZ;
|
|
13554
|
+
if (normalizedLayer === "bottom") {
|
|
13555
|
+
transform.translation.z = -maxZ + offsetZ;
|
|
13556
|
+
transform.rotation.x = normalizeDegrees(transform.rotation.x + 180);
|
|
13557
|
+
} else {
|
|
13558
|
+
transform.translation.z = halfThickness - minZ + offsetZ;
|
|
13559
|
+
}
|
|
13560
|
+
} else if (!isThroughHoleComponent) {
|
|
13561
|
+
transform.translation.z = targetZ - center.z;
|
|
13562
|
+
}
|
|
13563
|
+
}
|
|
13564
|
+
function normalizeDegrees(value) {
|
|
13565
|
+
const wrapped = value % 360;
|
|
13566
|
+
return wrapped < 0 ? wrapped + 360 : wrapped;
|
|
13567
|
+
}
|
|
13568
|
+
function pruneInvalidEntries(entries) {
|
|
13569
|
+
let remaining = entries.slice();
|
|
13570
|
+
let remainingIds = new Set(remaining.map(([id]) => id));
|
|
13571
|
+
let changed = true;
|
|
13572
|
+
while (changed) {
|
|
13573
|
+
changed = false;
|
|
13574
|
+
const toRemove = /* @__PURE__ */ new Set;
|
|
13575
|
+
for (const [entityId, entity] of remaining) {
|
|
13576
|
+
const refs = collectReferencedIds(entity);
|
|
13577
|
+
for (const refId of refs) {
|
|
13578
|
+
if (!remainingIds.has(refId)) {
|
|
13579
|
+
toRemove.add(entityId);
|
|
13580
|
+
break;
|
|
13581
|
+
}
|
|
13582
|
+
}
|
|
13583
|
+
}
|
|
13584
|
+
if (toRemove.size > 0) {
|
|
13585
|
+
changed = true;
|
|
13586
|
+
remaining = remaining.filter(([id]) => !toRemove.has(id));
|
|
13587
|
+
remainingIds = new Set(remaining.map(([id]) => id));
|
|
13588
|
+
}
|
|
13589
|
+
}
|
|
13590
|
+
return remaining;
|
|
13591
|
+
}
|
|
13592
|
+
function collectReferencedIds(entity) {
|
|
13593
|
+
const result = /* @__PURE__ */ new Set;
|
|
13594
|
+
collectReferencedIdsRecursive(entity, result, /* @__PURE__ */ new Set);
|
|
13595
|
+
return result;
|
|
13596
|
+
}
|
|
13597
|
+
function collectReferencedIdsRecursive(value, result, seen) {
|
|
13598
|
+
if (!value)
|
|
13599
|
+
return;
|
|
13600
|
+
if (value instanceof Ref) {
|
|
13601
|
+
result.add(Number(value.id));
|
|
13602
|
+
return;
|
|
13603
|
+
}
|
|
13604
|
+
if (value instanceof Unknown) {
|
|
13605
|
+
for (const arg of value.args) {
|
|
13606
|
+
arg.replace(/#(\d+)/g, (_, num) => {
|
|
13607
|
+
result.add(Number(num));
|
|
13608
|
+
return _;
|
|
13609
|
+
});
|
|
13610
|
+
}
|
|
13611
|
+
return;
|
|
13612
|
+
}
|
|
13613
|
+
if (Array.isArray(value)) {
|
|
13614
|
+
for (const item of value) {
|
|
13615
|
+
collectReferencedIdsRecursive(item, result, seen);
|
|
13616
|
+
}
|
|
13617
|
+
return;
|
|
13618
|
+
}
|
|
13619
|
+
if (typeof value === "object") {
|
|
13620
|
+
if (seen.has(value)) {
|
|
13621
|
+
return;
|
|
13622
|
+
}
|
|
13623
|
+
seen.add(value);
|
|
13624
|
+
for (const entry of Object.values(value)) {
|
|
13625
|
+
collectReferencedIdsRecursive(entry, result, seen);
|
|
13626
|
+
}
|
|
13627
|
+
}
|
|
13628
|
+
}
|
|
13629
|
+
function applyTransform(entries, transform) {
|
|
13630
|
+
const rotation = toRadians(transform.rotation);
|
|
13631
|
+
for (const [, entity] of entries) {
|
|
13632
|
+
if (entity instanceof CartesianPoint) {
|
|
13633
|
+
const [x, y, z] = transformPoint([entity.x, entity.y, entity.z], rotation, transform.translation);
|
|
13634
|
+
entity.x = x;
|
|
13635
|
+
entity.y = y;
|
|
13636
|
+
entity.z = z;
|
|
13637
|
+
} else if (entity instanceof Direction) {
|
|
13638
|
+
const [dx, dy, dz] = transformDirection([entity.dx, entity.dy, entity.dz], rotation);
|
|
13639
|
+
const length = Math.hypot(dx, dy, dz);
|
|
13640
|
+
if (length > 0) {
|
|
13641
|
+
entity.dx = dx / length;
|
|
13642
|
+
entity.dy = dy / length;
|
|
13643
|
+
entity.dz = dz / length;
|
|
13644
|
+
}
|
|
13645
|
+
}
|
|
13646
|
+
}
|
|
13647
|
+
}
|
|
13648
|
+
function allocateIds(targetRepo, entries) {
|
|
13649
|
+
let nextId = getNextEntityId(targetRepo);
|
|
13650
|
+
const idMapping = /* @__PURE__ */ new Map;
|
|
13651
|
+
for (const [oldId] of entries) {
|
|
13652
|
+
idMapping.set(oldId, nextId);
|
|
13653
|
+
nextId += 1;
|
|
13654
|
+
}
|
|
13655
|
+
return idMapping;
|
|
13656
|
+
}
|
|
13657
|
+
function getNextEntityId(repo) {
|
|
13658
|
+
let maxId = 0;
|
|
13659
|
+
for (const [id] of repo.entries()) {
|
|
13660
|
+
const numericId = Number(id);
|
|
13661
|
+
if (numericId > maxId) {
|
|
13662
|
+
maxId = numericId;
|
|
13663
|
+
}
|
|
13664
|
+
}
|
|
13665
|
+
return maxId + 1;
|
|
13666
|
+
}
|
|
13667
|
+
function remapReferences(entries, idMapping) {
|
|
13668
|
+
for (const [, entity] of entries) {
|
|
13669
|
+
remapValue(entity, idMapping, /* @__PURE__ */ new Set);
|
|
13670
|
+
}
|
|
13671
|
+
}
|
|
13672
|
+
function remapValue(value, idMapping, seen) {
|
|
13673
|
+
if (!value)
|
|
13674
|
+
return;
|
|
13675
|
+
if (value instanceof Ref) {
|
|
13676
|
+
const mapped = idMapping.get(Number(value.id));
|
|
13677
|
+
if (mapped !== undefined) {
|
|
13678
|
+
value.id = eid(mapped);
|
|
13679
|
+
}
|
|
13680
|
+
return;
|
|
13681
|
+
}
|
|
13682
|
+
if (value instanceof Unknown) {
|
|
13683
|
+
value.args = value.args.map((arg) => arg.replace(/#(\d+)/g, (match, num) => {
|
|
13684
|
+
const mapped = idMapping.get(Number(num));
|
|
13685
|
+
return mapped !== undefined ? `#${mapped}` : match;
|
|
13686
|
+
}));
|
|
13687
|
+
return;
|
|
13688
|
+
}
|
|
13689
|
+
if (Array.isArray(value)) {
|
|
13690
|
+
for (const item of value) {
|
|
13691
|
+
remapValue(item, idMapping, seen);
|
|
13692
|
+
}
|
|
13693
|
+
return;
|
|
13694
|
+
}
|
|
13695
|
+
if (typeof value === "object") {
|
|
13696
|
+
if (seen.has(value))
|
|
13697
|
+
return;
|
|
13698
|
+
seen.add(value);
|
|
13699
|
+
for (const key of Object.keys(value)) {
|
|
13700
|
+
remapValue(value[key], idMapping, seen);
|
|
13701
|
+
}
|
|
13702
|
+
}
|
|
13703
|
+
}
|
|
13704
|
+
function normalizeStepNumericExponents(stepText) {
|
|
13705
|
+
return stepText.replace(/(-?(?:\d+\.\d*|\.\d+|\d+))e([+-]?\d+)/g, (_match, mantissa, exponent) => `${mantissa}E${exponent}`);
|
|
13706
|
+
}
|
|
13707
|
+
var package_default = {
|
|
13708
|
+
name: "circuit-json-to-step",
|
|
13709
|
+
main: "dist/index.js",
|
|
13710
|
+
version: "0.0.27",
|
|
13711
|
+
type: "module",
|
|
13712
|
+
scripts: {
|
|
13713
|
+
"pull-reference": `git clone https://github.com/tscircuit/circuit-json.git && find circuit-json/tests -name '*.test.ts' -exec bash -c 'mv "$0" "\${0%.test.ts}.ts"' {} \\; && git clone https://github.com/tscircuit/stepts.git && find stepts/tests -name '*.test.ts' -exec bash -c 'mv "$0" "\${0%.test.ts}.ts"' {} \\;`,
|
|
13714
|
+
test: "bun test",
|
|
13715
|
+
"test:update-snapshots": "BUN_UPDATE_SNAPSHOTS=1 bun test",
|
|
13716
|
+
build: "tsup-node ./lib/index.ts --format esm --dts",
|
|
13717
|
+
format: "biome format --write .",
|
|
13718
|
+
"format:check": "biome format .",
|
|
13719
|
+
start: "bun site/index.html",
|
|
13720
|
+
"build:site": "bun build site/index.html --outdir=site-export"
|
|
13721
|
+
},
|
|
13722
|
+
devDependencies: {
|
|
13723
|
+
"@biomejs/biome": "^2.3.8",
|
|
13724
|
+
"@resvg/resvg-js": "^2.6.2",
|
|
13725
|
+
"@resvg/resvg-wasm": "^2.6.2",
|
|
13726
|
+
"@tscircuit/circuit-json-util": "^0.0.75",
|
|
13727
|
+
"@types/bun": "latest",
|
|
13728
|
+
"circuit-json": "^0.0.425",
|
|
13729
|
+
"looks-same": "^10.0.1",
|
|
13730
|
+
"occt-import-js": "^0.0.23",
|
|
13731
|
+
poppygl: "^0.0.17",
|
|
13732
|
+
tsup: "^8.5.0"
|
|
13733
|
+
},
|
|
13734
|
+
peerDependencies: {
|
|
13735
|
+
"@tscircuit/circuit-json-util": "*",
|
|
13736
|
+
typescript: "^5"
|
|
13737
|
+
},
|
|
13738
|
+
dependencies: {
|
|
13739
|
+
"circuit-json-to-connectivity-map": "^0.0.22",
|
|
13740
|
+
"circuit-json-to-gltf": "^0.0.100",
|
|
13741
|
+
"circuit-to-svg": "^0.0.345",
|
|
13742
|
+
"schematic-symbols": "^0.0.202",
|
|
13743
|
+
stepts: "^0.0.4"
|
|
13744
|
+
}
|
|
13745
|
+
};
|
|
13746
|
+
var VERSION = package_default.version;
|
|
13747
|
+
function getPillGeometry(hole) {
|
|
13748
|
+
const centerX = typeof hole.x === "number" ? hole.x : hole.x.value;
|
|
13749
|
+
const centerY = typeof hole.y === "number" ? hole.y : hole.y.value;
|
|
13750
|
+
const width = hole.hole_width;
|
|
13751
|
+
const height = hole.hole_height;
|
|
13752
|
+
const ccwRotation = hole.ccw_rotation ?? 0;
|
|
13753
|
+
const rotation = ccwRotation * Math.PI / 180;
|
|
13754
|
+
const isHorizontal = width >= height;
|
|
13755
|
+
const radius = Math.min(width, height) / 2;
|
|
13756
|
+
const straightHalfLength = Math.abs(width - height) / 2;
|
|
13757
|
+
return {
|
|
13758
|
+
centerX,
|
|
13759
|
+
centerY,
|
|
13760
|
+
width,
|
|
13761
|
+
height,
|
|
13762
|
+
rotation,
|
|
13763
|
+
radius,
|
|
13764
|
+
straightHalfLength,
|
|
13765
|
+
isHorizontal
|
|
13766
|
+
};
|
|
13767
|
+
}
|
|
13768
|
+
function rotatePoint(x, y, centerX, centerY, angle) {
|
|
13769
|
+
const cos = Math.cos(angle);
|
|
13770
|
+
const sin = Math.sin(angle);
|
|
13771
|
+
const dx = x - centerX;
|
|
13772
|
+
const dy = y - centerY;
|
|
13773
|
+
return {
|
|
13774
|
+
x: centerX + dx * cos - dy * sin,
|
|
13775
|
+
y: centerY + dx * sin + dy * cos
|
|
13776
|
+
};
|
|
13777
|
+
}
|
|
13778
|
+
function createLineEdge(repo, v1, v2) {
|
|
13779
|
+
const p1 = v1.resolve(repo).pnt.resolve(repo);
|
|
13780
|
+
const p2 = v2.resolve(repo).pnt.resolve(repo);
|
|
13781
|
+
const dx = p2.x - p1.x;
|
|
13782
|
+
const dy = p2.y - p1.y;
|
|
13783
|
+
const dz = p2.z - p1.z;
|
|
13784
|
+
const length = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
13785
|
+
if (length < 0.0000000001) {
|
|
13786
|
+
const dir2 = repo.add(new Direction("", 1, 0, 0));
|
|
13787
|
+
const vec2 = repo.add(new Vector("", dir2, 0.0000000001));
|
|
13788
|
+
const line2 = repo.add(new Line("", v1.resolve(repo).pnt, vec2));
|
|
13789
|
+
return repo.add(new EdgeCurve("", v1, v2, line2, true));
|
|
13790
|
+
}
|
|
13791
|
+
const dir = repo.add(new Direction("", dx / length, dy / length, dz / length));
|
|
13792
|
+
const vec = repo.add(new Vector("", dir, length));
|
|
13793
|
+
const line = repo.add(new Line("", v1.resolve(repo).pnt, vec));
|
|
13794
|
+
return repo.add(new EdgeCurve("", v1, v2, line, true));
|
|
13795
|
+
}
|
|
13796
|
+
function createArcEdge(repo, centerX, centerY, z, radius, startAngle, endAngle, rotation, centerX0, centerY0) {
|
|
13797
|
+
const startX = centerX + radius * Math.cos(startAngle);
|
|
13798
|
+
const startY = centerY + radius * Math.sin(startAngle);
|
|
13799
|
+
const endX = centerX + radius * Math.cos(endAngle);
|
|
13800
|
+
const endY = centerY + radius * Math.sin(endAngle);
|
|
13801
|
+
const startRotated = rotatePoint(startX, startY, centerX0, centerY0, rotation);
|
|
13802
|
+
const endRotated = rotatePoint(endX, endY, centerX0, centerY0, rotation);
|
|
13803
|
+
const startVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", startRotated.x, startRotated.y, z))));
|
|
13804
|
+
const endVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", endRotated.x, endRotated.y, z))));
|
|
13805
|
+
const centerRotated = rotatePoint(centerX, centerY, centerX0, centerY0, rotation);
|
|
13806
|
+
const centerPoint = repo.add(new CartesianPoint("", centerRotated.x, centerRotated.y, z));
|
|
13807
|
+
const normalDir = repo.add(new Direction("", 0, 0, -1));
|
|
13808
|
+
const refAngle = rotation;
|
|
13809
|
+
const refDir = repo.add(new Direction("", Math.cos(refAngle), Math.sin(refAngle), 0));
|
|
13810
|
+
const placement = repo.add(new Axis2Placement3D("", centerPoint, normalDir, refDir));
|
|
13811
|
+
const circle = repo.add(new Circle("", placement, radius));
|
|
13812
|
+
return repo.add(new EdgeCurve("", startVertex, endVertex, circle, false));
|
|
13813
|
+
}
|
|
13814
|
+
function createPillHoleLoop(repo, hole, z, xDir) {
|
|
13815
|
+
const geom = getPillGeometry(hole);
|
|
13816
|
+
const {
|
|
13817
|
+
centerX,
|
|
13818
|
+
centerY,
|
|
13819
|
+
radius,
|
|
13820
|
+
straightHalfLength,
|
|
13821
|
+
rotation,
|
|
13822
|
+
isHorizontal
|
|
13823
|
+
} = geom;
|
|
13824
|
+
const edges = [];
|
|
13825
|
+
if (isHorizontal) {
|
|
13826
|
+
const capOffset = straightHalfLength;
|
|
13827
|
+
const rightArc = createArcEdge(repo, centerX + capOffset, centerY, z, radius, -Math.PI / 2, Math.PI / 2, rotation, centerX, centerY);
|
|
13828
|
+
edges.push(rightArc);
|
|
13829
|
+
const bottomStart = rotatePoint(centerX + capOffset, centerY - radius, centerX, centerY, rotation);
|
|
13830
|
+
const bottomEnd = rotatePoint(centerX - capOffset, centerY - radius, centerX, centerY, rotation);
|
|
13831
|
+
const bottomV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, z))));
|
|
13832
|
+
const bottomV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, z))));
|
|
13833
|
+
edges.push(createLineEdge(repo, bottomV1, bottomV2));
|
|
13834
|
+
const leftArc = createArcEdge(repo, centerX - capOffset, centerY, z, radius, Math.PI / 2, 3 * Math.PI / 2, rotation, centerX, centerY);
|
|
13835
|
+
edges.push(leftArc);
|
|
13836
|
+
const topStart = rotatePoint(centerX - capOffset, centerY + radius, centerX, centerY, rotation);
|
|
13837
|
+
const topEnd = rotatePoint(centerX + capOffset, centerY + radius, centerX, centerY, rotation);
|
|
13838
|
+
const topV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", topStart.x, topStart.y, z))));
|
|
13839
|
+
const topV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", topEnd.x, topEnd.y, z))));
|
|
13840
|
+
edges.push(createLineEdge(repo, topV1, topV2));
|
|
13841
|
+
} else {
|
|
13842
|
+
const capOffset = straightHalfLength;
|
|
13843
|
+
const topArc = createArcEdge(repo, centerX, centerY - capOffset, z, radius, Math.PI, 0, rotation, centerX, centerY);
|
|
13844
|
+
edges.push(topArc);
|
|
13845
|
+
const rightStart = rotatePoint(centerX + radius, centerY - capOffset, centerX, centerY, rotation);
|
|
13846
|
+
const rightEnd = rotatePoint(centerX + radius, centerY + capOffset, centerX, centerY, rotation);
|
|
13847
|
+
const rightV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", rightStart.x, rightStart.y, z))));
|
|
13848
|
+
const rightV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", rightEnd.x, rightEnd.y, z))));
|
|
13849
|
+
edges.push(createLineEdge(repo, rightV1, rightV2));
|
|
13850
|
+
const bottomArc = createArcEdge(repo, centerX, centerY + capOffset, z, radius, 0, Math.PI, rotation, centerX, centerY);
|
|
13851
|
+
edges.push(bottomArc);
|
|
13852
|
+
const leftStart = rotatePoint(centerX - radius, centerY + capOffset, centerX, centerY, rotation);
|
|
13853
|
+
const leftEnd = rotatePoint(centerX - radius, centerY - capOffset, centerX, centerY, rotation);
|
|
13854
|
+
const leftV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", leftStart.x, leftStart.y, z))));
|
|
13855
|
+
const leftV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", leftEnd.x, leftEnd.y, z))));
|
|
13856
|
+
edges.push(createLineEdge(repo, leftV1, leftV2));
|
|
13857
|
+
}
|
|
13858
|
+
const orientedEdges = edges.map((edge) => repo.add(new OrientedEdge("", edge, true)));
|
|
13859
|
+
return repo.add(new EdgeLoop("", orientedEdges));
|
|
13860
|
+
}
|
|
13861
|
+
function createPillCylindricalFaces(repo, hole, zMin, zMax, xDir, zDir) {
|
|
13862
|
+
const geom = getPillGeometry(hole);
|
|
13863
|
+
const {
|
|
13864
|
+
centerX,
|
|
13865
|
+
centerY,
|
|
13866
|
+
radius,
|
|
13867
|
+
straightHalfLength,
|
|
13868
|
+
rotation,
|
|
13869
|
+
isHorizontal
|
|
13870
|
+
} = geom;
|
|
13871
|
+
const faces = [];
|
|
13872
|
+
if (isHorizontal) {
|
|
13873
|
+
const capOffset = straightHalfLength;
|
|
13874
|
+
faces.push(createCylindricalWall(repo, centerX + capOffset, centerY, radius, -Math.PI / 2, Math.PI / 2, rotation, centerX, centerY, zMin, zMax, zDir, xDir));
|
|
13875
|
+
faces.push(createPlanarWall(repo, centerX - capOffset, centerY - radius, centerX + capOffset, centerY - radius, rotation, centerX, centerY, zMin, zMax, zDir));
|
|
13876
|
+
faces.push(createCylindricalWall(repo, centerX - capOffset, centerY, radius, Math.PI / 2, 3 * Math.PI / 2, rotation, centerX, centerY, zMin, zMax, zDir, xDir));
|
|
13877
|
+
faces.push(createPlanarWall(repo, centerX + capOffset, centerY + radius, centerX - capOffset, centerY + radius, rotation, centerX, centerY, zMin, zMax, zDir));
|
|
13878
|
+
} else {
|
|
13879
|
+
const capOffset = straightHalfLength;
|
|
13880
|
+
faces.push(createCylindricalWall(repo, centerX, centerY - capOffset, radius, Math.PI, 0, rotation, centerX, centerY, zMin, zMax, zDir, xDir));
|
|
13881
|
+
faces.push(createPlanarWall(repo, centerX + radius, centerY - capOffset, centerX + radius, centerY + capOffset, rotation, centerX, centerY, zMin, zMax, zDir));
|
|
13882
|
+
faces.push(createCylindricalWall(repo, centerX, centerY + capOffset, radius, 0, Math.PI, rotation, centerX, centerY, zMin, zMax, zDir, xDir));
|
|
13883
|
+
faces.push(createPlanarWall(repo, centerX - radius, centerY + capOffset, centerX - radius, centerY - capOffset, rotation, centerX, centerY, zMin, zMax, zDir));
|
|
13884
|
+
}
|
|
13885
|
+
return faces;
|
|
13886
|
+
}
|
|
13887
|
+
function createCylindricalWall(repo, centerX, centerY, radius, startAngle, endAngle, rotation, centerX0, centerY0, zMin, zMax, zDir, xDir) {
|
|
13888
|
+
const bottomStartX = centerX + radius * Math.cos(startAngle);
|
|
13889
|
+
const bottomStartY = centerY + radius * Math.sin(startAngle);
|
|
13890
|
+
const bottomEndX = centerX + radius * Math.cos(endAngle);
|
|
13891
|
+
const bottomEndY = centerY + radius * Math.sin(endAngle);
|
|
13892
|
+
const bottomStart = rotatePoint(bottomStartX, bottomStartY, centerX0, centerY0, rotation);
|
|
13893
|
+
const bottomEnd = rotatePoint(bottomEndX, bottomEndY, centerX0, centerY0, rotation);
|
|
13894
|
+
const bottomStartVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, zMin))));
|
|
13895
|
+
const bottomEndVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, zMin))));
|
|
13896
|
+
const topStart = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, zMax))));
|
|
13897
|
+
const topEnd = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, zMax))));
|
|
13898
|
+
const centerRotated = rotatePoint(centerX, centerY, centerX0, centerY0, rotation);
|
|
13899
|
+
const bottomCenter = repo.add(new CartesianPoint("", centerRotated.x, centerRotated.y, zMin));
|
|
13900
|
+
const bottomPlacement = repo.add(new Axis2Placement3D("", bottomCenter, repo.add(new Direction("", 0, 0, -1)), xDir));
|
|
13901
|
+
const bottomCircle = repo.add(new Circle("", bottomPlacement, radius));
|
|
13902
|
+
const bottomArc = repo.add(new EdgeCurve("", bottomStartVertex, bottomEndVertex, bottomCircle, false));
|
|
13903
|
+
const topCenter = repo.add(new CartesianPoint("", centerRotated.x, centerRotated.y, zMax));
|
|
13904
|
+
const topPlacement = repo.add(new Axis2Placement3D("", topCenter, zDir, xDir));
|
|
13905
|
+
const topCircle = repo.add(new Circle("", topPlacement, radius));
|
|
13906
|
+
const topArc = repo.add(new EdgeCurve("", topEnd, topStart, topCircle, false));
|
|
13907
|
+
const v1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, zMin))));
|
|
13908
|
+
const v2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, zMax))));
|
|
13909
|
+
const v3 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, zMin))));
|
|
13910
|
+
const v4 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, zMax))));
|
|
13911
|
+
const dir1 = repo.add(new Direction("", 0, 0, 1));
|
|
13912
|
+
const height = zMax - zMin;
|
|
13913
|
+
const vec1 = repo.add(new Vector("", dir1, height));
|
|
13914
|
+
const line1 = repo.add(new Line("", v1.resolve(repo).pnt, vec1));
|
|
13915
|
+
const edge1 = repo.add(new EdgeCurve("", v1, v2, line1, true));
|
|
13916
|
+
const dir2 = repo.add(new Direction("", 0, 0, 1));
|
|
13917
|
+
const vec2 = repo.add(new Vector("", dir2, height));
|
|
13918
|
+
const line2 = repo.add(new Line("", v3.resolve(repo).pnt, vec2));
|
|
13919
|
+
const edge2 = repo.add(new EdgeCurve("", v3, v4, line2, true));
|
|
13920
|
+
const loop = repo.add(new EdgeLoop("", [
|
|
13921
|
+
repo.add(new OrientedEdge("", bottomArc, true)),
|
|
13922
|
+
repo.add(new OrientedEdge("", edge2, true)),
|
|
13923
|
+
repo.add(new OrientedEdge("", topArc, false)),
|
|
13924
|
+
repo.add(new OrientedEdge("", edge1, false))
|
|
13925
|
+
]));
|
|
13926
|
+
const cylinderPlacement = repo.add(new Axis2Placement3D("", bottomCenter, zDir, xDir));
|
|
13927
|
+
const cylinderSurface = repo.add(new CylindricalSurface("", cylinderPlacement, radius));
|
|
13928
|
+
return repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", loop, true))], cylinderSurface, false));
|
|
13929
|
+
}
|
|
13930
|
+
function createPlanarWall(repo, startX, startY, endX, endY, rotation, centerX0, centerY0, zMin, zMax, zDir) {
|
|
13931
|
+
const start = rotatePoint(startX, startY, centerX0, centerY0, rotation);
|
|
13932
|
+
const end = rotatePoint(endX, endY, centerX0, centerY0, rotation);
|
|
13933
|
+
const v1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", start.x, start.y, zMin))));
|
|
13934
|
+
const v2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", end.x, end.y, zMin))));
|
|
13935
|
+
const v3 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", end.x, end.y, zMax))));
|
|
13936
|
+
const v4 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", start.x, start.y, zMax))));
|
|
13937
|
+
const dx = end.x - start.x;
|
|
13938
|
+
const dy = end.y - start.y;
|
|
13939
|
+
const edgeLength = Math.sqrt(dx * dx + dy * dy);
|
|
13940
|
+
const bottomDir = repo.add(new Direction("", dx / edgeLength, dy / edgeLength, 0));
|
|
13941
|
+
const bottomVec = repo.add(new Vector("", bottomDir, edgeLength));
|
|
13942
|
+
const bottomLine = repo.add(new Line("", v1.resolve(repo).pnt, bottomVec));
|
|
13943
|
+
const bottomEdge = repo.add(new EdgeCurve("", v1, v2, bottomLine, true));
|
|
13944
|
+
const topDir = repo.add(new Direction("", dx / edgeLength, dy / edgeLength, 0));
|
|
13945
|
+
const topVec = repo.add(new Vector("", topDir, edgeLength));
|
|
13946
|
+
const topLine = repo.add(new Line("", v4.resolve(repo).pnt, topVec));
|
|
13947
|
+
const topEdge = repo.add(new EdgeCurve("", v4, v3, topLine, true));
|
|
13948
|
+
const vertDir = repo.add(new Direction("", 0, 0, 1));
|
|
13949
|
+
const height = zMax - zMin;
|
|
13950
|
+
const vertVec1 = repo.add(new Vector("", vertDir, height));
|
|
13951
|
+
const vertLine1 = repo.add(new Line("", v2.resolve(repo).pnt, vertVec1));
|
|
13952
|
+
const vertEdge1 = repo.add(new EdgeCurve("", v2, v3, vertLine1, true));
|
|
13953
|
+
const vertVec2 = repo.add(new Vector("", vertDir, height));
|
|
13954
|
+
const vertLine2 = repo.add(new Line("", v1.resolve(repo).pnt, vertVec2));
|
|
13955
|
+
const vertEdge2 = repo.add(new EdgeCurve("", v1, v4, vertLine2, true));
|
|
13956
|
+
const loop = repo.add(new EdgeLoop("", [
|
|
13957
|
+
repo.add(new OrientedEdge("", bottomEdge, true)),
|
|
13958
|
+
repo.add(new OrientedEdge("", vertEdge1, true)),
|
|
13959
|
+
repo.add(new OrientedEdge("", topEdge, false)),
|
|
13960
|
+
repo.add(new OrientedEdge("", vertEdge2, false))
|
|
13961
|
+
]));
|
|
13962
|
+
const normalDir = repo.add(new Direction("", dy / edgeLength, -dx / edgeLength, 0));
|
|
13963
|
+
const refDir = repo.add(new Direction("", dx / edgeLength, dy / edgeLength, 0));
|
|
13964
|
+
const planeOrigin = repo.add(new CartesianPoint("", start.x, start.y, zMin));
|
|
13965
|
+
const placement = repo.add(new Axis2Placement3D("", planeOrigin, normalDir, refDir));
|
|
13966
|
+
const plane = repo.add(new Plane("", placement));
|
|
13967
|
+
return repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", loop, true))], plane, true));
|
|
13968
|
+
}
|
|
13969
|
+
async function circuitJsonToStep(circuitJson, options = {}) {
|
|
13970
|
+
const repo = new Repository;
|
|
13971
|
+
const pcbBoard = circuitJson.find((item) => item.type === "pcb_board");
|
|
13972
|
+
const holes = circuitJson.filter((item) => item.type === "pcb_hole" || item.type === "pcb_plated_hole");
|
|
13973
|
+
const boardWidth = options.boardWidth ?? pcbBoard?.width;
|
|
13974
|
+
const boardHeight = options.boardHeight ?? pcbBoard?.height;
|
|
13975
|
+
const boardThickness = options.boardThickness ?? pcbBoard?.thickness ?? 1.6;
|
|
13976
|
+
const productName = options.productName ?? "PCB";
|
|
13977
|
+
const boardCenterX = pcbBoard?.center?.x ?? 0;
|
|
13978
|
+
const boardCenterY = pcbBoard?.center?.y ?? 0;
|
|
13979
|
+
const halfBoardThickness = boardThickness / 2;
|
|
13980
|
+
if (!boardWidth || !boardHeight) {
|
|
13981
|
+
throw new Error("Board dimensions not found. Either provide boardWidth and boardHeight in options, or include a pcb_board in the circuit JSON with width and height properties.");
|
|
13982
|
+
}
|
|
13983
|
+
const appContext = repo.add(new ApplicationContext("core data for automotive mechanical design processes"));
|
|
13984
|
+
repo.add(new ApplicationProtocolDefinition("international standard", "automotive_design", 2010, appContext));
|
|
13985
|
+
const productContext = repo.add(new ProductContext("", appContext, "mechanical"));
|
|
13986
|
+
const productDescription = `Generated by circuit-json-to-step v${VERSION}`;
|
|
13987
|
+
const product = repo.add(new Product(productName, productName, productDescription, [productContext]));
|
|
13988
|
+
const productDefContext = repo.add(new ProductDefinitionContext("part definition", appContext, "design"));
|
|
13989
|
+
const productDefFormation = repo.add(new ProductDefinitionFormation("", "", product));
|
|
13990
|
+
const productDef = repo.add(new ProductDefinition("", "", productDefFormation, productDefContext));
|
|
13991
|
+
const productDefShape = repo.add(new ProductDefinitionShape("", "", productDef));
|
|
13992
|
+
const lengthUnit = repo.add(new Unknown("", [
|
|
13993
|
+
"( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) )"
|
|
13994
|
+
]));
|
|
13995
|
+
const angleUnit = repo.add(new Unknown("", [
|
|
13996
|
+
"( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) )"
|
|
13997
|
+
]));
|
|
13998
|
+
const solidAngleUnit = repo.add(new Unknown("", [
|
|
13999
|
+
"( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() )"
|
|
14000
|
+
]));
|
|
14001
|
+
const uncertainty = repo.add(new Unknown("UNCERTAINTY_MEASURE_WITH_UNIT", [
|
|
14002
|
+
`LENGTH_MEASURE(1.E-07)`,
|
|
14003
|
+
`${lengthUnit}`,
|
|
14004
|
+
`'distance_accuracy_value'`,
|
|
14005
|
+
`'Maximum Tolerance'`
|
|
14006
|
+
]));
|
|
14007
|
+
const geomContext = repo.add(new Unknown("", [
|
|
14008
|
+
`( GEOMETRIC_REPRESENTATION_CONTEXT(3) GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((${uncertainty})) GLOBAL_UNIT_ASSIGNED_CONTEXT((${lengthUnit},${angleUnit},${solidAngleUnit})) REPRESENTATION_CONTEXT('${productName}','3D') )`
|
|
14009
|
+
]));
|
|
14010
|
+
const outline = pcbBoard?.outline;
|
|
14011
|
+
let bottomVertices;
|
|
14012
|
+
let topVertices;
|
|
14013
|
+
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
14014
|
+
const cleanedOutline = [];
|
|
14015
|
+
for (let i = 0;i < outline.length; i++) {
|
|
14016
|
+
const current = outline[i];
|
|
14017
|
+
const next = outline[(i + 1) % outline.length];
|
|
14018
|
+
const dx = next.x - current.x;
|
|
14019
|
+
const dy = next.y - current.y;
|
|
14020
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
14021
|
+
if (dist > 0.000001) {
|
|
14022
|
+
cleanedOutline.push(current);
|
|
14023
|
+
}
|
|
14024
|
+
}
|
|
14025
|
+
if (cleanedOutline.length < 3) {
|
|
14026
|
+
throw new Error(`Outline has too few unique vertices after removing duplicates (${cleanedOutline.length}). Need at least 3.`);
|
|
14027
|
+
}
|
|
14028
|
+
bottomVertices = cleanedOutline.map((point) => repo.add(new VertexPoint("", repo.add(new CartesianPoint("", point.x, point.y, -halfBoardThickness)))));
|
|
14029
|
+
topVertices = cleanedOutline.map((point) => repo.add(new VertexPoint("", repo.add(new CartesianPoint("", point.x, point.y, halfBoardThickness)))));
|
|
14030
|
+
} else {
|
|
14031
|
+
const halfWidth = boardWidth / 2;
|
|
14032
|
+
const halfHeight = boardHeight / 2;
|
|
14033
|
+
const corners = [
|
|
14034
|
+
[
|
|
14035
|
+
boardCenterX - halfWidth,
|
|
14036
|
+
boardCenterY - halfHeight,
|
|
14037
|
+
-halfBoardThickness
|
|
14038
|
+
],
|
|
14039
|
+
[
|
|
14040
|
+
boardCenterX + halfWidth,
|
|
14041
|
+
boardCenterY - halfHeight,
|
|
14042
|
+
-halfBoardThickness
|
|
14043
|
+
],
|
|
14044
|
+
[
|
|
14045
|
+
boardCenterX + halfWidth,
|
|
14046
|
+
boardCenterY + halfHeight,
|
|
14047
|
+
-halfBoardThickness
|
|
14048
|
+
],
|
|
14049
|
+
[
|
|
14050
|
+
boardCenterX - halfWidth,
|
|
14051
|
+
boardCenterY + halfHeight,
|
|
14052
|
+
-halfBoardThickness
|
|
14053
|
+
],
|
|
14054
|
+
[boardCenterX - halfWidth, boardCenterY - halfHeight, halfBoardThickness],
|
|
14055
|
+
[boardCenterX + halfWidth, boardCenterY - halfHeight, halfBoardThickness],
|
|
14056
|
+
[boardCenterX + halfWidth, boardCenterY + halfHeight, halfBoardThickness],
|
|
14057
|
+
[boardCenterX - halfWidth, boardCenterY + halfHeight, halfBoardThickness]
|
|
14058
|
+
];
|
|
14059
|
+
const vertices = corners.map(([x, y, z]) => repo.add(new VertexPoint("", repo.add(new CartesianPoint("", x, y, z)))));
|
|
14060
|
+
bottomVertices = [vertices[0], vertices[1], vertices[2], vertices[3]];
|
|
14061
|
+
topVertices = [vertices[4], vertices[5], vertices[6], vertices[7]];
|
|
14062
|
+
}
|
|
14063
|
+
function createEdge2(v1, v2) {
|
|
14064
|
+
const p1 = v1.resolve(repo).pnt.resolve(repo);
|
|
14065
|
+
const p2 = v2.resolve(repo).pnt.resolve(repo);
|
|
14066
|
+
const dx = p2.x - p1.x;
|
|
14067
|
+
const dy = p2.y - p1.y;
|
|
14068
|
+
const dz = p2.z - p1.z;
|
|
14069
|
+
const length = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
14070
|
+
if (length < 0.0000000001) {
|
|
14071
|
+
const dir2 = repo.add(new Direction("", 1, 0, 0));
|
|
14072
|
+
const vec2 = repo.add(new Vector("", dir2, 0.0000000001));
|
|
14073
|
+
const line2 = repo.add(new Line("", v1.resolve(repo).pnt, vec2));
|
|
14074
|
+
return repo.add(new EdgeCurve("", v1, v2, line2, true));
|
|
14075
|
+
}
|
|
14076
|
+
const dir = repo.add(new Direction("", dx / length, dy / length, dz / length));
|
|
14077
|
+
const vec = repo.add(new Vector("", dir, length));
|
|
14078
|
+
const line = repo.add(new Line("", v1.resolve(repo).pnt, vec));
|
|
14079
|
+
return repo.add(new EdgeCurve("", v1, v2, line, true));
|
|
14080
|
+
}
|
|
14081
|
+
const bottomEdges = [];
|
|
14082
|
+
const topEdges = [];
|
|
14083
|
+
const verticalEdges = [];
|
|
14084
|
+
for (let i = 0;i < bottomVertices.length; i++) {
|
|
14085
|
+
const v1 = bottomVertices[i];
|
|
14086
|
+
const v2 = bottomVertices[(i + 1) % bottomVertices.length];
|
|
14087
|
+
bottomEdges.push(createEdge2(v1, v2));
|
|
14088
|
+
}
|
|
14089
|
+
for (let i = 0;i < topVertices.length; i++) {
|
|
14090
|
+
const v1 = topVertices[i];
|
|
14091
|
+
const v2 = topVertices[(i + 1) % topVertices.length];
|
|
14092
|
+
topEdges.push(createEdge2(v1, v2));
|
|
14093
|
+
}
|
|
14094
|
+
for (let i = 0;i < bottomVertices.length; i++) {
|
|
14095
|
+
verticalEdges.push(createEdge2(bottomVertices[i], topVertices[i]));
|
|
14096
|
+
}
|
|
14097
|
+
const origin = repo.add(new CartesianPoint("", 0, 0, -halfBoardThickness));
|
|
14098
|
+
const xDir = repo.add(new Direction("", 1, 0, 0));
|
|
14099
|
+
const zDir = repo.add(new Direction("", 0, 0, 1));
|
|
14100
|
+
const bottomFrame = repo.add(new Axis2Placement3D("", origin, repo.add(new Direction("", 0, 0, -1)), xDir));
|
|
14101
|
+
const bottomPlane = repo.add(new Plane("", bottomFrame));
|
|
14102
|
+
const bottomLoop = repo.add(new EdgeLoop("", bottomEdges.map((edge) => repo.add(new OrientedEdge("", edge, true)))));
|
|
14103
|
+
const bottomHoleLoops = [];
|
|
14104
|
+
for (const hole of holes) {
|
|
14105
|
+
const holeShape = hole.hole_shape ?? hole.shape;
|
|
14106
|
+
if (holeShape === "circle") {
|
|
14107
|
+
const holeX = typeof hole.x === "number" ? hole.x : hole.x ?? 0;
|
|
14108
|
+
const holeY = typeof hole.y === "number" ? hole.y : hole.y ?? 0;
|
|
14109
|
+
const radius = (hole.hole_diameter ?? 0) / 2;
|
|
14110
|
+
const holeCenter = repo.add(new CartesianPoint("", holeX, holeY, -halfBoardThickness));
|
|
14111
|
+
const holeVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, -halfBoardThickness))));
|
|
14112
|
+
const holePlacement = repo.add(new Axis2Placement3D("", holeCenter, repo.add(new Direction("", 0, 0, -1)), xDir));
|
|
14113
|
+
const holeCircle = repo.add(new Circle("", holePlacement, radius));
|
|
14114
|
+
const holeEdge = repo.add(new EdgeCurve("", holeVertex, holeVertex, holeCircle, true));
|
|
14115
|
+
const holeLoop = repo.add(new EdgeLoop("", [repo.add(new OrientedEdge("", holeEdge, false))]));
|
|
14116
|
+
bottomHoleLoops.push(repo.add(new FaceBound("", holeLoop, true)));
|
|
14117
|
+
} else if (holeShape === "rotated_pill" || holeShape === "pill") {
|
|
14118
|
+
const pillLoop = createPillHoleLoop(repo, hole, -halfBoardThickness, xDir);
|
|
14119
|
+
bottomHoleLoops.push(repo.add(new FaceBound("", pillLoop, true)));
|
|
14120
|
+
}
|
|
14121
|
+
}
|
|
14122
|
+
const bottomFace = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", bottomLoop, true)), ...bottomHoleLoops], bottomPlane, true));
|
|
14123
|
+
const topOrigin = repo.add(new CartesianPoint("", 0, 0, halfBoardThickness));
|
|
14124
|
+
const topFrame = repo.add(new Axis2Placement3D("", topOrigin, zDir, xDir));
|
|
14125
|
+
const topPlane = repo.add(new Plane("", topFrame));
|
|
14126
|
+
const topLoop = repo.add(new EdgeLoop("", topEdges.map((edge) => repo.add(new OrientedEdge("", edge, false)))));
|
|
14127
|
+
const topHoleLoops = [];
|
|
14128
|
+
for (const hole of holes) {
|
|
14129
|
+
const holeShape = hole.hole_shape ?? hole.shape;
|
|
14130
|
+
if (holeShape === "circle") {
|
|
14131
|
+
const holeX = typeof hole.x === "number" ? hole.x : hole.x ?? 0;
|
|
14132
|
+
const holeY = typeof hole.y === "number" ? hole.y : hole.y ?? 0;
|
|
14133
|
+
const radius = (hole.hole_diameter ?? 0) / 2;
|
|
14134
|
+
const holeCenter = repo.add(new CartesianPoint("", holeX, holeY, halfBoardThickness));
|
|
14135
|
+
const holeVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, halfBoardThickness))));
|
|
14136
|
+
const holePlacement = repo.add(new Axis2Placement3D("", holeCenter, zDir, xDir));
|
|
14137
|
+
const holeCircle = repo.add(new Circle("", holePlacement, radius));
|
|
14138
|
+
const holeEdge = repo.add(new EdgeCurve("", holeVertex, holeVertex, holeCircle, true));
|
|
14139
|
+
const holeLoop = repo.add(new EdgeLoop("", [repo.add(new OrientedEdge("", holeEdge, true))]));
|
|
14140
|
+
topHoleLoops.push(repo.add(new FaceBound("", holeLoop, true)));
|
|
14141
|
+
} else if (holeShape === "rotated_pill" || holeShape === "pill") {
|
|
14142
|
+
const pillLoop = createPillHoleLoop(repo, hole, halfBoardThickness, xDir);
|
|
14143
|
+
topHoleLoops.push(repo.add(new FaceBound("", pillLoop, true)));
|
|
14144
|
+
}
|
|
14145
|
+
}
|
|
14146
|
+
const topFace = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", topLoop, true)), ...topHoleLoops], topPlane, true));
|
|
14147
|
+
const sideFaces = [];
|
|
14148
|
+
for (let i = 0;i < bottomEdges.length; i++) {
|
|
14149
|
+
const nextI = (i + 1) % bottomEdges.length;
|
|
14150
|
+
const bottomV1Pnt = bottomVertices[i].resolve(repo).pnt;
|
|
14151
|
+
const bottomV2Pnt = bottomVertices[nextI].resolve(repo).pnt;
|
|
14152
|
+
const bottomV1 = bottomV1Pnt.resolve(repo);
|
|
14153
|
+
const bottomV2 = bottomV2Pnt.resolve(repo);
|
|
14154
|
+
const edgeDir = {
|
|
14155
|
+
x: bottomV2.x - bottomV1.x,
|
|
14156
|
+
y: bottomV2.y - bottomV1.y,
|
|
14157
|
+
z: -halfBoardThickness
|
|
14158
|
+
};
|
|
14159
|
+
const normalDir = repo.add(new Direction("", edgeDir.y, -edgeDir.x, 0));
|
|
14160
|
+
const refDir = repo.add(new Direction("", edgeDir.x, edgeDir.y, 0));
|
|
14161
|
+
const sideFrame = repo.add(new Axis2Placement3D("", bottomV1Pnt, normalDir, refDir));
|
|
14162
|
+
const sidePlane = repo.add(new Plane("", sideFrame));
|
|
14163
|
+
const sideLoop = repo.add(new EdgeLoop("", [
|
|
14164
|
+
repo.add(new OrientedEdge("", bottomEdges[i], true)),
|
|
14165
|
+
repo.add(new OrientedEdge("", verticalEdges[nextI], true)),
|
|
14166
|
+
repo.add(new OrientedEdge("", topEdges[i], false)),
|
|
14167
|
+
repo.add(new OrientedEdge("", verticalEdges[i], false))
|
|
14168
|
+
]));
|
|
14169
|
+
const sideFace = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", sideLoop, true))], sidePlane, true));
|
|
14170
|
+
sideFaces.push(sideFace);
|
|
14171
|
+
}
|
|
14172
|
+
const holeCylindricalFaces = [];
|
|
14173
|
+
for (const hole of holes) {
|
|
14174
|
+
const holeShape = hole.hole_shape ?? hole.shape;
|
|
14175
|
+
if (holeShape === "circle") {
|
|
14176
|
+
const holeX = typeof hole.x === "number" ? hole.x : hole.x ?? 0;
|
|
14177
|
+
const holeY = typeof hole.y === "number" ? hole.y : hole.y ?? 0;
|
|
14178
|
+
const radius = (hole.hole_diameter ?? 0) / 2;
|
|
14179
|
+
const bottomHoleCenter = repo.add(new CartesianPoint("", holeX, holeY, -halfBoardThickness));
|
|
14180
|
+
const bottomHoleVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, -halfBoardThickness))));
|
|
14181
|
+
const bottomHolePlacement = repo.add(new Axis2Placement3D("", bottomHoleCenter, repo.add(new Direction("", 0, 0, -1)), xDir));
|
|
14182
|
+
const bottomHoleCircle = repo.add(new Circle("", bottomHolePlacement, radius));
|
|
14183
|
+
const bottomHoleEdge = repo.add(new EdgeCurve("", bottomHoleVertex, bottomHoleVertex, bottomHoleCircle, true));
|
|
14184
|
+
const topHoleCenter = repo.add(new CartesianPoint("", holeX, holeY, halfBoardThickness));
|
|
14185
|
+
const topHoleVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, halfBoardThickness))));
|
|
14186
|
+
const topHolePlacement = repo.add(new Axis2Placement3D("", topHoleCenter, zDir, xDir));
|
|
14187
|
+
const topHoleCircle = repo.add(new Circle("", topHolePlacement, radius));
|
|
14188
|
+
const topHoleEdge = repo.add(new EdgeCurve("", topHoleVertex, topHoleVertex, topHoleCircle, true));
|
|
14189
|
+
const holeCylinderLoop = repo.add(new EdgeLoop("", [
|
|
14190
|
+
repo.add(new OrientedEdge("", bottomHoleEdge, true)),
|
|
14191
|
+
repo.add(new OrientedEdge("", topHoleEdge, false))
|
|
14192
|
+
]));
|
|
14193
|
+
const holeCylinderPlacement = repo.add(new Axis2Placement3D("", bottomHoleCenter, zDir, xDir));
|
|
14194
|
+
const holeCylinderSurface = repo.add(new CylindricalSurface("", holeCylinderPlacement, radius));
|
|
14195
|
+
const holeCylinderFace = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", holeCylinderLoop, true))], holeCylinderSurface, false));
|
|
14196
|
+
holeCylindricalFaces.push(holeCylinderFace);
|
|
14197
|
+
} else if (holeShape === "rotated_pill" || holeShape === "pill") {
|
|
14198
|
+
const pillFaces = createPillCylindricalFaces(repo, hole, -halfBoardThickness, halfBoardThickness, xDir, zDir);
|
|
14199
|
+
holeCylindricalFaces.push(...pillFaces);
|
|
14200
|
+
}
|
|
14201
|
+
}
|
|
14202
|
+
const allFaces = [bottomFace, topFace, ...sideFaces, ...holeCylindricalFaces];
|
|
14203
|
+
const styleCache = createStyleCache();
|
|
14204
|
+
const boardStyledItems = createStyledItems(repo, {
|
|
14205
|
+
itemRefs: allFaces,
|
|
14206
|
+
rgb: [0.2, 0.6, 0.2],
|
|
14207
|
+
styleCache
|
|
14208
|
+
});
|
|
14209
|
+
const shell = repo.add(new ClosedShell("", allFaces));
|
|
14210
|
+
const solid = repo.add(new ManifoldSolidBrep(productName, shell));
|
|
14211
|
+
const allSolids = [solid];
|
|
14212
|
+
const componentStyledItems = [];
|
|
14213
|
+
const solidsWithIntrinsicFaceStyles = /* @__PURE__ */ new Set;
|
|
14214
|
+
let handledComponentIds = /* @__PURE__ */ new Set;
|
|
14215
|
+
let handledPcbComponentIds = /* @__PURE__ */ new Set;
|
|
14216
|
+
if (options.includeComponents && options.includeExternalMeshes) {
|
|
14217
|
+
const mergeResult = await mergeExternalStepModels({
|
|
14218
|
+
repo,
|
|
14219
|
+
circuitJson,
|
|
14220
|
+
boardThickness,
|
|
14221
|
+
fsMap: options.fsMap
|
|
14222
|
+
});
|
|
14223
|
+
handledComponentIds = mergeResult.handledComponentIds;
|
|
14224
|
+
handledPcbComponentIds = mergeResult.handledPcbComponentIds;
|
|
14225
|
+
allSolids.push(...mergeResult.solids);
|
|
14226
|
+
mergeResult.solids.forEach((solidRef) => {
|
|
14227
|
+
solidsWithIntrinsicFaceStyles.add(String(solidRef.id));
|
|
14228
|
+
});
|
|
14229
|
+
}
|
|
14230
|
+
if (options.includeComponents) {
|
|
14231
|
+
const pcbComponentIdsWithStepUrl = /* @__PURE__ */ new Set;
|
|
14232
|
+
for (const item of circuitJson) {
|
|
14233
|
+
if (item.type === "cad_component" && item.model_step_url && item.pcb_component_id) {
|
|
14234
|
+
pcbComponentIdsWithStepUrl.add(item.pcb_component_id);
|
|
14235
|
+
}
|
|
14236
|
+
}
|
|
14237
|
+
const hasComponentsNeedingMesh = circuitJson.some((item) => {
|
|
14238
|
+
if (item.type === "cad_component") {
|
|
14239
|
+
if (item.cad_component_id && handledComponentIds.has(item.cad_component_id)) {
|
|
14240
|
+
return false;
|
|
14241
|
+
}
|
|
14242
|
+
if (item.pcb_component_id && pcbComponentIdsWithStepUrl.has(item.pcb_component_id)) {
|
|
14243
|
+
return false;
|
|
14244
|
+
}
|
|
14245
|
+
return !item.model_step_url;
|
|
14246
|
+
}
|
|
14247
|
+
if (item.type === "pcb_component") {
|
|
14248
|
+
if (item.pcb_component_id && handledPcbComponentIds.has(item.pcb_component_id)) {
|
|
14249
|
+
return false;
|
|
14250
|
+
}
|
|
14251
|
+
if (item.pcb_component_id && pcbComponentIdsWithStepUrl.has(item.pcb_component_id)) {
|
|
14252
|
+
return false;
|
|
14253
|
+
}
|
|
14254
|
+
return true;
|
|
14255
|
+
}
|
|
14256
|
+
return false;
|
|
14257
|
+
});
|
|
14258
|
+
if (hasComponentsNeedingMesh) {
|
|
14259
|
+
const componentSolids = await generateComponentMeshes({
|
|
14260
|
+
repo,
|
|
14261
|
+
circuitJson,
|
|
14262
|
+
boardThickness,
|
|
14263
|
+
includeExternalMeshes: options.includeExternalMeshes,
|
|
14264
|
+
excludeCadComponentIds: handledComponentIds,
|
|
14265
|
+
excludePcbComponentIds: handledPcbComponentIds,
|
|
14266
|
+
pcbComponentIdsWithStepUrl
|
|
14267
|
+
});
|
|
14268
|
+
for (const componentSolid of componentSolids) {
|
|
14269
|
+
allSolids.push(componentSolid.solid);
|
|
14270
|
+
componentStyledItems.push(...componentSolid.styledItems);
|
|
14271
|
+
if (componentSolid.usesIntrinsicFaceStyles) {
|
|
14272
|
+
solidsWithIntrinsicFaceStyles.add(String(componentSolid.solid.id));
|
|
14273
|
+
} else if (componentSolid.styleTargets.length > 0) {
|
|
14274
|
+
componentStyledItems.push(...createStyledItems(repo, {
|
|
14275
|
+
itemRefs: componentSolid.styleTargets,
|
|
14276
|
+
rgb: [0.75, 0.75, 0.75],
|
|
14277
|
+
styleCache
|
|
14278
|
+
}));
|
|
14279
|
+
solidsWithIntrinsicFaceStyles.add(String(componentSolid.solid.id));
|
|
14280
|
+
}
|
|
14281
|
+
}
|
|
14282
|
+
}
|
|
14283
|
+
}
|
|
14284
|
+
const styledItems = [
|
|
14285
|
+
...boardStyledItems,
|
|
14286
|
+
...componentStyledItems
|
|
14287
|
+
];
|
|
14288
|
+
allSolids.forEach((itemRef, index) => {
|
|
14289
|
+
const isBoard = index === 0;
|
|
14290
|
+
if (isBoard || solidsWithIntrinsicFaceStyles.has(String(itemRef.id))) {
|
|
14291
|
+
return;
|
|
14292
|
+
}
|
|
14293
|
+
const styledItem = createStyledItem(repo, {
|
|
14294
|
+
itemRef,
|
|
14295
|
+
rgb: [0.75, 0.75, 0.75],
|
|
14296
|
+
styleCache,
|
|
14297
|
+
name: ""
|
|
14298
|
+
});
|
|
14299
|
+
styledItems.push(styledItem);
|
|
14300
|
+
});
|
|
14301
|
+
repo.add(new MechanicalDesignGeometricPresentationRepresentation("", styledItems, geomContext));
|
|
14302
|
+
const shapeRep = repo.add(new AdvancedBrepShapeRepresentation(productName, allSolids, geomContext));
|
|
14303
|
+
repo.add(new ShapeDefinitionRepresentation(productDefShape, shapeRep));
|
|
14304
|
+
const stepText = repo.toPartFile({ name: productName });
|
|
14305
|
+
return normalizeStepNumericExponents(stepText);
|
|
14306
|
+
}
|
|
14307
|
+
|
|
14308
|
+
// cli/build/worker-output-generators.ts
|
|
12009
14309
|
import {
|
|
12010
14310
|
convertCircuitJsonToGltf,
|
|
12011
14311
|
getBestCameraPosition
|
|
@@ -13581,35 +15881,67 @@ var convertSvgToPngBuffer = async (svg) => {
|
|
|
13581
15881
|
return resvg.render().asPng();
|
|
13582
15882
|
};
|
|
13583
15883
|
|
|
15884
|
+
// lib/shared/load-local-step-model-fs-map.ts
|
|
15885
|
+
import { existsSync } from "node:fs";
|
|
15886
|
+
import { readFile } from "node:fs/promises";
|
|
15887
|
+
import path12 from "node:path";
|
|
15888
|
+
var isRemoteUrl = (value) => /^https?:\/\//i.test(value);
|
|
15889
|
+
async function loadLocalStepModelFsMap(circuitJson) {
|
|
15890
|
+
const fsMap = {};
|
|
15891
|
+
for (const element of circuitJson) {
|
|
15892
|
+
if (!element || typeof element !== "object")
|
|
15893
|
+
continue;
|
|
15894
|
+
const modelUrl = element.model_step_url;
|
|
15895
|
+
if (typeof modelUrl !== "string" || modelUrl.length === 0)
|
|
15896
|
+
continue;
|
|
15897
|
+
if (isRemoteUrl(modelUrl) || fsMap[modelUrl])
|
|
15898
|
+
continue;
|
|
15899
|
+
const localPath = path12.resolve(process.cwd(), modelUrl);
|
|
15900
|
+
if (!existsSync(localPath))
|
|
15901
|
+
continue;
|
|
15902
|
+
fsMap[modelUrl] = await readFile(localPath, "utf-8");
|
|
15903
|
+
}
|
|
15904
|
+
return fsMap;
|
|
15905
|
+
}
|
|
15906
|
+
|
|
13584
15907
|
// cli/build/worker-output-generators.ts
|
|
13585
15908
|
var writeGlbFromCircuitJson = async (circuitJson, glbOutputPath) => {
|
|
13586
15909
|
const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
|
|
13587
15910
|
const glbBuffer = await convertCircuitJsonToGltf(circuitJsonWithFileUrls, getCircuitJsonToGltfOptions({ format: "glb" }));
|
|
13588
15911
|
const glbData = normalizeToUint8Array(glbBuffer);
|
|
13589
|
-
fs9.mkdirSync(
|
|
15912
|
+
fs9.mkdirSync(path13.dirname(glbOutputPath), { recursive: true });
|
|
13590
15913
|
fs9.writeFileSync(glbOutputPath, Buffer.from(glbData));
|
|
13591
15914
|
};
|
|
15915
|
+
var writeStepFromCircuitJson = async (circuitJson, stepOutputPath) => {
|
|
15916
|
+
const stepContent = await circuitJsonToStep(circuitJson, {
|
|
15917
|
+
includeComponents: true,
|
|
15918
|
+
includeExternalMeshes: true,
|
|
15919
|
+
fsMap: await loadLocalStepModelFsMap(circuitJson)
|
|
15920
|
+
});
|
|
15921
|
+
fs9.mkdirSync(path13.dirname(stepOutputPath), { recursive: true });
|
|
15922
|
+
fs9.writeFileSync(stepOutputPath, stepContent);
|
|
15923
|
+
};
|
|
13592
15924
|
var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
|
|
13593
15925
|
const { outputDir, imageFormats, pcbSnapshotSettings } = options;
|
|
13594
15926
|
fs9.mkdirSync(outputDir, { recursive: true });
|
|
13595
15927
|
if (imageFormats.pcbSvgs) {
|
|
13596
15928
|
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson, pcbSnapshotSettings);
|
|
13597
|
-
fs9.writeFileSync(
|
|
15929
|
+
fs9.writeFileSync(path13.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
13598
15930
|
}
|
|
13599
15931
|
if (imageFormats.pcbPngs) {
|
|
13600
15932
|
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson, pcbSnapshotSettings);
|
|
13601
|
-
fs9.writeFileSync(
|
|
15933
|
+
fs9.writeFileSync(path13.join(outputDir, "pcb.png"), await convertSvgToPngBuffer(pcbSvg));
|
|
13602
15934
|
}
|
|
13603
15935
|
if (imageFormats.schematicSvgs) {
|
|
13604
15936
|
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson);
|
|
13605
|
-
fs9.writeFileSync(
|
|
15937
|
+
fs9.writeFileSync(path13.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
|
|
13606
15938
|
}
|
|
13607
15939
|
if (imageFormats.threeDPngs) {
|
|
13608
15940
|
const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
|
|
13609
15941
|
const glbBuffer = await convertCircuitJsonToGltf(circuitJsonWithFileUrls, getCircuitJsonToGltfOptions({ format: "glb" }));
|
|
13610
15942
|
const glbArrayBuffer = await normalizeToArrayBuffer(glbBuffer);
|
|
13611
15943
|
const pngBuffer = await renderGLTFToPNGBufferFromGLBBuffer(glbArrayBuffer, getBestCameraPosition(circuitJson));
|
|
13612
|
-
fs9.writeFileSync(
|
|
15944
|
+
fs9.writeFileSync(path13.join(outputDir, "3d.png"), Buffer.from(normalizeToUint8Array(pngBuffer)));
|
|
13613
15945
|
}
|
|
13614
15946
|
};
|
|
13615
15947
|
|
|
@@ -13618,13 +15950,13 @@ var loadCircuitJsonFromInputFile = (filePath) => {
|
|
|
13618
15950
|
const parsed = JSON.parse(fs10.readFileSync(filePath, "utf-8"));
|
|
13619
15951
|
return Array.isArray(parsed) ? parsed : [];
|
|
13620
15952
|
};
|
|
13621
|
-
var handleBuildFile = async (filePath, outputPath, glbOutputPath, previewOutputDir, projectDir, options, workerLog, workerStatus) => {
|
|
15953
|
+
var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath, previewOutputDir, projectDir, options, workerLog, workerStatus) => {
|
|
13622
15954
|
const errors = [];
|
|
13623
15955
|
const warnings = [];
|
|
13624
15956
|
const startedAt = options?.profile ? performance.now() : 0;
|
|
13625
15957
|
try {
|
|
13626
15958
|
process.chdir(projectDir);
|
|
13627
|
-
workerLog(`Generating circuit JSON for ${
|
|
15959
|
+
workerLog(`Generating circuit JSON for ${path14.relative(projectDir, filePath)}...`);
|
|
13628
15960
|
await registerStaticAssetLoaders();
|
|
13629
15961
|
const completePlatformConfig = getCompletePlatformConfig(options?.platformConfig);
|
|
13630
15962
|
const normalizedInputPath = filePath.toLowerCase().replaceAll("\\", "/");
|
|
@@ -13637,9 +15969,9 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, previewOutputD
|
|
|
13637
15969
|
workerStatus(`waiting on ${asyncEffectName}…`);
|
|
13638
15970
|
}
|
|
13639
15971
|
})).circuitJson;
|
|
13640
|
-
fs10.mkdirSync(
|
|
15972
|
+
fs10.mkdirSync(path14.dirname(outputPath), { recursive: true });
|
|
13641
15973
|
fs10.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
13642
|
-
workerLog(`Circuit JSON written to ${
|
|
15974
|
+
workerLog(`Circuit JSON written to ${path14.relative(projectDir, outputPath)}`);
|
|
13643
15975
|
const diagnostics = analyzeCircuitJson(circuitJson);
|
|
13644
15976
|
const filteredDiagnostics = filterDiagnosticsByDrcCategory({
|
|
13645
15977
|
errors: diagnostics.errors,
|
|
@@ -13663,11 +15995,13 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, previewOutputD
|
|
|
13663
15995
|
const hasErrors = filteredDiagnostics.errors.length > 0 && !options?.ignoreErrors;
|
|
13664
15996
|
let glbOk;
|
|
13665
15997
|
let glbError;
|
|
15998
|
+
let stepOk;
|
|
15999
|
+
let stepError;
|
|
13666
16000
|
let previewOk;
|
|
13667
16001
|
let previewError;
|
|
13668
16002
|
if (glbOutputPath) {
|
|
13669
16003
|
try {
|
|
13670
|
-
workerLog(`Converting ${
|
|
16004
|
+
workerLog(`Converting ${path14.relative(projectDir, outputPath)} to GLB in same worker...`);
|
|
13671
16005
|
await writeGlbFromCircuitJson(circuitJson, glbOutputPath);
|
|
13672
16006
|
glbOk = true;
|
|
13673
16007
|
} catch (err) {
|
|
@@ -13676,10 +16010,21 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, previewOutputD
|
|
|
13676
16010
|
workerLog(`GLB conversion error: ${glbError}`);
|
|
13677
16011
|
}
|
|
13678
16012
|
}
|
|
16013
|
+
if (stepOutputPath) {
|
|
16014
|
+
try {
|
|
16015
|
+
workerLog(`Converting ${path14.relative(projectDir, outputPath)} to STEP in same worker...`);
|
|
16016
|
+
await writeStepFromCircuitJson(circuitJson, stepOutputPath);
|
|
16017
|
+
stepOk = true;
|
|
16018
|
+
} catch (err) {
|
|
16019
|
+
stepOk = false;
|
|
16020
|
+
stepError = err instanceof Error ? err.message : String(err);
|
|
16021
|
+
workerLog(`STEP conversion error: ${stepError}`);
|
|
16022
|
+
}
|
|
16023
|
+
}
|
|
13679
16024
|
if (options?.generatePreviewAssets) {
|
|
13680
16025
|
try {
|
|
13681
|
-
const resolvedPreviewOutputDir = previewOutputDir ??
|
|
13682
|
-
workerLog(`Generating preview assets for ${
|
|
16026
|
+
const resolvedPreviewOutputDir = previewOutputDir ?? path14.dirname(outputPath);
|
|
16027
|
+
workerLog(`Generating preview assets for ${path14.relative(projectDir, resolvedPreviewOutputDir)} in same worker...`);
|
|
13683
16028
|
await writeImageAssetsFromCircuitJson(circuitJson, {
|
|
13684
16029
|
outputDir: resolvedPreviewOutputDir,
|
|
13685
16030
|
imageFormats: options?.imageFormats ?? DEFAULT_IMAGE_FORMAT_SELECTION,
|
|
@@ -13698,9 +16043,12 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, previewOutputD
|
|
|
13698
16043
|
output_path: outputPath,
|
|
13699
16044
|
circuit_json_path: outputPath,
|
|
13700
16045
|
glb_output_path: glbOutputPath,
|
|
16046
|
+
step_output_path: stepOutputPath,
|
|
13701
16047
|
preview_output_dir: previewOutputDir,
|
|
13702
16048
|
glb_ok: glbOk,
|
|
13703
16049
|
glb_error: glbError,
|
|
16050
|
+
step_ok: stepOk,
|
|
16051
|
+
step_error: stepError,
|
|
13704
16052
|
preview_ok: previewOk,
|
|
13705
16053
|
preview_error: previewError,
|
|
13706
16054
|
ok: true,
|
|
@@ -13721,6 +16069,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, previewOutputD
|
|
|
13721
16069
|
output_path: outputPath,
|
|
13722
16070
|
circuit_json_path: outputPath,
|
|
13723
16071
|
glb_output_path: glbOutputPath,
|
|
16072
|
+
step_output_path: stepOutputPath,
|
|
13724
16073
|
preview_output_dir: previewOutputDir,
|
|
13725
16074
|
ok: false,
|
|
13726
16075
|
hasErrors: true,
|
|
@@ -13760,7 +16109,7 @@ var workerStatus = (statusLine) => {
|
|
|
13760
16109
|
};
|
|
13761
16110
|
parentPort.on("message", async (msg) => {
|
|
13762
16111
|
if (msg.message_type === "build_file") {
|
|
13763
|
-
const result = await handleBuildFile(msg.file_path, msg.output_path, msg.glb_output_path, msg.preview_output_dir, msg.project_dir, msg.options, workerLog, workerStatus);
|
|
16112
|
+
const result = await handleBuildFile(msg.file_path, msg.output_path, msg.glb_output_path, msg.step_output_path, msg.preview_output_dir, msg.project_dir, msg.options, workerLog, workerStatus);
|
|
13764
16113
|
sendMessage(result);
|
|
13765
16114
|
}
|
|
13766
16115
|
});
|