@tscircuit/core 0.0.845 → 0.0.847
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/index.d.ts +3 -0
- package/dist/index.js +29 -242
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -24655,6 +24655,7 @@ declare class CopperPour extends PrimitiveComponent<typeof copperPourProps> {
|
|
|
24655
24655
|
padMargin: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
24656
24656
|
traceMargin: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
24657
24657
|
clearance: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
24658
|
+
boardEdgeMargin: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
24658
24659
|
coveredWithSolderMask: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
|
|
24659
24660
|
}, "strip", zod.ZodTypeAny, {
|
|
24660
24661
|
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
@@ -24664,6 +24665,7 @@ declare class CopperPour extends PrimitiveComponent<typeof copperPourProps> {
|
|
|
24664
24665
|
padMargin?: number | undefined;
|
|
24665
24666
|
traceMargin?: number | undefined;
|
|
24666
24667
|
clearance?: number | undefined;
|
|
24668
|
+
boardEdgeMargin?: number | undefined;
|
|
24667
24669
|
}, {
|
|
24668
24670
|
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
24669
24671
|
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
@@ -24674,6 +24676,7 @@ declare class CopperPour extends PrimitiveComponent<typeof copperPourProps> {
|
|
|
24674
24676
|
padMargin?: string | number | undefined;
|
|
24675
24677
|
traceMargin?: string | number | undefined;
|
|
24676
24678
|
clearance?: string | number | undefined;
|
|
24679
|
+
boardEdgeMargin?: string | number | undefined;
|
|
24677
24680
|
}>;
|
|
24678
24681
|
};
|
|
24679
24682
|
getPcbSize(): {
|
package/dist/index.js
CHANGED
|
@@ -16324,216 +16324,10 @@ var Via = class extends PrimitiveComponent2 {
|
|
|
16324
16324
|
|
|
16325
16325
|
// lib/components/primitive-components/CopperPour/CopperPour.ts
|
|
16326
16326
|
import { copperPourProps } from "@tscircuit/props";
|
|
16327
|
-
import {
|
|
16328
|
-
|
|
16329
|
-
|
|
16330
|
-
|
|
16331
|
-
import Flatten from "@flatten-js/core";
|
|
16332
|
-
var getBoardPolygon = (board) => {
|
|
16333
|
-
if (board.outline && board.outline.length > 0) {
|
|
16334
|
-
return new Flatten.Polygon(
|
|
16335
|
-
board.outline.map((p) => Flatten.point(p.x, p.y))
|
|
16336
|
-
);
|
|
16337
|
-
}
|
|
16338
|
-
return new Flatten.Polygon(
|
|
16339
|
-
new Flatten.Box(
|
|
16340
|
-
board.center.x - board.width / 2,
|
|
16341
|
-
board.center.y - board.height / 2,
|
|
16342
|
-
board.center.x + board.width / 2,
|
|
16343
|
-
board.center.y + board.height / 2
|
|
16344
|
-
).toPoints()
|
|
16345
|
-
);
|
|
16346
|
-
};
|
|
16347
|
-
|
|
16348
|
-
// lib/components/primitive-components/CopperPour/utils/get-trace-obstacles.ts
|
|
16349
|
-
var getTraceObstacles = (db, layer) => {
|
|
16350
|
-
const traceObstacles = [];
|
|
16351
|
-
for (const pcb_trace of db.pcb_trace.list()) {
|
|
16352
|
-
if (!pcb_trace.route) continue;
|
|
16353
|
-
const source_trace = pcb_trace.source_trace_id ? db.source_trace.get(pcb_trace.source_trace_id) : null;
|
|
16354
|
-
const connectedToIds = /* @__PURE__ */ new Set();
|
|
16355
|
-
if (pcb_trace.source_trace_id) {
|
|
16356
|
-
connectedToIds.add(pcb_trace.source_trace_id);
|
|
16357
|
-
}
|
|
16358
|
-
if (source_trace) {
|
|
16359
|
-
for (const id of source_trace.connected_source_net_ids)
|
|
16360
|
-
connectedToIds.add(id);
|
|
16361
|
-
for (const id of source_trace.connected_source_port_ids)
|
|
16362
|
-
connectedToIds.add(id);
|
|
16363
|
-
}
|
|
16364
|
-
for (const pt of pcb_trace.route) {
|
|
16365
|
-
if (pt.route_type === "wire") {
|
|
16366
|
-
if (pt.start_pcb_port_id) {
|
|
16367
|
-
const pcb_port = db.pcb_port.get(pt.start_pcb_port_id);
|
|
16368
|
-
if (pcb_port?.source_port_id)
|
|
16369
|
-
connectedToIds.add(pcb_port.source_port_id);
|
|
16370
|
-
}
|
|
16371
|
-
if (pt.end_pcb_port_id) {
|
|
16372
|
-
const pcb_port = db.pcb_port.get(pt.end_pcb_port_id);
|
|
16373
|
-
if (pcb_port?.source_port_id)
|
|
16374
|
-
connectedToIds.add(pcb_port.source_port_id);
|
|
16375
|
-
}
|
|
16376
|
-
}
|
|
16377
|
-
}
|
|
16378
|
-
const connectedTo = Array.from(connectedToIds);
|
|
16379
|
-
for (let i = 0; i < pcb_trace.route.length - 1; i++) {
|
|
16380
|
-
const p1 = pcb_trace.route[i];
|
|
16381
|
-
const p2 = pcb_trace.route[i + 1];
|
|
16382
|
-
if (p1.route_type !== "wire" || p2.route_type !== "wire") continue;
|
|
16383
|
-
if (p1.layer !== layer) continue;
|
|
16384
|
-
const segmentWidth = p1.width;
|
|
16385
|
-
if (segmentWidth === 0) continue;
|
|
16386
|
-
const segmentLength = Math.hypot(p1.x - p2.x, p1.y - p2.y);
|
|
16387
|
-
if (segmentLength === 0) continue;
|
|
16388
|
-
const centerX = (p1.x + p2.x) / 2;
|
|
16389
|
-
const centerY = (p1.y + p2.y) / 2;
|
|
16390
|
-
const rotationDeg = Math.atan2(p2.y - p1.y, p2.x - p1.x) * 180 / Math.PI;
|
|
16391
|
-
const rotatedRect = {
|
|
16392
|
-
center: { x: centerX, y: centerY },
|
|
16393
|
-
width: segmentLength,
|
|
16394
|
-
height: segmentWidth,
|
|
16395
|
-
rotation: rotationDeg
|
|
16396
|
-
};
|
|
16397
|
-
const approximatingRects = generateApproximatingRects(rotatedRect);
|
|
16398
|
-
for (const rect of approximatingRects) {
|
|
16399
|
-
traceObstacles.push({
|
|
16400
|
-
type: "rect",
|
|
16401
|
-
layers: [p1.layer],
|
|
16402
|
-
center: rect.center,
|
|
16403
|
-
width: rect.width,
|
|
16404
|
-
height: rect.height,
|
|
16405
|
-
connectedTo,
|
|
16406
|
-
obstacle_type: "trace"
|
|
16407
|
-
});
|
|
16408
|
-
}
|
|
16409
|
-
}
|
|
16410
|
-
}
|
|
16411
|
-
return traceObstacles;
|
|
16412
|
-
};
|
|
16413
|
-
|
|
16414
|
-
// lib/components/primitive-components/CopperPour/utils/process-obstacles.ts
|
|
16415
|
-
import Flatten2 from "@flatten-js/core";
|
|
16416
|
-
var processObstaclesForPour = (obstacles, connMap, net, margins) => {
|
|
16417
|
-
const rectObstaclesToSubtract = [];
|
|
16418
|
-
const circularObstacles = [];
|
|
16419
|
-
const { traceMargin, padMargin } = margins;
|
|
16420
|
-
for (const obs of obstacles) {
|
|
16421
|
-
const isOnNet = obs.connectedTo.some(
|
|
16422
|
-
(id) => connMap.areIdsConnected(id, net.source_net_id)
|
|
16423
|
-
);
|
|
16424
|
-
if (isOnNet) {
|
|
16425
|
-
continue;
|
|
16426
|
-
}
|
|
16427
|
-
if (obs.type === "oval" && obs.width === obs.height) {
|
|
16428
|
-
const radius = obs.width / 2 + padMargin;
|
|
16429
|
-
circularObstacles.push({
|
|
16430
|
-
center: obs.center,
|
|
16431
|
-
radius
|
|
16432
|
-
});
|
|
16433
|
-
continue;
|
|
16434
|
-
}
|
|
16435
|
-
if (obs.type === "rect" && obs.width === obs.height && obs.connectedTo.length === 0) {
|
|
16436
|
-
const radius = obs.width / 2;
|
|
16437
|
-
circularObstacles.push({
|
|
16438
|
-
center: obs.center,
|
|
16439
|
-
radius
|
|
16440
|
-
});
|
|
16441
|
-
continue;
|
|
16442
|
-
}
|
|
16443
|
-
const margin = traceMargin;
|
|
16444
|
-
const b = new Flatten2.Box(
|
|
16445
|
-
obs.center.x - obs.width / 2 - margin,
|
|
16446
|
-
obs.center.y - obs.height / 2 - margin,
|
|
16447
|
-
obs.center.x + obs.width / 2 + margin,
|
|
16448
|
-
obs.center.y + obs.height / 2 + margin
|
|
16449
|
-
);
|
|
16450
|
-
rectObstaclesToSubtract.push(new Flatten2.Polygon(b.toPoints()));
|
|
16451
|
-
}
|
|
16452
|
-
return { rectObstaclesToSubtract, circularObstacles };
|
|
16453
|
-
};
|
|
16454
|
-
|
|
16455
|
-
// lib/components/primitive-components/CopperPour/utils/generate-and-insert-brep.ts
|
|
16456
|
-
import Flatten3 from "@flatten-js/core";
|
|
16457
|
-
var faceToVertices = (face) => face.edges.map((e) => {
|
|
16458
|
-
const pt = {
|
|
16459
|
-
x: e.start.x,
|
|
16460
|
-
y: e.start.y
|
|
16461
|
-
};
|
|
16462
|
-
if (e.isArc) {
|
|
16463
|
-
const bulge = Math.tan(e.shape.sweep / 4);
|
|
16464
|
-
if (Math.abs(bulge) > 1e-9) {
|
|
16465
|
-
pt.bulge = bulge;
|
|
16466
|
-
}
|
|
16467
|
-
}
|
|
16468
|
-
return pt;
|
|
16469
|
-
});
|
|
16470
|
-
var generateAndInsertBRep = (pourPolygons, circularObstacles, {
|
|
16471
|
-
db,
|
|
16472
|
-
copperPour
|
|
16473
|
-
}) => {
|
|
16474
|
-
const props = copperPour._parsedProps;
|
|
16475
|
-
const net = copperPour.getSubcircuit().selectOne(props.connectsTo);
|
|
16476
|
-
const subcircuit = copperPour.getSubcircuit();
|
|
16477
|
-
const polygons = Array.isArray(pourPolygons) ? pourPolygons : [pourPolygons];
|
|
16478
|
-
for (const p of polygons) {
|
|
16479
|
-
const islands = p.splitToIslands();
|
|
16480
|
-
for (const island of islands) {
|
|
16481
|
-
if (island.isEmpty()) continue;
|
|
16482
|
-
const faces = [...island.faces];
|
|
16483
|
-
const outer_face_ccw = faces.find(
|
|
16484
|
-
(f) => f.orientation() === Flatten3.ORIENTATION.CCW
|
|
16485
|
-
);
|
|
16486
|
-
const inner_faces_cw = faces.filter(
|
|
16487
|
-
(f) => f.orientation() === Flatten3.ORIENTATION.CW
|
|
16488
|
-
);
|
|
16489
|
-
if (!outer_face_ccw) continue;
|
|
16490
|
-
if (!db.pcb_copper_pour) {
|
|
16491
|
-
copperPour.renderError(
|
|
16492
|
-
"db.pcb_copper_pour not found. The database schema may be outdated."
|
|
16493
|
-
);
|
|
16494
|
-
return;
|
|
16495
|
-
}
|
|
16496
|
-
outer_face_ccw.reverse();
|
|
16497
|
-
const outer_ring_vertices = faceToVertices(outer_face_ccw);
|
|
16498
|
-
const inner_rings = inner_faces_cw.map((f) => {
|
|
16499
|
-
f.reverse();
|
|
16500
|
-
return { vertices: faceToVertices(f) };
|
|
16501
|
-
});
|
|
16502
|
-
for (const circle of circularObstacles) {
|
|
16503
|
-
const centerPoint = Flatten3.point(circle.center.x, circle.center.y);
|
|
16504
|
-
const isContained = island.contains(centerPoint);
|
|
16505
|
-
if (isContained) {
|
|
16506
|
-
inner_rings.push({
|
|
16507
|
-
vertices: [
|
|
16508
|
-
{
|
|
16509
|
-
x: circle.center.x,
|
|
16510
|
-
y: circle.center.y - circle.radius,
|
|
16511
|
-
bulge: 1
|
|
16512
|
-
},
|
|
16513
|
-
{
|
|
16514
|
-
x: circle.center.x,
|
|
16515
|
-
y: circle.center.y + circle.radius,
|
|
16516
|
-
bulge: 1
|
|
16517
|
-
}
|
|
16518
|
-
]
|
|
16519
|
-
});
|
|
16520
|
-
}
|
|
16521
|
-
}
|
|
16522
|
-
db.pcb_copper_pour.insert({
|
|
16523
|
-
shape: "brep",
|
|
16524
|
-
layer: props.layer,
|
|
16525
|
-
brep_shape: {
|
|
16526
|
-
outer_ring: { vertices: outer_ring_vertices },
|
|
16527
|
-
inner_rings
|
|
16528
|
-
},
|
|
16529
|
-
source_net_id: net.source_net_id,
|
|
16530
|
-
subcircuit_id: subcircuit?.subcircuit_id ?? void 0
|
|
16531
|
-
});
|
|
16532
|
-
}
|
|
16533
|
-
}
|
|
16534
|
-
};
|
|
16535
|
-
|
|
16536
|
-
// lib/components/primitive-components/CopperPour/CopperPour.ts
|
|
16327
|
+
import {
|
|
16328
|
+
CopperPourPipelineSolver,
|
|
16329
|
+
convertCircuitJsonToInputProblem
|
|
16330
|
+
} from "@tscircuit/copper-pour-solver";
|
|
16537
16331
|
var CopperPour = class extends PrimitiveComponent2 {
|
|
16538
16332
|
isPcbPrimitive = true;
|
|
16539
16333
|
get config() {
|
|
@@ -16555,38 +16349,29 @@ var CopperPour = class extends PrimitiveComponent2 {
|
|
|
16555
16349
|
this.renderError(`Net "${props.connectsTo}" not found for copper pour`);
|
|
16556
16350
|
return;
|
|
16557
16351
|
}
|
|
16558
|
-
const
|
|
16559
|
-
|
|
16560
|
-
|
|
16561
|
-
|
|
16562
|
-
|
|
16563
|
-
const
|
|
16564
|
-
|
|
16565
|
-
|
|
16566
|
-
|
|
16567
|
-
|
|
16568
|
-
|
|
16569
|
-
obstaclesRaw.push(...getTraceObstacles(db, props.layer));
|
|
16570
|
-
const { rectObstaclesToSubtract, circularObstacles } = processObstaclesForPour(obstaclesRaw, connMap, net, {
|
|
16571
|
-
traceMargin: props.traceMargin ?? 0.2,
|
|
16572
|
-
padMargin: props.padMargin ?? 0.2
|
|
16352
|
+
const subcircuit = this.getSubcircuit();
|
|
16353
|
+
const sourceNet = db.toArray().filter(
|
|
16354
|
+
(elm) => elm.type === "source_net" && elm.name === net.name
|
|
16355
|
+
)[0] || "";
|
|
16356
|
+
const clearance = props.clearance ?? 0.2;
|
|
16357
|
+
const inputProblem = convertCircuitJsonToInputProblem(db.toArray(), {
|
|
16358
|
+
layer: props.layer,
|
|
16359
|
+
pour_connectivity_key: sourceNet.subcircuit_connectivity_map_key || "",
|
|
16360
|
+
pad_margin: props.padMargin ?? clearance,
|
|
16361
|
+
trace_margin: props.traceMargin ?? clearance,
|
|
16362
|
+
board_edge_margin: props.boardEdgeMargin ?? clearance
|
|
16573
16363
|
});
|
|
16574
|
-
|
|
16575
|
-
|
|
16576
|
-
|
|
16577
|
-
|
|
16578
|
-
|
|
16579
|
-
|
|
16580
|
-
|
|
16581
|
-
|
|
16582
|
-
|
|
16583
|
-
|
|
16584
|
-
}
|
|
16364
|
+
const solver = new CopperPourPipelineSolver(inputProblem);
|
|
16365
|
+
const { brep_shapes } = solver.getOutput();
|
|
16366
|
+
for (const brep_shape of brep_shapes) {
|
|
16367
|
+
db.pcb_copper_pour.insert({
|
|
16368
|
+
shape: "brep",
|
|
16369
|
+
layer: props.layer,
|
|
16370
|
+
brep_shape,
|
|
16371
|
+
source_net_id: net.source_net_id,
|
|
16372
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0
|
|
16373
|
+
});
|
|
16585
16374
|
}
|
|
16586
|
-
generateAndInsertBRep(pourPolygons, circularObstacles, {
|
|
16587
|
-
db,
|
|
16588
|
-
copperPour: this
|
|
16589
|
-
});
|
|
16590
16375
|
});
|
|
16591
16376
|
}
|
|
16592
16377
|
};
|
|
@@ -17829,7 +17614,7 @@ import { identity as identity6 } from "transformation-matrix";
|
|
|
17829
17614
|
var package_default = {
|
|
17830
17615
|
name: "@tscircuit/core",
|
|
17831
17616
|
type: "module",
|
|
17832
|
-
version: "0.0.
|
|
17617
|
+
version: "0.0.846",
|
|
17833
17618
|
types: "dist/index.d.ts",
|
|
17834
17619
|
main: "dist/index.js",
|
|
17835
17620
|
module: "dist/index.js",
|
|
@@ -17864,6 +17649,7 @@ var package_default = {
|
|
|
17864
17649
|
"@tscircuit/checks": "^0.0.85",
|
|
17865
17650
|
"@tscircuit/circuit-json-util": "^0.0.72",
|
|
17866
17651
|
"@tscircuit/common": "^0.0.20",
|
|
17652
|
+
"@tscircuit/copper-pour-solver": "^0.0.6",
|
|
17867
17653
|
"@tscircuit/footprinter": "^0.0.236",
|
|
17868
17654
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
17869
17655
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
@@ -17872,10 +17658,11 @@ var package_default = {
|
|
|
17872
17658
|
"@tscircuit/math-utils": "^0.0.29",
|
|
17873
17659
|
"@tscircuit/miniflex": "^0.0.4",
|
|
17874
17660
|
"@tscircuit/ngspice-spice-engine": "^0.0.2",
|
|
17875
|
-
"@tscircuit/props": "^0.0.
|
|
17661
|
+
"@tscircuit/props": "^0.0.394",
|
|
17876
17662
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
17877
17663
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
17878
17664
|
"@tscircuit/schematic-trace-solver": "^0.0.43",
|
|
17665
|
+
"@tscircuit/solver-utils": "^0.0.3",
|
|
17879
17666
|
"@types/bun": "^1.2.16",
|
|
17880
17667
|
"@types/debug": "^4.1.12",
|
|
17881
17668
|
"@types/react": "^19.1.8",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.847",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@tscircuit/checks": "^0.0.85",
|
|
37
37
|
"@tscircuit/circuit-json-util": "^0.0.72",
|
|
38
38
|
"@tscircuit/common": "^0.0.20",
|
|
39
|
+
"@tscircuit/copper-pour-solver": "^0.0.6",
|
|
39
40
|
"@tscircuit/footprinter": "^0.0.236",
|
|
40
41
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
41
42
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
@@ -44,10 +45,11 @@
|
|
|
44
45
|
"@tscircuit/math-utils": "^0.0.29",
|
|
45
46
|
"@tscircuit/miniflex": "^0.0.4",
|
|
46
47
|
"@tscircuit/ngspice-spice-engine": "^0.0.2",
|
|
47
|
-
"@tscircuit/props": "^0.0.
|
|
48
|
+
"@tscircuit/props": "^0.0.394",
|
|
48
49
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
49
50
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
50
51
|
"@tscircuit/schematic-trace-solver": "^0.0.43",
|
|
52
|
+
"@tscircuit/solver-utils": "^0.0.3",
|
|
51
53
|
"@types/bun": "^1.2.16",
|
|
52
54
|
"@types/debug": "^4.1.12",
|
|
53
55
|
"@types/react": "^19.1.8",
|