@tscircuit/core 0.0.1843 → 0.0.1845
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.js +281 -38
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -16537,7 +16537,7 @@ import {
|
|
|
16537
16537
|
runAllRoutingChecks as runAllRoutingChecks2,
|
|
16538
16538
|
runAllSchematicChecks
|
|
16539
16539
|
} from "@tscircuit/checks";
|
|
16540
|
-
import { getBoundsFromPoints as
|
|
16540
|
+
import { getBoundsFromPoints as getBoundsFromPoints10 } from "@tscircuit/math-utils";
|
|
16541
16541
|
import { boardProps } from "@tscircuit/props";
|
|
16542
16542
|
import { compose as compose11, translate as translate11 } from "transformation-matrix";
|
|
16543
16543
|
|
|
@@ -18166,7 +18166,7 @@ import {
|
|
|
18166
18166
|
getRerouteSimpleRouteJson,
|
|
18167
18167
|
reconnectReroutedSimpleRouteJsonRegion
|
|
18168
18168
|
} from "@tscircuit/capacity-autorouter";
|
|
18169
|
-
import { getBoundsFromPoints as
|
|
18169
|
+
import { getBoundsFromPoints as getBoundsFromPoints9 } from "@tscircuit/math-utils";
|
|
18170
18170
|
import {
|
|
18171
18171
|
groupProps
|
|
18172
18172
|
} from "@tscircuit/props";
|
|
@@ -34559,7 +34559,14 @@ import {
|
|
|
34559
34559
|
} from "@tscircuit/solver-utils";
|
|
34560
34560
|
|
|
34561
34561
|
// node_modules/@tscircuit/implicit-copper-pour-solver/lib/grid-solver.ts
|
|
34562
|
-
import {
|
|
34562
|
+
import {
|
|
34563
|
+
clamp as clamp2,
|
|
34564
|
+
distSq,
|
|
34565
|
+
getBoundsFromPoints as getBoundsFromPoints4,
|
|
34566
|
+
grid,
|
|
34567
|
+
midpoint,
|
|
34568
|
+
pointToSegmentClosestPoint as pointToSegmentClosestPoint2
|
|
34569
|
+
} from "@tscircuit/math-utils";
|
|
34563
34570
|
import { applyToPoint as applyToPoint26, compose as compose8, scale as scale2, translate as translate6 } from "transformation-matrix";
|
|
34564
34571
|
|
|
34565
34572
|
// node_modules/@tscircuit/implicit-copper-pour-solver/lib/geometry.ts
|
|
@@ -34680,13 +34687,19 @@ var getClosestPointOnPrimitive = (primitive, point6) => {
|
|
|
34680
34687
|
y: clamp(localPoint.y, -primitive.halfHeight, primitive.halfHeight)
|
|
34681
34688
|
});
|
|
34682
34689
|
};
|
|
34683
|
-
var doesSegmentCrossTrace = (
|
|
34690
|
+
var doesSegmentCrossTrace = ({
|
|
34691
|
+
start,
|
|
34692
|
+
end,
|
|
34693
|
+
trace,
|
|
34694
|
+
clearance = 0
|
|
34695
|
+
}) => {
|
|
34696
|
+
const blockingRadius = trace.halfWidth + clearance;
|
|
34684
34697
|
const pathBounds = getBoundsFromPoints3([start, end]);
|
|
34685
34698
|
const expandedPathBounds = {
|
|
34686
|
-
minX: pathBounds.minX -
|
|
34687
|
-
minY: pathBounds.minY -
|
|
34688
|
-
maxX: pathBounds.maxX +
|
|
34689
|
-
maxY: pathBounds.maxY +
|
|
34699
|
+
minX: pathBounds.minX - blockingRadius,
|
|
34700
|
+
minY: pathBounds.minY - blockingRadius,
|
|
34701
|
+
maxX: pathBounds.maxX + blockingRadius,
|
|
34702
|
+
maxY: pathBounds.maxY + blockingRadius
|
|
34690
34703
|
};
|
|
34691
34704
|
const traceStart = { x: trace.x1, y: trace.y1 };
|
|
34692
34705
|
const traceEnd = { x: trace.x2, y: trace.y2 };
|
|
@@ -34694,7 +34707,7 @@ var doesSegmentCrossTrace = (start, end, trace) => {
|
|
|
34694
34707
|
if (!doBoundsOverlap2(traceBounds, expandedPathBounds)) {
|
|
34695
34708
|
return false;
|
|
34696
34709
|
}
|
|
34697
|
-
return segmentToSegmentMinDistance(start, end, traceStart, traceEnd) <=
|
|
34710
|
+
return segmentToSegmentMinDistance(start, end, traceStart, traceEnd) <= blockingRadius;
|
|
34698
34711
|
};
|
|
34699
34712
|
var traceLoops = (cells, nx) => {
|
|
34700
34713
|
const inSet = new Set(cells);
|
|
@@ -34742,7 +34755,197 @@ var traceLoops = (cells, nx) => {
|
|
|
34742
34755
|
|
|
34743
34756
|
// node_modules/@tscircuit/implicit-copper-pour-solver/lib/grid-solver.ts
|
|
34744
34757
|
var BLOCKED_CELL_LOCAL_REPAIR_RADIUS = 2;
|
|
34745
|
-
var
|
|
34758
|
+
var CELL_BOUNDARY_SAMPLE_COUNT = 9;
|
|
34759
|
+
var getGridNeighbors = (cell, { nx, ny }) => {
|
|
34760
|
+
const i = cell % nx;
|
|
34761
|
+
const j = Math.floor(cell / nx);
|
|
34762
|
+
const neighbors = [];
|
|
34763
|
+
if (i > 0) neighbors.push(cell - 1);
|
|
34764
|
+
if (i < nx - 1) neighbors.push(cell + 1);
|
|
34765
|
+
if (j > 0) neighbors.push(cell - nx);
|
|
34766
|
+
if (j < ny - 1) neighbors.push(cell + nx);
|
|
34767
|
+
return neighbors;
|
|
34768
|
+
};
|
|
34769
|
+
var createCanCrossGridEdgeForNet = (netIndex, ctx) => {
|
|
34770
|
+
const crossingCache = new Uint8Array(ctx.labels.length * 2);
|
|
34771
|
+
return (startCell, endCell) => {
|
|
34772
|
+
const edgeIndex = Math.min(startCell, endCell) * 2 + (Math.abs(startCell - endCell) === ctx.nx ? 1 : 0);
|
|
34773
|
+
const cachedCrossing = crossingCache[edgeIndex];
|
|
34774
|
+
if (cachedCrossing !== 0) return cachedCrossing === 1;
|
|
34775
|
+
const start = ctx.gridCells[startCell].center;
|
|
34776
|
+
const end = ctx.gridCells[endCell].center;
|
|
34777
|
+
const boundaryMidpoint = midpoint(start, end);
|
|
34778
|
+
const isHorizontalNeighbor = start.y === end.y;
|
|
34779
|
+
const boundary = isHorizontalNeighbor ? {
|
|
34780
|
+
minX: boundaryMidpoint.x,
|
|
34781
|
+
minY: boundaryMidpoint.y - ctx.gridPitch / 2,
|
|
34782
|
+
maxX: boundaryMidpoint.x,
|
|
34783
|
+
maxY: boundaryMidpoint.y + ctx.gridPitch / 2
|
|
34784
|
+
} : {
|
|
34785
|
+
minX: boundaryMidpoint.x - ctx.gridPitch / 2,
|
|
34786
|
+
minY: boundaryMidpoint.y,
|
|
34787
|
+
maxX: boundaryMidpoint.x + ctx.gridPitch / 2,
|
|
34788
|
+
maxY: boundaryMidpoint.y
|
|
34789
|
+
};
|
|
34790
|
+
let blockedSamples = 0;
|
|
34791
|
+
const allSamplesBlocked = (1 << CELL_BOUNDARY_SAMPLE_COUNT) - 1;
|
|
34792
|
+
for (const trace of ctx.traceBarriers) {
|
|
34793
|
+
if (trace.netIndex === netIndex || trace.maxX < boundary.minX || trace.minX > boundary.maxX || trace.maxY < boundary.minY || trace.minY > boundary.maxY) {
|
|
34794
|
+
continue;
|
|
34795
|
+
}
|
|
34796
|
+
for (let sampleIndex = 0; sampleIndex < CELL_BOUNDARY_SAMPLE_COUNT; sampleIndex++) {
|
|
34797
|
+
const sampleBit = 1 << sampleIndex;
|
|
34798
|
+
if ((blockedSamples & sampleBit) !== 0) continue;
|
|
34799
|
+
const offset = -ctx.gridPitch / 2 + ctx.gridPitch * sampleIndex / (CELL_BOUNDARY_SAMPLE_COUNT - 1);
|
|
34800
|
+
const point6 = isHorizontalNeighbor ? { x: boundaryMidpoint.x, y: boundaryMidpoint.y + offset } : { x: boundaryMidpoint.x + offset, y: boundaryMidpoint.y };
|
|
34801
|
+
const closestTracePoint = pointToSegmentClosestPoint2(
|
|
34802
|
+
point6,
|
|
34803
|
+
trace.start,
|
|
34804
|
+
trace.end
|
|
34805
|
+
);
|
|
34806
|
+
if (distSq(point6, closestTracePoint) <= trace.radiusSquared) {
|
|
34807
|
+
blockedSamples |= sampleBit;
|
|
34808
|
+
}
|
|
34809
|
+
}
|
|
34810
|
+
if (blockedSamples === allSamplesBlocked) {
|
|
34811
|
+
crossingCache[edgeIndex] = 2;
|
|
34812
|
+
return false;
|
|
34813
|
+
}
|
|
34814
|
+
}
|
|
34815
|
+
crossingCache[edgeIndex] = 1;
|
|
34816
|
+
return true;
|
|
34817
|
+
};
|
|
34818
|
+
};
|
|
34819
|
+
var getCanCrossGridEdgeForNet = (netIndex, ctx) => {
|
|
34820
|
+
let canCrossGridEdge = ctx.canCrossGridEdgeByNetIndex.get(netIndex);
|
|
34821
|
+
if (!canCrossGridEdge) {
|
|
34822
|
+
canCrossGridEdge = createCanCrossGridEdgeForNet(netIndex, ctx);
|
|
34823
|
+
ctx.canCrossGridEdgeByNetIndex.set(netIndex, canCrossGridEdge);
|
|
34824
|
+
}
|
|
34825
|
+
return canCrossGridEdge;
|
|
34826
|
+
};
|
|
34827
|
+
var normalizeClearanceSeparatedRegions = ({
|
|
34828
|
+
labeledLayer,
|
|
34829
|
+
insideCells,
|
|
34830
|
+
connectivitySeedNetIndices,
|
|
34831
|
+
traceBarriers,
|
|
34832
|
+
gridCells,
|
|
34833
|
+
traceClearance,
|
|
34834
|
+
gridPitch
|
|
34835
|
+
}) => {
|
|
34836
|
+
if (traceClearance === 0) return;
|
|
34837
|
+
const { labels, nx, ny } = labeledLayer;
|
|
34838
|
+
const clearanceTraceBarriers = traceBarriers.map(
|
|
34839
|
+
(trace) => {
|
|
34840
|
+
const radius = trace.halfWidth + traceClearance;
|
|
34841
|
+
const start = { x: trace.x1, y: trace.y1 };
|
|
34842
|
+
const end = { x: trace.x2, y: trace.y2 };
|
|
34843
|
+
const centerlineBounds = getBoundsFromPoints4([start, end]);
|
|
34844
|
+
return {
|
|
34845
|
+
netIndex: trace.netIndex,
|
|
34846
|
+
start,
|
|
34847
|
+
end,
|
|
34848
|
+
radiusSquared: radius ** 2,
|
|
34849
|
+
minX: centerlineBounds.minX - radius,
|
|
34850
|
+
minY: centerlineBounds.minY - radius,
|
|
34851
|
+
maxX: centerlineBounds.maxX + radius,
|
|
34852
|
+
maxY: centerlineBounds.maxY + radius
|
|
34853
|
+
};
|
|
34854
|
+
}
|
|
34855
|
+
);
|
|
34856
|
+
const clearanceConnectivityContext = {
|
|
34857
|
+
labels,
|
|
34858
|
+
nx,
|
|
34859
|
+
traceBarriers: clearanceTraceBarriers,
|
|
34860
|
+
gridCells,
|
|
34861
|
+
gridPitch,
|
|
34862
|
+
canCrossGridEdgeByNetIndex: /* @__PURE__ */ new Map()
|
|
34863
|
+
};
|
|
34864
|
+
const reachableCells = new Uint8Array(labels.length);
|
|
34865
|
+
const queue = [];
|
|
34866
|
+
for (let cell = 0; cell < labels.length; cell++) {
|
|
34867
|
+
if (insideCells[cell] !== 1 || connectivitySeedNetIndices[cell] !== labels[cell]) {
|
|
34868
|
+
continue;
|
|
34869
|
+
}
|
|
34870
|
+
reachableCells[cell] = 1;
|
|
34871
|
+
queue.push(cell);
|
|
34872
|
+
}
|
|
34873
|
+
let queueIndex = 0;
|
|
34874
|
+
while (queueIndex < queue.length) {
|
|
34875
|
+
const cell = queue[queueIndex++];
|
|
34876
|
+
const netIndex = labels[cell];
|
|
34877
|
+
for (const neighbor of getGridNeighbors(cell, labeledLayer)) {
|
|
34878
|
+
if (insideCells[neighbor] !== 1 || reachableCells[neighbor] === 1 || labels[neighbor] !== netIndex || !getCanCrossGridEdgeForNet(netIndex, clearanceConnectivityContext)(
|
|
34879
|
+
cell,
|
|
34880
|
+
neighbor
|
|
34881
|
+
)) {
|
|
34882
|
+
continue;
|
|
34883
|
+
}
|
|
34884
|
+
reachableCells[neighbor] = 1;
|
|
34885
|
+
queue.push(neighbor);
|
|
34886
|
+
}
|
|
34887
|
+
}
|
|
34888
|
+
const visitedCells = new Uint8Array(labels.length);
|
|
34889
|
+
const relabels = [];
|
|
34890
|
+
for (let start = 0; start < labels.length; start++) {
|
|
34891
|
+
if (insideCells[start] !== 1 || labels[start] < 0 || reachableCells[start] === 1 || visitedCells[start] === 1) {
|
|
34892
|
+
continue;
|
|
34893
|
+
}
|
|
34894
|
+
const netIndex = labels[start];
|
|
34895
|
+
const component = [];
|
|
34896
|
+
const componentQueue = [start];
|
|
34897
|
+
visitedCells[start] = 1;
|
|
34898
|
+
while (componentQueue.length > 0) {
|
|
34899
|
+
const cell = componentQueue.pop();
|
|
34900
|
+
component.push(cell);
|
|
34901
|
+
for (const neighbor of getGridNeighbors(cell, labeledLayer)) {
|
|
34902
|
+
if (insideCells[neighbor] !== 1 || visitedCells[neighbor] === 1 || reachableCells[neighbor] === 1 || labels[neighbor] !== netIndex || !getCanCrossGridEdgeForNet(netIndex, clearanceConnectivityContext)(
|
|
34903
|
+
cell,
|
|
34904
|
+
neighbor
|
|
34905
|
+
)) {
|
|
34906
|
+
continue;
|
|
34907
|
+
}
|
|
34908
|
+
visitedCells[neighbor] = 1;
|
|
34909
|
+
componentQueue.push(neighbor);
|
|
34910
|
+
}
|
|
34911
|
+
}
|
|
34912
|
+
const sharedEdgesByNetIndex = /* @__PURE__ */ new Map();
|
|
34913
|
+
for (const cell of component) {
|
|
34914
|
+
for (const neighbor of getGridNeighbors(cell, labeledLayer)) {
|
|
34915
|
+
const neighborNetIndex = labels[neighbor];
|
|
34916
|
+
if (reachableCells[neighbor] !== 1 || neighborNetIndex < 0 || neighborNetIndex === netIndex || !getCanCrossGridEdgeForNet(
|
|
34917
|
+
neighborNetIndex,
|
|
34918
|
+
clearanceConnectivityContext
|
|
34919
|
+
)(cell, neighbor)) {
|
|
34920
|
+
continue;
|
|
34921
|
+
}
|
|
34922
|
+
sharedEdgesByNetIndex.set(
|
|
34923
|
+
neighborNetIndex,
|
|
34924
|
+
(sharedEdgesByNetIndex.get(neighborNetIndex) ?? 0) + 1
|
|
34925
|
+
);
|
|
34926
|
+
}
|
|
34927
|
+
}
|
|
34928
|
+
const targetNetIndex = [...sharedEdgesByNetIndex.entries()].sort(
|
|
34929
|
+
(a, b) => b[1] - a[1]
|
|
34930
|
+
)[0]?.[0];
|
|
34931
|
+
if (targetNetIndex !== void 0) {
|
|
34932
|
+
relabels.push({ cells: component, netIndex: targetNetIndex });
|
|
34933
|
+
} else {
|
|
34934
|
+
relabels.push({ cells: component, netIndex: -1 });
|
|
34935
|
+
}
|
|
34936
|
+
}
|
|
34937
|
+
for (const relabel of relabels) {
|
|
34938
|
+
for (const cell of relabel.cells) labels[cell] = relabel.netIndex;
|
|
34939
|
+
}
|
|
34940
|
+
};
|
|
34941
|
+
var normalizeBlockedCellBoundaries = ({
|
|
34942
|
+
labeledLayer,
|
|
34943
|
+
insideCells,
|
|
34944
|
+
visibleCells,
|
|
34945
|
+
traceBarriers,
|
|
34946
|
+
gridCells,
|
|
34947
|
+
traceClearance
|
|
34948
|
+
}) => {
|
|
34746
34949
|
const { labels, nx, ny } = labeledLayer;
|
|
34747
34950
|
const netIndices = /* @__PURE__ */ new Set();
|
|
34748
34951
|
for (let cell = 0; cell < labels.length; cell++) {
|
|
@@ -34777,7 +34980,12 @@ var normalizeBlockedCellBoundaries = (labeledLayer, insideCells, visibleCells, t
|
|
|
34777
34980
|
}
|
|
34778
34981
|
const end = gridCells[neighbor].center;
|
|
34779
34982
|
const isBlocked = traceBarriers.some(
|
|
34780
|
-
(trace) => trace.netIndex !== netIndex && doesSegmentCrossTrace(
|
|
34983
|
+
(trace) => trace.netIndex !== netIndex && doesSegmentCrossTrace({
|
|
34984
|
+
start,
|
|
34985
|
+
end,
|
|
34986
|
+
trace,
|
|
34987
|
+
clearance: traceClearance
|
|
34988
|
+
})
|
|
34781
34989
|
);
|
|
34782
34990
|
if (isBlocked) continue;
|
|
34783
34991
|
distances[neighbor] = distances[cell] + 1;
|
|
@@ -34805,7 +35013,13 @@ var normalizeBlockedCellBoundaries = (labeledLayer, insideCells, visibleCells, t
|
|
|
34805
35013
|
}
|
|
34806
35014
|
};
|
|
34807
35015
|
var assignGridCells = (problem) => {
|
|
34808
|
-
const {
|
|
35016
|
+
const {
|
|
35017
|
+
bounds,
|
|
35018
|
+
boardOutline,
|
|
35019
|
+
gridPitch,
|
|
35020
|
+
regionNormalizationArea,
|
|
35021
|
+
traceClearance
|
|
35022
|
+
} = problem;
|
|
34809
35023
|
const nx = Math.max(1, Math.round((bounds.maxX - bounds.minX) / gridPitch));
|
|
34810
35024
|
const ny = Math.max(1, Math.round((bounds.maxY - bounds.minY) / gridPitch));
|
|
34811
35025
|
const normalizationMinCells = Math.max(
|
|
@@ -34834,6 +35048,8 @@ var assignGridCells = (problem) => {
|
|
|
34834
35048
|
const anchoredCells = new Uint8Array(nx * ny);
|
|
34835
35049
|
const insideCells = new Uint8Array(nx * ny);
|
|
34836
35050
|
const visibleCells = new Uint8Array(nx * ny);
|
|
35051
|
+
const connectivitySeedNetIndices = new Int32Array(nx * ny).fill(-1);
|
|
35052
|
+
const gridCellHalfDiagonal = gridPitch * Math.SQRT2 / 2;
|
|
34837
35053
|
for (const { index: cell, center: point6 } of gridCells) {
|
|
34838
35054
|
if (!isPointInsidePolygon(point6, boardOutline)) continue;
|
|
34839
35055
|
insideCells[cell] = 1;
|
|
@@ -34842,11 +35058,13 @@ var assignGridCells = (problem) => {
|
|
|
34842
35058
|
distance: distanceToPrimitive(primitive, point6.x, point6.y)
|
|
34843
35059
|
})).sort((a, b) => a.distance - b.distance);
|
|
34844
35060
|
let bestNetIndex = candidates[0]?.primitive.netIndex ?? -1;
|
|
35061
|
+
let bestDistance = candidates[0]?.distance ?? Number.POSITIVE_INFINITY;
|
|
34845
35062
|
let isAnchored = false;
|
|
34846
35063
|
let hasVisibleCandidate = false;
|
|
34847
35064
|
for (const candidate of candidates) {
|
|
34848
35065
|
if (candidate.distance === 0) {
|
|
34849
35066
|
bestNetIndex = candidate.primitive.netIndex;
|
|
35067
|
+
bestDistance = candidate.distance;
|
|
34850
35068
|
isAnchored = true;
|
|
34851
35069
|
hasVisibleCandidate = true;
|
|
34852
35070
|
break;
|
|
@@ -34856,10 +35074,16 @@ var assignGridCells = (problem) => {
|
|
|
34856
35074
|
point6
|
|
34857
35075
|
);
|
|
34858
35076
|
const isBlocked = traceBarriers.some(
|
|
34859
|
-
(trace) => trace.netIndex !== candidate.primitive.netIndex && doesSegmentCrossTrace(
|
|
35077
|
+
(trace) => trace.netIndex !== candidate.primitive.netIndex && doesSegmentCrossTrace({
|
|
35078
|
+
start: point6,
|
|
35079
|
+
end: closestPoint,
|
|
35080
|
+
trace,
|
|
35081
|
+
clearance: traceClearance
|
|
35082
|
+
})
|
|
34860
35083
|
);
|
|
34861
35084
|
if (!isBlocked) {
|
|
34862
35085
|
bestNetIndex = candidate.primitive.netIndex;
|
|
35086
|
+
bestDistance = candidate.distance;
|
|
34863
35087
|
hasVisibleCandidate = true;
|
|
34864
35088
|
break;
|
|
34865
35089
|
}
|
|
@@ -34867,15 +35091,28 @@ var assignGridCells = (problem) => {
|
|
|
34867
35091
|
labels[cell] = bestNetIndex;
|
|
34868
35092
|
if (isAnchored) anchoredCells[cell] = 1;
|
|
34869
35093
|
if (hasVisibleCandidate) visibleCells[cell] = 1;
|
|
35094
|
+
if (hasVisibleCandidate && bestDistance <= gridCellHalfDiagonal) {
|
|
35095
|
+
connectivitySeedNetIndices[cell] = bestNetIndex;
|
|
35096
|
+
}
|
|
34870
35097
|
}
|
|
34871
35098
|
const labeledLayer = { layer, labels, nx, ny };
|
|
34872
|
-
normalizeBlockedCellBoundaries(
|
|
35099
|
+
normalizeBlockedCellBoundaries({
|
|
34873
35100
|
labeledLayer,
|
|
34874
35101
|
insideCells,
|
|
34875
35102
|
visibleCells,
|
|
34876
35103
|
traceBarriers,
|
|
34877
|
-
gridCells
|
|
34878
|
-
|
|
35104
|
+
gridCells,
|
|
35105
|
+
traceClearance
|
|
35106
|
+
});
|
|
35107
|
+
normalizeClearanceSeparatedRegions({
|
|
35108
|
+
labeledLayer,
|
|
35109
|
+
insideCells,
|
|
35110
|
+
connectivitySeedNetIndices,
|
|
35111
|
+
traceBarriers,
|
|
35112
|
+
gridCells,
|
|
35113
|
+
traceClearance,
|
|
35114
|
+
gridPitch
|
|
35115
|
+
});
|
|
34879
35116
|
normalizeLabeledLayerRegions(
|
|
34880
35117
|
labeledLayer,
|
|
34881
35118
|
anchoredCells,
|
|
@@ -35083,7 +35320,7 @@ var getLayerColor = (layer) => layer === "top" ? "#c2453a" : layer === "bottom"
|
|
|
35083
35320
|
import { getElementId } from "@tscircuit/circuit-json-util";
|
|
35084
35321
|
import {
|
|
35085
35322
|
getBoundFromCenteredRect,
|
|
35086
|
-
getBoundsFromPoints as
|
|
35323
|
+
getBoundsFromPoints as getBoundsFromPoints5
|
|
35087
35324
|
} from "@tscircuit/math-utils";
|
|
35088
35325
|
import {
|
|
35089
35326
|
ConnectivityMap as ConnectivityMap2,
|
|
@@ -35097,6 +35334,7 @@ import {
|
|
|
35097
35334
|
translate as translate7
|
|
35098
35335
|
} from "transformation-matrix";
|
|
35099
35336
|
var DEFAULT_GRID_PITCH = 0.25;
|
|
35337
|
+
var DEFAULT_TRACE_CLEARANCE = 0.2;
|
|
35100
35338
|
var DEFAULT_MIN_REGION_AREA = 0;
|
|
35101
35339
|
var DEFAULT_REGION_NORMALIZATION_AREA = 0.5;
|
|
35102
35340
|
var getBoardOutline = (board) => {
|
|
@@ -35258,10 +35496,14 @@ var addTrace = (primitives, trace, netIndex) => {
|
|
|
35258
35496
|
};
|
|
35259
35497
|
var prepareCircuitJson = (input) => {
|
|
35260
35498
|
const gridPitch = input.gridPitch ?? DEFAULT_GRID_PITCH;
|
|
35499
|
+
const traceClearance = input.traceClearance ?? DEFAULT_TRACE_CLEARANCE;
|
|
35261
35500
|
const edgeSimplificationTolerance = input.edgeSimplificationTolerance ?? gridPitch;
|
|
35262
35501
|
const minRegionArea = input.minRegionArea ?? DEFAULT_MIN_REGION_AREA;
|
|
35263
35502
|
const regionNormalizationArea = input.regionNormalizationArea ?? DEFAULT_REGION_NORMALIZATION_AREA;
|
|
35264
35503
|
if (!(gridPitch > 0)) throw new Error("gridPitch must be greater than zero");
|
|
35504
|
+
if (!Number.isFinite(traceClearance) || traceClearance < 0) {
|
|
35505
|
+
throw new Error("traceClearance must be zero or greater");
|
|
35506
|
+
}
|
|
35265
35507
|
if (!Number.isFinite(edgeSimplificationTolerance) || edgeSimplificationTolerance < 0) {
|
|
35266
35508
|
throw new Error("edgeSimplificationTolerance must be zero or greater");
|
|
35267
35509
|
}
|
|
@@ -35276,7 +35518,7 @@ var prepareCircuitJson = (input) => {
|
|
|
35276
35518
|
);
|
|
35277
35519
|
if (!board) throw new Error("No pcb_board found in Circuit JSON");
|
|
35278
35520
|
const boardOutline = getBoardOutline(board);
|
|
35279
|
-
const bounds =
|
|
35521
|
+
const bounds = getBoundsFromPoints5(boardOutline);
|
|
35280
35522
|
const sourceNets = input.circuitJson.filter(
|
|
35281
35523
|
(element) => element.type === "source_net"
|
|
35282
35524
|
);
|
|
@@ -35477,6 +35719,7 @@ var prepareCircuitJson = (input) => {
|
|
|
35477
35719
|
nets,
|
|
35478
35720
|
primitives,
|
|
35479
35721
|
gridPitch,
|
|
35722
|
+
traceClearance,
|
|
35480
35723
|
minRegionArea,
|
|
35481
35724
|
regionNormalizationArea,
|
|
35482
35725
|
coveredWithSolderMask: input.coveredWithSolderMask ?? true
|
|
@@ -39069,7 +39312,7 @@ function collectPadElementsByReference(component) {
|
|
|
39069
39312
|
}
|
|
39070
39313
|
|
|
39071
39314
|
// lib/components/primitive-components/Group/Group_doInitialPcbComponentAnchorAlignment.ts
|
|
39072
|
-
import { getBoundsFromPoints as
|
|
39315
|
+
import { getBoundsFromPoints as getBoundsFromPoints6 } from "@tscircuit/math-utils";
|
|
39073
39316
|
function Group_doInitialPcbComponentAnchorAlignment(group) {
|
|
39074
39317
|
if (group.root?.pcbDisabled) return;
|
|
39075
39318
|
if (!group.pcb_group_id) return;
|
|
@@ -39085,7 +39328,7 @@ function Group_doInitialPcbComponentAnchorAlignment(group) {
|
|
|
39085
39328
|
let height = pcbGroup.height;
|
|
39086
39329
|
const { center } = pcbGroup;
|
|
39087
39330
|
if (pcbGroup.outline && pcbGroup.outline.length > 0) {
|
|
39088
|
-
const bounds2 =
|
|
39331
|
+
const bounds2 = getBoundsFromPoints6(pcbGroup.outline);
|
|
39089
39332
|
if (bounds2) {
|
|
39090
39333
|
width = bounds2.maxX - bounds2.minX;
|
|
39091
39334
|
height = bounds2.maxY - bounds2.minY;
|
|
@@ -43849,7 +44092,7 @@ import {
|
|
|
43849
44092
|
} from "@tscircuit/math-utils";
|
|
43850
44093
|
|
|
43851
44094
|
// lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/getSchematicTextBounds.ts
|
|
43852
|
-
import { getBoundsFromPoints as
|
|
44095
|
+
import { getBoundsFromPoints as getBoundsFromPoints7 } from "@tscircuit/math-utils";
|
|
43853
44096
|
var DEFAULT_SCHEMATIC_TEXT_FONT_SIZE = 0.18;
|
|
43854
44097
|
function getSchematicTextBounds(text) {
|
|
43855
44098
|
const fontSize = text.font_size ?? DEFAULT_SCHEMATIC_TEXT_FONT_SIZE;
|
|
@@ -43895,7 +44138,7 @@ function getSchematicTextBounds(text) {
|
|
|
43895
44138
|
x: text.position.x + corner.x * cos - corner.y * sin,
|
|
43896
44139
|
y: text.position.y + corner.x * sin + corner.y * cos
|
|
43897
44140
|
}));
|
|
43898
|
-
return
|
|
44141
|
+
return getBoundsFromPoints7(corners);
|
|
43899
44142
|
}
|
|
43900
44143
|
|
|
43901
44144
|
// lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/schematicTextToTextBounds.ts
|
|
@@ -45805,7 +46048,7 @@ var Group_getFanoutPourNetMap = (group, routingPhasePlans) => {
|
|
|
45805
46048
|
};
|
|
45806
46049
|
|
|
45807
46050
|
// lib/components/primitive-components/Group/Group_getRoutingPhasePlans.ts
|
|
45808
|
-
import { getBoundsFromPoints as
|
|
46051
|
+
import { getBoundsFromPoints as getBoundsFromPoints8 } from "@tscircuit/math-utils";
|
|
45809
46052
|
|
|
45810
46053
|
// lib/components/primitive-components/BreakoutPoint.ts
|
|
45811
46054
|
import { breakoutPointProps } from "@tscircuit/props";
|
|
@@ -46177,7 +46420,7 @@ function Group_getRoutingPhasePlans(group) {
|
|
|
46177
46420
|
(trace) => !trace.pcb_trace_id
|
|
46178
46421
|
);
|
|
46179
46422
|
const pcbGroup = breakout.pcb_group_id ? breakout.root?.db.pcb_group.get(breakout.pcb_group_id) : null;
|
|
46180
|
-
const outlineBounds = pcbGroup?.outline ?
|
|
46423
|
+
const outlineBounds = pcbGroup?.outline ? getBoundsFromPoints8(pcbGroup.outline) : null;
|
|
46181
46424
|
const routingWidth = pcbGroup?.width ?? (outlineBounds ? outlineBounds.maxX - outlineBounds.minX : void 0);
|
|
46182
46425
|
const routingHeight = pcbGroup?.height ?? (outlineBounds ? outlineBounds.maxY - outlineBounds.minY : void 0);
|
|
46183
46426
|
const routingBounds = pcbGroup && routingWidth && routingHeight ? {
|
|
@@ -46263,7 +46506,7 @@ function Group_getRoutingPhasePlans(group) {
|
|
|
46263
46506
|
var package_default = {
|
|
46264
46507
|
name: "@tscircuit/core",
|
|
46265
46508
|
type: "module",
|
|
46266
|
-
version: "0.0.
|
|
46509
|
+
version: "0.0.1844",
|
|
46267
46510
|
types: "dist/index.d.ts",
|
|
46268
46511
|
main: "dist/index.js",
|
|
46269
46512
|
module: "dist/index.js",
|
|
@@ -46298,7 +46541,7 @@ var package_default = {
|
|
|
46298
46541
|
"@tscircuit/alphabet": "0.0.25",
|
|
46299
46542
|
"@tscircuit/bga-fanout-solver": "github:tscircuit/bga-fanout-solver#247c835cb8d69b65e53891dcf869731079415b39",
|
|
46300
46543
|
"@tscircuit/capacity-autorouter": "^0.0.874",
|
|
46301
|
-
"@tscircuit/checks": "^0.0.
|
|
46544
|
+
"@tscircuit/checks": "^0.0.183",
|
|
46302
46545
|
"@tscircuit/circuit-json-util": "^0.0.106",
|
|
46303
46546
|
"@tscircuit/common": "^0.0.20",
|
|
46304
46547
|
"@tscircuit/copper-pour-solver": "^0.0.52",
|
|
@@ -46306,7 +46549,7 @@ var package_default = {
|
|
|
46306
46549
|
"@tscircuit/fanout-solver": "0.0.57",
|
|
46307
46550
|
"@tscircuit/footprinter": "^0.0.426",
|
|
46308
46551
|
"@tscircuit/image-utils": "^0.0.8",
|
|
46309
|
-
"@tscircuit/implicit-copper-pour-solver": "github:tscircuit/implicit-copper-pour-solver#
|
|
46552
|
+
"@tscircuit/implicit-copper-pour-solver": "github:tscircuit/implicit-copper-pour-solver#a5cbbda0cd65fd4707c5c1af25779837c25aba92",
|
|
46310
46553
|
"@tscircuit/infer-cable-insertion-point": "^0.0.4",
|
|
46311
46554
|
"@tscircuit/infgrid-ijump-astar": "^0.0.35",
|
|
46312
46555
|
"@tscircuit/jlcpcb-manufacturing-specs": "git+https://github.com/tscircuit/jlcpcb-manufacturing-specs#e08af159db01a37db007e33f0a7268d0e4a279a5",
|
|
@@ -47760,7 +48003,7 @@ var Group5 = class extends NormalComponent3 {
|
|
|
47760
48003
|
x: distance14.parse(point6.x),
|
|
47761
48004
|
y: distance14.parse(point6.y)
|
|
47762
48005
|
}));
|
|
47763
|
-
const outlineBounds =
|
|
48006
|
+
const outlineBounds = getBoundsFromPoints9(numericOutline);
|
|
47764
48007
|
if (!outlineBounds) return;
|
|
47765
48008
|
const centerX2 = (outlineBounds.minX + outlineBounds.maxX) / 2;
|
|
47766
48009
|
const centerY2 = (outlineBounds.minY + outlineBounds.maxY) / 2;
|
|
@@ -51803,7 +52046,7 @@ var Board = class extends Group5 {
|
|
|
51803
52046
|
let width = dbBoard?.width ?? props.width;
|
|
51804
52047
|
let height = dbBoard?.height ?? props.height;
|
|
51805
52048
|
if ((width == null || height == null) && props.outline?.length) {
|
|
51806
|
-
const outlineBounds =
|
|
52049
|
+
const outlineBounds = getBoundsFromPoints10(props.outline);
|
|
51807
52050
|
if (outlineBounds) {
|
|
51808
52051
|
width ??= outlineBounds.maxX - outlineBounds.minX;
|
|
51809
52052
|
height ??= outlineBounds.maxY - outlineBounds.minY;
|
|
@@ -51860,7 +52103,7 @@ var Board = class extends Group5 {
|
|
|
51860
52103
|
let width = pcbGroup.width ?? 0;
|
|
51861
52104
|
let height = pcbGroup.height ?? 0;
|
|
51862
52105
|
if (pcbGroup.outline && pcbGroup.outline.length > 0) {
|
|
51863
|
-
const bounds =
|
|
52106
|
+
const bounds = getBoundsFromPoints10(pcbGroup.outline);
|
|
51864
52107
|
if (bounds) {
|
|
51865
52108
|
width = bounds.maxX - bounds.minX;
|
|
51866
52109
|
height = bounds.maxY - bounds.minY;
|
|
@@ -52035,7 +52278,7 @@ var Board = class extends Group5 {
|
|
|
52035
52278
|
}
|
|
52036
52279
|
let outlineTranslation = { x: 0, y: 0 };
|
|
52037
52280
|
if (outline && outline.length > 0 && (this.parent?.lowercaseComponentName === "panel" || this.parent?.lowercaseComponentName === "subpanel")) {
|
|
52038
|
-
const outlineBounds =
|
|
52281
|
+
const outlineBounds = getBoundsFromPoints10(outline);
|
|
52039
52282
|
if (outlineBounds) {
|
|
52040
52283
|
const outlineCenterX = (outlineBounds.minX + outlineBounds.maxX) / 2;
|
|
52041
52284
|
const outlineCenterY = (outlineBounds.minY + outlineBounds.maxY) / 2;
|
|
@@ -52212,7 +52455,7 @@ var Board = class extends Group5 {
|
|
|
52212
52455
|
if (this.pcb_board_id) {
|
|
52213
52456
|
db.pcb_board.update(this.pcb_board_id, { center: position });
|
|
52214
52457
|
if (pcbBoard?.outline) {
|
|
52215
|
-
const outlineBounds =
|
|
52458
|
+
const outlineBounds = getBoundsFromPoints10(pcbBoard.outline);
|
|
52216
52459
|
if (outlineBounds) {
|
|
52217
52460
|
const oldOutlineCenter = {
|
|
52218
52461
|
x: (outlineBounds.minX + outlineBounds.maxX) / 2,
|
|
@@ -52673,14 +52916,14 @@ function generatePanelOutlineRoutingCutouts(boards, options) {
|
|
|
52673
52916
|
import { distance as distance17 } from "circuit-json";
|
|
52674
52917
|
|
|
52675
52918
|
// lib/utils/panels/get-board-dimensions-from-props.ts
|
|
52676
|
-
import { getBoundsFromPoints as
|
|
52919
|
+
import { getBoundsFromPoints as getBoundsFromPoints11 } from "@tscircuit/math-utils";
|
|
52677
52920
|
import { distance as distance16 } from "circuit-json";
|
|
52678
52921
|
var getBoardDimensionsFromProps = (board) => {
|
|
52679
52922
|
const props = board._parsedProps;
|
|
52680
52923
|
let width = props.width != null ? distance16.parse(props.width) : void 0;
|
|
52681
52924
|
let height = props.height != null ? distance16.parse(props.height) : void 0;
|
|
52682
52925
|
if ((width === void 0 || height === void 0) && props.outline?.length) {
|
|
52683
|
-
const outlineBounds =
|
|
52926
|
+
const outlineBounds = getBoundsFromPoints11(props.outline);
|
|
52684
52927
|
if (outlineBounds) {
|
|
52685
52928
|
width ??= outlineBounds.maxX - outlineBounds.minX;
|
|
52686
52929
|
height ??= outlineBounds.maxY - outlineBounds.minY;
|
|
@@ -54313,7 +54556,7 @@ var getConnectedSchematicPort = ({
|
|
|
54313
54556
|
}
|
|
54314
54557
|
return null;
|
|
54315
54558
|
};
|
|
54316
|
-
var
|
|
54559
|
+
var midpoint2 = (ports) => ({
|
|
54317
54560
|
x: ports.reduce((sum, port) => sum + port.center.x, 0) / ports.length,
|
|
54318
54561
|
y: ports.reduce((sum, port) => sum + port.center.y, 0) / ports.length
|
|
54319
54562
|
});
|
|
@@ -54388,7 +54631,7 @@ var Ammeter_doInitialSchematicLayout = (ammeter) => {
|
|
|
54388
54631
|
})
|
|
54389
54632
|
).filter((port) => port !== null);
|
|
54390
54633
|
if (connectedSchematicPorts.length === 0) return;
|
|
54391
|
-
const baseCenter =
|
|
54634
|
+
const baseCenter = midpoint2(connectedSchematicPorts);
|
|
54392
54635
|
const obstacles = db.schematic_component.list().filter(
|
|
54393
54636
|
(component) => component.schematic_component_id !== schematicComponent.schematic_component_id && !component.is_schematic_group && component.schematic_sheet_id === schematicComponent.schematic_sheet_id
|
|
54394
54637
|
).map((component) => rectForComponent(component, PLACEMENT_MARGIN));
|
|
@@ -56625,9 +56868,9 @@ var defaultImplicitBreakoutPointSolverFn = (input) => {
|
|
|
56625
56868
|
};
|
|
56626
56869
|
|
|
56627
56870
|
// lib/components/primitive-components/Breakout/Breakout_doInitialPcbPlacementDesignRuleChecks.ts
|
|
56628
|
-
import { getBoundsFromPoints as
|
|
56871
|
+
import { getBoundsFromPoints as getBoundsFromPoints12 } from "@tscircuit/math-utils";
|
|
56629
56872
|
var getFanoutBounds = (pcbGroup) => {
|
|
56630
|
-
const outlineBounds = pcbGroup.outline ?
|
|
56873
|
+
const outlineBounds = pcbGroup.outline ? getBoundsFromPoints12(pcbGroup.outline) : null;
|
|
56631
56874
|
const width = pcbGroup.width ?? (outlineBounds ? outlineBounds.maxX - outlineBounds.minX : void 0);
|
|
56632
56875
|
const height = pcbGroup.height ?? (outlineBounds ? outlineBounds.maxY - outlineBounds.minY : void 0);
|
|
56633
56876
|
if (width === void 0 || height === void 0) return null;
|
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.1845",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@tscircuit/alphabet": "0.0.25",
|
|
37
37
|
"@tscircuit/bga-fanout-solver": "github:tscircuit/bga-fanout-solver#247c835cb8d69b65e53891dcf869731079415b39",
|
|
38
38
|
"@tscircuit/capacity-autorouter": "^0.0.874",
|
|
39
|
-
"@tscircuit/checks": "^0.0.
|
|
39
|
+
"@tscircuit/checks": "^0.0.183",
|
|
40
40
|
"@tscircuit/circuit-json-util": "^0.0.106",
|
|
41
41
|
"@tscircuit/common": "^0.0.20",
|
|
42
42
|
"@tscircuit/copper-pour-solver": "^0.0.52",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@tscircuit/fanout-solver": "0.0.57",
|
|
45
45
|
"@tscircuit/footprinter": "^0.0.426",
|
|
46
46
|
"@tscircuit/image-utils": "^0.0.8",
|
|
47
|
-
"@tscircuit/implicit-copper-pour-solver": "github:tscircuit/implicit-copper-pour-solver#
|
|
47
|
+
"@tscircuit/implicit-copper-pour-solver": "github:tscircuit/implicit-copper-pour-solver#a5cbbda0cd65fd4707c5c1af25779837c25aba92",
|
|
48
48
|
"@tscircuit/infer-cable-insertion-point": "^0.0.4",
|
|
49
49
|
"@tscircuit/infgrid-ijump-astar": "^0.0.35",
|
|
50
50
|
"@tscircuit/jlcpcb-manufacturing-specs": "git+https://github.com/tscircuit/jlcpcb-manufacturing-specs#e08af159db01a37db007e33f0a7268d0e4a279a5",
|