@tscircuit/cli 0.1.1162 → 0.1.1163
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/main.js +2436 -7
- package/dist/lib/index.js +238 -3
- package/package.json +5 -3
package/dist/cli/main.js
CHANGED
|
@@ -10751,6 +10751,7 @@ var require_constants3 = __commonJS((exports2, module2) => {
|
|
|
10751
10751
|
var path2 = __require("path");
|
|
10752
10752
|
var WIN_SLASH = "\\\\/";
|
|
10753
10753
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
10754
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
10754
10755
|
var DOT_LITERAL = "\\.";
|
|
10755
10756
|
var PLUS_LITERAL = "\\+";
|
|
10756
10757
|
var QMARK_LITERAL = "\\?";
|
|
@@ -10798,6 +10799,7 @@ var require_constants3 = __commonJS((exports2, module2) => {
|
|
|
10798
10799
|
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
|
10799
10800
|
};
|
|
10800
10801
|
var POSIX_REGEX_SOURCE = {
|
|
10802
|
+
__proto__: null,
|
|
10801
10803
|
alnum: "a-zA-Z0-9",
|
|
10802
10804
|
alpha: "a-zA-Z",
|
|
10803
10805
|
ascii: "\\x00-\\x7F",
|
|
@@ -10814,6 +10816,7 @@ var require_constants3 = __commonJS((exports2, module2) => {
|
|
|
10814
10816
|
xdigit: "A-Fa-f0-9"
|
|
10815
10817
|
};
|
|
10816
10818
|
module2.exports = {
|
|
10819
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
10817
10820
|
MAX_LENGTH: 1024 * 64,
|
|
10818
10821
|
POSIX_REGEX_SOURCE,
|
|
10819
10822
|
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
@@ -10823,6 +10826,7 @@ var require_constants3 = __commonJS((exports2, module2) => {
|
|
|
10823
10826
|
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
10824
10827
|
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
10825
10828
|
REPLACEMENTS: {
|
|
10829
|
+
__proto__: null,
|
|
10826
10830
|
"***": "*",
|
|
10827
10831
|
"**/**": "**",
|
|
10828
10832
|
"**/**/**": "**"
|
|
@@ -11288,6 +11292,213 @@ var require_parse3 = __commonJS((exports2, module2) => {
|
|
|
11288
11292
|
var syntaxError = (type, char) => {
|
|
11289
11293
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
11290
11294
|
};
|
|
11295
|
+
var splitTopLevel = (input) => {
|
|
11296
|
+
const parts = [];
|
|
11297
|
+
let bracket = 0;
|
|
11298
|
+
let paren = 0;
|
|
11299
|
+
let quote = 0;
|
|
11300
|
+
let value = "";
|
|
11301
|
+
let escaped = false;
|
|
11302
|
+
for (const ch of input) {
|
|
11303
|
+
if (escaped === true) {
|
|
11304
|
+
value += ch;
|
|
11305
|
+
escaped = false;
|
|
11306
|
+
continue;
|
|
11307
|
+
}
|
|
11308
|
+
if (ch === "\\") {
|
|
11309
|
+
value += ch;
|
|
11310
|
+
escaped = true;
|
|
11311
|
+
continue;
|
|
11312
|
+
}
|
|
11313
|
+
if (ch === '"') {
|
|
11314
|
+
quote = quote === 1 ? 0 : 1;
|
|
11315
|
+
value += ch;
|
|
11316
|
+
continue;
|
|
11317
|
+
}
|
|
11318
|
+
if (quote === 0) {
|
|
11319
|
+
if (ch === "[") {
|
|
11320
|
+
bracket++;
|
|
11321
|
+
} else if (ch === "]" && bracket > 0) {
|
|
11322
|
+
bracket--;
|
|
11323
|
+
} else if (bracket === 0) {
|
|
11324
|
+
if (ch === "(") {
|
|
11325
|
+
paren++;
|
|
11326
|
+
} else if (ch === ")" && paren > 0) {
|
|
11327
|
+
paren--;
|
|
11328
|
+
} else if (ch === "|" && paren === 0) {
|
|
11329
|
+
parts.push(value);
|
|
11330
|
+
value = "";
|
|
11331
|
+
continue;
|
|
11332
|
+
}
|
|
11333
|
+
}
|
|
11334
|
+
}
|
|
11335
|
+
value += ch;
|
|
11336
|
+
}
|
|
11337
|
+
parts.push(value);
|
|
11338
|
+
return parts;
|
|
11339
|
+
};
|
|
11340
|
+
var isPlainBranch = (branch) => {
|
|
11341
|
+
let escaped = false;
|
|
11342
|
+
for (const ch of branch) {
|
|
11343
|
+
if (escaped === true) {
|
|
11344
|
+
escaped = false;
|
|
11345
|
+
continue;
|
|
11346
|
+
}
|
|
11347
|
+
if (ch === "\\") {
|
|
11348
|
+
escaped = true;
|
|
11349
|
+
continue;
|
|
11350
|
+
}
|
|
11351
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
11352
|
+
return false;
|
|
11353
|
+
}
|
|
11354
|
+
}
|
|
11355
|
+
return true;
|
|
11356
|
+
};
|
|
11357
|
+
var normalizeSimpleBranch = (branch) => {
|
|
11358
|
+
let value = branch.trim();
|
|
11359
|
+
let changed = true;
|
|
11360
|
+
while (changed === true) {
|
|
11361
|
+
changed = false;
|
|
11362
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
11363
|
+
value = value.slice(2, -1);
|
|
11364
|
+
changed = true;
|
|
11365
|
+
}
|
|
11366
|
+
}
|
|
11367
|
+
if (!isPlainBranch(value)) {
|
|
11368
|
+
return;
|
|
11369
|
+
}
|
|
11370
|
+
return value.replace(/\\(.)/g, "$1");
|
|
11371
|
+
};
|
|
11372
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
11373
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
11374
|
+
for (let i = 0;i < values.length; i++) {
|
|
11375
|
+
for (let j = i + 1;j < values.length; j++) {
|
|
11376
|
+
const a = values[i];
|
|
11377
|
+
const b = values[j];
|
|
11378
|
+
const char = a[0];
|
|
11379
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
11380
|
+
continue;
|
|
11381
|
+
}
|
|
11382
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
11383
|
+
return true;
|
|
11384
|
+
}
|
|
11385
|
+
}
|
|
11386
|
+
}
|
|
11387
|
+
return false;
|
|
11388
|
+
};
|
|
11389
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
11390
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
11391
|
+
return;
|
|
11392
|
+
}
|
|
11393
|
+
let bracket = 0;
|
|
11394
|
+
let paren = 0;
|
|
11395
|
+
let quote = 0;
|
|
11396
|
+
let escaped = false;
|
|
11397
|
+
for (let i = 1;i < pattern.length; i++) {
|
|
11398
|
+
const ch = pattern[i];
|
|
11399
|
+
if (escaped === true) {
|
|
11400
|
+
escaped = false;
|
|
11401
|
+
continue;
|
|
11402
|
+
}
|
|
11403
|
+
if (ch === "\\") {
|
|
11404
|
+
escaped = true;
|
|
11405
|
+
continue;
|
|
11406
|
+
}
|
|
11407
|
+
if (ch === '"') {
|
|
11408
|
+
quote = quote === 1 ? 0 : 1;
|
|
11409
|
+
continue;
|
|
11410
|
+
}
|
|
11411
|
+
if (quote === 1) {
|
|
11412
|
+
continue;
|
|
11413
|
+
}
|
|
11414
|
+
if (ch === "[") {
|
|
11415
|
+
bracket++;
|
|
11416
|
+
continue;
|
|
11417
|
+
}
|
|
11418
|
+
if (ch === "]" && bracket > 0) {
|
|
11419
|
+
bracket--;
|
|
11420
|
+
continue;
|
|
11421
|
+
}
|
|
11422
|
+
if (bracket > 0) {
|
|
11423
|
+
continue;
|
|
11424
|
+
}
|
|
11425
|
+
if (ch === "(") {
|
|
11426
|
+
paren++;
|
|
11427
|
+
continue;
|
|
11428
|
+
}
|
|
11429
|
+
if (ch === ")") {
|
|
11430
|
+
paren--;
|
|
11431
|
+
if (paren === 0) {
|
|
11432
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
11433
|
+
return;
|
|
11434
|
+
}
|
|
11435
|
+
return {
|
|
11436
|
+
type: pattern[0],
|
|
11437
|
+
body: pattern.slice(2, i),
|
|
11438
|
+
end: i
|
|
11439
|
+
};
|
|
11440
|
+
}
|
|
11441
|
+
}
|
|
11442
|
+
}
|
|
11443
|
+
};
|
|
11444
|
+
var getStarExtglobSequenceOutput = (pattern) => {
|
|
11445
|
+
let index = 0;
|
|
11446
|
+
const chars = [];
|
|
11447
|
+
while (index < pattern.length) {
|
|
11448
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
11449
|
+
if (!match || match.type !== "*") {
|
|
11450
|
+
return;
|
|
11451
|
+
}
|
|
11452
|
+
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
11453
|
+
if (branches.length !== 1) {
|
|
11454
|
+
return;
|
|
11455
|
+
}
|
|
11456
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
11457
|
+
if (!branch || branch.length !== 1) {
|
|
11458
|
+
return;
|
|
11459
|
+
}
|
|
11460
|
+
chars.push(branch);
|
|
11461
|
+
index += match.end + 1;
|
|
11462
|
+
}
|
|
11463
|
+
if (chars.length < 1) {
|
|
11464
|
+
return;
|
|
11465
|
+
}
|
|
11466
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
11467
|
+
return `${source}*`;
|
|
11468
|
+
};
|
|
11469
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
11470
|
+
let depth = 0;
|
|
11471
|
+
let value = pattern.trim();
|
|
11472
|
+
let match = parseRepeatedExtglob(value);
|
|
11473
|
+
while (match) {
|
|
11474
|
+
depth++;
|
|
11475
|
+
value = match.body.trim();
|
|
11476
|
+
match = parseRepeatedExtglob(value);
|
|
11477
|
+
}
|
|
11478
|
+
return depth;
|
|
11479
|
+
};
|
|
11480
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
11481
|
+
if (options.maxExtglobRecursion === false) {
|
|
11482
|
+
return { risky: false };
|
|
11483
|
+
}
|
|
11484
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
11485
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
11486
|
+
if (branches.length > 1) {
|
|
11487
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
11488
|
+
return { risky: true };
|
|
11489
|
+
}
|
|
11490
|
+
}
|
|
11491
|
+
for (const branch of branches) {
|
|
11492
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
11493
|
+
if (safeOutput) {
|
|
11494
|
+
return { risky: true, safeOutput };
|
|
11495
|
+
}
|
|
11496
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
11497
|
+
return { risky: true };
|
|
11498
|
+
}
|
|
11499
|
+
}
|
|
11500
|
+
return { risky: false };
|
|
11501
|
+
};
|
|
11291
11502
|
var parse = (input, options) => {
|
|
11292
11503
|
if (typeof input !== "string") {
|
|
11293
11504
|
throw new TypeError("Expected a string");
|
|
@@ -11420,6 +11631,8 @@ var require_parse3 = __commonJS((exports2, module2) => {
|
|
|
11420
11631
|
token.prev = prev;
|
|
11421
11632
|
token.parens = state.parens;
|
|
11422
11633
|
token.output = state.output;
|
|
11634
|
+
token.startIndex = state.index;
|
|
11635
|
+
token.tokensIndex = tokens.length;
|
|
11423
11636
|
const output = (opts.capture ? "(" : "") + token.open;
|
|
11424
11637
|
increment("parens");
|
|
11425
11638
|
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
@@ -11427,6 +11640,26 @@ var require_parse3 = __commonJS((exports2, module2) => {
|
|
|
11427
11640
|
extglobs.push(token);
|
|
11428
11641
|
};
|
|
11429
11642
|
const extglobClose = (token) => {
|
|
11643
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
11644
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
11645
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
11646
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
11647
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : undefined;
|
|
11648
|
+
const open = tokens[token.tokensIndex];
|
|
11649
|
+
open.type = "text";
|
|
11650
|
+
open.value = literal;
|
|
11651
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
11652
|
+
for (let i = token.tokensIndex + 1;i < tokens.length; i++) {
|
|
11653
|
+
tokens[i].value = "";
|
|
11654
|
+
tokens[i].output = "";
|
|
11655
|
+
delete tokens[i].suffix;
|
|
11656
|
+
}
|
|
11657
|
+
state.output = token.output + open.output;
|
|
11658
|
+
state.backtrack = true;
|
|
11659
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
11660
|
+
decrement("parens");
|
|
11661
|
+
return;
|
|
11662
|
+
}
|
|
11430
11663
|
let output = token.close + (opts.capture ? ")" : "");
|
|
11431
11664
|
let rest;
|
|
11432
11665
|
if (token.type === "negate") {
|
|
@@ -98176,7 +98409,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
98176
98409
|
// lib/getVersion.ts
|
|
98177
98410
|
import { createRequire as createRequire2 } from "node:module";
|
|
98178
98411
|
// package.json
|
|
98179
|
-
var version = "0.1.
|
|
98412
|
+
var version = "0.1.1162";
|
|
98180
98413
|
var package_default = {
|
|
98181
98414
|
name: "@tscircuit/cli",
|
|
98182
98415
|
version,
|
|
@@ -98240,10 +98473,12 @@ var package_default = {
|
|
|
98240
98473
|
redaxios: "^0.5.1",
|
|
98241
98474
|
semver: "^7.6.3",
|
|
98242
98475
|
tempy: "^3.1.0",
|
|
98243
|
-
tscircuit: "0.0.
|
|
98476
|
+
tscircuit: "0.0.1563-libonly",
|
|
98244
98477
|
tsx: "^4.7.1",
|
|
98245
98478
|
"typed-ky": "^0.0.4",
|
|
98246
|
-
zod: "^3.23.8"
|
|
98479
|
+
zod: "^3.23.8",
|
|
98480
|
+
"circuit-json-to-step": "^0.0.19",
|
|
98481
|
+
stepts: "^0.0.3"
|
|
98247
98482
|
},
|
|
98248
98483
|
peerDependencies: {
|
|
98249
98484
|
tscircuit: "*"
|
|
@@ -243346,6 +243581,2195 @@ var debug102 = Debug10("dsn-converter:parse-dsn-to-dsn-json");
|
|
|
243346
243581
|
|
|
243347
243582
|
// lib/shared/export-snippet.ts
|
|
243348
243583
|
var import_jszip5 = __toESM2(require_lib4(), 1);
|
|
243584
|
+
|
|
243585
|
+
// node_modules/stepts/dist/index.js
|
|
243586
|
+
var Entity = class {
|
|
243587
|
+
static parse(_a3, _ctx) {
|
|
243588
|
+
throw new Error("not implemented");
|
|
243589
|
+
}
|
|
243590
|
+
};
|
|
243591
|
+
var eid = (n3) => n3;
|
|
243592
|
+
var Ref = class {
|
|
243593
|
+
constructor(id2) {
|
|
243594
|
+
this.id = id2;
|
|
243595
|
+
}
|
|
243596
|
+
resolve(repo) {
|
|
243597
|
+
const e4 = repo.get(this.id);
|
|
243598
|
+
if (!e4)
|
|
243599
|
+
throw new Error(`Unresolved #${this.id}`);
|
|
243600
|
+
return e4;
|
|
243601
|
+
}
|
|
243602
|
+
toString() {
|
|
243603
|
+
return `#${this.id}`;
|
|
243604
|
+
}
|
|
243605
|
+
};
|
|
243606
|
+
var stepStr = (s2) => `'${s2.replace(/'/g, "''")}'`;
|
|
243607
|
+
var fmtNum = (n3) => Number.isInteger(n3) ? `${n3}.` : `${n3}`;
|
|
243608
|
+
var Repository = class {
|
|
243609
|
+
map = /* @__PURE__ */ new Map;
|
|
243610
|
+
order = [];
|
|
243611
|
+
maxId = 0;
|
|
243612
|
+
schema = "AP214";
|
|
243613
|
+
units = { length: "MM", angle: "RAD", solidAngle: "SR" };
|
|
243614
|
+
set(id2, e4) {
|
|
243615
|
+
if (!this.map.has(id2)) {
|
|
243616
|
+
this.order.push(id2);
|
|
243617
|
+
if (id2 > this.maxId)
|
|
243618
|
+
this.maxId = id2;
|
|
243619
|
+
}
|
|
243620
|
+
this.map.set(id2, e4);
|
|
243621
|
+
}
|
|
243622
|
+
add(e4) {
|
|
243623
|
+
this.maxId++;
|
|
243624
|
+
const id2 = eid(this.maxId);
|
|
243625
|
+
this.set(id2, e4);
|
|
243626
|
+
return new Ref(id2);
|
|
243627
|
+
}
|
|
243628
|
+
get(id2) {
|
|
243629
|
+
return this.map.get(id2);
|
|
243630
|
+
}
|
|
243631
|
+
entries() {
|
|
243632
|
+
return this.order.map((id2) => [id2, this.map.get(id2)]);
|
|
243633
|
+
}
|
|
243634
|
+
toPartFile(meta) {
|
|
243635
|
+
const now = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "-");
|
|
243636
|
+
const hdr = [
|
|
243637
|
+
"ISO-10303-21;",
|
|
243638
|
+
"HEADER;",
|
|
243639
|
+
`FILE_DESCRIPTION((${stepStr(meta.name)}),'2;1');`,
|
|
243640
|
+
`FILE_NAME(${stepStr(meta.name)},${stepStr(now)},(${stepStr(meta.author ?? "tscircuit")}),(${stepStr(meta.org ?? "tscircuit")}),${stepStr("generator")},${stepStr("")},${stepStr("")});`,
|
|
243641
|
+
`FILE_SCHEMA(('${this.schema === "AP214" ? "AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }" : "AP242_MANAGED_MODEL_BASED_3D_ENGINEERING"}'));`,
|
|
243642
|
+
"ENDSEC;",
|
|
243643
|
+
"DATA;"
|
|
243644
|
+
];
|
|
243645
|
+
const data = this.entries().map(([id2, e4]) => `#${id2} = ${e4.toStep(this)};`);
|
|
243646
|
+
const ftr = ["ENDSEC;", "END-ISO-10303-21;"];
|
|
243647
|
+
return [...hdr, ...data, ...ftr].join(`
|
|
243648
|
+
`);
|
|
243649
|
+
}
|
|
243650
|
+
};
|
|
243651
|
+
var registry = /* @__PURE__ */ new Map;
|
|
243652
|
+
function register(type, parser) {
|
|
243653
|
+
registry.set(type, parser);
|
|
243654
|
+
}
|
|
243655
|
+
function getParser(type) {
|
|
243656
|
+
return registry.get(type);
|
|
243657
|
+
}
|
|
243658
|
+
var Axis2Placement3D = class _Axis2Placement3D extends Entity {
|
|
243659
|
+
constructor(name, location, axis, refDirection) {
|
|
243660
|
+
super();
|
|
243661
|
+
this.name = name;
|
|
243662
|
+
this.location = location;
|
|
243663
|
+
this.axis = axis;
|
|
243664
|
+
this.refDirection = refDirection;
|
|
243665
|
+
}
|
|
243666
|
+
type = "AXIS2_PLACEMENT_3D";
|
|
243667
|
+
static parse(a2, ctx) {
|
|
243668
|
+
const name = ctx.parseString(a2[0]);
|
|
243669
|
+
const loc = ctx.parseRef(a2[1]);
|
|
243670
|
+
const axis = a2[2] !== "$" ? ctx.parseRef(a2[2]) : undefined;
|
|
243671
|
+
const refd = a2[3] !== "$" ? ctx.parseRef(a2[3]) : undefined;
|
|
243672
|
+
return new _Axis2Placement3D(name, loc, axis, refd);
|
|
243673
|
+
}
|
|
243674
|
+
toStep() {
|
|
243675
|
+
const A4 = this.axis ? this.axis.toString() : "$";
|
|
243676
|
+
const R4 = this.refDirection ? this.refDirection.toString() : "$";
|
|
243677
|
+
return `AXIS2_PLACEMENT_3D(${stepStr(this.name)},${this.location},${A4},${R4})`;
|
|
243678
|
+
}
|
|
243679
|
+
};
|
|
243680
|
+
register("AXIS2_PLACEMENT_3D", Axis2Placement3D.parse.bind(Axis2Placement3D));
|
|
243681
|
+
var CartesianPoint = class _CartesianPoint extends Entity {
|
|
243682
|
+
constructor(name, x3, y4, z21) {
|
|
243683
|
+
super();
|
|
243684
|
+
this.name = name;
|
|
243685
|
+
this.x = x3;
|
|
243686
|
+
this.y = y4;
|
|
243687
|
+
this.z = z21;
|
|
243688
|
+
}
|
|
243689
|
+
type = "CARTESIAN_POINT";
|
|
243690
|
+
static parse(a2, ctx) {
|
|
243691
|
+
const name = ctx.parseString(a2[0]);
|
|
243692
|
+
const coords = a2[1].replace(/^\(|\)$/g, "").split(",").map(ctx.parseNumber);
|
|
243693
|
+
return new _CartesianPoint(name, coords[0], coords[1], coords[2] ?? 0);
|
|
243694
|
+
}
|
|
243695
|
+
toStep() {
|
|
243696
|
+
return `CARTESIAN_POINT(${stepStr(this.name)},(${fmtNum(this.x)},${fmtNum(this.y)},${fmtNum(this.z)}))`;
|
|
243697
|
+
}
|
|
243698
|
+
};
|
|
243699
|
+
register("CARTESIAN_POINT", CartesianPoint.parse.bind(CartesianPoint));
|
|
243700
|
+
var Circle3 = class _Circle extends Entity {
|
|
243701
|
+
constructor(name, placement, radius) {
|
|
243702
|
+
super();
|
|
243703
|
+
this.name = name;
|
|
243704
|
+
this.placement = placement;
|
|
243705
|
+
this.radius = radius;
|
|
243706
|
+
}
|
|
243707
|
+
type = "CIRCLE";
|
|
243708
|
+
static parse(a2, ctx) {
|
|
243709
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
243710
|
+
const pl4 = ctx.parseRef(a2[1]);
|
|
243711
|
+
const r4 = ctx.parseNumber(a2[2]);
|
|
243712
|
+
return new _Circle(name, pl4, r4);
|
|
243713
|
+
}
|
|
243714
|
+
toStep() {
|
|
243715
|
+
return `CIRCLE(${this.name ? `'${this.name}'` : "''"},${this.placement},${fmtNum(this.radius)})`;
|
|
243716
|
+
}
|
|
243717
|
+
};
|
|
243718
|
+
register("CIRCLE", Circle3.parse.bind(Circle3));
|
|
243719
|
+
var CylindricalSurface = class _CylindricalSurface extends Entity {
|
|
243720
|
+
constructor(name, position2, radius) {
|
|
243721
|
+
super();
|
|
243722
|
+
this.name = name;
|
|
243723
|
+
this.position = position2;
|
|
243724
|
+
this.radius = radius;
|
|
243725
|
+
}
|
|
243726
|
+
type = "CYLINDRICAL_SURFACE";
|
|
243727
|
+
static parse(a2, ctx) {
|
|
243728
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
243729
|
+
const position2 = ctx.parseRef(a2[1]);
|
|
243730
|
+
const radius = ctx.parseNumber(a2[2]);
|
|
243731
|
+
return new _CylindricalSurface(name, position2, radius);
|
|
243732
|
+
}
|
|
243733
|
+
toStep() {
|
|
243734
|
+
return `CYLINDRICAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.radius)})`;
|
|
243735
|
+
}
|
|
243736
|
+
};
|
|
243737
|
+
register("CYLINDRICAL_SURFACE", CylindricalSurface.parse.bind(CylindricalSurface));
|
|
243738
|
+
var Direction = class _Direction extends Entity {
|
|
243739
|
+
constructor(name, dx2, dy2, dz) {
|
|
243740
|
+
super();
|
|
243741
|
+
this.name = name;
|
|
243742
|
+
this.dx = dx2;
|
|
243743
|
+
this.dy = dy2;
|
|
243744
|
+
this.dz = dz;
|
|
243745
|
+
}
|
|
243746
|
+
type = "DIRECTION";
|
|
243747
|
+
static parse(a2, ctx) {
|
|
243748
|
+
const name = ctx.parseString(a2[0]);
|
|
243749
|
+
const comps = a2[1].replace(/^\(|\)$/g, "").split(",").map(ctx.parseNumber);
|
|
243750
|
+
return new _Direction(name, comps[0], comps[1], comps[2] ?? 0);
|
|
243751
|
+
}
|
|
243752
|
+
toStep() {
|
|
243753
|
+
return `DIRECTION(${stepStr(this.name)},(${fmtNum(this.dx)},${fmtNum(this.dy)},${fmtNum(this.dz)}))`;
|
|
243754
|
+
}
|
|
243755
|
+
};
|
|
243756
|
+
register("DIRECTION", Direction.parse.bind(Direction));
|
|
243757
|
+
var Line3 = class _Line extends Entity {
|
|
243758
|
+
constructor(name, pnt, dir) {
|
|
243759
|
+
super();
|
|
243760
|
+
this.name = name;
|
|
243761
|
+
this.pnt = pnt;
|
|
243762
|
+
this.dir = dir;
|
|
243763
|
+
}
|
|
243764
|
+
type = "LINE";
|
|
243765
|
+
static parse(a2, ctx) {
|
|
243766
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
243767
|
+
const p3 = ctx.parseRef(a2[1]);
|
|
243768
|
+
const vecTok = a2[2];
|
|
243769
|
+
if (vecTok.startsWith("VECTOR(")) {
|
|
243770
|
+
throw new Error("Inline VECTOR in LINE is not supported - VECTOR should be a separate entity");
|
|
243771
|
+
}
|
|
243772
|
+
const vec = ctx.parseRef(vecTok);
|
|
243773
|
+
return new _Line(name, p3, vec);
|
|
243774
|
+
}
|
|
243775
|
+
toStep() {
|
|
243776
|
+
return `LINE(${this.name ? `'${this.name}'` : "''"},${this.pnt},${this.dir})`;
|
|
243777
|
+
}
|
|
243778
|
+
};
|
|
243779
|
+
register("LINE", Line3.parse.bind(Line3));
|
|
243780
|
+
var Plane = class _Plane extends Entity {
|
|
243781
|
+
constructor(name, placement) {
|
|
243782
|
+
super();
|
|
243783
|
+
this.name = name;
|
|
243784
|
+
this.placement = placement;
|
|
243785
|
+
}
|
|
243786
|
+
type = "PLANE";
|
|
243787
|
+
static parse(a2, ctx) {
|
|
243788
|
+
return new _Plane(ctx.parseString(a2[0]), ctx.parseRef(a2[1]));
|
|
243789
|
+
}
|
|
243790
|
+
toStep() {
|
|
243791
|
+
return `PLANE(${stepStr(this.name)},${this.placement})`;
|
|
243792
|
+
}
|
|
243793
|
+
};
|
|
243794
|
+
register("PLANE", Plane.parse.bind(Plane));
|
|
243795
|
+
var ToroidalSurface = class _ToroidalSurface extends Entity {
|
|
243796
|
+
constructor(name, position2, majorRadius, minorRadius) {
|
|
243797
|
+
super();
|
|
243798
|
+
this.name = name;
|
|
243799
|
+
this.position = position2;
|
|
243800
|
+
this.majorRadius = majorRadius;
|
|
243801
|
+
this.minorRadius = minorRadius;
|
|
243802
|
+
}
|
|
243803
|
+
type = "TOROIDAL_SURFACE";
|
|
243804
|
+
static parse(a2, ctx) {
|
|
243805
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
243806
|
+
const position2 = ctx.parseRef(a2[1]);
|
|
243807
|
+
const majorRadius = ctx.parseNumber(a2[2]);
|
|
243808
|
+
const minorRadius = ctx.parseNumber(a2[3]);
|
|
243809
|
+
return new _ToroidalSurface(name, position2, majorRadius, minorRadius);
|
|
243810
|
+
}
|
|
243811
|
+
toStep() {
|
|
243812
|
+
return `TOROIDAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.majorRadius)},${fmtNum(this.minorRadius)})`;
|
|
243813
|
+
}
|
|
243814
|
+
};
|
|
243815
|
+
register("TOROIDAL_SURFACE", ToroidalSurface.parse.bind(ToroidalSurface));
|
|
243816
|
+
var Vector3 = class _Vector extends Entity {
|
|
243817
|
+
constructor(name, orientation3, magnitude) {
|
|
243818
|
+
super();
|
|
243819
|
+
this.name = name;
|
|
243820
|
+
this.orientation = orientation3;
|
|
243821
|
+
this.magnitude = magnitude;
|
|
243822
|
+
}
|
|
243823
|
+
type = "VECTOR";
|
|
243824
|
+
static parse(a2, ctx) {
|
|
243825
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
243826
|
+
const orientation3 = ctx.parseRef(a2[1]);
|
|
243827
|
+
const magnitude = ctx.parseNumber(a2[2]);
|
|
243828
|
+
return new _Vector(name, orientation3, magnitude);
|
|
243829
|
+
}
|
|
243830
|
+
toStep() {
|
|
243831
|
+
return `VECTOR(${stepStr(this.name)},${this.orientation},${fmtNum(this.magnitude)})`;
|
|
243832
|
+
}
|
|
243833
|
+
};
|
|
243834
|
+
register("VECTOR", Vector3.parse.bind(Vector3));
|
|
243835
|
+
var Ellipse = class _Ellipse extends Entity {
|
|
243836
|
+
constructor(name, placement, semiAxis1, semiAxis2) {
|
|
243837
|
+
super();
|
|
243838
|
+
this.name = name;
|
|
243839
|
+
this.placement = placement;
|
|
243840
|
+
this.semiAxis1 = semiAxis1;
|
|
243841
|
+
this.semiAxis2 = semiAxis2;
|
|
243842
|
+
}
|
|
243843
|
+
type = "ELLIPSE";
|
|
243844
|
+
static parse(a2, ctx) {
|
|
243845
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
243846
|
+
const placement = ctx.parseRef(a2[1]);
|
|
243847
|
+
const semiAxis1 = ctx.parseNumber(a2[2]);
|
|
243848
|
+
const semiAxis2 = ctx.parseNumber(a2[3]);
|
|
243849
|
+
return new _Ellipse(name, placement, semiAxis1, semiAxis2);
|
|
243850
|
+
}
|
|
243851
|
+
toStep() {
|
|
243852
|
+
return `ELLIPSE(${stepStr(this.name)},${this.placement},${fmtNum(this.semiAxis1)},${fmtNum(this.semiAxis2)})`;
|
|
243853
|
+
}
|
|
243854
|
+
};
|
|
243855
|
+
register("ELLIPSE", Ellipse.parse.bind(Ellipse));
|
|
243856
|
+
var ConicalSurface = class _ConicalSurface extends Entity {
|
|
243857
|
+
constructor(name, position2, radius, semiAngle) {
|
|
243858
|
+
super();
|
|
243859
|
+
this.name = name;
|
|
243860
|
+
this.position = position2;
|
|
243861
|
+
this.radius = radius;
|
|
243862
|
+
this.semiAngle = semiAngle;
|
|
243863
|
+
}
|
|
243864
|
+
type = "CONICAL_SURFACE";
|
|
243865
|
+
static parse(a2, ctx) {
|
|
243866
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
243867
|
+
const position2 = ctx.parseRef(a2[1]);
|
|
243868
|
+
const radius = ctx.parseNumber(a2[2]);
|
|
243869
|
+
const semiAngle = ctx.parseNumber(a2[3]);
|
|
243870
|
+
return new _ConicalSurface(name, position2, radius, semiAngle);
|
|
243871
|
+
}
|
|
243872
|
+
toStep() {
|
|
243873
|
+
return `CONICAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.radius)},${fmtNum(this.semiAngle)})`;
|
|
243874
|
+
}
|
|
243875
|
+
};
|
|
243876
|
+
register("CONICAL_SURFACE", ConicalSurface.parse.bind(ConicalSurface));
|
|
243877
|
+
var SphericalSurface = class _SphericalSurface extends Entity {
|
|
243878
|
+
constructor(name, position2, radius) {
|
|
243879
|
+
super();
|
|
243880
|
+
this.name = name;
|
|
243881
|
+
this.position = position2;
|
|
243882
|
+
this.radius = radius;
|
|
243883
|
+
}
|
|
243884
|
+
type = "SPHERICAL_SURFACE";
|
|
243885
|
+
static parse(a2, ctx) {
|
|
243886
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
243887
|
+
const position2 = ctx.parseRef(a2[1]);
|
|
243888
|
+
const radius = ctx.parseNumber(a2[2]);
|
|
243889
|
+
return new _SphericalSurface(name, position2, radius);
|
|
243890
|
+
}
|
|
243891
|
+
toStep() {
|
|
243892
|
+
return `SPHERICAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.radius)})`;
|
|
243893
|
+
}
|
|
243894
|
+
};
|
|
243895
|
+
register("SPHERICAL_SURFACE", SphericalSurface.parse.bind(SphericalSurface));
|
|
243896
|
+
var BSplineCurveWithKnots = class _BSplineCurveWithKnots extends Entity {
|
|
243897
|
+
constructor(name, degree, controlPointsList, curveForm, closedCurve, selfIntersect, knotMultiplicities, knots, knotSpec) {
|
|
243898
|
+
super();
|
|
243899
|
+
this.name = name;
|
|
243900
|
+
this.degree = degree;
|
|
243901
|
+
this.controlPointsList = controlPointsList;
|
|
243902
|
+
this.curveForm = curveForm;
|
|
243903
|
+
this.closedCurve = closedCurve;
|
|
243904
|
+
this.selfIntersect = selfIntersect;
|
|
243905
|
+
this.knotMultiplicities = knotMultiplicities;
|
|
243906
|
+
this.knots = knots;
|
|
243907
|
+
this.knotSpec = knotSpec;
|
|
243908
|
+
}
|
|
243909
|
+
type = "B_SPLINE_CURVE_WITH_KNOTS";
|
|
243910
|
+
static parse(a2, ctx) {
|
|
243911
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
243912
|
+
const degree = ctx.parseNumber(a2[1]);
|
|
243913
|
+
const controlPoints = a2[2].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
|
|
243914
|
+
const curveForm = a2[3].trim();
|
|
243915
|
+
const closedCurve = a2[4].trim() === ".T.";
|
|
243916
|
+
const selfIntersect = a2[5].trim() === ".T.";
|
|
243917
|
+
const knotMults = a2[6].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseNumber(tok.trim()));
|
|
243918
|
+
const knots = a2[7].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseNumber(tok.trim()));
|
|
243919
|
+
const knotSpec = a2[8].trim();
|
|
243920
|
+
return new _BSplineCurveWithKnots(name, degree, controlPoints, curveForm, closedCurve, selfIntersect, knotMults, knots, knotSpec);
|
|
243921
|
+
}
|
|
243922
|
+
toStep() {
|
|
243923
|
+
const cps = `(${this.controlPointsList.join(",")})`;
|
|
243924
|
+
const kms = `(${this.knotMultiplicities.map(fmtNum).join(",")})`;
|
|
243925
|
+
const ks3 = `(${this.knots.map(fmtNum).join(",")})`;
|
|
243926
|
+
const closed = this.closedCurve ? ".T." : ".F.";
|
|
243927
|
+
const self2 = this.selfIntersect ? ".T." : ".F.";
|
|
243928
|
+
return `B_SPLINE_CURVE_WITH_KNOTS(${stepStr(this.name)},${this.degree},${cps},${this.curveForm},${closed},${self2},${kms},${ks3},${this.knotSpec})`;
|
|
243929
|
+
}
|
|
243930
|
+
};
|
|
243931
|
+
register("B_SPLINE_CURVE_WITH_KNOTS", BSplineCurveWithKnots.parse.bind(BSplineCurveWithKnots));
|
|
243932
|
+
var ColourRgb = class _ColourRgb extends Entity {
|
|
243933
|
+
constructor(name, r4, g6, b) {
|
|
243934
|
+
super();
|
|
243935
|
+
this.name = name;
|
|
243936
|
+
this.r = r4;
|
|
243937
|
+
this.g = g6;
|
|
243938
|
+
this.b = b;
|
|
243939
|
+
}
|
|
243940
|
+
type = "COLOUR_RGB";
|
|
243941
|
+
static parse(a2, ctx) {
|
|
243942
|
+
return new _ColourRgb(ctx.parseString(a2[0]), ctx.parseNumber(a2[1]), ctx.parseNumber(a2[2]), ctx.parseNumber(a2[3]));
|
|
243943
|
+
}
|
|
243944
|
+
toStep() {
|
|
243945
|
+
return `COLOUR_RGB(${stepStr(this.name)},${this.r},${this.g},${this.b})`;
|
|
243946
|
+
}
|
|
243947
|
+
};
|
|
243948
|
+
register("COLOUR_RGB", ColourRgb.parse.bind(ColourRgb));
|
|
243949
|
+
var FillAreaStyle = class _FillAreaStyle extends Entity {
|
|
243950
|
+
constructor(name, items) {
|
|
243951
|
+
super();
|
|
243952
|
+
this.name = name;
|
|
243953
|
+
this.items = items;
|
|
243954
|
+
}
|
|
243955
|
+
type = "FILL_AREA_STYLE";
|
|
243956
|
+
static parse(a2, ctx) {
|
|
243957
|
+
const items = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
243958
|
+
return new _FillAreaStyle(a2[0] === "$" ? "" : ctx.parseString(a2[0]), items);
|
|
243959
|
+
}
|
|
243960
|
+
toStep() {
|
|
243961
|
+
return `FILL_AREA_STYLE(${stepStr(this.name)},(${this.items.join(",")}))`;
|
|
243962
|
+
}
|
|
243963
|
+
};
|
|
243964
|
+
register("FILL_AREA_STYLE", FillAreaStyle.parse.bind(FillAreaStyle));
|
|
243965
|
+
var FillAreaStyleColour = class _FillAreaStyleColour extends Entity {
|
|
243966
|
+
constructor(name, colour) {
|
|
243967
|
+
super();
|
|
243968
|
+
this.name = name;
|
|
243969
|
+
this.colour = colour;
|
|
243970
|
+
}
|
|
243971
|
+
type = "FILL_AREA_STYLE_COLOUR";
|
|
243972
|
+
static parse(a2, ctx) {
|
|
243973
|
+
return new _FillAreaStyleColour(ctx.parseString(a2[0]), ctx.parseRef(a2[1]));
|
|
243974
|
+
}
|
|
243975
|
+
toStep() {
|
|
243976
|
+
return `FILL_AREA_STYLE_COLOUR(${stepStr(this.name)},${this.colour})`;
|
|
243977
|
+
}
|
|
243978
|
+
};
|
|
243979
|
+
register("FILL_AREA_STYLE_COLOUR", FillAreaStyleColour.parse.bind(FillAreaStyleColour));
|
|
243980
|
+
var MechanicalDesignGeometricPresentationRepresentation = class _MechanicalDesignGeometricPresentationRepresentation extends Entity {
|
|
243981
|
+
constructor(name, items, contextOfItems) {
|
|
243982
|
+
super();
|
|
243983
|
+
this.name = name;
|
|
243984
|
+
this.items = items;
|
|
243985
|
+
this.contextOfItems = contextOfItems;
|
|
243986
|
+
}
|
|
243987
|
+
type = "MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION";
|
|
243988
|
+
static parse(a2, ctx) {
|
|
243989
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
243990
|
+
const items = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
243991
|
+
const contextOfItems = ctx.parseRef(a2[2]);
|
|
243992
|
+
return new _MechanicalDesignGeometricPresentationRepresentation(name, items, contextOfItems);
|
|
243993
|
+
}
|
|
243994
|
+
toStep() {
|
|
243995
|
+
return `MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION(${stepStr(this.name)},(${this.items.join(",")}),${this.contextOfItems})`;
|
|
243996
|
+
}
|
|
243997
|
+
};
|
|
243998
|
+
register("MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION", MechanicalDesignGeometricPresentationRepresentation.parse.bind(MechanicalDesignGeometricPresentationRepresentation));
|
|
243999
|
+
var PresentationStyleAssignment = class _PresentationStyleAssignment extends Entity {
|
|
244000
|
+
constructor(items) {
|
|
244001
|
+
super();
|
|
244002
|
+
this.items = items;
|
|
244003
|
+
}
|
|
244004
|
+
type = "PRESENTATION_STYLE_ASSIGNMENT";
|
|
244005
|
+
static parse(a2, ctx) {
|
|
244006
|
+
const list = a2[0].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
244007
|
+
return new _PresentationStyleAssignment(list);
|
|
244008
|
+
}
|
|
244009
|
+
toStep() {
|
|
244010
|
+
return `PRESENTATION_STYLE_ASSIGNMENT((${this.items.join(",")}))`;
|
|
244011
|
+
}
|
|
244012
|
+
};
|
|
244013
|
+
register("PRESENTATION_STYLE_ASSIGNMENT", PresentationStyleAssignment.parse.bind(PresentationStyleAssignment));
|
|
244014
|
+
var StyledItem = class _StyledItem extends Entity {
|
|
244015
|
+
constructor(name, styles, item) {
|
|
244016
|
+
super();
|
|
244017
|
+
this.name = name;
|
|
244018
|
+
this.styles = styles;
|
|
244019
|
+
this.item = item;
|
|
244020
|
+
}
|
|
244021
|
+
type = "STYLED_ITEM";
|
|
244022
|
+
static parse(a2, ctx) {
|
|
244023
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244024
|
+
const styles = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
244025
|
+
const item = ctx.parseRef(a2[2]);
|
|
244026
|
+
return new _StyledItem(name, styles, item);
|
|
244027
|
+
}
|
|
244028
|
+
toStep() {
|
|
244029
|
+
return `STYLED_ITEM(${stepStr(this.name)},(${this.styles.join(",")}),${this.item})`;
|
|
244030
|
+
}
|
|
244031
|
+
};
|
|
244032
|
+
register("STYLED_ITEM", StyledItem.parse.bind(StyledItem));
|
|
244033
|
+
var SurfaceSideStyle = class _SurfaceSideStyle extends Entity {
|
|
244034
|
+
constructor(name, styles) {
|
|
244035
|
+
super();
|
|
244036
|
+
this.name = name;
|
|
244037
|
+
this.styles = styles;
|
|
244038
|
+
}
|
|
244039
|
+
type = "SURFACE_SIDE_STYLE";
|
|
244040
|
+
static parse(a2, ctx) {
|
|
244041
|
+
const list = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
244042
|
+
return new _SurfaceSideStyle(a2[0] === "$" ? "" : ctx.parseString(a2[0]), list);
|
|
244043
|
+
}
|
|
244044
|
+
toStep() {
|
|
244045
|
+
return `SURFACE_SIDE_STYLE(${stepStr(this.name)},(${this.styles.join(",")}))`;
|
|
244046
|
+
}
|
|
244047
|
+
};
|
|
244048
|
+
register("SURFACE_SIDE_STYLE", SurfaceSideStyle.parse.bind(SurfaceSideStyle));
|
|
244049
|
+
var SurfaceStyleFillArea = class _SurfaceStyleFillArea extends Entity {
|
|
244050
|
+
constructor(style) {
|
|
244051
|
+
super();
|
|
244052
|
+
this.style = style;
|
|
244053
|
+
}
|
|
244054
|
+
type = "SURFACE_STYLE_FILL_AREA";
|
|
244055
|
+
static parse(a2, ctx) {
|
|
244056
|
+
return new _SurfaceStyleFillArea(ctx.parseRef(a2[0]));
|
|
244057
|
+
}
|
|
244058
|
+
toStep() {
|
|
244059
|
+
return `SURFACE_STYLE_FILL_AREA(${this.style})`;
|
|
244060
|
+
}
|
|
244061
|
+
};
|
|
244062
|
+
register("SURFACE_STYLE_FILL_AREA", SurfaceStyleFillArea.parse.bind(SurfaceStyleFillArea));
|
|
244063
|
+
var SurfaceStyleUsage = class _SurfaceStyleUsage extends Entity {
|
|
244064
|
+
constructor(side, style) {
|
|
244065
|
+
super();
|
|
244066
|
+
this.side = side;
|
|
244067
|
+
this.style = style;
|
|
244068
|
+
}
|
|
244069
|
+
type = "SURFACE_STYLE_USAGE";
|
|
244070
|
+
static parse(a2, ctx) {
|
|
244071
|
+
return new _SurfaceStyleUsage(a2[0].trim(), ctx.parseRef(a2[1]));
|
|
244072
|
+
}
|
|
244073
|
+
toStep() {
|
|
244074
|
+
return `SURFACE_STYLE_USAGE(${this.side},${this.style})`;
|
|
244075
|
+
}
|
|
244076
|
+
};
|
|
244077
|
+
register("SURFACE_STYLE_USAGE", SurfaceStyleUsage.parse.bind(SurfaceStyleUsage));
|
|
244078
|
+
var AdvancedBrepShapeRepresentation = class _AdvancedBrepShapeRepresentation extends Entity {
|
|
244079
|
+
constructor(name, items, context) {
|
|
244080
|
+
super();
|
|
244081
|
+
this.name = name;
|
|
244082
|
+
this.items = items;
|
|
244083
|
+
this.context = context;
|
|
244084
|
+
}
|
|
244085
|
+
type = "ADVANCED_BREP_SHAPE_REPRESENTATION";
|
|
244086
|
+
static parse(a2, ctx) {
|
|
244087
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244088
|
+
const items = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
244089
|
+
const c3 = ctx.parseRef(a2[2]);
|
|
244090
|
+
return new _AdvancedBrepShapeRepresentation(name, items, c3);
|
|
244091
|
+
}
|
|
244092
|
+
toStep() {
|
|
244093
|
+
return `ADVANCED_BREP_SHAPE_REPRESENTATION(${stepStr(this.name)},(${this.items.join(",")}),${this.context})`;
|
|
244094
|
+
}
|
|
244095
|
+
};
|
|
244096
|
+
register("ADVANCED_BREP_SHAPE_REPRESENTATION", AdvancedBrepShapeRepresentation.parse.bind(AdvancedBrepShapeRepresentation));
|
|
244097
|
+
var ApplicationContext = class _ApplicationContext extends Entity {
|
|
244098
|
+
constructor(application) {
|
|
244099
|
+
super();
|
|
244100
|
+
this.application = application;
|
|
244101
|
+
}
|
|
244102
|
+
type = "APPLICATION_CONTEXT";
|
|
244103
|
+
static parse(a2, ctx) {
|
|
244104
|
+
const application = ctx.parseString(a2[0]);
|
|
244105
|
+
return new _ApplicationContext(application);
|
|
244106
|
+
}
|
|
244107
|
+
toStep() {
|
|
244108
|
+
return `APPLICATION_CONTEXT(${stepStr(this.application)})`;
|
|
244109
|
+
}
|
|
244110
|
+
};
|
|
244111
|
+
register("APPLICATION_CONTEXT", ApplicationContext.parse.bind(ApplicationContext));
|
|
244112
|
+
var ApplicationProtocolDefinition = class _ApplicationProtocolDefinition extends Entity {
|
|
244113
|
+
constructor(status, applicationInterpretedModelSchemaName, applicationProtocolYear, application) {
|
|
244114
|
+
super();
|
|
244115
|
+
this.status = status;
|
|
244116
|
+
this.applicationInterpretedModelSchemaName = applicationInterpretedModelSchemaName;
|
|
244117
|
+
this.applicationProtocolYear = applicationProtocolYear;
|
|
244118
|
+
this.application = application;
|
|
244119
|
+
}
|
|
244120
|
+
type = "APPLICATION_PROTOCOL_DEFINITION";
|
|
244121
|
+
static parse(a2, ctx) {
|
|
244122
|
+
const status = ctx.parseString(a2[0]);
|
|
244123
|
+
const schemaName = ctx.parseString(a2[1]);
|
|
244124
|
+
const year = ctx.parseNumber(a2[2]);
|
|
244125
|
+
const application = ctx.parseRef(a2[3]);
|
|
244126
|
+
return new _ApplicationProtocolDefinition(status, schemaName, year, application);
|
|
244127
|
+
}
|
|
244128
|
+
toStep() {
|
|
244129
|
+
return `APPLICATION_PROTOCOL_DEFINITION(${stepStr(this.status)},${stepStr(this.applicationInterpretedModelSchemaName)},${this.applicationProtocolYear},${this.application})`;
|
|
244130
|
+
}
|
|
244131
|
+
};
|
|
244132
|
+
register("APPLICATION_PROTOCOL_DEFINITION", ApplicationProtocolDefinition.parse.bind(ApplicationProtocolDefinition));
|
|
244133
|
+
var ContextDependentShapeRepresentation = class _ContextDependentShapeRepresentation extends Entity {
|
|
244134
|
+
constructor(representationRelation, representedProductRelation) {
|
|
244135
|
+
super();
|
|
244136
|
+
this.representationRelation = representationRelation;
|
|
244137
|
+
this.representedProductRelation = representedProductRelation;
|
|
244138
|
+
}
|
|
244139
|
+
type = "CONTEXT_DEPENDENT_SHAPE_REPRESENTATION";
|
|
244140
|
+
static parse(a2, ctx) {
|
|
244141
|
+
const representationRelation = ctx.parseRef(a2[0]);
|
|
244142
|
+
const representedProductRelation = ctx.parseRef(a2[1]);
|
|
244143
|
+
return new _ContextDependentShapeRepresentation(representationRelation, representedProductRelation);
|
|
244144
|
+
}
|
|
244145
|
+
toStep() {
|
|
244146
|
+
return `CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(${this.representationRelation},${this.representedProductRelation})`;
|
|
244147
|
+
}
|
|
244148
|
+
};
|
|
244149
|
+
register("CONTEXT_DEPENDENT_SHAPE_REPRESENTATION", ContextDependentShapeRepresentation.parse.bind(ContextDependentShapeRepresentation));
|
|
244150
|
+
var ItemDefinedTransformation = class _ItemDefinedTransformation extends Entity {
|
|
244151
|
+
constructor(name, description, transformItem1, transformItem2) {
|
|
244152
|
+
super();
|
|
244153
|
+
this.name = name;
|
|
244154
|
+
this.description = description;
|
|
244155
|
+
this.transformItem1 = transformItem1;
|
|
244156
|
+
this.transformItem2 = transformItem2;
|
|
244157
|
+
}
|
|
244158
|
+
type = "ITEM_DEFINED_TRANSFORMATION";
|
|
244159
|
+
static parse(a2, ctx) {
|
|
244160
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244161
|
+
const description = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
|
|
244162
|
+
const item1 = ctx.parseRef(a2[2]);
|
|
244163
|
+
const item2 = ctx.parseRef(a2[3]);
|
|
244164
|
+
return new _ItemDefinedTransformation(name, description, item1, item2);
|
|
244165
|
+
}
|
|
244166
|
+
toStep() {
|
|
244167
|
+
return `ITEM_DEFINED_TRANSFORMATION(${stepStr(this.name)},${stepStr(this.description)},${this.transformItem1},${this.transformItem2})`;
|
|
244168
|
+
}
|
|
244169
|
+
};
|
|
244170
|
+
register("ITEM_DEFINED_TRANSFORMATION", ItemDefinedTransformation.parse.bind(ItemDefinedTransformation));
|
|
244171
|
+
var NextAssemblyUsageOccurrence = class _NextAssemblyUsageOccurrence extends Entity {
|
|
244172
|
+
constructor(id2, name, description, relatingProductDefinition, relatedProductDefinition, referenceDesignator) {
|
|
244173
|
+
super();
|
|
244174
|
+
this.id = id2;
|
|
244175
|
+
this.name = name;
|
|
244176
|
+
this.description = description;
|
|
244177
|
+
this.relatingProductDefinition = relatingProductDefinition;
|
|
244178
|
+
this.relatedProductDefinition = relatedProductDefinition;
|
|
244179
|
+
this.referenceDesignator = referenceDesignator;
|
|
244180
|
+
}
|
|
244181
|
+
type = "NEXT_ASSEMBLY_USAGE_OCCURRENCE";
|
|
244182
|
+
static parse(a2, ctx) {
|
|
244183
|
+
const id2 = ctx.parseString(a2[0]);
|
|
244184
|
+
const name = ctx.parseString(a2[1]);
|
|
244185
|
+
const description = a2[2] === "$" ? "" : ctx.parseString(a2[2]);
|
|
244186
|
+
const relating = ctx.parseRef(a2[3]);
|
|
244187
|
+
const related = ctx.parseRef(a2[4]);
|
|
244188
|
+
const designator = a2[5] === "$" ? "" : ctx.parseString(a2[5]);
|
|
244189
|
+
return new _NextAssemblyUsageOccurrence(id2, name, description, relating, related, designator);
|
|
244190
|
+
}
|
|
244191
|
+
toStep() {
|
|
244192
|
+
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) : "$"})`;
|
|
244193
|
+
}
|
|
244194
|
+
};
|
|
244195
|
+
register("NEXT_ASSEMBLY_USAGE_OCCURRENCE", NextAssemblyUsageOccurrence.parse.bind(NextAssemblyUsageOccurrence));
|
|
244196
|
+
var Product = class _Product extends Entity {
|
|
244197
|
+
constructor(name, id2, description, frameOfReference) {
|
|
244198
|
+
super();
|
|
244199
|
+
this.name = name;
|
|
244200
|
+
this.id = id2;
|
|
244201
|
+
this.description = description;
|
|
244202
|
+
this.frameOfReference = frameOfReference;
|
|
244203
|
+
}
|
|
244204
|
+
type = "PRODUCT";
|
|
244205
|
+
static parse(a2, ctx) {
|
|
244206
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244207
|
+
const id2 = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
|
|
244208
|
+
const description = a2[2] === "$" ? "" : ctx.parseString(a2[2]);
|
|
244209
|
+
const refs = a2[3].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
|
|
244210
|
+
return new _Product(name, id2, description, refs);
|
|
244211
|
+
}
|
|
244212
|
+
toStep() {
|
|
244213
|
+
return `PRODUCT(${stepStr(this.name)},${stepStr(this.id)},${stepStr(this.description)},(${this.frameOfReference.join(",")}))`;
|
|
244214
|
+
}
|
|
244215
|
+
};
|
|
244216
|
+
register("PRODUCT", Product.parse.bind(Product));
|
|
244217
|
+
var ProductContext = class _ProductContext extends Entity {
|
|
244218
|
+
constructor(name, frameOfReference, disciplineType) {
|
|
244219
|
+
super();
|
|
244220
|
+
this.name = name;
|
|
244221
|
+
this.frameOfReference = frameOfReference;
|
|
244222
|
+
this.disciplineType = disciplineType;
|
|
244223
|
+
}
|
|
244224
|
+
type = "PRODUCT_CONTEXT";
|
|
244225
|
+
static parse(a2, ctx) {
|
|
244226
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244227
|
+
const frameOfReference = ctx.parseRef(a2[1]);
|
|
244228
|
+
const disciplineType = ctx.parseString(a2[2]);
|
|
244229
|
+
return new _ProductContext(name, frameOfReference, disciplineType);
|
|
244230
|
+
}
|
|
244231
|
+
toStep() {
|
|
244232
|
+
return `PRODUCT_CONTEXT(${stepStr(this.name)},${this.frameOfReference},${stepStr(this.disciplineType)})`;
|
|
244233
|
+
}
|
|
244234
|
+
};
|
|
244235
|
+
register("PRODUCT_CONTEXT", ProductContext.parse.bind(ProductContext));
|
|
244236
|
+
var ProductDefinition = class _ProductDefinition extends Entity {
|
|
244237
|
+
constructor(id2, description, formation, frameOfReference) {
|
|
244238
|
+
super();
|
|
244239
|
+
this.id = id2;
|
|
244240
|
+
this.description = description;
|
|
244241
|
+
this.formation = formation;
|
|
244242
|
+
this.frameOfReference = frameOfReference;
|
|
244243
|
+
}
|
|
244244
|
+
type = "PRODUCT_DEFINITION";
|
|
244245
|
+
static parse(a2, ctx) {
|
|
244246
|
+
const id2 = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244247
|
+
const description = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
|
|
244248
|
+
const formation = ctx.parseRef(a2[2]);
|
|
244249
|
+
const frameOfReference = ctx.parseRef(a2[3]);
|
|
244250
|
+
return new _ProductDefinition(id2, description, formation, frameOfReference);
|
|
244251
|
+
}
|
|
244252
|
+
toStep() {
|
|
244253
|
+
return `PRODUCT_DEFINITION(${stepStr(this.id)},${stepStr(this.description)},${this.formation},${this.frameOfReference})`;
|
|
244254
|
+
}
|
|
244255
|
+
};
|
|
244256
|
+
register("PRODUCT_DEFINITION", ProductDefinition.parse.bind(ProductDefinition));
|
|
244257
|
+
var ProductDefinitionContext = class _ProductDefinitionContext extends Entity {
|
|
244258
|
+
constructor(name, frameOfReference, lifecycleStage) {
|
|
244259
|
+
super();
|
|
244260
|
+
this.name = name;
|
|
244261
|
+
this.frameOfReference = frameOfReference;
|
|
244262
|
+
this.lifecycleStage = lifecycleStage;
|
|
244263
|
+
}
|
|
244264
|
+
type = "PRODUCT_DEFINITION_CONTEXT";
|
|
244265
|
+
static parse(a2, ctx) {
|
|
244266
|
+
const name = ctx.parseString(a2[0]);
|
|
244267
|
+
const frameOfReference = ctx.parseRef(a2[1]);
|
|
244268
|
+
const lifecycleStage = ctx.parseString(a2[2]);
|
|
244269
|
+
return new _ProductDefinitionContext(name, frameOfReference, lifecycleStage);
|
|
244270
|
+
}
|
|
244271
|
+
toStep() {
|
|
244272
|
+
return `PRODUCT_DEFINITION_CONTEXT(${stepStr(this.name)},${this.frameOfReference},${stepStr(this.lifecycleStage)})`;
|
|
244273
|
+
}
|
|
244274
|
+
};
|
|
244275
|
+
register("PRODUCT_DEFINITION_CONTEXT", ProductDefinitionContext.parse.bind(ProductDefinitionContext));
|
|
244276
|
+
var ProductDefinitionFormation = class _ProductDefinitionFormation extends Entity {
|
|
244277
|
+
constructor(id2, description, ofProduct) {
|
|
244278
|
+
super();
|
|
244279
|
+
this.id = id2;
|
|
244280
|
+
this.description = description;
|
|
244281
|
+
this.ofProduct = ofProduct;
|
|
244282
|
+
}
|
|
244283
|
+
type = "PRODUCT_DEFINITION_FORMATION";
|
|
244284
|
+
static parse(a2, ctx) {
|
|
244285
|
+
const id2 = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244286
|
+
const description = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
|
|
244287
|
+
const ofProduct = ctx.parseRef(a2[2]);
|
|
244288
|
+
return new _ProductDefinitionFormation(id2, description, ofProduct);
|
|
244289
|
+
}
|
|
244290
|
+
toStep() {
|
|
244291
|
+
return `PRODUCT_DEFINITION_FORMATION(${stepStr(this.id)},${stepStr(this.description)},${this.ofProduct})`;
|
|
244292
|
+
}
|
|
244293
|
+
};
|
|
244294
|
+
register("PRODUCT_DEFINITION_FORMATION", ProductDefinitionFormation.parse.bind(ProductDefinitionFormation));
|
|
244295
|
+
var ProductDefinitionShape = class _ProductDefinitionShape extends Entity {
|
|
244296
|
+
constructor(name, description, definition) {
|
|
244297
|
+
super();
|
|
244298
|
+
this.name = name;
|
|
244299
|
+
this.description = description;
|
|
244300
|
+
this.definition = definition;
|
|
244301
|
+
}
|
|
244302
|
+
type = "PRODUCT_DEFINITION_SHAPE";
|
|
244303
|
+
static parse(a2, ctx) {
|
|
244304
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244305
|
+
const description = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
|
|
244306
|
+
const definition = ctx.parseRef(a2[2]);
|
|
244307
|
+
return new _ProductDefinitionShape(name, description, definition);
|
|
244308
|
+
}
|
|
244309
|
+
toStep() {
|
|
244310
|
+
return `PRODUCT_DEFINITION_SHAPE(${stepStr(this.name)},${stepStr(this.description)},${this.definition})`;
|
|
244311
|
+
}
|
|
244312
|
+
};
|
|
244313
|
+
register("PRODUCT_DEFINITION_SHAPE", ProductDefinitionShape.parse.bind(ProductDefinitionShape));
|
|
244314
|
+
var ProductRelatedProductCategory = class _ProductRelatedProductCategory extends Entity {
|
|
244315
|
+
constructor(name, description, products) {
|
|
244316
|
+
super();
|
|
244317
|
+
this.name = name;
|
|
244318
|
+
this.description = description;
|
|
244319
|
+
this.products = products;
|
|
244320
|
+
}
|
|
244321
|
+
type = "PRODUCT_RELATED_PRODUCT_CATEGORY";
|
|
244322
|
+
static parse(a2, ctx) {
|
|
244323
|
+
const name = ctx.parseString(a2[0]);
|
|
244324
|
+
const description = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
|
|
244325
|
+
const products = a2[2].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
244326
|
+
return new _ProductRelatedProductCategory(name, description, products);
|
|
244327
|
+
}
|
|
244328
|
+
toStep() {
|
|
244329
|
+
return `PRODUCT_RELATED_PRODUCT_CATEGORY(${stepStr(this.name)},${this.description ? stepStr(this.description) : "$"},(${this.products.join(",")}))`;
|
|
244330
|
+
}
|
|
244331
|
+
};
|
|
244332
|
+
register("PRODUCT_RELATED_PRODUCT_CATEGORY", ProductRelatedProductCategory.parse.bind(ProductRelatedProductCategory));
|
|
244333
|
+
var ShapeDefinitionRepresentation = class _ShapeDefinitionRepresentation extends Entity {
|
|
244334
|
+
constructor(definition, usedRepresentation) {
|
|
244335
|
+
super();
|
|
244336
|
+
this.definition = definition;
|
|
244337
|
+
this.usedRepresentation = usedRepresentation;
|
|
244338
|
+
}
|
|
244339
|
+
type = "SHAPE_DEFINITION_REPRESENTATION";
|
|
244340
|
+
static parse(a2, ctx) {
|
|
244341
|
+
const definition = ctx.parseRef(a2[0]);
|
|
244342
|
+
const usedRepresentation = ctx.parseRef(a2[1]);
|
|
244343
|
+
return new _ShapeDefinitionRepresentation(definition, usedRepresentation);
|
|
244344
|
+
}
|
|
244345
|
+
toStep() {
|
|
244346
|
+
return `SHAPE_DEFINITION_REPRESENTATION(${this.definition},${this.usedRepresentation})`;
|
|
244347
|
+
}
|
|
244348
|
+
};
|
|
244349
|
+
register("SHAPE_DEFINITION_REPRESENTATION", ShapeDefinitionRepresentation.parse.bind(ShapeDefinitionRepresentation));
|
|
244350
|
+
var ShapeRepresentation = class _ShapeRepresentation extends Entity {
|
|
244351
|
+
constructor(name, items, contextOfItems) {
|
|
244352
|
+
super();
|
|
244353
|
+
this.name = name;
|
|
244354
|
+
this.items = items;
|
|
244355
|
+
this.contextOfItems = contextOfItems;
|
|
244356
|
+
}
|
|
244357
|
+
type = "SHAPE_REPRESENTATION";
|
|
244358
|
+
static parse(a2, ctx) {
|
|
244359
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244360
|
+
const items = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
244361
|
+
const contextOfItems = ctx.parseRef(a2[2]);
|
|
244362
|
+
return new _ShapeRepresentation(name, items, contextOfItems);
|
|
244363
|
+
}
|
|
244364
|
+
toStep() {
|
|
244365
|
+
return `SHAPE_REPRESENTATION(${stepStr(this.name)},(${this.items.join(",")}),${this.contextOfItems})`;
|
|
244366
|
+
}
|
|
244367
|
+
};
|
|
244368
|
+
register("SHAPE_REPRESENTATION", ShapeRepresentation.parse.bind(ShapeRepresentation));
|
|
244369
|
+
var AdvancedFace = class _AdvancedFace extends Entity {
|
|
244370
|
+
constructor(name, bounds, surface, sameSense) {
|
|
244371
|
+
super();
|
|
244372
|
+
this.name = name;
|
|
244373
|
+
this.bounds = bounds;
|
|
244374
|
+
this.surface = surface;
|
|
244375
|
+
this.sameSense = sameSense;
|
|
244376
|
+
}
|
|
244377
|
+
type = "ADVANCED_FACE";
|
|
244378
|
+
static parse(a2, ctx) {
|
|
244379
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244380
|
+
const bounds = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
|
|
244381
|
+
const surf = ctx.parseRef(a2[2]);
|
|
244382
|
+
const ss3 = a2[3].trim() === ".T.";
|
|
244383
|
+
return new _AdvancedFace(name, bounds, surf, ss3);
|
|
244384
|
+
}
|
|
244385
|
+
toStep() {
|
|
244386
|
+
return `ADVANCED_FACE(${this.name ? `'${this.name}'` : "''"},(${this.bounds.join(",")}),${this.surface},${this.sameSense ? ".T." : ".F."})`;
|
|
244387
|
+
}
|
|
244388
|
+
};
|
|
244389
|
+
register("ADVANCED_FACE", AdvancedFace.parse.bind(AdvancedFace));
|
|
244390
|
+
var ClosedShell = class _ClosedShell extends Entity {
|
|
244391
|
+
constructor(name, faces) {
|
|
244392
|
+
super();
|
|
244393
|
+
this.name = name;
|
|
244394
|
+
this.faces = faces;
|
|
244395
|
+
}
|
|
244396
|
+
type = "CLOSED_SHELL";
|
|
244397
|
+
static parse(a2, ctx) {
|
|
244398
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244399
|
+
const faces = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
|
|
244400
|
+
return new _ClosedShell(name, faces);
|
|
244401
|
+
}
|
|
244402
|
+
toStep() {
|
|
244403
|
+
return `CLOSED_SHELL(${this.name ? `'${this.name}'` : "''"},(${this.faces.join(",")}))`;
|
|
244404
|
+
}
|
|
244405
|
+
};
|
|
244406
|
+
register("CLOSED_SHELL", ClosedShell.parse.bind(ClosedShell));
|
|
244407
|
+
var EdgeCurve = class _EdgeCurve extends Entity {
|
|
244408
|
+
constructor(name, start, end, curve, sameSense) {
|
|
244409
|
+
super();
|
|
244410
|
+
this.name = name;
|
|
244411
|
+
this.start = start;
|
|
244412
|
+
this.end = end;
|
|
244413
|
+
this.curve = curve;
|
|
244414
|
+
this.sameSense = sameSense;
|
|
244415
|
+
}
|
|
244416
|
+
type = "EDGE_CURVE";
|
|
244417
|
+
static parse(a2, ctx) {
|
|
244418
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244419
|
+
const s2 = ctx.parseRef(a2[1]);
|
|
244420
|
+
const e4 = ctx.parseRef(a2[2]);
|
|
244421
|
+
const c3 = ctx.parseRef(a2[3]);
|
|
244422
|
+
const same = a2[4].trim() === ".T.";
|
|
244423
|
+
return new _EdgeCurve(name, s2, e4, c3, same);
|
|
244424
|
+
}
|
|
244425
|
+
toStep() {
|
|
244426
|
+
return `EDGE_CURVE(${this.name ? `'${this.name}'` : "''"},${this.start},${this.end},${this.curve},${this.sameSense ? ".T." : ".F."})`;
|
|
244427
|
+
}
|
|
244428
|
+
};
|
|
244429
|
+
register("EDGE_CURVE", EdgeCurve.parse.bind(EdgeCurve));
|
|
244430
|
+
var EdgeLoop = class _EdgeLoop extends Entity {
|
|
244431
|
+
constructor(name, edges) {
|
|
244432
|
+
super();
|
|
244433
|
+
this.name = name;
|
|
244434
|
+
this.edges = edges;
|
|
244435
|
+
}
|
|
244436
|
+
type = "EDGE_LOOP";
|
|
244437
|
+
static parse(a2, ctx) {
|
|
244438
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244439
|
+
const list = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
|
|
244440
|
+
return new _EdgeLoop(name, list);
|
|
244441
|
+
}
|
|
244442
|
+
toStep() {
|
|
244443
|
+
return `EDGE_LOOP(${stepStr(this.name)},(${this.edges.join(",")}))`;
|
|
244444
|
+
}
|
|
244445
|
+
};
|
|
244446
|
+
register("EDGE_LOOP", EdgeLoop.parse.bind(EdgeLoop));
|
|
244447
|
+
var FaceBound = class _FaceBound extends Entity {
|
|
244448
|
+
constructor(name, bound, sameSense) {
|
|
244449
|
+
super();
|
|
244450
|
+
this.name = name;
|
|
244451
|
+
this.bound = bound;
|
|
244452
|
+
this.sameSense = sameSense;
|
|
244453
|
+
}
|
|
244454
|
+
type = "FACE_BOUND";
|
|
244455
|
+
static parse(a2, ctx) {
|
|
244456
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244457
|
+
return new _FaceBound(name, ctx.parseRef(a2[1]), a2[2].trim() === ".T.");
|
|
244458
|
+
}
|
|
244459
|
+
toStep() {
|
|
244460
|
+
return `FACE_BOUND(${stepStr(this.name)},${this.bound},${this.sameSense ? ".T." : ".F."})`;
|
|
244461
|
+
}
|
|
244462
|
+
};
|
|
244463
|
+
register("FACE_BOUND", FaceBound.parse.bind(FaceBound));
|
|
244464
|
+
var FaceOuterBound = class _FaceOuterBound extends Entity {
|
|
244465
|
+
constructor(name, bound, sameSense) {
|
|
244466
|
+
super();
|
|
244467
|
+
this.name = name;
|
|
244468
|
+
this.bound = bound;
|
|
244469
|
+
this.sameSense = sameSense;
|
|
244470
|
+
}
|
|
244471
|
+
type = "FACE_OUTER_BOUND";
|
|
244472
|
+
static parse(a2, ctx) {
|
|
244473
|
+
return new _FaceOuterBound(ctx.parseString(a2[0]), ctx.parseRef(a2[1]), a2[2].trim() === ".T.");
|
|
244474
|
+
}
|
|
244475
|
+
toStep() {
|
|
244476
|
+
return `FACE_OUTER_BOUND('${this.name}',${this.bound},${this.sameSense ? ".T." : ".F."})`;
|
|
244477
|
+
}
|
|
244478
|
+
};
|
|
244479
|
+
register("FACE_OUTER_BOUND", FaceOuterBound.parse.bind(FaceOuterBound));
|
|
244480
|
+
var ManifoldSolidBrep = class _ManifoldSolidBrep extends Entity {
|
|
244481
|
+
constructor(name, outer) {
|
|
244482
|
+
super();
|
|
244483
|
+
this.name = name;
|
|
244484
|
+
this.outer = outer;
|
|
244485
|
+
}
|
|
244486
|
+
type = "MANIFOLD_SOLID_BREP";
|
|
244487
|
+
static parse(a2, ctx) {
|
|
244488
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244489
|
+
return new _ManifoldSolidBrep(name, ctx.parseRef(a2[1]));
|
|
244490
|
+
}
|
|
244491
|
+
toStep() {
|
|
244492
|
+
return `MANIFOLD_SOLID_BREP(${stepStr(this.name)},${this.outer})`;
|
|
244493
|
+
}
|
|
244494
|
+
};
|
|
244495
|
+
register("MANIFOLD_SOLID_BREP", ManifoldSolidBrep.parse.bind(ManifoldSolidBrep));
|
|
244496
|
+
var OrientedEdge = class _OrientedEdge extends Entity {
|
|
244497
|
+
constructor(name, edge, orientation3) {
|
|
244498
|
+
super();
|
|
244499
|
+
this.name = name;
|
|
244500
|
+
this.edge = edge;
|
|
244501
|
+
this.orientation = orientation3;
|
|
244502
|
+
}
|
|
244503
|
+
type = "ORIENTED_EDGE";
|
|
244504
|
+
static parse(a2, ctx) {
|
|
244505
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244506
|
+
const edge = ctx.parseRef(a2[3]);
|
|
244507
|
+
const orient = a2[4]?.trim?.() === ".T." || a2[2]?.trim?.() === ".T.";
|
|
244508
|
+
return new _OrientedEdge(name, edge, orient);
|
|
244509
|
+
}
|
|
244510
|
+
toStep() {
|
|
244511
|
+
return `ORIENTED_EDGE(${stepStr(this.name)},*,*,${this.edge},${this.orientation ? ".T." : ".F."})`;
|
|
244512
|
+
}
|
|
244513
|
+
};
|
|
244514
|
+
register("ORIENTED_EDGE", OrientedEdge.parse.bind(OrientedEdge));
|
|
244515
|
+
var VertexPoint = class _VertexPoint extends Entity {
|
|
244516
|
+
constructor(name, pnt) {
|
|
244517
|
+
super();
|
|
244518
|
+
this.name = name;
|
|
244519
|
+
this.pnt = pnt;
|
|
244520
|
+
}
|
|
244521
|
+
type = "VERTEX_POINT";
|
|
244522
|
+
static parse(a2, ctx) {
|
|
244523
|
+
const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
|
|
244524
|
+
return new _VertexPoint(name, ctx.parseRef(a2[1]));
|
|
244525
|
+
}
|
|
244526
|
+
toStep() {
|
|
244527
|
+
return `VERTEX_POINT(${this.name ? `'${this.name}'` : "''"},${this.pnt})`;
|
|
244528
|
+
}
|
|
244529
|
+
};
|
|
244530
|
+
register("VERTEX_POINT", VertexPoint.parse.bind(VertexPoint));
|
|
244531
|
+
var Unknown = class extends Entity {
|
|
244532
|
+
constructor(type, args) {
|
|
244533
|
+
super();
|
|
244534
|
+
this.type = type;
|
|
244535
|
+
this.args = args;
|
|
244536
|
+
}
|
|
244537
|
+
toStep() {
|
|
244538
|
+
if (this.args.length === 1 && this.args[0].startsWith("( ")) {
|
|
244539
|
+
const content = this.args[0].slice(2, -2).trim();
|
|
244540
|
+
const parts = content.split(/\s+(?=[A-Z_])/g);
|
|
244541
|
+
return `(
|
|
244542
|
+
${parts.join(`
|
|
244543
|
+
`)}
|
|
244544
|
+
)`;
|
|
244545
|
+
}
|
|
244546
|
+
return `${this.type}(${this.args.join(",")})`;
|
|
244547
|
+
}
|
|
244548
|
+
};
|
|
244549
|
+
function tokenizeSTEP(data) {
|
|
244550
|
+
const entities = [];
|
|
244551
|
+
const dataStart = data.indexOf("DATA;");
|
|
244552
|
+
const dataEnd = data.indexOf("ENDSEC;", dataStart);
|
|
244553
|
+
if (dataStart === -1 || dataEnd === -1) {
|
|
244554
|
+
throw new Error("Could not find DATA section in STEP file");
|
|
244555
|
+
}
|
|
244556
|
+
const dataSection = data.substring(dataStart + 5, dataEnd);
|
|
244557
|
+
const entityPattern = /#(\d+)\s*=\s*/g;
|
|
244558
|
+
let match;
|
|
244559
|
+
const entityStarts = [];
|
|
244560
|
+
while ((match = entityPattern.exec(dataSection)) !== null) {
|
|
244561
|
+
entityStarts.push({
|
|
244562
|
+
index: match.index,
|
|
244563
|
+
id: parseInt(match[1], 10)
|
|
244564
|
+
});
|
|
244565
|
+
}
|
|
244566
|
+
for (let i2 = 0;i2 < entityStarts.length; i2++) {
|
|
244567
|
+
const start = entityStarts[i2];
|
|
244568
|
+
const nextStart = i2 + 1 < entityStarts.length ? entityStarts[i2 + 1].index : dataSection.length;
|
|
244569
|
+
const entityText = dataSection.substring(start.index, nextStart);
|
|
244570
|
+
const semiIndex = entityText.indexOf(";");
|
|
244571
|
+
if (semiIndex === -1) {
|
|
244572
|
+
throw new Error(`Could not find closing semicolon for entity #${start.id}`);
|
|
244573
|
+
}
|
|
244574
|
+
const fullEntity = entityText.substring(0, semiIndex + 1);
|
|
244575
|
+
if (fullEntity.match(/#\d+\s*=\s*\(/)) {
|
|
244576
|
+
const complexMatch = fullEntity.match(/#\d+\s*=\s*\(([\s\S]*)\);/);
|
|
244577
|
+
if (!complexMatch) {
|
|
244578
|
+
throw new Error(`Could not parse complex entity: ${fullEntity.substring(0, 100)}`);
|
|
244579
|
+
}
|
|
244580
|
+
entities.push({
|
|
244581
|
+
id: eid(start.id),
|
|
244582
|
+
type: "Unknown",
|
|
244583
|
+
args: [`( ${complexMatch[1].trim()} )`]
|
|
244584
|
+
});
|
|
244585
|
+
} else {
|
|
244586
|
+
const match2 = fullEntity.match(/#\d+\s*=\s*([A-Z0-9_]+)\s*\(([\s\S]*)\);/);
|
|
244587
|
+
if (!match2) {
|
|
244588
|
+
throw new Error(`Could not parse entity: ${fullEntity.substring(0, 100)}`);
|
|
244589
|
+
}
|
|
244590
|
+
const type = match2[1].trim();
|
|
244591
|
+
const argsBody = match2[2].trim();
|
|
244592
|
+
const args = splitArgs(argsBody);
|
|
244593
|
+
entities.push({ id: eid(start.id), type, args });
|
|
244594
|
+
}
|
|
244595
|
+
}
|
|
244596
|
+
return entities;
|
|
244597
|
+
}
|
|
244598
|
+
function splitArgs(s2) {
|
|
244599
|
+
const out = [];
|
|
244600
|
+
let buf = "";
|
|
244601
|
+
let depth = 0;
|
|
244602
|
+
let inStr = false;
|
|
244603
|
+
for (let i2 = 0;i2 < s2.length; i2++) {
|
|
244604
|
+
const c3 = s2[i2];
|
|
244605
|
+
if (c3 === "'" && s2[i2 - 1] !== "\\")
|
|
244606
|
+
inStr = !inStr;
|
|
244607
|
+
if (!inStr) {
|
|
244608
|
+
if (c3 === "(")
|
|
244609
|
+
depth++;
|
|
244610
|
+
if (c3 === ")")
|
|
244611
|
+
depth--;
|
|
244612
|
+
if (c3 === "," && depth === 0) {
|
|
244613
|
+
out.push(buf.trim());
|
|
244614
|
+
buf = "";
|
|
244615
|
+
continue;
|
|
244616
|
+
}
|
|
244617
|
+
}
|
|
244618
|
+
buf += c3;
|
|
244619
|
+
}
|
|
244620
|
+
if (buf.trim())
|
|
244621
|
+
out.push(buf.trim());
|
|
244622
|
+
return out;
|
|
244623
|
+
}
|
|
244624
|
+
function parseRepository(data) {
|
|
244625
|
+
const repo = new Repository;
|
|
244626
|
+
const ctx = {
|
|
244627
|
+
repo,
|
|
244628
|
+
parseRef(_tok) {
|
|
244629
|
+
const n3 = +_tok.replace("#", "").trim();
|
|
244630
|
+
return new Ref(eid(n3));
|
|
244631
|
+
},
|
|
244632
|
+
parseNumber(tok) {
|
|
244633
|
+
return Number(tok);
|
|
244634
|
+
},
|
|
244635
|
+
parseString(tok) {
|
|
244636
|
+
const m3 = tok.match(/^'(.*)'$/);
|
|
244637
|
+
if (!m3)
|
|
244638
|
+
throw new Error(`Expected string: ${tok}`);
|
|
244639
|
+
return m3[1].replace(/''/g, "'");
|
|
244640
|
+
}
|
|
244641
|
+
};
|
|
244642
|
+
for (const row of tokenizeSTEP(data)) {
|
|
244643
|
+
const parser = getParser(row.type);
|
|
244644
|
+
if (!parser) {
|
|
244645
|
+
repo.set(row.id, new Unknown(row.type, row.args));
|
|
244646
|
+
continue;
|
|
244647
|
+
}
|
|
244648
|
+
const entity = parser(row.args, ctx);
|
|
244649
|
+
repo.set(row.id, entity);
|
|
244650
|
+
}
|
|
244651
|
+
return repo;
|
|
244652
|
+
}
|
|
244653
|
+
|
|
244654
|
+
// node_modules/stepts/lib/core/EntityId.ts
|
|
244655
|
+
var eid2 = (n3) => n3;
|
|
244656
|
+
|
|
244657
|
+
// node_modules/circuit-json-to-step/dist/index.js
|
|
244658
|
+
function createBoxTriangles(box2) {
|
|
244659
|
+
const { center: center2, size: size2 } = box2;
|
|
244660
|
+
const halfX = size2.x / 2;
|
|
244661
|
+
const halfY = size2.y / 2;
|
|
244662
|
+
const halfZ = size2.z / 2;
|
|
244663
|
+
const corners = [
|
|
244664
|
+
{ x: -halfX, y: -halfY, z: -halfZ },
|
|
244665
|
+
{ x: halfX, y: -halfY, z: -halfZ },
|
|
244666
|
+
{ x: halfX, y: halfY, z: -halfZ },
|
|
244667
|
+
{ x: -halfX, y: halfY, z: -halfZ },
|
|
244668
|
+
{ x: -halfX, y: -halfY, z: halfZ },
|
|
244669
|
+
{ x: halfX, y: -halfY, z: halfZ },
|
|
244670
|
+
{ x: halfX, y: halfY, z: halfZ },
|
|
244671
|
+
{ x: -halfX, y: halfY, z: halfZ }
|
|
244672
|
+
].map((p3) => ({ x: p3.x + center2.x, y: p3.y + center2.y, z: p3.z + center2.z }));
|
|
244673
|
+
const triangles = [
|
|
244674
|
+
{
|
|
244675
|
+
vertices: [corners[0], corners[1], corners[2]],
|
|
244676
|
+
normal: { x: 0, y: 0, z: -1 }
|
|
244677
|
+
},
|
|
244678
|
+
{
|
|
244679
|
+
vertices: [corners[0], corners[2], corners[3]],
|
|
244680
|
+
normal: { x: 0, y: 0, z: -1 }
|
|
244681
|
+
},
|
|
244682
|
+
{
|
|
244683
|
+
vertices: [corners[4], corners[6], corners[5]],
|
|
244684
|
+
normal: { x: 0, y: 0, z: 1 }
|
|
244685
|
+
},
|
|
244686
|
+
{
|
|
244687
|
+
vertices: [corners[4], corners[7], corners[6]],
|
|
244688
|
+
normal: { x: 0, y: 0, z: 1 }
|
|
244689
|
+
},
|
|
244690
|
+
{
|
|
244691
|
+
vertices: [corners[0], corners[5], corners[1]],
|
|
244692
|
+
normal: { x: 0, y: -1, z: 0 }
|
|
244693
|
+
},
|
|
244694
|
+
{
|
|
244695
|
+
vertices: [corners[0], corners[4], corners[5]],
|
|
244696
|
+
normal: { x: 0, y: -1, z: 0 }
|
|
244697
|
+
},
|
|
244698
|
+
{
|
|
244699
|
+
vertices: [corners[2], corners[6], corners[7]],
|
|
244700
|
+
normal: { x: 0, y: 1, z: 0 }
|
|
244701
|
+
},
|
|
244702
|
+
{
|
|
244703
|
+
vertices: [corners[2], corners[7], corners[3]],
|
|
244704
|
+
normal: { x: 0, y: 1, z: 0 }
|
|
244705
|
+
},
|
|
244706
|
+
{
|
|
244707
|
+
vertices: [corners[0], corners[3], corners[7]],
|
|
244708
|
+
normal: { x: -1, y: 0, z: 0 }
|
|
244709
|
+
},
|
|
244710
|
+
{
|
|
244711
|
+
vertices: [corners[0], corners[7], corners[4]],
|
|
244712
|
+
normal: { x: -1, y: 0, z: 0 }
|
|
244713
|
+
},
|
|
244714
|
+
{
|
|
244715
|
+
vertices: [corners[1], corners[6], corners[2]],
|
|
244716
|
+
normal: { x: 1, y: 0, z: 0 }
|
|
244717
|
+
},
|
|
244718
|
+
{
|
|
244719
|
+
vertices: [corners[1], corners[5], corners[6]],
|
|
244720
|
+
normal: { x: 1, y: 0, z: 0 }
|
|
244721
|
+
}
|
|
244722
|
+
];
|
|
244723
|
+
return triangles;
|
|
244724
|
+
}
|
|
244725
|
+
function createStepFacesFromTriangles(repo, triangles) {
|
|
244726
|
+
const faces = [];
|
|
244727
|
+
for (const triangle of triangles) {
|
|
244728
|
+
const v12 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", triangle.vertices[0].x, triangle.vertices[0].y, triangle.vertices[0].z))));
|
|
244729
|
+
const v23 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", triangle.vertices[1].x, triangle.vertices[1].y, triangle.vertices[1].z))));
|
|
244730
|
+
const v3 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", triangle.vertices[2].x, triangle.vertices[2].y, triangle.vertices[2].z))));
|
|
244731
|
+
const p12 = v12.resolve(repo).pnt.resolve(repo);
|
|
244732
|
+
const p23 = v23.resolve(repo).pnt.resolve(repo);
|
|
244733
|
+
const createEdge = (vStart, vEnd) => {
|
|
244734
|
+
const pStart = vStart.resolve(repo).pnt.resolve(repo);
|
|
244735
|
+
const pEnd = vEnd.resolve(repo).pnt.resolve(repo);
|
|
244736
|
+
const dir = repo.add(new Direction("", pEnd.x - pStart.x, pEnd.y - pStart.y, pEnd.z - pStart.z));
|
|
244737
|
+
const vec = repo.add(new Vector3("", dir, 1));
|
|
244738
|
+
const line2 = repo.add(new Line3("", vStart.resolve(repo).pnt, vec));
|
|
244739
|
+
return repo.add(new EdgeCurve("", vStart, vEnd, line2, true));
|
|
244740
|
+
};
|
|
244741
|
+
const edge1 = createEdge(v12, v23);
|
|
244742
|
+
const edge2 = createEdge(v23, v3);
|
|
244743
|
+
const edge3 = createEdge(v3, v12);
|
|
244744
|
+
const edgeLoop = repo.add(new EdgeLoop("", [
|
|
244745
|
+
repo.add(new OrientedEdge("", edge1, true)),
|
|
244746
|
+
repo.add(new OrientedEdge("", edge2, true)),
|
|
244747
|
+
repo.add(new OrientedEdge("", edge3, true))
|
|
244748
|
+
]));
|
|
244749
|
+
const normalDir = repo.add(new Direction("", triangle.normal.x, triangle.normal.y, triangle.normal.z));
|
|
244750
|
+
const refX = p23.x - p12.x;
|
|
244751
|
+
const refY = p23.y - p12.y;
|
|
244752
|
+
const refZ = p23.z - p12.z;
|
|
244753
|
+
const refDir = repo.add(new Direction("", refX, refY, refZ));
|
|
244754
|
+
const placement = repo.add(new Axis2Placement3D("", v12.resolve(repo).pnt, normalDir, refDir));
|
|
244755
|
+
const plane = repo.add(new Plane("", placement));
|
|
244756
|
+
const face = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", edgeLoop, true))], plane, true));
|
|
244757
|
+
faces.push(face);
|
|
244758
|
+
}
|
|
244759
|
+
return faces;
|
|
244760
|
+
}
|
|
244761
|
+
async function generateComponentMeshes(options) {
|
|
244762
|
+
const {
|
|
244763
|
+
repo,
|
|
244764
|
+
circuitJson,
|
|
244765
|
+
boardThickness,
|
|
244766
|
+
includeExternalMeshes = false,
|
|
244767
|
+
excludeCadComponentIds,
|
|
244768
|
+
excludePcbComponentIds,
|
|
244769
|
+
pcbComponentIdsWithStepUrl
|
|
244770
|
+
} = options;
|
|
244771
|
+
const solids = [];
|
|
244772
|
+
try {
|
|
244773
|
+
const filteredCircuitJson = circuitJson.filter((e4) => {
|
|
244774
|
+
if (e4.type === "pcb_board")
|
|
244775
|
+
return false;
|
|
244776
|
+
if (e4.type === "cad_component" && e4.cad_component_id && excludeCadComponentIds?.has(e4.cad_component_id)) {
|
|
244777
|
+
return false;
|
|
244778
|
+
}
|
|
244779
|
+
if (e4.type === "pcb_component" && e4.pcb_component_id && excludePcbComponentIds?.has(e4.pcb_component_id)) {
|
|
244780
|
+
return false;
|
|
244781
|
+
}
|
|
244782
|
+
if (e4.type === "cad_component" && e4.model_step_url) {
|
|
244783
|
+
return false;
|
|
244784
|
+
}
|
|
244785
|
+
if (e4.type === "cad_component" && e4.pcb_component_id && pcbComponentIdsWithStepUrl?.has(e4.pcb_component_id)) {
|
|
244786
|
+
return false;
|
|
244787
|
+
}
|
|
244788
|
+
return true;
|
|
244789
|
+
}).map((e4) => {
|
|
244790
|
+
if (!includeExternalMeshes && e4.type === "cad_component") {
|
|
244791
|
+
return {
|
|
244792
|
+
...e4,
|
|
244793
|
+
model_3mf_url: undefined,
|
|
244794
|
+
model_obj_url: undefined,
|
|
244795
|
+
model_stl_url: undefined,
|
|
244796
|
+
model_glb_url: undefined,
|
|
244797
|
+
model_gltf_url: undefined
|
|
244798
|
+
};
|
|
244799
|
+
}
|
|
244800
|
+
return e4;
|
|
244801
|
+
});
|
|
244802
|
+
const gltfModule = "circuit-json-to-gltf";
|
|
244803
|
+
const { convertCircuitJsonTo3D } = await import(gltfModule);
|
|
244804
|
+
const scene3d = await convertCircuitJsonTo3D(filteredCircuitJson, {
|
|
244805
|
+
boardThickness,
|
|
244806
|
+
renderBoardTextures: false
|
|
244807
|
+
});
|
|
244808
|
+
const allTriangles = [];
|
|
244809
|
+
for (const box2 of scene3d.boxes) {
|
|
244810
|
+
if (box2.mesh && "triangles" in box2.mesh) {
|
|
244811
|
+
allTriangles.push(...box2.mesh.triangles);
|
|
244812
|
+
} else {
|
|
244813
|
+
const boxTriangles = createBoxTriangles(box2);
|
|
244814
|
+
allTriangles.push(...boxTriangles);
|
|
244815
|
+
}
|
|
244816
|
+
}
|
|
244817
|
+
if (allTriangles.length > 0) {
|
|
244818
|
+
const transformedTriangles = allTriangles.map((tri) => ({
|
|
244819
|
+
vertices: tri.vertices.map((v3) => ({
|
|
244820
|
+
x: v3.x,
|
|
244821
|
+
y: v3.z,
|
|
244822
|
+
z: v3.y
|
|
244823
|
+
})),
|
|
244824
|
+
normal: {
|
|
244825
|
+
x: tri.normal.x,
|
|
244826
|
+
y: tri.normal.z,
|
|
244827
|
+
z: tri.normal.y
|
|
244828
|
+
}
|
|
244829
|
+
}));
|
|
244830
|
+
const componentFaces = createStepFacesFromTriangles(repo, transformedTriangles);
|
|
244831
|
+
const componentShell = repo.add(new ClosedShell("", componentFaces));
|
|
244832
|
+
const componentSolid = repo.add(new ManifoldSolidBrep("Components", componentShell));
|
|
244833
|
+
solids.push(componentSolid);
|
|
244834
|
+
}
|
|
244835
|
+
} catch (error) {
|
|
244836
|
+
console.warn("Failed to generate component mesh:", error);
|
|
244837
|
+
}
|
|
244838
|
+
return solids;
|
|
244839
|
+
}
|
|
244840
|
+
var EXCLUDED_ENTITY_TYPES = /* @__PURE__ */ new Set([
|
|
244841
|
+
"APPLICATION_CONTEXT",
|
|
244842
|
+
"APPLICATION_PROTOCOL_DEFINITION",
|
|
244843
|
+
"PRODUCT",
|
|
244844
|
+
"PRODUCT_CONTEXT",
|
|
244845
|
+
"PRODUCT_DEFINITION",
|
|
244846
|
+
"PRODUCT_DEFINITION_FORMATION",
|
|
244847
|
+
"PRODUCT_DEFINITION_CONTEXT",
|
|
244848
|
+
"PRODUCT_DEFINITION_SHAPE",
|
|
244849
|
+
"SHAPE_DEFINITION_REPRESENTATION",
|
|
244850
|
+
"ADVANCED_BREP_SHAPE_REPRESENTATION",
|
|
244851
|
+
"MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION",
|
|
244852
|
+
"PRESENTATION_STYLE_ASSIGNMENT",
|
|
244853
|
+
"SURFACE_STYLE_USAGE",
|
|
244854
|
+
"SURFACE_SIDE_STYLE",
|
|
244855
|
+
"SURFACE_STYLE_FILL_AREA",
|
|
244856
|
+
"FILL_AREA_STYLE",
|
|
244857
|
+
"FILL_AREA_STYLE_COLOUR",
|
|
244858
|
+
"COLOUR_RGB",
|
|
244859
|
+
"STYLED_ITEM",
|
|
244860
|
+
"CURVE_STYLE",
|
|
244861
|
+
"DRAUGHTING_PRE_DEFINED_CURVE_FONT",
|
|
244862
|
+
"PRODUCT_RELATED_PRODUCT_CATEGORY",
|
|
244863
|
+
"NEXT_ASSEMBLY_USAGE_OCCURRENCE",
|
|
244864
|
+
"CONTEXT_DEPENDENT_SHAPE_REPRESENTATION",
|
|
244865
|
+
"ITEM_DEFINED_TRANSFORMATION"
|
|
244866
|
+
]);
|
|
244867
|
+
function asVector3(value) {
|
|
244868
|
+
return {
|
|
244869
|
+
x: value?.x ?? 0,
|
|
244870
|
+
y: value?.y ?? 0,
|
|
244871
|
+
z: value?.z ?? 0
|
|
244872
|
+
};
|
|
244873
|
+
}
|
|
244874
|
+
function toRadians(rotation4) {
|
|
244875
|
+
const factor = Math.PI / 180;
|
|
244876
|
+
return {
|
|
244877
|
+
x: rotation4.x * factor,
|
|
244878
|
+
y: rotation4.y * factor,
|
|
244879
|
+
z: rotation4.z * factor
|
|
244880
|
+
};
|
|
244881
|
+
}
|
|
244882
|
+
function transformPoint(point5, rotation4, translation) {
|
|
244883
|
+
const rotated = rotateVector(point5, rotation4);
|
|
244884
|
+
return [
|
|
244885
|
+
rotated[0] + translation.x,
|
|
244886
|
+
rotated[1] + translation.y,
|
|
244887
|
+
rotated[2] + translation.z
|
|
244888
|
+
];
|
|
244889
|
+
}
|
|
244890
|
+
function transformDirection(vector2, rotation4) {
|
|
244891
|
+
return rotateVector(vector2, rotation4);
|
|
244892
|
+
}
|
|
244893
|
+
function rotateVector(vector2, rotation4) {
|
|
244894
|
+
let [x3, y4, z21] = vector2;
|
|
244895
|
+
if (rotation4.x !== 0) {
|
|
244896
|
+
const cosX = Math.cos(rotation4.x);
|
|
244897
|
+
const sinX = Math.sin(rotation4.x);
|
|
244898
|
+
const y12 = y4 * cosX - z21 * sinX;
|
|
244899
|
+
const z110 = y4 * sinX + z21 * cosX;
|
|
244900
|
+
y4 = y12;
|
|
244901
|
+
z21 = z110;
|
|
244902
|
+
}
|
|
244903
|
+
if (rotation4.y !== 0) {
|
|
244904
|
+
const cosY = Math.cos(rotation4.y);
|
|
244905
|
+
const sinY = Math.sin(rotation4.y);
|
|
244906
|
+
const x12 = x3 * cosY + z21 * sinY;
|
|
244907
|
+
const z110 = -x3 * sinY + z21 * cosY;
|
|
244908
|
+
x3 = x12;
|
|
244909
|
+
z21 = z110;
|
|
244910
|
+
}
|
|
244911
|
+
if (rotation4.z !== 0) {
|
|
244912
|
+
const cosZ = Math.cos(rotation4.z);
|
|
244913
|
+
const sinZ = Math.sin(rotation4.z);
|
|
244914
|
+
const x12 = x3 * cosZ - y4 * sinZ;
|
|
244915
|
+
const y12 = x3 * sinZ + y4 * cosZ;
|
|
244916
|
+
x3 = x12;
|
|
244917
|
+
y4 = y12;
|
|
244918
|
+
}
|
|
244919
|
+
return [x3, y4, z21];
|
|
244920
|
+
}
|
|
244921
|
+
async function readStepFile(modelUrl) {
|
|
244922
|
+
if (!/^https?:\/\//i.test(modelUrl)) {
|
|
244923
|
+
throw new Error(`Only HTTP(S) URLs are supported. For local files, read the file content and pass it directly. Received: ${modelUrl}`);
|
|
244924
|
+
}
|
|
244925
|
+
const globalFetch = globalThis.fetch;
|
|
244926
|
+
if (!globalFetch) {
|
|
244927
|
+
throw new Error("fetch is not available in this environment");
|
|
244928
|
+
}
|
|
244929
|
+
const res2 = await globalFetch(modelUrl);
|
|
244930
|
+
if (!res2.ok) {
|
|
244931
|
+
throw new Error(`HTTP ${res2.status} ${res2.statusText}`);
|
|
244932
|
+
}
|
|
244933
|
+
return await res2.text();
|
|
244934
|
+
}
|
|
244935
|
+
async function mergeExternalStepModels(options) {
|
|
244936
|
+
const { repo, circuitJson, boardThickness, fsMap } = options;
|
|
244937
|
+
const cadComponents = circuitJson.filter((item) => item?.type === "cad_component" && typeof item.model_step_url === "string");
|
|
244938
|
+
const pcbComponentMap = /* @__PURE__ */ new Map;
|
|
244939
|
+
for (const item of circuitJson) {
|
|
244940
|
+
if (item?.type === "pcb_component" && item.pcb_component_id) {
|
|
244941
|
+
pcbComponentMap.set(item.pcb_component_id, item);
|
|
244942
|
+
}
|
|
244943
|
+
}
|
|
244944
|
+
const solids = [];
|
|
244945
|
+
const handledComponentIds = /* @__PURE__ */ new Set;
|
|
244946
|
+
const handledPcbComponentIds = /* @__PURE__ */ new Set;
|
|
244947
|
+
for (const component of cadComponents) {
|
|
244948
|
+
const componentId = component.cad_component_id ?? "";
|
|
244949
|
+
const stepUrl = component.model_step_url;
|
|
244950
|
+
try {
|
|
244951
|
+
const stepText = fsMap?.[stepUrl] ?? await readStepFile(stepUrl);
|
|
244952
|
+
if (!stepText.trim()) {
|
|
244953
|
+
throw new Error("STEP file is empty");
|
|
244954
|
+
}
|
|
244955
|
+
const pcbComponent = component.pcb_component_id ? pcbComponentMap.get(component.pcb_component_id) : undefined;
|
|
244956
|
+
const layer = pcbComponent?.layer?.toLowerCase();
|
|
244957
|
+
const transform2 = {
|
|
244958
|
+
translation: asVector3(component.position),
|
|
244959
|
+
rotation: asVector3(component.rotation)
|
|
244960
|
+
};
|
|
244961
|
+
const componentSolids = mergeSingleStepModel(repo, stepText, transform2, {
|
|
244962
|
+
layer,
|
|
244963
|
+
boardThickness
|
|
244964
|
+
});
|
|
244965
|
+
if (componentSolids.length > 0) {
|
|
244966
|
+
if (componentId) {
|
|
244967
|
+
handledComponentIds.add(componentId);
|
|
244968
|
+
}
|
|
244969
|
+
const pcbComponentId = component.pcb_component_id;
|
|
244970
|
+
if (pcbComponentId) {
|
|
244971
|
+
handledPcbComponentIds.add(pcbComponentId);
|
|
244972
|
+
}
|
|
244973
|
+
}
|
|
244974
|
+
solids.push(...componentSolids);
|
|
244975
|
+
} catch (error) {
|
|
244976
|
+
console.warn(`Failed to merge STEP model from ${stepUrl}:`, error);
|
|
244977
|
+
}
|
|
244978
|
+
}
|
|
244979
|
+
return { solids, handledComponentIds, handledPcbComponentIds };
|
|
244980
|
+
}
|
|
244981
|
+
function mergeSingleStepModel(targetRepo, stepText, transform2, placement) {
|
|
244982
|
+
const sourceRepo = parseRepository(stepText);
|
|
244983
|
+
let entries = sourceRepo.entries().map(([id2, entity]) => [Number(id2), entity]).filter(([, entity]) => !EXCLUDED_ENTITY_TYPES.has(entity.type));
|
|
244984
|
+
entries = pruneInvalidEntries(entries);
|
|
244985
|
+
adjustTransformForPlacement(entries, transform2, placement);
|
|
244986
|
+
applyTransform(entries, transform2);
|
|
244987
|
+
const idMapping = allocateIds(targetRepo, entries);
|
|
244988
|
+
remapReferences(entries, idMapping);
|
|
244989
|
+
for (const [oldId, entity] of entries) {
|
|
244990
|
+
const mappedId = idMapping.get(oldId);
|
|
244991
|
+
if (mappedId === undefined)
|
|
244992
|
+
continue;
|
|
244993
|
+
targetRepo.set(eid2(mappedId), entity);
|
|
244994
|
+
}
|
|
244995
|
+
const solids = [];
|
|
244996
|
+
for (const [oldId, entity] of entries) {
|
|
244997
|
+
if (entity instanceof ManifoldSolidBrep) {
|
|
244998
|
+
const mappedId = idMapping.get(oldId);
|
|
244999
|
+
if (mappedId !== undefined) {
|
|
245000
|
+
solids.push(new Ref(eid2(mappedId)));
|
|
245001
|
+
}
|
|
245002
|
+
}
|
|
245003
|
+
}
|
|
245004
|
+
return solids;
|
|
245005
|
+
}
|
|
245006
|
+
function adjustTransformForPlacement(entries, transform2, placement) {
|
|
245007
|
+
if (!placement)
|
|
245008
|
+
return;
|
|
245009
|
+
const points = [];
|
|
245010
|
+
for (const [, entity] of entries) {
|
|
245011
|
+
if (entity instanceof CartesianPoint) {
|
|
245012
|
+
points.push([entity.x, entity.y, entity.z]);
|
|
245013
|
+
}
|
|
245014
|
+
}
|
|
245015
|
+
if (!points.length)
|
|
245016
|
+
return;
|
|
245017
|
+
const rotationRadians = toRadians(transform2.rotation);
|
|
245018
|
+
let minX = Infinity;
|
|
245019
|
+
let minY = Infinity;
|
|
245020
|
+
let minZ = Infinity;
|
|
245021
|
+
let maxX = -Infinity;
|
|
245022
|
+
let maxY = -Infinity;
|
|
245023
|
+
let maxZ = -Infinity;
|
|
245024
|
+
for (const point5 of points) {
|
|
245025
|
+
const [x3, y4, z21] = rotateVector(point5, rotationRadians);
|
|
245026
|
+
if (x3 < minX)
|
|
245027
|
+
minX = x3;
|
|
245028
|
+
if (y4 < minY)
|
|
245029
|
+
minY = y4;
|
|
245030
|
+
if (z21 < minZ)
|
|
245031
|
+
minZ = z21;
|
|
245032
|
+
if (x3 > maxX)
|
|
245033
|
+
maxX = x3;
|
|
245034
|
+
if (y4 > maxY)
|
|
245035
|
+
maxY = y4;
|
|
245036
|
+
if (z21 > maxZ)
|
|
245037
|
+
maxZ = z21;
|
|
245038
|
+
}
|
|
245039
|
+
if (!Number.isFinite(minX))
|
|
245040
|
+
return;
|
|
245041
|
+
const center2 = {
|
|
245042
|
+
x: (minX + maxX) / 2,
|
|
245043
|
+
y: (minY + maxY) / 2,
|
|
245044
|
+
z: (minZ + maxZ) / 2
|
|
245045
|
+
};
|
|
245046
|
+
const normalizedLayer = placement.layer?.toLowerCase() === "bottom" ? "bottom" : "top";
|
|
245047
|
+
const boardThickness = placement.boardThickness ?? 0;
|
|
245048
|
+
const targetX = transform2.translation.x;
|
|
245049
|
+
const targetY = transform2.translation.y;
|
|
245050
|
+
const targetZ = transform2.translation.z;
|
|
245051
|
+
const THROUGH_HOLE_Z_TOLERANCE = 0.001;
|
|
245052
|
+
const isThroughHoleComponent = minZ < -THROUGH_HOLE_Z_TOLERANCE && maxZ > THROUGH_HOLE_Z_TOLERANCE;
|
|
245053
|
+
transform2.translation.x = targetX - center2.x;
|
|
245054
|
+
transform2.translation.y = targetY - center2.y;
|
|
245055
|
+
if (isThroughHoleComponent) {
|
|
245056
|
+
transform2.translation.z = boardThickness;
|
|
245057
|
+
}
|
|
245058
|
+
if (!isThroughHoleComponent && boardThickness > 0) {
|
|
245059
|
+
const halfThickness = boardThickness / 2;
|
|
245060
|
+
const offsetZ = targetZ - halfThickness;
|
|
245061
|
+
if (normalizedLayer === "bottom") {
|
|
245062
|
+
transform2.translation.z = -maxZ + offsetZ;
|
|
245063
|
+
transform2.rotation.x = normalizeDegrees2(transform2.rotation.x + 180);
|
|
245064
|
+
} else {
|
|
245065
|
+
transform2.translation.z = boardThickness - minZ + offsetZ;
|
|
245066
|
+
}
|
|
245067
|
+
} else if (!isThroughHoleComponent) {
|
|
245068
|
+
transform2.translation.z = targetZ - center2.z;
|
|
245069
|
+
}
|
|
245070
|
+
}
|
|
245071
|
+
function normalizeDegrees2(value) {
|
|
245072
|
+
const wrapped = value % 360;
|
|
245073
|
+
return wrapped < 0 ? wrapped + 360 : wrapped;
|
|
245074
|
+
}
|
|
245075
|
+
function pruneInvalidEntries(entries) {
|
|
245076
|
+
let remaining = entries.slice();
|
|
245077
|
+
let remainingIds = new Set(remaining.map(([id2]) => id2));
|
|
245078
|
+
let changed = true;
|
|
245079
|
+
while (changed) {
|
|
245080
|
+
changed = false;
|
|
245081
|
+
const toRemove = /* @__PURE__ */ new Set;
|
|
245082
|
+
for (const [entityId, entity] of remaining) {
|
|
245083
|
+
const refs = collectReferencedIds(entity);
|
|
245084
|
+
for (const refId of refs) {
|
|
245085
|
+
if (!remainingIds.has(refId)) {
|
|
245086
|
+
toRemove.add(entityId);
|
|
245087
|
+
break;
|
|
245088
|
+
}
|
|
245089
|
+
}
|
|
245090
|
+
}
|
|
245091
|
+
if (toRemove.size > 0) {
|
|
245092
|
+
changed = true;
|
|
245093
|
+
remaining = remaining.filter(([id2]) => !toRemove.has(id2));
|
|
245094
|
+
remainingIds = new Set(remaining.map(([id2]) => id2));
|
|
245095
|
+
}
|
|
245096
|
+
}
|
|
245097
|
+
return remaining;
|
|
245098
|
+
}
|
|
245099
|
+
function collectReferencedIds(entity) {
|
|
245100
|
+
const result = /* @__PURE__ */ new Set;
|
|
245101
|
+
collectReferencedIdsRecursive(entity, result, /* @__PURE__ */ new Set);
|
|
245102
|
+
return result;
|
|
245103
|
+
}
|
|
245104
|
+
function collectReferencedIdsRecursive(value, result, seen) {
|
|
245105
|
+
if (!value)
|
|
245106
|
+
return;
|
|
245107
|
+
if (value instanceof Ref) {
|
|
245108
|
+
result.add(Number(value.id));
|
|
245109
|
+
return;
|
|
245110
|
+
}
|
|
245111
|
+
if (value instanceof Unknown) {
|
|
245112
|
+
for (const arg of value.args) {
|
|
245113
|
+
arg.replace(/#(\d+)/g, (_4, num) => {
|
|
245114
|
+
result.add(Number(num));
|
|
245115
|
+
return _4;
|
|
245116
|
+
});
|
|
245117
|
+
}
|
|
245118
|
+
return;
|
|
245119
|
+
}
|
|
245120
|
+
if (Array.isArray(value)) {
|
|
245121
|
+
for (const item of value) {
|
|
245122
|
+
collectReferencedIdsRecursive(item, result, seen);
|
|
245123
|
+
}
|
|
245124
|
+
return;
|
|
245125
|
+
}
|
|
245126
|
+
if (typeof value === "object") {
|
|
245127
|
+
if (seen.has(value)) {
|
|
245128
|
+
return;
|
|
245129
|
+
}
|
|
245130
|
+
seen.add(value);
|
|
245131
|
+
for (const entry of Object.values(value)) {
|
|
245132
|
+
collectReferencedIdsRecursive(entry, result, seen);
|
|
245133
|
+
}
|
|
245134
|
+
}
|
|
245135
|
+
}
|
|
245136
|
+
function applyTransform(entries, transform2) {
|
|
245137
|
+
const rotation4 = toRadians(transform2.rotation);
|
|
245138
|
+
for (const [, entity] of entries) {
|
|
245139
|
+
if (entity instanceof CartesianPoint) {
|
|
245140
|
+
const [x3, y4, z21] = transformPoint([entity.x, entity.y, entity.z], rotation4, transform2.translation);
|
|
245141
|
+
entity.x = x3;
|
|
245142
|
+
entity.y = y4;
|
|
245143
|
+
entity.z = z21;
|
|
245144
|
+
} else if (entity instanceof Direction) {
|
|
245145
|
+
const [dx2, dy2, dz] = transformDirection([entity.dx, entity.dy, entity.dz], rotation4);
|
|
245146
|
+
const length2 = Math.hypot(dx2, dy2, dz);
|
|
245147
|
+
if (length2 > 0) {
|
|
245148
|
+
entity.dx = dx2 / length2;
|
|
245149
|
+
entity.dy = dy2 / length2;
|
|
245150
|
+
entity.dz = dz / length2;
|
|
245151
|
+
}
|
|
245152
|
+
}
|
|
245153
|
+
}
|
|
245154
|
+
}
|
|
245155
|
+
function allocateIds(targetRepo, entries) {
|
|
245156
|
+
let nextId = getNextEntityId(targetRepo);
|
|
245157
|
+
const idMapping = /* @__PURE__ */ new Map;
|
|
245158
|
+
for (const [oldId] of entries) {
|
|
245159
|
+
idMapping.set(oldId, nextId);
|
|
245160
|
+
nextId += 1;
|
|
245161
|
+
}
|
|
245162
|
+
return idMapping;
|
|
245163
|
+
}
|
|
245164
|
+
function getNextEntityId(repo) {
|
|
245165
|
+
let maxId = 0;
|
|
245166
|
+
for (const [id2] of repo.entries()) {
|
|
245167
|
+
const numericId = Number(id2);
|
|
245168
|
+
if (numericId > maxId) {
|
|
245169
|
+
maxId = numericId;
|
|
245170
|
+
}
|
|
245171
|
+
}
|
|
245172
|
+
return maxId + 1;
|
|
245173
|
+
}
|
|
245174
|
+
function remapReferences(entries, idMapping) {
|
|
245175
|
+
for (const [, entity] of entries) {
|
|
245176
|
+
remapValue(entity, idMapping, /* @__PURE__ */ new Set);
|
|
245177
|
+
}
|
|
245178
|
+
}
|
|
245179
|
+
function remapValue(value, idMapping, seen) {
|
|
245180
|
+
if (!value)
|
|
245181
|
+
return;
|
|
245182
|
+
if (value instanceof Ref) {
|
|
245183
|
+
const mapped = idMapping.get(Number(value.id));
|
|
245184
|
+
if (mapped !== undefined) {
|
|
245185
|
+
value.id = eid2(mapped);
|
|
245186
|
+
}
|
|
245187
|
+
return;
|
|
245188
|
+
}
|
|
245189
|
+
if (value instanceof Unknown) {
|
|
245190
|
+
value.args = value.args.map((arg) => arg.replace(/#(\d+)/g, (match, num) => {
|
|
245191
|
+
const mapped = idMapping.get(Number(num));
|
|
245192
|
+
return mapped !== undefined ? `#${mapped}` : match;
|
|
245193
|
+
}));
|
|
245194
|
+
return;
|
|
245195
|
+
}
|
|
245196
|
+
if (Array.isArray(value)) {
|
|
245197
|
+
for (const item of value) {
|
|
245198
|
+
remapValue(item, idMapping, seen);
|
|
245199
|
+
}
|
|
245200
|
+
return;
|
|
245201
|
+
}
|
|
245202
|
+
if (typeof value === "object") {
|
|
245203
|
+
if (seen.has(value))
|
|
245204
|
+
return;
|
|
245205
|
+
seen.add(value);
|
|
245206
|
+
for (const key of Object.keys(value)) {
|
|
245207
|
+
remapValue(value[key], idMapping, seen);
|
|
245208
|
+
}
|
|
245209
|
+
}
|
|
245210
|
+
}
|
|
245211
|
+
function normalizeStepNumericExponents(stepText) {
|
|
245212
|
+
return stepText.replace(/(-?(?:\d+\.\d*|\.\d+|\d+))e([+-]?\d+)/g, (_match, mantissa, exponent) => `${mantissa}E${exponent}`);
|
|
245213
|
+
}
|
|
245214
|
+
var package_default4 = {
|
|
245215
|
+
name: "circuit-json-to-step",
|
|
245216
|
+
main: "dist/index.js",
|
|
245217
|
+
version: "0.0.18",
|
|
245218
|
+
type: "module",
|
|
245219
|
+
scripts: {
|
|
245220
|
+
"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"' {} \\;`,
|
|
245221
|
+
test: "bun test",
|
|
245222
|
+
"test:update-snapshots": "BUN_UPDATE_SNAPSHOTS=1 bun test",
|
|
245223
|
+
build: "tsup-node ./lib/index.ts --format esm --dts",
|
|
245224
|
+
format: "biome format --write .",
|
|
245225
|
+
"format:check": "biome format .",
|
|
245226
|
+
start: "bun site/index.html",
|
|
245227
|
+
"build:site": "bun build site/index.html --outdir=site-export"
|
|
245228
|
+
},
|
|
245229
|
+
devDependencies: {
|
|
245230
|
+
"@biomejs/biome": "^2.3.8",
|
|
245231
|
+
"@resvg/resvg-js": "^2.6.2",
|
|
245232
|
+
"@resvg/resvg-wasm": "^2.6.2",
|
|
245233
|
+
"@tscircuit/circuit-json-util": "^0.0.75",
|
|
245234
|
+
"@types/bun": "latest",
|
|
245235
|
+
"circuit-json": "^0.0.286",
|
|
245236
|
+
"looks-same": "^10.0.1",
|
|
245237
|
+
"occt-import-js": "^0.0.23",
|
|
245238
|
+
poppygl: "^0.0.17",
|
|
245239
|
+
stepts: "^0.0.3",
|
|
245240
|
+
tsup: "^8.5.0"
|
|
245241
|
+
},
|
|
245242
|
+
peerDependencies: {
|
|
245243
|
+
"@tscircuit/circuit-json-util": "*",
|
|
245244
|
+
typescript: "^5"
|
|
245245
|
+
},
|
|
245246
|
+
dependencies: {
|
|
245247
|
+
"circuit-json-to-connectivity-map": "^0.0.22",
|
|
245248
|
+
"circuit-json-to-gltf": "^0.0.87",
|
|
245249
|
+
"circuit-to-svg": "^0.0.327",
|
|
245250
|
+
"schematic-symbols": "^0.0.202"
|
|
245251
|
+
}
|
|
245252
|
+
};
|
|
245253
|
+
var VERSION = package_default4.version;
|
|
245254
|
+
function getPillGeometry(hole) {
|
|
245255
|
+
const centerX = typeof hole.x === "number" ? hole.x : hole.x.value;
|
|
245256
|
+
const centerY = typeof hole.y === "number" ? hole.y : hole.y.value;
|
|
245257
|
+
const width = hole.hole_width;
|
|
245258
|
+
const height = hole.hole_height;
|
|
245259
|
+
const ccwRotation = hole.ccw_rotation ?? 0;
|
|
245260
|
+
const rotation4 = ccwRotation * Math.PI / 180;
|
|
245261
|
+
const isHorizontal2 = width >= height;
|
|
245262
|
+
const radius = Math.min(width, height) / 2;
|
|
245263
|
+
const straightHalfLength = Math.abs(width - height) / 2;
|
|
245264
|
+
return {
|
|
245265
|
+
centerX,
|
|
245266
|
+
centerY,
|
|
245267
|
+
width,
|
|
245268
|
+
height,
|
|
245269
|
+
rotation: rotation4,
|
|
245270
|
+
radius,
|
|
245271
|
+
straightHalfLength,
|
|
245272
|
+
isHorizontal: isHorizontal2
|
|
245273
|
+
};
|
|
245274
|
+
}
|
|
245275
|
+
function rotatePoint3(x3, y4, centerX, centerY, angle) {
|
|
245276
|
+
const cos2 = Math.cos(angle);
|
|
245277
|
+
const sin2 = Math.sin(angle);
|
|
245278
|
+
const dx2 = x3 - centerX;
|
|
245279
|
+
const dy2 = y4 - centerY;
|
|
245280
|
+
return {
|
|
245281
|
+
x: centerX + dx2 * cos2 - dy2 * sin2,
|
|
245282
|
+
y: centerY + dx2 * sin2 + dy2 * cos2
|
|
245283
|
+
};
|
|
245284
|
+
}
|
|
245285
|
+
function createLineEdge(repo, v12, v23) {
|
|
245286
|
+
const p12 = v12.resolve(repo).pnt.resolve(repo);
|
|
245287
|
+
const p23 = v23.resolve(repo).pnt.resolve(repo);
|
|
245288
|
+
const dx2 = p23.x - p12.x;
|
|
245289
|
+
const dy2 = p23.y - p12.y;
|
|
245290
|
+
const dz = p23.z - p12.z;
|
|
245291
|
+
const length2 = Math.sqrt(dx2 * dx2 + dy2 * dy2 + dz * dz);
|
|
245292
|
+
if (length2 < 0.0000000001) {
|
|
245293
|
+
const dir2 = repo.add(new Direction("", 1, 0, 0));
|
|
245294
|
+
const vec2 = repo.add(new Vector3("", dir2, 0.0000000001));
|
|
245295
|
+
const line22 = repo.add(new Line3("", v12.resolve(repo).pnt, vec2));
|
|
245296
|
+
return repo.add(new EdgeCurve("", v12, v23, line22, true));
|
|
245297
|
+
}
|
|
245298
|
+
const dir = repo.add(new Direction("", dx2 / length2, dy2 / length2, dz / length2));
|
|
245299
|
+
const vec = repo.add(new Vector3("", dir, length2));
|
|
245300
|
+
const line2 = repo.add(new Line3("", v12.resolve(repo).pnt, vec));
|
|
245301
|
+
return repo.add(new EdgeCurve("", v12, v23, line2, true));
|
|
245302
|
+
}
|
|
245303
|
+
function createArcEdge(repo, centerX, centerY, z21, radius, startAngle, endAngle, rotation4, centerX0, centerY0) {
|
|
245304
|
+
const startX = centerX + radius * Math.cos(startAngle);
|
|
245305
|
+
const startY = centerY + radius * Math.sin(startAngle);
|
|
245306
|
+
const endX = centerX + radius * Math.cos(endAngle);
|
|
245307
|
+
const endY = centerY + radius * Math.sin(endAngle);
|
|
245308
|
+
const startRotated = rotatePoint3(startX, startY, centerX0, centerY0, rotation4);
|
|
245309
|
+
const endRotated = rotatePoint3(endX, endY, centerX0, centerY0, rotation4);
|
|
245310
|
+
const startVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", startRotated.x, startRotated.y, z21))));
|
|
245311
|
+
const endVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", endRotated.x, endRotated.y, z21))));
|
|
245312
|
+
const centerRotated = rotatePoint3(centerX, centerY, centerX0, centerY0, rotation4);
|
|
245313
|
+
const centerPoint = repo.add(new CartesianPoint("", centerRotated.x, centerRotated.y, z21));
|
|
245314
|
+
const normalDir = repo.add(new Direction("", 0, 0, -1));
|
|
245315
|
+
const refAngle = rotation4;
|
|
245316
|
+
const refDir = repo.add(new Direction("", Math.cos(refAngle), Math.sin(refAngle), 0));
|
|
245317
|
+
const placement = repo.add(new Axis2Placement3D("", centerPoint, normalDir, refDir));
|
|
245318
|
+
const circle2 = repo.add(new Circle3("", placement, radius));
|
|
245319
|
+
return repo.add(new EdgeCurve("", startVertex, endVertex, circle2, false));
|
|
245320
|
+
}
|
|
245321
|
+
function createPillHoleLoop(repo, hole, z21, xDir) {
|
|
245322
|
+
const geom = getPillGeometry(hole);
|
|
245323
|
+
const {
|
|
245324
|
+
centerX,
|
|
245325
|
+
centerY,
|
|
245326
|
+
radius,
|
|
245327
|
+
straightHalfLength,
|
|
245328
|
+
rotation: rotation4,
|
|
245329
|
+
isHorizontal: isHorizontal2
|
|
245330
|
+
} = geom;
|
|
245331
|
+
const edges = [];
|
|
245332
|
+
if (isHorizontal2) {
|
|
245333
|
+
const capOffset = straightHalfLength;
|
|
245334
|
+
const rightArc = createArcEdge(repo, centerX + capOffset, centerY, z21, radius, -Math.PI / 2, Math.PI / 2, rotation4, centerX, centerY);
|
|
245335
|
+
edges.push(rightArc);
|
|
245336
|
+
const bottomStart = rotatePoint3(centerX + capOffset, centerY - radius, centerX, centerY, rotation4);
|
|
245337
|
+
const bottomEnd = rotatePoint3(centerX - capOffset, centerY - radius, centerX, centerY, rotation4);
|
|
245338
|
+
const bottomV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, z21))));
|
|
245339
|
+
const bottomV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, z21))));
|
|
245340
|
+
edges.push(createLineEdge(repo, bottomV1, bottomV2));
|
|
245341
|
+
const leftArc = createArcEdge(repo, centerX - capOffset, centerY, z21, radius, Math.PI / 2, 3 * Math.PI / 2, rotation4, centerX, centerY);
|
|
245342
|
+
edges.push(leftArc);
|
|
245343
|
+
const topStart = rotatePoint3(centerX - capOffset, centerY + radius, centerX, centerY, rotation4);
|
|
245344
|
+
const topEnd = rotatePoint3(centerX + capOffset, centerY + radius, centerX, centerY, rotation4);
|
|
245345
|
+
const topV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", topStart.x, topStart.y, z21))));
|
|
245346
|
+
const topV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", topEnd.x, topEnd.y, z21))));
|
|
245347
|
+
edges.push(createLineEdge(repo, topV1, topV2));
|
|
245348
|
+
} else {
|
|
245349
|
+
const capOffset = straightHalfLength;
|
|
245350
|
+
const topArc = createArcEdge(repo, centerX, centerY - capOffset, z21, radius, Math.PI, 0, rotation4, centerX, centerY);
|
|
245351
|
+
edges.push(topArc);
|
|
245352
|
+
const rightStart = rotatePoint3(centerX + radius, centerY - capOffset, centerX, centerY, rotation4);
|
|
245353
|
+
const rightEnd = rotatePoint3(centerX + radius, centerY + capOffset, centerX, centerY, rotation4);
|
|
245354
|
+
const rightV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", rightStart.x, rightStart.y, z21))));
|
|
245355
|
+
const rightV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", rightEnd.x, rightEnd.y, z21))));
|
|
245356
|
+
edges.push(createLineEdge(repo, rightV1, rightV2));
|
|
245357
|
+
const bottomArc = createArcEdge(repo, centerX, centerY + capOffset, z21, radius, 0, Math.PI, rotation4, centerX, centerY);
|
|
245358
|
+
edges.push(bottomArc);
|
|
245359
|
+
const leftStart = rotatePoint3(centerX - radius, centerY + capOffset, centerX, centerY, rotation4);
|
|
245360
|
+
const leftEnd = rotatePoint3(centerX - radius, centerY - capOffset, centerX, centerY, rotation4);
|
|
245361
|
+
const leftV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", leftStart.x, leftStart.y, z21))));
|
|
245362
|
+
const leftV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", leftEnd.x, leftEnd.y, z21))));
|
|
245363
|
+
edges.push(createLineEdge(repo, leftV1, leftV2));
|
|
245364
|
+
}
|
|
245365
|
+
const orientedEdges = edges.map((edge) => repo.add(new OrientedEdge("", edge, true)));
|
|
245366
|
+
return repo.add(new EdgeLoop("", orientedEdges));
|
|
245367
|
+
}
|
|
245368
|
+
function createPillCylindricalFaces(repo, hole, boardThickness, xDir, zDir) {
|
|
245369
|
+
const geom = getPillGeometry(hole);
|
|
245370
|
+
const {
|
|
245371
|
+
centerX,
|
|
245372
|
+
centerY,
|
|
245373
|
+
radius,
|
|
245374
|
+
straightHalfLength,
|
|
245375
|
+
rotation: rotation4,
|
|
245376
|
+
isHorizontal: isHorizontal2
|
|
245377
|
+
} = geom;
|
|
245378
|
+
const faces = [];
|
|
245379
|
+
if (isHorizontal2) {
|
|
245380
|
+
const capOffset = straightHalfLength;
|
|
245381
|
+
faces.push(createCylindricalWall(repo, centerX + capOffset, centerY, radius, -Math.PI / 2, Math.PI / 2, rotation4, centerX, centerY, boardThickness, zDir, xDir));
|
|
245382
|
+
faces.push(createPlanarWall(repo, centerX - capOffset, centerY - radius, centerX + capOffset, centerY - radius, rotation4, centerX, centerY, boardThickness, zDir));
|
|
245383
|
+
faces.push(createCylindricalWall(repo, centerX - capOffset, centerY, radius, Math.PI / 2, 3 * Math.PI / 2, rotation4, centerX, centerY, boardThickness, zDir, xDir));
|
|
245384
|
+
faces.push(createPlanarWall(repo, centerX + capOffset, centerY + radius, centerX - capOffset, centerY + radius, rotation4, centerX, centerY, boardThickness, zDir));
|
|
245385
|
+
} else {
|
|
245386
|
+
const capOffset = straightHalfLength;
|
|
245387
|
+
faces.push(createCylindricalWall(repo, centerX, centerY - capOffset, radius, Math.PI, 0, rotation4, centerX, centerY, boardThickness, zDir, xDir));
|
|
245388
|
+
faces.push(createPlanarWall(repo, centerX + radius, centerY - capOffset, centerX + radius, centerY + capOffset, rotation4, centerX, centerY, boardThickness, zDir));
|
|
245389
|
+
faces.push(createCylindricalWall(repo, centerX, centerY + capOffset, radius, 0, Math.PI, rotation4, centerX, centerY, boardThickness, zDir, xDir));
|
|
245390
|
+
faces.push(createPlanarWall(repo, centerX - radius, centerY + capOffset, centerX - radius, centerY - capOffset, rotation4, centerX, centerY, boardThickness, zDir));
|
|
245391
|
+
}
|
|
245392
|
+
return faces;
|
|
245393
|
+
}
|
|
245394
|
+
function createCylindricalWall(repo, centerX, centerY, radius, startAngle, endAngle, rotation4, centerX0, centerY0, boardThickness, zDir, xDir) {
|
|
245395
|
+
const bottomStartX = centerX + radius * Math.cos(startAngle);
|
|
245396
|
+
const bottomStartY = centerY + radius * Math.sin(startAngle);
|
|
245397
|
+
const bottomEndX = centerX + radius * Math.cos(endAngle);
|
|
245398
|
+
const bottomEndY = centerY + radius * Math.sin(endAngle);
|
|
245399
|
+
const bottomStart = rotatePoint3(bottomStartX, bottomStartY, centerX0, centerY0, rotation4);
|
|
245400
|
+
const bottomEnd = rotatePoint3(bottomEndX, bottomEndY, centerX0, centerY0, rotation4);
|
|
245401
|
+
const bottomStartVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, 0))));
|
|
245402
|
+
const bottomEndVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, 0))));
|
|
245403
|
+
const topStart = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, boardThickness))));
|
|
245404
|
+
const topEnd = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, boardThickness))));
|
|
245405
|
+
const centerRotated = rotatePoint3(centerX, centerY, centerX0, centerY0, rotation4);
|
|
245406
|
+
const bottomCenter = repo.add(new CartesianPoint("", centerRotated.x, centerRotated.y, 0));
|
|
245407
|
+
const bottomPlacement = repo.add(new Axis2Placement3D("", bottomCenter, repo.add(new Direction("", 0, 0, -1)), xDir));
|
|
245408
|
+
const bottomCircle = repo.add(new Circle3("", bottomPlacement, radius));
|
|
245409
|
+
const bottomArc = repo.add(new EdgeCurve("", bottomStartVertex, bottomEndVertex, bottomCircle, false));
|
|
245410
|
+
const topCenter = repo.add(new CartesianPoint("", centerRotated.x, centerRotated.y, boardThickness));
|
|
245411
|
+
const topPlacement = repo.add(new Axis2Placement3D("", topCenter, zDir, xDir));
|
|
245412
|
+
const topCircle = repo.add(new Circle3("", topPlacement, radius));
|
|
245413
|
+
const topArc = repo.add(new EdgeCurve("", topEnd, topStart, topCircle, false));
|
|
245414
|
+
const v12 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, 0))));
|
|
245415
|
+
const v23 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, boardThickness))));
|
|
245416
|
+
const v3 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, 0))));
|
|
245417
|
+
const v4 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, boardThickness))));
|
|
245418
|
+
const dir1 = repo.add(new Direction("", 0, 0, 1));
|
|
245419
|
+
const vec1 = repo.add(new Vector3("", dir1, boardThickness));
|
|
245420
|
+
const line1 = repo.add(new Line3("", v12.resolve(repo).pnt, vec1));
|
|
245421
|
+
const edge1 = repo.add(new EdgeCurve("", v12, v23, line1, true));
|
|
245422
|
+
const dir2 = repo.add(new Direction("", 0, 0, 1));
|
|
245423
|
+
const vec2 = repo.add(new Vector3("", dir2, boardThickness));
|
|
245424
|
+
const line2 = repo.add(new Line3("", v3.resolve(repo).pnt, vec2));
|
|
245425
|
+
const edge2 = repo.add(new EdgeCurve("", v3, v4, line2, true));
|
|
245426
|
+
const loop = repo.add(new EdgeLoop("", [
|
|
245427
|
+
repo.add(new OrientedEdge("", bottomArc, true)),
|
|
245428
|
+
repo.add(new OrientedEdge("", edge2, true)),
|
|
245429
|
+
repo.add(new OrientedEdge("", topArc, false)),
|
|
245430
|
+
repo.add(new OrientedEdge("", edge1, false))
|
|
245431
|
+
]));
|
|
245432
|
+
const cylinderPlacement = repo.add(new Axis2Placement3D("", bottomCenter, zDir, xDir));
|
|
245433
|
+
const cylinderSurface = repo.add(new CylindricalSurface("", cylinderPlacement, radius));
|
|
245434
|
+
return repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", loop, true))], cylinderSurface, false));
|
|
245435
|
+
}
|
|
245436
|
+
function createPlanarWall(repo, startX, startY, endX, endY, rotation4, centerX0, centerY0, boardThickness, zDir) {
|
|
245437
|
+
const start = rotatePoint3(startX, startY, centerX0, centerY0, rotation4);
|
|
245438
|
+
const end = rotatePoint3(endX, endY, centerX0, centerY0, rotation4);
|
|
245439
|
+
const v12 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", start.x, start.y, 0))));
|
|
245440
|
+
const v23 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", end.x, end.y, 0))));
|
|
245441
|
+
const v3 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", end.x, end.y, boardThickness))));
|
|
245442
|
+
const v4 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", start.x, start.y, boardThickness))));
|
|
245443
|
+
const dx2 = end.x - start.x;
|
|
245444
|
+
const dy2 = end.y - start.y;
|
|
245445
|
+
const edgeLength = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
|
245446
|
+
const bottomDir = repo.add(new Direction("", dx2 / edgeLength, dy2 / edgeLength, 0));
|
|
245447
|
+
const bottomVec = repo.add(new Vector3("", bottomDir, edgeLength));
|
|
245448
|
+
const bottomLine = repo.add(new Line3("", v12.resolve(repo).pnt, bottomVec));
|
|
245449
|
+
const bottomEdge = repo.add(new EdgeCurve("", v12, v23, bottomLine, true));
|
|
245450
|
+
const topDir = repo.add(new Direction("", dx2 / edgeLength, dy2 / edgeLength, 0));
|
|
245451
|
+
const topVec = repo.add(new Vector3("", topDir, edgeLength));
|
|
245452
|
+
const topLine = repo.add(new Line3("", v4.resolve(repo).pnt, topVec));
|
|
245453
|
+
const topEdge = repo.add(new EdgeCurve("", v4, v3, topLine, true));
|
|
245454
|
+
const vertDir = repo.add(new Direction("", 0, 0, 1));
|
|
245455
|
+
const vertVec1 = repo.add(new Vector3("", vertDir, boardThickness));
|
|
245456
|
+
const vertLine1 = repo.add(new Line3("", v23.resolve(repo).pnt, vertVec1));
|
|
245457
|
+
const vertEdge1 = repo.add(new EdgeCurve("", v23, v3, vertLine1, true));
|
|
245458
|
+
const vertVec2 = repo.add(new Vector3("", vertDir, boardThickness));
|
|
245459
|
+
const vertLine2 = repo.add(new Line3("", v12.resolve(repo).pnt, vertVec2));
|
|
245460
|
+
const vertEdge2 = repo.add(new EdgeCurve("", v12, v4, vertLine2, true));
|
|
245461
|
+
const loop = repo.add(new EdgeLoop("", [
|
|
245462
|
+
repo.add(new OrientedEdge("", bottomEdge, true)),
|
|
245463
|
+
repo.add(new OrientedEdge("", vertEdge1, true)),
|
|
245464
|
+
repo.add(new OrientedEdge("", topEdge, false)),
|
|
245465
|
+
repo.add(new OrientedEdge("", vertEdge2, false))
|
|
245466
|
+
]));
|
|
245467
|
+
const normalDir = repo.add(new Direction("", dy2 / edgeLength, -dx2 / edgeLength, 0));
|
|
245468
|
+
const refDir = repo.add(new Direction("", dx2 / edgeLength, dy2 / edgeLength, 0));
|
|
245469
|
+
const planeOrigin = repo.add(new CartesianPoint("", start.x, start.y, 0));
|
|
245470
|
+
const placement = repo.add(new Axis2Placement3D("", planeOrigin, normalDir, refDir));
|
|
245471
|
+
const plane = repo.add(new Plane("", placement));
|
|
245472
|
+
return repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", loop, true))], plane, true));
|
|
245473
|
+
}
|
|
245474
|
+
async function circuitJsonToStep(circuitJson, options = {}) {
|
|
245475
|
+
const repo = new Repository;
|
|
245476
|
+
const pcbBoard = circuitJson.find((item) => item.type === "pcb_board");
|
|
245477
|
+
const holes = circuitJson.filter((item) => item.type === "pcb_hole" || item.type === "pcb_plated_hole");
|
|
245478
|
+
const boardWidth = options.boardWidth ?? pcbBoard?.width;
|
|
245479
|
+
const boardHeight = options.boardHeight ?? pcbBoard?.height;
|
|
245480
|
+
const boardThickness = options.boardThickness ?? pcbBoard?.thickness ?? 1.6;
|
|
245481
|
+
const productName = options.productName ?? "PCB";
|
|
245482
|
+
const boardCenterX = pcbBoard?.center?.x ?? 0;
|
|
245483
|
+
const boardCenterY = pcbBoard?.center?.y ?? 0;
|
|
245484
|
+
if (!boardWidth || !boardHeight) {
|
|
245485
|
+
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.");
|
|
245486
|
+
}
|
|
245487
|
+
const appContext = repo.add(new ApplicationContext("core data for automotive mechanical design processes"));
|
|
245488
|
+
repo.add(new ApplicationProtocolDefinition("international standard", "automotive_design", 2010, appContext));
|
|
245489
|
+
const productContext = repo.add(new ProductContext("", appContext, "mechanical"));
|
|
245490
|
+
const productDescription = `Generated by circuit-json-to-step v${VERSION}`;
|
|
245491
|
+
const product = repo.add(new Product(productName, productName, productDescription, [productContext]));
|
|
245492
|
+
const productDefContext = repo.add(new ProductDefinitionContext("part definition", appContext, "design"));
|
|
245493
|
+
const productDefFormation = repo.add(new ProductDefinitionFormation("", "", product));
|
|
245494
|
+
const productDef = repo.add(new ProductDefinition("", "", productDefFormation, productDefContext));
|
|
245495
|
+
const productDefShape = repo.add(new ProductDefinitionShape("", "", productDef));
|
|
245496
|
+
const lengthUnit = repo.add(new Unknown("", [
|
|
245497
|
+
"( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) )"
|
|
245498
|
+
]));
|
|
245499
|
+
const angleUnit = repo.add(new Unknown("", [
|
|
245500
|
+
"( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) )"
|
|
245501
|
+
]));
|
|
245502
|
+
const solidAngleUnit = repo.add(new Unknown("", [
|
|
245503
|
+
"( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() )"
|
|
245504
|
+
]));
|
|
245505
|
+
const uncertainty = repo.add(new Unknown("UNCERTAINTY_MEASURE_WITH_UNIT", [
|
|
245506
|
+
`LENGTH_MEASURE(1.E-07)`,
|
|
245507
|
+
`${lengthUnit}`,
|
|
245508
|
+
`'distance_accuracy_value'`,
|
|
245509
|
+
`'Maximum Tolerance'`
|
|
245510
|
+
]));
|
|
245511
|
+
const geomContext = repo.add(new Unknown("", [
|
|
245512
|
+
`( GEOMETRIC_REPRESENTATION_CONTEXT(3) GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((${uncertainty})) GLOBAL_UNIT_ASSIGNED_CONTEXT((${lengthUnit},${angleUnit},${solidAngleUnit})) REPRESENTATION_CONTEXT('${productName}','3D') )`
|
|
245513
|
+
]));
|
|
245514
|
+
const outline = pcbBoard?.outline;
|
|
245515
|
+
let bottomVertices;
|
|
245516
|
+
let topVertices;
|
|
245517
|
+
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
245518
|
+
const cleanedOutline = [];
|
|
245519
|
+
for (let i2 = 0;i2 < outline.length; i2++) {
|
|
245520
|
+
const current2 = outline[i2];
|
|
245521
|
+
const next = outline[(i2 + 1) % outline.length];
|
|
245522
|
+
const dx2 = next.x - current2.x;
|
|
245523
|
+
const dy2 = next.y - current2.y;
|
|
245524
|
+
const dist = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
|
245525
|
+
if (dist > 0.000001) {
|
|
245526
|
+
cleanedOutline.push(current2);
|
|
245527
|
+
}
|
|
245528
|
+
}
|
|
245529
|
+
if (cleanedOutline.length < 3) {
|
|
245530
|
+
throw new Error(`Outline has too few unique vertices after removing duplicates (${cleanedOutline.length}). Need at least 3.`);
|
|
245531
|
+
}
|
|
245532
|
+
bottomVertices = cleanedOutline.map((point5) => repo.add(new VertexPoint("", repo.add(new CartesianPoint("", point5.x, point5.y, 0)))));
|
|
245533
|
+
topVertices = cleanedOutline.map((point5) => repo.add(new VertexPoint("", repo.add(new CartesianPoint("", point5.x, point5.y, boardThickness)))));
|
|
245534
|
+
} else {
|
|
245535
|
+
const halfWidth = boardWidth / 2;
|
|
245536
|
+
const halfHeight = boardHeight / 2;
|
|
245537
|
+
const corners = [
|
|
245538
|
+
[boardCenterX - halfWidth, boardCenterY - halfHeight, 0],
|
|
245539
|
+
[boardCenterX + halfWidth, boardCenterY - halfHeight, 0],
|
|
245540
|
+
[boardCenterX + halfWidth, boardCenterY + halfHeight, 0],
|
|
245541
|
+
[boardCenterX - halfWidth, boardCenterY + halfHeight, 0],
|
|
245542
|
+
[boardCenterX - halfWidth, boardCenterY - halfHeight, boardThickness],
|
|
245543
|
+
[boardCenterX + halfWidth, boardCenterY - halfHeight, boardThickness],
|
|
245544
|
+
[boardCenterX + halfWidth, boardCenterY + halfHeight, boardThickness],
|
|
245545
|
+
[boardCenterX - halfWidth, boardCenterY + halfHeight, boardThickness]
|
|
245546
|
+
];
|
|
245547
|
+
const vertices = corners.map(([x3, y4, z21]) => repo.add(new VertexPoint("", repo.add(new CartesianPoint("", x3, y4, z21)))));
|
|
245548
|
+
bottomVertices = [vertices[0], vertices[1], vertices[2], vertices[3]];
|
|
245549
|
+
topVertices = [vertices[4], vertices[5], vertices[6], vertices[7]];
|
|
245550
|
+
}
|
|
245551
|
+
function createEdge(v12, v23) {
|
|
245552
|
+
const p12 = v12.resolve(repo).pnt.resolve(repo);
|
|
245553
|
+
const p23 = v23.resolve(repo).pnt.resolve(repo);
|
|
245554
|
+
const dx2 = p23.x - p12.x;
|
|
245555
|
+
const dy2 = p23.y - p12.y;
|
|
245556
|
+
const dz = p23.z - p12.z;
|
|
245557
|
+
const length2 = Math.sqrt(dx2 * dx2 + dy2 * dy2 + dz * dz);
|
|
245558
|
+
if (length2 < 0.0000000001) {
|
|
245559
|
+
const dir2 = repo.add(new Direction("", 1, 0, 0));
|
|
245560
|
+
const vec2 = repo.add(new Vector3("", dir2, 0.0000000001));
|
|
245561
|
+
const line22 = repo.add(new Line3("", v12.resolve(repo).pnt, vec2));
|
|
245562
|
+
return repo.add(new EdgeCurve("", v12, v23, line22, true));
|
|
245563
|
+
}
|
|
245564
|
+
const dir = repo.add(new Direction("", dx2 / length2, dy2 / length2, dz / length2));
|
|
245565
|
+
const vec = repo.add(new Vector3("", dir, length2));
|
|
245566
|
+
const line2 = repo.add(new Line3("", v12.resolve(repo).pnt, vec));
|
|
245567
|
+
return repo.add(new EdgeCurve("", v12, v23, line2, true));
|
|
245568
|
+
}
|
|
245569
|
+
const bottomEdges = [];
|
|
245570
|
+
const topEdges = [];
|
|
245571
|
+
const verticalEdges = [];
|
|
245572
|
+
for (let i2 = 0;i2 < bottomVertices.length; i2++) {
|
|
245573
|
+
const v12 = bottomVertices[i2];
|
|
245574
|
+
const v23 = bottomVertices[(i2 + 1) % bottomVertices.length];
|
|
245575
|
+
bottomEdges.push(createEdge(v12, v23));
|
|
245576
|
+
}
|
|
245577
|
+
for (let i2 = 0;i2 < topVertices.length; i2++) {
|
|
245578
|
+
const v12 = topVertices[i2];
|
|
245579
|
+
const v23 = topVertices[(i2 + 1) % topVertices.length];
|
|
245580
|
+
topEdges.push(createEdge(v12, v23));
|
|
245581
|
+
}
|
|
245582
|
+
for (let i2 = 0;i2 < bottomVertices.length; i2++) {
|
|
245583
|
+
verticalEdges.push(createEdge(bottomVertices[i2], topVertices[i2]));
|
|
245584
|
+
}
|
|
245585
|
+
const origin = repo.add(new CartesianPoint("", 0, 0, 0));
|
|
245586
|
+
const xDir = repo.add(new Direction("", 1, 0, 0));
|
|
245587
|
+
const zDir = repo.add(new Direction("", 0, 0, 1));
|
|
245588
|
+
const bottomFrame = repo.add(new Axis2Placement3D("", origin, repo.add(new Direction("", 0, 0, -1)), xDir));
|
|
245589
|
+
const bottomPlane = repo.add(new Plane("", bottomFrame));
|
|
245590
|
+
const bottomLoop = repo.add(new EdgeLoop("", bottomEdges.map((edge) => repo.add(new OrientedEdge("", edge, true)))));
|
|
245591
|
+
const bottomHoleLoops = [];
|
|
245592
|
+
for (const hole of holes) {
|
|
245593
|
+
const holeShape = hole.hole_shape || hole.shape;
|
|
245594
|
+
if (holeShape === "circle") {
|
|
245595
|
+
const holeX = typeof hole.x === "number" ? hole.x : hole.x.value;
|
|
245596
|
+
const holeY = typeof hole.y === "number" ? hole.y : hole.y.value;
|
|
245597
|
+
const radius = hole.hole_diameter / 2;
|
|
245598
|
+
const holeCenter = repo.add(new CartesianPoint("", holeX, holeY, 0));
|
|
245599
|
+
const holeVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, 0))));
|
|
245600
|
+
const holePlacement = repo.add(new Axis2Placement3D("", holeCenter, repo.add(new Direction("", 0, 0, -1)), xDir));
|
|
245601
|
+
const holeCircle = repo.add(new Circle3("", holePlacement, radius));
|
|
245602
|
+
const holeEdge = repo.add(new EdgeCurve("", holeVertex, holeVertex, holeCircle, true));
|
|
245603
|
+
const holeLoop = repo.add(new EdgeLoop("", [repo.add(new OrientedEdge("", holeEdge, false))]));
|
|
245604
|
+
bottomHoleLoops.push(repo.add(new FaceBound("", holeLoop, true)));
|
|
245605
|
+
} else if (holeShape === "rotated_pill" || holeShape === "pill") {
|
|
245606
|
+
const pillLoop = createPillHoleLoop(repo, hole, 0, xDir);
|
|
245607
|
+
bottomHoleLoops.push(repo.add(new FaceBound("", pillLoop, true)));
|
|
245608
|
+
}
|
|
245609
|
+
}
|
|
245610
|
+
const bottomFace = repo.add(new AdvancedFace("", [
|
|
245611
|
+
repo.add(new FaceOuterBound("", bottomLoop, true)),
|
|
245612
|
+
...bottomHoleLoops
|
|
245613
|
+
], bottomPlane, true));
|
|
245614
|
+
const topOrigin = repo.add(new CartesianPoint("", 0, 0, boardThickness));
|
|
245615
|
+
const topFrame = repo.add(new Axis2Placement3D("", topOrigin, zDir, xDir));
|
|
245616
|
+
const topPlane = repo.add(new Plane("", topFrame));
|
|
245617
|
+
const topLoop = repo.add(new EdgeLoop("", topEdges.map((edge) => repo.add(new OrientedEdge("", edge, false)))));
|
|
245618
|
+
const topHoleLoops = [];
|
|
245619
|
+
for (const hole of holes) {
|
|
245620
|
+
const holeShape = hole.hole_shape || hole.shape;
|
|
245621
|
+
if (holeShape === "circle") {
|
|
245622
|
+
const holeX = typeof hole.x === "number" ? hole.x : hole.x.value;
|
|
245623
|
+
const holeY = typeof hole.y === "number" ? hole.y : hole.y.value;
|
|
245624
|
+
const radius = hole.hole_diameter / 2;
|
|
245625
|
+
const holeCenter = repo.add(new CartesianPoint("", holeX, holeY, boardThickness));
|
|
245626
|
+
const holeVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, boardThickness))));
|
|
245627
|
+
const holePlacement = repo.add(new Axis2Placement3D("", holeCenter, zDir, xDir));
|
|
245628
|
+
const holeCircle = repo.add(new Circle3("", holePlacement, radius));
|
|
245629
|
+
const holeEdge = repo.add(new EdgeCurve("", holeVertex, holeVertex, holeCircle, true));
|
|
245630
|
+
const holeLoop = repo.add(new EdgeLoop("", [repo.add(new OrientedEdge("", holeEdge, true))]));
|
|
245631
|
+
topHoleLoops.push(repo.add(new FaceBound("", holeLoop, true)));
|
|
245632
|
+
} else if (holeShape === "rotated_pill" || holeShape === "pill") {
|
|
245633
|
+
const pillLoop = createPillHoleLoop(repo, hole, boardThickness, xDir);
|
|
245634
|
+
topHoleLoops.push(repo.add(new FaceBound("", pillLoop, true)));
|
|
245635
|
+
}
|
|
245636
|
+
}
|
|
245637
|
+
const topFace = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", topLoop, true)), ...topHoleLoops], topPlane, true));
|
|
245638
|
+
const sideFaces = [];
|
|
245639
|
+
for (let i2 = 0;i2 < bottomEdges.length; i2++) {
|
|
245640
|
+
const nextI = (i2 + 1) % bottomEdges.length;
|
|
245641
|
+
const bottomV1Pnt = bottomVertices[i2].resolve(repo).pnt;
|
|
245642
|
+
const bottomV2Pnt = bottomVertices[nextI].resolve(repo).pnt;
|
|
245643
|
+
const bottomV1 = bottomV1Pnt.resolve(repo);
|
|
245644
|
+
const bottomV2 = bottomV2Pnt.resolve(repo);
|
|
245645
|
+
const edgeDir = {
|
|
245646
|
+
x: bottomV2.x - bottomV1.x,
|
|
245647
|
+
y: bottomV2.y - bottomV1.y,
|
|
245648
|
+
z: 0
|
|
245649
|
+
};
|
|
245650
|
+
const normalDir = repo.add(new Direction("", edgeDir.y, -edgeDir.x, 0));
|
|
245651
|
+
const refDir = repo.add(new Direction("", edgeDir.x, edgeDir.y, 0));
|
|
245652
|
+
const sideFrame = repo.add(new Axis2Placement3D("", bottomV1Pnt, normalDir, refDir));
|
|
245653
|
+
const sidePlane = repo.add(new Plane("", sideFrame));
|
|
245654
|
+
const sideLoop = repo.add(new EdgeLoop("", [
|
|
245655
|
+
repo.add(new OrientedEdge("", bottomEdges[i2], true)),
|
|
245656
|
+
repo.add(new OrientedEdge("", verticalEdges[nextI], true)),
|
|
245657
|
+
repo.add(new OrientedEdge("", topEdges[i2], false)),
|
|
245658
|
+
repo.add(new OrientedEdge("", verticalEdges[i2], false))
|
|
245659
|
+
]));
|
|
245660
|
+
const sideFace = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", sideLoop, true))], sidePlane, true));
|
|
245661
|
+
sideFaces.push(sideFace);
|
|
245662
|
+
}
|
|
245663
|
+
const holeCylindricalFaces = [];
|
|
245664
|
+
for (const hole of holes) {
|
|
245665
|
+
const holeShape = hole.hole_shape || hole.shape;
|
|
245666
|
+
if (holeShape === "circle") {
|
|
245667
|
+
const holeX = typeof hole.x === "number" ? hole.x : hole.x.value;
|
|
245668
|
+
const holeY = typeof hole.y === "number" ? hole.y : hole.y.value;
|
|
245669
|
+
const radius = hole.hole_diameter / 2;
|
|
245670
|
+
const bottomHoleCenter = repo.add(new CartesianPoint("", holeX, holeY, 0));
|
|
245671
|
+
const bottomHoleVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, 0))));
|
|
245672
|
+
const bottomHolePlacement = repo.add(new Axis2Placement3D("", bottomHoleCenter, repo.add(new Direction("", 0, 0, -1)), xDir));
|
|
245673
|
+
const bottomHoleCircle = repo.add(new Circle3("", bottomHolePlacement, radius));
|
|
245674
|
+
const bottomHoleEdge = repo.add(new EdgeCurve("", bottomHoleVertex, bottomHoleVertex, bottomHoleCircle, true));
|
|
245675
|
+
const topHoleCenter = repo.add(new CartesianPoint("", holeX, holeY, boardThickness));
|
|
245676
|
+
const topHoleVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, boardThickness))));
|
|
245677
|
+
const topHolePlacement = repo.add(new Axis2Placement3D("", topHoleCenter, zDir, xDir));
|
|
245678
|
+
const topHoleCircle = repo.add(new Circle3("", topHolePlacement, radius));
|
|
245679
|
+
const topHoleEdge = repo.add(new EdgeCurve("", topHoleVertex, topHoleVertex, topHoleCircle, true));
|
|
245680
|
+
const holeCylinderLoop = repo.add(new EdgeLoop("", [
|
|
245681
|
+
repo.add(new OrientedEdge("", bottomHoleEdge, true)),
|
|
245682
|
+
repo.add(new OrientedEdge("", topHoleEdge, false))
|
|
245683
|
+
]));
|
|
245684
|
+
const holeCylinderPlacement = repo.add(new Axis2Placement3D("", bottomHoleCenter, zDir, xDir));
|
|
245685
|
+
const holeCylinderSurface = repo.add(new CylindricalSurface("", holeCylinderPlacement, radius));
|
|
245686
|
+
const holeCylinderFace = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", holeCylinderLoop, true))], holeCylinderSurface, false));
|
|
245687
|
+
holeCylindricalFaces.push(holeCylinderFace);
|
|
245688
|
+
} else if (holeShape === "rotated_pill" || holeShape === "pill") {
|
|
245689
|
+
const pillFaces = createPillCylindricalFaces(repo, hole, boardThickness, xDir, zDir);
|
|
245690
|
+
holeCylindricalFaces.push(...pillFaces);
|
|
245691
|
+
}
|
|
245692
|
+
}
|
|
245693
|
+
const allFaces = [bottomFace, topFace, ...sideFaces, ...holeCylindricalFaces];
|
|
245694
|
+
const shell = repo.add(new ClosedShell("", allFaces));
|
|
245695
|
+
const solid = repo.add(new ManifoldSolidBrep(productName, shell));
|
|
245696
|
+
const allSolids = [solid];
|
|
245697
|
+
let handledComponentIds = /* @__PURE__ */ new Set;
|
|
245698
|
+
let handledPcbComponentIds = /* @__PURE__ */ new Set;
|
|
245699
|
+
if (options.includeComponents && options.includeExternalMeshes) {
|
|
245700
|
+
const mergeResult = await mergeExternalStepModels({
|
|
245701
|
+
repo,
|
|
245702
|
+
circuitJson,
|
|
245703
|
+
boardThickness,
|
|
245704
|
+
fsMap: options.fsMap
|
|
245705
|
+
});
|
|
245706
|
+
handledComponentIds = mergeResult.handledComponentIds;
|
|
245707
|
+
handledPcbComponentIds = mergeResult.handledPcbComponentIds;
|
|
245708
|
+
allSolids.push(...mergeResult.solids);
|
|
245709
|
+
}
|
|
245710
|
+
if (options.includeComponents) {
|
|
245711
|
+
const pcbComponentIdsWithStepUrl = /* @__PURE__ */ new Set;
|
|
245712
|
+
for (const item of circuitJson) {
|
|
245713
|
+
if (item.type === "cad_component" && item.model_step_url && item.pcb_component_id) {
|
|
245714
|
+
pcbComponentIdsWithStepUrl.add(item.pcb_component_id);
|
|
245715
|
+
}
|
|
245716
|
+
}
|
|
245717
|
+
const hasComponentsNeedingMesh = circuitJson.some((item) => {
|
|
245718
|
+
if (item.type === "cad_component") {
|
|
245719
|
+
if (item.cad_component_id && handledComponentIds.has(item.cad_component_id)) {
|
|
245720
|
+
return false;
|
|
245721
|
+
}
|
|
245722
|
+
if (item.pcb_component_id && pcbComponentIdsWithStepUrl.has(item.pcb_component_id)) {
|
|
245723
|
+
return false;
|
|
245724
|
+
}
|
|
245725
|
+
return !item.model_step_url;
|
|
245726
|
+
}
|
|
245727
|
+
if (item.type === "pcb_component") {
|
|
245728
|
+
if (item.pcb_component_id && handledPcbComponentIds.has(item.pcb_component_id)) {
|
|
245729
|
+
return false;
|
|
245730
|
+
}
|
|
245731
|
+
if (item.pcb_component_id && pcbComponentIdsWithStepUrl.has(item.pcb_component_id)) {
|
|
245732
|
+
return false;
|
|
245733
|
+
}
|
|
245734
|
+
return true;
|
|
245735
|
+
}
|
|
245736
|
+
return false;
|
|
245737
|
+
});
|
|
245738
|
+
if (hasComponentsNeedingMesh) {
|
|
245739
|
+
const componentSolids = await generateComponentMeshes({
|
|
245740
|
+
repo,
|
|
245741
|
+
circuitJson,
|
|
245742
|
+
boardThickness,
|
|
245743
|
+
includeExternalMeshes: options.includeExternalMeshes,
|
|
245744
|
+
excludeCadComponentIds: handledComponentIds,
|
|
245745
|
+
excludePcbComponentIds: handledPcbComponentIds,
|
|
245746
|
+
pcbComponentIdsWithStepUrl
|
|
245747
|
+
});
|
|
245748
|
+
allSolids.push(...componentSolids);
|
|
245749
|
+
}
|
|
245750
|
+
}
|
|
245751
|
+
const styledItems = [];
|
|
245752
|
+
allSolids.forEach((solidRef, index) => {
|
|
245753
|
+
const isBoard = index === 0;
|
|
245754
|
+
const [r4, g6, b] = isBoard ? [0.2, 0.6, 0.2] : [0.75, 0.75, 0.75];
|
|
245755
|
+
const color = repo.add(new ColourRgb("", r4, g6, b));
|
|
245756
|
+
const fillColor = repo.add(new FillAreaStyleColour("", color));
|
|
245757
|
+
const fillStyle = repo.add(new FillAreaStyle("", [fillColor]));
|
|
245758
|
+
const surfaceFill = repo.add(new SurfaceStyleFillArea(fillStyle));
|
|
245759
|
+
const surfaceSide = repo.add(new SurfaceSideStyle("", [surfaceFill]));
|
|
245760
|
+
const surfaceUsage = repo.add(new SurfaceStyleUsage(".BOTH.", surfaceSide));
|
|
245761
|
+
const presStyle = repo.add(new PresentationStyleAssignment([surfaceUsage]));
|
|
245762
|
+
const styledItem = repo.add(new StyledItem("", [presStyle], solidRef));
|
|
245763
|
+
styledItems.push(styledItem);
|
|
245764
|
+
});
|
|
245765
|
+
repo.add(new MechanicalDesignGeometricPresentationRepresentation("", styledItems, geomContext));
|
|
245766
|
+
const shapeRep = repo.add(new AdvancedBrepShapeRepresentation(productName, allSolids, geomContext));
|
|
245767
|
+
repo.add(new ShapeDefinitionRepresentation(productDefShape, shapeRep));
|
|
245768
|
+
const stepText = repo.toPartFile({ name: productName });
|
|
245769
|
+
return normalizeStepNumericExponents(stepText);
|
|
245770
|
+
}
|
|
245771
|
+
|
|
245772
|
+
// lib/shared/export-snippet.ts
|
|
243349
245773
|
var writeFileAsync = promisify3(fs53.writeFile);
|
|
243350
245774
|
var ALLOWED_EXPORT_FORMATS = [
|
|
243351
245775
|
"json",
|
|
@@ -243361,7 +245785,8 @@ var ALLOWED_EXPORT_FORMATS = [
|
|
|
243361
245785
|
"kicad_pcb",
|
|
243362
245786
|
"kicad_zip",
|
|
243363
245787
|
"kicad-library",
|
|
243364
|
-
"srj"
|
|
245788
|
+
"srj",
|
|
245789
|
+
"step"
|
|
243365
245790
|
];
|
|
243366
245791
|
var OUTPUT_EXTENSIONS = {
|
|
243367
245792
|
json: ".circuit.json",
|
|
@@ -243377,7 +245802,8 @@ var OUTPUT_EXTENSIONS = {
|
|
|
243377
245802
|
kicad_pcb: ".kicad_pcb",
|
|
243378
245803
|
kicad_zip: "-kicad.zip",
|
|
243379
245804
|
"kicad-library": "",
|
|
243380
|
-
srj: ".simple-route.json"
|
|
245805
|
+
srj: ".simple-route.json",
|
|
245806
|
+
step: ".step"
|
|
243381
245807
|
};
|
|
243382
245808
|
var exportSnippet = async ({
|
|
243383
245809
|
filePath,
|
|
@@ -243528,6 +245954,9 @@ var exportSnippet = async ({
|
|
|
243528
245954
|
outputContent = await zip.generateAsync({ type: "nodebuffer" });
|
|
243529
245955
|
break;
|
|
243530
245956
|
}
|
|
245957
|
+
case "step":
|
|
245958
|
+
outputContent = await circuitJsonToStep(circuitJson);
|
|
245959
|
+
break;
|
|
243531
245960
|
default:
|
|
243532
245961
|
outputContent = JSON.stringify(circuitJson, null, 2);
|
|
243533
245962
|
}
|
|
@@ -262872,7 +265301,7 @@ class ExtendedSearch {
|
|
|
262872
265301
|
}
|
|
262873
265302
|
}
|
|
262874
265303
|
var registeredSearchers = [];
|
|
262875
|
-
function
|
|
265304
|
+
function register2(...args) {
|
|
262876
265305
|
registeredSearchers.push(...args);
|
|
262877
265306
|
}
|
|
262878
265307
|
function createSearcher(pattern, options) {
|
|
@@ -263204,7 +265633,7 @@ Fuse2.config = Config;
|
|
|
263204
265633
|
Fuse2.parseQuery = parse3;
|
|
263205
265634
|
}
|
|
263206
265635
|
{
|
|
263207
|
-
|
|
265636
|
+
register2(ExtendedSearch);
|
|
263208
265637
|
}
|
|
263209
265638
|
|
|
263210
265639
|
// cli/search/register.ts
|