@tscircuit/hypergraph 0.0.43 → 0.0.44
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 +15 -75
- package/dist/index.js +18 -693
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -306,7 +306,7 @@ declare class HyperGraphSolver<RegionType extends Region = Region, RegionPortTyp
|
|
|
306
306
|
_step(): void;
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
type Bounds$
|
|
309
|
+
type Bounds$1 = {
|
|
310
310
|
minX: number;
|
|
311
311
|
minY: number;
|
|
312
312
|
maxX: number;
|
|
@@ -315,7 +315,7 @@ type Bounds$2 = {
|
|
|
315
315
|
|
|
316
316
|
interface JRegion extends Region {
|
|
317
317
|
d: {
|
|
318
|
-
bounds: Bounds$
|
|
318
|
+
bounds: Bounds$1;
|
|
319
319
|
center: {
|
|
320
320
|
x: number;
|
|
321
321
|
y: number;
|
|
@@ -406,7 +406,7 @@ declare class JumperGraphSolver extends HyperGraphSolver<JRegion, JPort> {
|
|
|
406
406
|
visualize(): GraphicsObject;
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
-
declare const calculateGraphBounds: (regions: JRegion[]) => Bounds$
|
|
409
|
+
declare const calculateGraphBounds: (regions: JRegion[]) => Bounds$1;
|
|
410
410
|
|
|
411
411
|
type XYConnection = {
|
|
412
412
|
start: {
|
|
@@ -502,7 +502,7 @@ type SharedBoundary = {
|
|
|
502
502
|
};
|
|
503
503
|
type RegionData = {
|
|
504
504
|
id: string;
|
|
505
|
-
bounds: Bounds$
|
|
505
|
+
bounds: Bounds$1 | null;
|
|
506
506
|
polygon: {
|
|
507
507
|
x: number;
|
|
508
508
|
y: number;
|
|
@@ -543,7 +543,7 @@ declare class RegionBuilder implements RegionRef {
|
|
|
543
543
|
private data;
|
|
544
544
|
constructor(id: string);
|
|
545
545
|
get id(): string;
|
|
546
|
-
rect(b: Bounds$
|
|
546
|
+
rect(b: Bounds$1): this;
|
|
547
547
|
polygon(points: {
|
|
548
548
|
x: number;
|
|
549
549
|
y: number;
|
|
@@ -572,7 +572,7 @@ declare class ConnectBuilder {
|
|
|
572
572
|
private portIds;
|
|
573
573
|
private boundary;
|
|
574
574
|
private prefixWasExplicitlySet;
|
|
575
|
-
constructor(region1Id: string, region2Id: string, bounds1: Bounds$
|
|
575
|
+
constructor(region1Id: string, region2Id: string, bounds1: Bounds$1, bounds2: Bounds$1, addPortFn: AddPortFn$1, prefixIdFn: PrefixIdFn, opts?: {
|
|
576
576
|
idPrefix?: string;
|
|
577
577
|
tolerance?: number;
|
|
578
578
|
});
|
|
@@ -592,7 +592,7 @@ declare class ConnectBuilder {
|
|
|
592
592
|
|
|
593
593
|
type ResolveRegionFn = (ref: RegionRef | string) => {
|
|
594
594
|
id: string;
|
|
595
|
-
bounds: Bounds$
|
|
595
|
+
bounds: Bounds$1;
|
|
596
596
|
};
|
|
597
597
|
type AddPortFn = (port: PortData) => void;
|
|
598
598
|
declare class PortBuilder {
|
|
@@ -920,9 +920,13 @@ var routeSegments = [
|
|
|
920
920
|
]
|
|
921
921
|
}
|
|
922
922
|
];
|
|
923
|
+
var tileWidth = 3.735441;
|
|
924
|
+
var tileHeight = 4.029267;
|
|
923
925
|
var viaTile4Regions = {
|
|
924
926
|
viasByNet: viasByNet,
|
|
925
|
-
routeSegments: routeSegments
|
|
927
|
+
routeSegments: routeSegments,
|
|
928
|
+
tileWidth: tileWidth,
|
|
929
|
+
tileHeight: tileHeight
|
|
926
930
|
};
|
|
927
931
|
|
|
928
932
|
type ResolvedRouteLineSegment = {
|
|
@@ -960,6 +964,8 @@ type ViaByNet = Record<string, ViaData[]>;
|
|
|
960
964
|
type ViaTile = {
|
|
961
965
|
viasByNet: ViaByNet;
|
|
962
966
|
routeSegments: RouteSegment[];
|
|
967
|
+
tileWidth?: number;
|
|
968
|
+
tileHeight?: number;
|
|
963
969
|
};
|
|
964
970
|
declare class ViaGraphSolver extends HyperGraphSolver<JRegion, JPort> {
|
|
965
971
|
getSolverName(): string;
|
|
@@ -998,36 +1004,6 @@ declare class ViaGraphSolver extends HyperGraphSolver<JRegion, JPort> {
|
|
|
998
1004
|
visualize(): GraphicsObject;
|
|
999
1005
|
}
|
|
1000
1006
|
|
|
1001
|
-
type Bounds$1 = {
|
|
1002
|
-
minX: number;
|
|
1003
|
-
maxX: number;
|
|
1004
|
-
minY: number;
|
|
1005
|
-
maxY: number;
|
|
1006
|
-
};
|
|
1007
|
-
/**
|
|
1008
|
-
* Generates a tiled grid of via topologies with outer frame regions.
|
|
1009
|
-
*
|
|
1010
|
-
* The via tiles are centered within the given bounds. If the bounds are smaller
|
|
1011
|
-
* than one tile, no via tiles are created - only outer frame regions.
|
|
1012
|
-
*
|
|
1013
|
-
* The outer frame consists of rectangular regions (T, B, L, R) that fill the
|
|
1014
|
-
* space between the tiled area and the problem bounds.
|
|
1015
|
-
*/
|
|
1016
|
-
declare function generateViaTopologyGrid(opts: {
|
|
1017
|
-
viaTile: ViaTile;
|
|
1018
|
-
bounds: Bounds$1;
|
|
1019
|
-
tileSize?: number;
|
|
1020
|
-
portPitch?: number;
|
|
1021
|
-
}): {
|
|
1022
|
-
regions: JRegion[];
|
|
1023
|
-
ports: JPort[];
|
|
1024
|
-
viaTile: ViaTile;
|
|
1025
|
-
tileCount: {
|
|
1026
|
-
rows: number;
|
|
1027
|
-
cols: number;
|
|
1028
|
-
};
|
|
1029
|
-
};
|
|
1030
|
-
|
|
1031
1007
|
/**
|
|
1032
1008
|
* Generates four outer topology regions (top, bottom, left, right) that wrap
|
|
1033
1009
|
* around all vias, forming a closed frame that extends to the graph boundary.
|
|
@@ -1048,15 +1024,6 @@ declare function generateDefaultViaTopologyRegions(opts: Parameters<typeof gener
|
|
|
1048
1024
|
regions: JRegion[];
|
|
1049
1025
|
ports: JPort[];
|
|
1050
1026
|
};
|
|
1051
|
-
declare function generateDefaultViaTopologyGrid(opts: Omit<Parameters<typeof generateViaTopologyGrid>[0], "viaTile">): {
|
|
1052
|
-
regions: JRegion[];
|
|
1053
|
-
ports: JPort[];
|
|
1054
|
-
viaTile: ViaTile;
|
|
1055
|
-
tileCount: {
|
|
1056
|
-
rows: number;
|
|
1057
|
-
cols: number;
|
|
1058
|
-
};
|
|
1059
|
-
};
|
|
1060
1027
|
|
|
1061
1028
|
type ConvexViaGraphFromXYConnectionsResult = JumperGraph & {
|
|
1062
1029
|
connections: Connection[];
|
|
@@ -1092,33 +1059,6 @@ declare function createConvexViaGraphFromXYConnections(xyConnections: XYConnecti
|
|
|
1092
1059
|
concavityTolerance?: number;
|
|
1093
1060
|
}): ConvexViaGraphFromXYConnectionsResult;
|
|
1094
1061
|
|
|
1095
|
-
type ViaGraphFromXYConnectionsResult = JumperGraph & {
|
|
1096
|
-
connections: Connection[];
|
|
1097
|
-
viaTile: ViaTile;
|
|
1098
|
-
tileCount: {
|
|
1099
|
-
rows: number;
|
|
1100
|
-
cols: number;
|
|
1101
|
-
};
|
|
1102
|
-
};
|
|
1103
|
-
/**
|
|
1104
|
-
* Creates a complete via topology graph from XY connections.
|
|
1105
|
-
*
|
|
1106
|
-
* This is the main entry point for integrating ViaGraphSolver with dataset02.
|
|
1107
|
-
* It:
|
|
1108
|
-
* 1. Calculates bounds from connection XY coordinates (no margin)
|
|
1109
|
-
* 2. Generates a tiled grid of via topologies that fits within bounds
|
|
1110
|
-
* 3. Creates outer frame regions to fill remaining space
|
|
1111
|
-
* 4. Attaches connection regions to the graph
|
|
1112
|
-
*
|
|
1113
|
-
* @param xyConnections - Array of connections with start/end XY coordinates
|
|
1114
|
-
* @param viaTile - Via tile data (vias grouped by net plus route segments)
|
|
1115
|
-
* @param opts - Optional configuration (tileSize defaults to 5mm, portPitch to 0.4mm)
|
|
1116
|
-
*/
|
|
1117
|
-
declare function createViaGraphFromXYConnections(xyConnections: XYConnection[], viaTile: ViaTile, opts?: {
|
|
1118
|
-
tileSize?: number;
|
|
1119
|
-
portPitch?: number;
|
|
1120
|
-
}): ViaGraphFromXYConnectionsResult;
|
|
1121
|
-
|
|
1122
1062
|
type ViaGraphWithConnections = JumperGraph & {
|
|
1123
1063
|
connections: Connection[];
|
|
1124
1064
|
};
|
|
@@ -1165,4 +1105,4 @@ declare function generateConvexViaTopologyRegions(opts: {
|
|
|
1165
1105
|
};
|
|
1166
1106
|
};
|
|
1167
1107
|
|
|
1168
|
-
export { type Bounds$
|
|
1108
|
+
export { type Bounds$1 as Bounds, type BuildOpts, type Candidate, ConnectBuilder, type ConnectOpts, type Connection, type ConnectionId, type ConvexViaGraphFromXYConnectionsResult, type GScore, type GraphEdgeId, type HyperGraph, HyperGraphSolver, type JPort, type JRegion, JUMPER_GRAPH_SOLVER_DEFAULTS, type JumperGraph, JumperGraphSolver, type JumperGraphWithConnections, type NetworkId, type PortAssignment, PortBuilder, type PortData, type PortId, type PortSpread, type Region, RegionBuilder, type RegionData, type RegionId, type RegionPort, type RegionPortAssignment, type RegionRef, type RouteSegment, type SerializedConnection, type SerializedGraphPort, type SerializedGraphRegion, type SerializedHyperGraph, type SerializedRegionPortAssignment, type SharedBoundary, type SolvedRoute, Topology, TopologyError, VIA_GRAPH_SOLVER_DEFAULTS, type ValidateOpts, type ViaByNet, type ViaData, ViaGraphSolver, type ViaGraphWithConnections, type ViaTile, type XYConnection, applyTransformToGraph, calculateGraphBounds, convertConnectionsToSerializedConnections, convertHyperGraphToSerializedHyperGraph, createConvexViaGraphFromXYConnections, createGraphWithConnectionsFromBaseGraph, createViaGraphWithConnections, generateConvexViaTopologyRegions, generateDefaultViaTopologyRegions, generateJumperGrid, generateJumperX4Grid, generateViaTopologyRegions, rotateGraph90Degrees, viaTile4Regions as viaTile };
|
package/dist/index.js
CHANGED
|
@@ -5504,7 +5504,9 @@ var via_tile_4_regions_default = {
|
|
|
5504
5504
|
}
|
|
5505
5505
|
]
|
|
5506
5506
|
}
|
|
5507
|
-
]
|
|
5507
|
+
],
|
|
5508
|
+
tileWidth: 3.735441,
|
|
5509
|
+
tileHeight: 4.029267
|
|
5508
5510
|
};
|
|
5509
5511
|
|
|
5510
5512
|
// lib/ViaGraphSolver/via-graph-generator/generateViaTopologyRegions.ts
|
|
@@ -5770,645 +5772,10 @@ var generateViaTopologyRegions = (viaTile, opts) => {
|
|
|
5770
5772
|
return { regions, ports };
|
|
5771
5773
|
};
|
|
5772
5774
|
|
|
5773
|
-
// lib/ViaGraphSolver/via-graph-generator/generateViaTopologyGrid.ts
|
|
5774
|
-
var DEFAULT_PORT_PITCH = 0.4;
|
|
5775
|
-
var DEFAULT_TILE_SIZE = 5;
|
|
5776
|
-
function translateGraph(graph, dx, dy, prefix) {
|
|
5777
|
-
const regionMap = /* @__PURE__ */ new Map();
|
|
5778
|
-
const regions = graph.regions.map((r) => {
|
|
5779
|
-
const newRegion = {
|
|
5780
|
-
regionId: `${prefix}:${r.regionId}`,
|
|
5781
|
-
ports: [],
|
|
5782
|
-
d: {
|
|
5783
|
-
bounds: {
|
|
5784
|
-
minX: r.d.bounds.minX + dx,
|
|
5785
|
-
maxX: r.d.bounds.maxX + dx,
|
|
5786
|
-
minY: r.d.bounds.minY + dy,
|
|
5787
|
-
maxY: r.d.bounds.maxY + dy
|
|
5788
|
-
},
|
|
5789
|
-
center: {
|
|
5790
|
-
x: r.d.center.x + dx,
|
|
5791
|
-
y: r.d.center.y + dy
|
|
5792
|
-
},
|
|
5793
|
-
polygon: r.d.polygon?.map((p) => ({ x: p.x + dx, y: p.y + dy })),
|
|
5794
|
-
isPad: r.d.isPad,
|
|
5795
|
-
isThroughJumper: r.d.isThroughJumper,
|
|
5796
|
-
isConnectionRegion: r.d.isConnectionRegion,
|
|
5797
|
-
isViaRegion: r.d.isViaRegion
|
|
5798
|
-
}
|
|
5799
|
-
};
|
|
5800
|
-
regionMap.set(r, newRegion);
|
|
5801
|
-
return newRegion;
|
|
5802
|
-
});
|
|
5803
|
-
const ports = graph.ports.map((p) => {
|
|
5804
|
-
const newPort = {
|
|
5805
|
-
portId: `${prefix}:${p.portId}`,
|
|
5806
|
-
region1: regionMap.get(p.region1),
|
|
5807
|
-
region2: regionMap.get(p.region2),
|
|
5808
|
-
d: { x: p.d.x + dx, y: p.d.y + dy }
|
|
5809
|
-
};
|
|
5810
|
-
newPort.region1.ports.push(newPort);
|
|
5811
|
-
newPort.region2.ports.push(newPort);
|
|
5812
|
-
return newPort;
|
|
5813
|
-
});
|
|
5814
|
-
return { regions, ports };
|
|
5815
|
-
}
|
|
5816
|
-
function translateRouteSegments(routeSegments, dx, dy, prefix) {
|
|
5817
|
-
return routeSegments.map((segment2) => ({
|
|
5818
|
-
routeId: `${prefix}:${segment2.routeId}`,
|
|
5819
|
-
fromPort: `${prefix}:${segment2.fromPort}`,
|
|
5820
|
-
toPort: `${prefix}:${segment2.toPort}`,
|
|
5821
|
-
layer: segment2.layer,
|
|
5822
|
-
segments: segment2.segments.map((point2) => ({
|
|
5823
|
-
x: point2.x + dx,
|
|
5824
|
-
y: point2.y + dy
|
|
5825
|
-
}))
|
|
5826
|
-
}));
|
|
5827
|
-
}
|
|
5828
|
-
function createBoundaryPorts(portIdPrefix, region1, region2, axis, fixedCoord, start, end, portPitch) {
|
|
5829
|
-
const length = Math.abs(end - start);
|
|
5830
|
-
if (length < 1e-3) return [];
|
|
5831
|
-
const count = Math.max(1, Math.floor(length / portPitch));
|
|
5832
|
-
const min = Math.min(start, end);
|
|
5833
|
-
const ports = [];
|
|
5834
|
-
for (let i = 0; i < count; i++) {
|
|
5835
|
-
const t = (i + 0.5) / count;
|
|
5836
|
-
const varying = min + t * length;
|
|
5837
|
-
const x = axis === "horizontal" ? varying : fixedCoord;
|
|
5838
|
-
const y = axis === "horizontal" ? fixedCoord : varying;
|
|
5839
|
-
const portId = count === 1 ? portIdPrefix : `${portIdPrefix}_${i}`;
|
|
5840
|
-
const port = {
|
|
5841
|
-
portId,
|
|
5842
|
-
region1,
|
|
5843
|
-
region2,
|
|
5844
|
-
d: { x, y }
|
|
5845
|
-
};
|
|
5846
|
-
region1.ports.push(port);
|
|
5847
|
-
region2.ports.push(port);
|
|
5848
|
-
ports.push(port);
|
|
5849
|
-
}
|
|
5850
|
-
return ports;
|
|
5851
|
-
}
|
|
5852
|
-
function createRectRegion(regionId, minX, maxX, minY, maxY) {
|
|
5853
|
-
const polygon2 = [
|
|
5854
|
-
{ x: minX, y: minY },
|
|
5855
|
-
{ x: maxX, y: minY },
|
|
5856
|
-
{ x: maxX, y: maxY },
|
|
5857
|
-
{ x: minX, y: maxY }
|
|
5858
|
-
];
|
|
5859
|
-
return {
|
|
5860
|
-
regionId,
|
|
5861
|
-
ports: [],
|
|
5862
|
-
d: {
|
|
5863
|
-
bounds: { minX, maxX, minY, maxY },
|
|
5864
|
-
center: { x: (minX + maxX) / 2, y: (minY + maxY) / 2 },
|
|
5865
|
-
polygon: polygon2,
|
|
5866
|
-
isPad: false
|
|
5867
|
-
}
|
|
5868
|
-
};
|
|
5869
|
-
}
|
|
5870
|
-
function findRegionBySuffix(graph, suffix) {
|
|
5871
|
-
const region = graph.regions.find((r) => r.regionId.endsWith(`:${suffix}`));
|
|
5872
|
-
if (!region) throw new Error(`Region with suffix ${suffix} not found`);
|
|
5873
|
-
return region;
|
|
5874
|
-
}
|
|
5875
|
-
function getBoundarySegments(polygon2, edge, boundaryCoord) {
|
|
5876
|
-
const eps = 1e-3;
|
|
5877
|
-
const segments = [];
|
|
5878
|
-
for (let i = 0; i < polygon2.length; i++) {
|
|
5879
|
-
const a = polygon2[i];
|
|
5880
|
-
const b = polygon2[(i + 1) % polygon2.length];
|
|
5881
|
-
const isVerticalEdge = edge === "right" || edge === "left";
|
|
5882
|
-
if (isVerticalEdge) {
|
|
5883
|
-
if (Math.abs(a.x - boundaryCoord) < eps && Math.abs(b.x - boundaryCoord) < eps) {
|
|
5884
|
-
segments.push({ from: Math.min(a.y, b.y), to: Math.max(a.y, b.y) });
|
|
5885
|
-
}
|
|
5886
|
-
} else {
|
|
5887
|
-
if (Math.abs(a.y - boundaryCoord) < eps && Math.abs(b.y - boundaryCoord) < eps) {
|
|
5888
|
-
segments.push({ from: Math.min(a.x, b.x), to: Math.max(a.x, b.x) });
|
|
5889
|
-
}
|
|
5890
|
-
}
|
|
5891
|
-
}
|
|
5892
|
-
return segments;
|
|
5893
|
-
}
|
|
5894
|
-
function rangeOverlap(a, b) {
|
|
5895
|
-
const from = Math.max(a.from, b.from);
|
|
5896
|
-
const to = Math.min(a.to, b.to);
|
|
5897
|
-
if (to - from < 1e-3) return null;
|
|
5898
|
-
return { from, to };
|
|
5899
|
-
}
|
|
5900
|
-
function generateViaTopologyGrid(opts) {
|
|
5901
|
-
const tileSize = opts.tileSize ?? DEFAULT_TILE_SIZE;
|
|
5902
|
-
const portPitch = opts.portPitch ?? DEFAULT_PORT_PITCH;
|
|
5903
|
-
const { bounds, viaTile: inputViaTile } = opts;
|
|
5904
|
-
const { viasByNet, routeSegments } = inputViaTile;
|
|
5905
|
-
const width = bounds.maxX - bounds.minX;
|
|
5906
|
-
const height = bounds.maxY - bounds.minY;
|
|
5907
|
-
const cols = Math.floor(width / tileSize);
|
|
5908
|
-
const rows = Math.floor(height / tileSize);
|
|
5909
|
-
const allRegions = [];
|
|
5910
|
-
const allPorts = [];
|
|
5911
|
-
const viaTile = { viasByNet: {}, routeSegments: [] };
|
|
5912
|
-
const gridWidth = cols * tileSize;
|
|
5913
|
-
const gridHeight = rows * tileSize;
|
|
5914
|
-
const gridMinX = bounds.minX + (width - gridWidth) / 2;
|
|
5915
|
-
const gridMinY = bounds.minY + (height - gridHeight) / 2;
|
|
5916
|
-
const gridMaxX = gridMinX + gridWidth;
|
|
5917
|
-
const gridMaxY = gridMinY + gridHeight;
|
|
5918
|
-
const tileGraphs = [];
|
|
5919
|
-
if (rows > 0 && cols > 0) {
|
|
5920
|
-
const baseGraph = generateViaTopologyRegions(inputViaTile, {
|
|
5921
|
-
graphSize: tileSize,
|
|
5922
|
-
idPrefix: "v"
|
|
5923
|
-
});
|
|
5924
|
-
const half = tileSize / 2;
|
|
5925
|
-
const outerIds = ["T", "B", "L", "R"];
|
|
5926
|
-
const baseBoundarySegs = {};
|
|
5927
|
-
for (const id of outerIds) {
|
|
5928
|
-
const r = baseGraph.regions.find((r2) => r2.regionId === `v:${id}`);
|
|
5929
|
-
baseBoundarySegs[id] = {
|
|
5930
|
-
right: getBoundarySegments(r.d.polygon, "right", half),
|
|
5931
|
-
left: getBoundarySegments(r.d.polygon, "left", -half),
|
|
5932
|
-
top: getBoundarySegments(r.d.polygon, "top", half),
|
|
5933
|
-
bottom: getBoundarySegments(r.d.polygon, "bottom", -half)
|
|
5934
|
-
};
|
|
5935
|
-
}
|
|
5936
|
-
for (let row = 0; row < rows; row++) {
|
|
5937
|
-
tileGraphs[row] = [];
|
|
5938
|
-
for (let col = 0; col < cols; col++) {
|
|
5939
|
-
const tileCenterX = gridMinX + col * tileSize + half;
|
|
5940
|
-
const tileCenterY = gridMinY + row * tileSize + half;
|
|
5941
|
-
const prefix = `t${row}_${col}`;
|
|
5942
|
-
const tile = translateGraph(baseGraph, tileCenterX, tileCenterY, prefix);
|
|
5943
|
-
tileGraphs[row][col] = tile;
|
|
5944
|
-
allRegions.push(...tile.regions);
|
|
5945
|
-
allPorts.push(...tile.ports);
|
|
5946
|
-
for (const [netName, vias] of Object.entries(viasByNet)) {
|
|
5947
|
-
if (!viaTile.viasByNet[netName]) {
|
|
5948
|
-
viaTile.viasByNet[netName] = [];
|
|
5949
|
-
}
|
|
5950
|
-
for (const via of vias) {
|
|
5951
|
-
viaTile.viasByNet[netName].push({
|
|
5952
|
-
viaId: `${prefix}:${via.viaId}`,
|
|
5953
|
-
diameter: via.diameter,
|
|
5954
|
-
position: {
|
|
5955
|
-
x: via.position.x + tileCenterX,
|
|
5956
|
-
y: via.position.y + tileCenterY
|
|
5957
|
-
}
|
|
5958
|
-
});
|
|
5959
|
-
}
|
|
5960
|
-
}
|
|
5961
|
-
viaTile.routeSegments.push(
|
|
5962
|
-
...translateRouteSegments(
|
|
5963
|
-
routeSegments,
|
|
5964
|
-
tileCenterX,
|
|
5965
|
-
tileCenterY,
|
|
5966
|
-
prefix
|
|
5967
|
-
)
|
|
5968
|
-
);
|
|
5969
|
-
}
|
|
5970
|
-
}
|
|
5971
|
-
const hPairs = [
|
|
5972
|
-
{
|
|
5973
|
-
leftRegionId: "T",
|
|
5974
|
-
leftEdge: "right",
|
|
5975
|
-
rightRegionId: "T",
|
|
5976
|
-
rightEdge: "left"
|
|
5977
|
-
},
|
|
5978
|
-
{
|
|
5979
|
-
leftRegionId: "R",
|
|
5980
|
-
leftEdge: "right",
|
|
5981
|
-
rightRegionId: "L",
|
|
5982
|
-
rightEdge: "left"
|
|
5983
|
-
},
|
|
5984
|
-
{
|
|
5985
|
-
leftRegionId: "B",
|
|
5986
|
-
leftEdge: "right",
|
|
5987
|
-
rightRegionId: "B",
|
|
5988
|
-
rightEdge: "left"
|
|
5989
|
-
}
|
|
5990
|
-
];
|
|
5991
|
-
for (let row = 0; row < rows; row++) {
|
|
5992
|
-
for (let col = 0; col < cols - 1; col++) {
|
|
5993
|
-
const leftTile = tileGraphs[row][col];
|
|
5994
|
-
const rightTile = tileGraphs[row][col + 1];
|
|
5995
|
-
const boundaryX = gridMinX + (col + 1) * tileSize;
|
|
5996
|
-
const yOffset = gridMinY + row * tileSize + half;
|
|
5997
|
-
for (const pair of hPairs) {
|
|
5998
|
-
const leftSegs = baseBoundarySegs[pair.leftRegionId][pair.leftEdge];
|
|
5999
|
-
const rightSegs = baseBoundarySegs[pair.rightRegionId][pair.rightEdge];
|
|
6000
|
-
for (const ls of leftSegs) {
|
|
6001
|
-
for (const rs of rightSegs) {
|
|
6002
|
-
const overlap = rangeOverlap(ls, rs);
|
|
6003
|
-
if (!overlap) continue;
|
|
6004
|
-
const r1 = findRegionBySuffix(leftTile, `v:${pair.leftRegionId}`);
|
|
6005
|
-
const r2 = findRegionBySuffix(
|
|
6006
|
-
rightTile,
|
|
6007
|
-
`v:${pair.rightRegionId}`
|
|
6008
|
-
);
|
|
6009
|
-
const tag = `${pair.leftRegionId}${pair.rightRegionId}`;
|
|
6010
|
-
const ports = createBoundaryPorts(
|
|
6011
|
-
`cross:h:${row}_${col}:${tag}`,
|
|
6012
|
-
r1,
|
|
6013
|
-
r2,
|
|
6014
|
-
"vertical",
|
|
6015
|
-
boundaryX,
|
|
6016
|
-
overlap.from + yOffset,
|
|
6017
|
-
overlap.to + yOffset,
|
|
6018
|
-
portPitch
|
|
6019
|
-
);
|
|
6020
|
-
allPorts.push(...ports);
|
|
6021
|
-
}
|
|
6022
|
-
}
|
|
6023
|
-
}
|
|
6024
|
-
}
|
|
6025
|
-
}
|
|
6026
|
-
const vPairs = [
|
|
6027
|
-
{
|
|
6028
|
-
bottomRegionId: "T",
|
|
6029
|
-
bottomEdge: "top",
|
|
6030
|
-
topRegionId: "B",
|
|
6031
|
-
topEdge: "bottom"
|
|
6032
|
-
},
|
|
6033
|
-
{
|
|
6034
|
-
bottomRegionId: "L",
|
|
6035
|
-
bottomEdge: "top",
|
|
6036
|
-
topRegionId: "L",
|
|
6037
|
-
topEdge: "bottom"
|
|
6038
|
-
},
|
|
6039
|
-
{
|
|
6040
|
-
bottomRegionId: "R",
|
|
6041
|
-
bottomEdge: "top",
|
|
6042
|
-
topRegionId: "R",
|
|
6043
|
-
topEdge: "bottom"
|
|
6044
|
-
}
|
|
6045
|
-
];
|
|
6046
|
-
for (let row = 0; row < rows - 1; row++) {
|
|
6047
|
-
for (let col = 0; col < cols; col++) {
|
|
6048
|
-
const bottomTile = tileGraphs[row][col];
|
|
6049
|
-
const topTile = tileGraphs[row + 1][col];
|
|
6050
|
-
const boundaryY = gridMinY + (row + 1) * tileSize;
|
|
6051
|
-
const xOffset = gridMinX + col * tileSize + half;
|
|
6052
|
-
for (const pair of vPairs) {
|
|
6053
|
-
const bottomSegs = baseBoundarySegs[pair.bottomRegionId][pair.bottomEdge];
|
|
6054
|
-
const topSegs = baseBoundarySegs[pair.topRegionId][pair.topEdge];
|
|
6055
|
-
for (const bs of bottomSegs) {
|
|
6056
|
-
for (const ts of topSegs) {
|
|
6057
|
-
const overlap = rangeOverlap(bs, ts);
|
|
6058
|
-
if (!overlap) continue;
|
|
6059
|
-
const r1 = findRegionBySuffix(
|
|
6060
|
-
bottomTile,
|
|
6061
|
-
`v:${pair.bottomRegionId}`
|
|
6062
|
-
);
|
|
6063
|
-
const r2 = findRegionBySuffix(topTile, `v:${pair.topRegionId}`);
|
|
6064
|
-
const tag = `${pair.bottomRegionId}${pair.topRegionId}`;
|
|
6065
|
-
const ports = createBoundaryPorts(
|
|
6066
|
-
`cross:v:${row}_${col}:${tag}`,
|
|
6067
|
-
r1,
|
|
6068
|
-
r2,
|
|
6069
|
-
"horizontal",
|
|
6070
|
-
boundaryY,
|
|
6071
|
-
overlap.from + xOffset,
|
|
6072
|
-
overlap.to + xOffset,
|
|
6073
|
-
portPitch
|
|
6074
|
-
);
|
|
6075
|
-
allPorts.push(...ports);
|
|
6076
|
-
}
|
|
6077
|
-
}
|
|
6078
|
-
}
|
|
6079
|
-
}
|
|
6080
|
-
}
|
|
6081
|
-
}
|
|
6082
|
-
const hasTopGap = bounds.maxY > gridMaxY || rows === 0;
|
|
6083
|
-
const hasBottomGap = bounds.minY < gridMinY || rows === 0;
|
|
6084
|
-
const hasLeftGap = bounds.minX < gridMinX || cols === 0;
|
|
6085
|
-
const hasRightGap = bounds.maxX > gridMaxX || cols === 0;
|
|
6086
|
-
let outerTop = null;
|
|
6087
|
-
let outerBottom = null;
|
|
6088
|
-
let outerLeft = null;
|
|
6089
|
-
let outerRight = null;
|
|
6090
|
-
const frameMinX = cols > 0 ? gridMinX : bounds.minX;
|
|
6091
|
-
const frameMaxX = cols > 0 ? gridMaxX : bounds.maxX;
|
|
6092
|
-
const frameMinY = rows > 0 ? gridMinY : bounds.minY;
|
|
6093
|
-
const frameMaxY = rows > 0 ? gridMaxY : bounds.maxY;
|
|
6094
|
-
if (hasLeftGap && bounds.minX < frameMinX) {
|
|
6095
|
-
outerLeft = createRectRegion(
|
|
6096
|
-
"outer:L",
|
|
6097
|
-
bounds.minX,
|
|
6098
|
-
frameMinX,
|
|
6099
|
-
bounds.minY,
|
|
6100
|
-
bounds.maxY
|
|
6101
|
-
);
|
|
6102
|
-
allRegions.push(outerLeft);
|
|
6103
|
-
}
|
|
6104
|
-
if (hasRightGap && bounds.maxX > frameMaxX) {
|
|
6105
|
-
outerRight = createRectRegion(
|
|
6106
|
-
"outer:R",
|
|
6107
|
-
frameMaxX,
|
|
6108
|
-
bounds.maxX,
|
|
6109
|
-
bounds.minY,
|
|
6110
|
-
bounds.maxY
|
|
6111
|
-
);
|
|
6112
|
-
allRegions.push(outerRight);
|
|
6113
|
-
}
|
|
6114
|
-
if (hasTopGap && bounds.maxY > frameMaxY) {
|
|
6115
|
-
outerTop = createRectRegion(
|
|
6116
|
-
"outer:T",
|
|
6117
|
-
frameMinX,
|
|
6118
|
-
frameMaxX,
|
|
6119
|
-
frameMaxY,
|
|
6120
|
-
bounds.maxY
|
|
6121
|
-
);
|
|
6122
|
-
allRegions.push(outerTop);
|
|
6123
|
-
}
|
|
6124
|
-
if (hasBottomGap && bounds.minY < frameMinY) {
|
|
6125
|
-
outerBottom = createRectRegion(
|
|
6126
|
-
"outer:B",
|
|
6127
|
-
frameMinX,
|
|
6128
|
-
frameMaxX,
|
|
6129
|
-
bounds.minY,
|
|
6130
|
-
frameMinY
|
|
6131
|
-
);
|
|
6132
|
-
allRegions.push(outerBottom);
|
|
6133
|
-
}
|
|
6134
|
-
if (outerTop && outerLeft) {
|
|
6135
|
-
allPorts.push(
|
|
6136
|
-
...createBoundaryPorts(
|
|
6137
|
-
"outer:T-L",
|
|
6138
|
-
outerTop,
|
|
6139
|
-
outerLeft,
|
|
6140
|
-
"vertical",
|
|
6141
|
-
frameMinX,
|
|
6142
|
-
frameMaxY,
|
|
6143
|
-
bounds.maxY,
|
|
6144
|
-
portPitch
|
|
6145
|
-
)
|
|
6146
|
-
);
|
|
6147
|
-
}
|
|
6148
|
-
if (outerTop && outerRight) {
|
|
6149
|
-
allPorts.push(
|
|
6150
|
-
...createBoundaryPorts(
|
|
6151
|
-
"outer:T-R",
|
|
6152
|
-
outerTop,
|
|
6153
|
-
outerRight,
|
|
6154
|
-
"vertical",
|
|
6155
|
-
frameMaxX,
|
|
6156
|
-
frameMaxY,
|
|
6157
|
-
bounds.maxY,
|
|
6158
|
-
portPitch
|
|
6159
|
-
)
|
|
6160
|
-
);
|
|
6161
|
-
}
|
|
6162
|
-
if (outerBottom && outerLeft) {
|
|
6163
|
-
allPorts.push(
|
|
6164
|
-
...createBoundaryPorts(
|
|
6165
|
-
"outer:B-L",
|
|
6166
|
-
outerBottom,
|
|
6167
|
-
outerLeft,
|
|
6168
|
-
"vertical",
|
|
6169
|
-
frameMinX,
|
|
6170
|
-
bounds.minY,
|
|
6171
|
-
frameMinY,
|
|
6172
|
-
portPitch
|
|
6173
|
-
)
|
|
6174
|
-
);
|
|
6175
|
-
}
|
|
6176
|
-
if (outerBottom && outerRight) {
|
|
6177
|
-
allPorts.push(
|
|
6178
|
-
...createBoundaryPorts(
|
|
6179
|
-
"outer:B-R",
|
|
6180
|
-
outerBottom,
|
|
6181
|
-
outerRight,
|
|
6182
|
-
"vertical",
|
|
6183
|
-
frameMaxX,
|
|
6184
|
-
bounds.minY,
|
|
6185
|
-
frameMinY,
|
|
6186
|
-
portPitch
|
|
6187
|
-
)
|
|
6188
|
-
);
|
|
6189
|
-
}
|
|
6190
|
-
if (rows > 0 && cols > 0) {
|
|
6191
|
-
const half = tileSize / 2;
|
|
6192
|
-
if (outerTop) {
|
|
6193
|
-
for (let col = 0; col < cols; col++) {
|
|
6194
|
-
const tile = tileGraphs[rows - 1][col];
|
|
6195
|
-
const tileT = findRegionBySuffix(tile, "v:T");
|
|
6196
|
-
const baseT = generateViaTopologyRegions(inputViaTile, {
|
|
6197
|
-
graphSize: tileSize,
|
|
6198
|
-
idPrefix: "v"
|
|
6199
|
-
}).regions.find((r) => r.regionId === "v:T");
|
|
6200
|
-
const topSegs = getBoundarySegments(baseT.d.polygon, "top", half);
|
|
6201
|
-
for (const seg of topSegs) {
|
|
6202
|
-
const tileCenterX = gridMinX + col * tileSize + half;
|
|
6203
|
-
allPorts.push(
|
|
6204
|
-
...createBoundaryPorts(
|
|
6205
|
-
`outer:T-tile${col}`,
|
|
6206
|
-
outerTop,
|
|
6207
|
-
tileT,
|
|
6208
|
-
"horizontal",
|
|
6209
|
-
gridMaxY,
|
|
6210
|
-
seg.from + tileCenterX,
|
|
6211
|
-
seg.to + tileCenterX,
|
|
6212
|
-
portPitch
|
|
6213
|
-
)
|
|
6214
|
-
);
|
|
6215
|
-
}
|
|
6216
|
-
}
|
|
6217
|
-
}
|
|
6218
|
-
if (outerBottom) {
|
|
6219
|
-
for (let col = 0; col < cols; col++) {
|
|
6220
|
-
const tile = tileGraphs[0][col];
|
|
6221
|
-
const tileB = findRegionBySuffix(tile, "v:B");
|
|
6222
|
-
const baseB = generateViaTopologyRegions(inputViaTile, {
|
|
6223
|
-
graphSize: tileSize,
|
|
6224
|
-
idPrefix: "v"
|
|
6225
|
-
}).regions.find((r) => r.regionId === "v:B");
|
|
6226
|
-
const bottomSegs = getBoundarySegments(
|
|
6227
|
-
baseB.d.polygon,
|
|
6228
|
-
"bottom",
|
|
6229
|
-
-half
|
|
6230
|
-
);
|
|
6231
|
-
for (const seg of bottomSegs) {
|
|
6232
|
-
const tileCenterX = gridMinX + col * tileSize + half;
|
|
6233
|
-
allPorts.push(
|
|
6234
|
-
...createBoundaryPorts(
|
|
6235
|
-
`outer:B-tile${col}`,
|
|
6236
|
-
outerBottom,
|
|
6237
|
-
tileB,
|
|
6238
|
-
"horizontal",
|
|
6239
|
-
gridMinY,
|
|
6240
|
-
seg.from + tileCenterX,
|
|
6241
|
-
seg.to + tileCenterX,
|
|
6242
|
-
portPitch
|
|
6243
|
-
)
|
|
6244
|
-
);
|
|
6245
|
-
}
|
|
6246
|
-
}
|
|
6247
|
-
}
|
|
6248
|
-
if (outerLeft) {
|
|
6249
|
-
for (let row = 0; row < rows; row++) {
|
|
6250
|
-
const tile = tileGraphs[row][0];
|
|
6251
|
-
const tileL = findRegionBySuffix(tile, "v:L");
|
|
6252
|
-
const baseL = generateViaTopologyRegions(inputViaTile, {
|
|
6253
|
-
graphSize: tileSize,
|
|
6254
|
-
idPrefix: "v"
|
|
6255
|
-
}).regions.find((r) => r.regionId === "v:L");
|
|
6256
|
-
const leftSegs = getBoundarySegments(baseL.d.polygon, "left", -half);
|
|
6257
|
-
for (const seg of leftSegs) {
|
|
6258
|
-
const tileCenterY = gridMinY + row * tileSize + half;
|
|
6259
|
-
allPorts.push(
|
|
6260
|
-
...createBoundaryPorts(
|
|
6261
|
-
`outer:L-tile${row}`,
|
|
6262
|
-
outerLeft,
|
|
6263
|
-
tileL,
|
|
6264
|
-
"vertical",
|
|
6265
|
-
gridMinX,
|
|
6266
|
-
seg.from + tileCenterY,
|
|
6267
|
-
seg.to + tileCenterY,
|
|
6268
|
-
portPitch
|
|
6269
|
-
)
|
|
6270
|
-
);
|
|
6271
|
-
}
|
|
6272
|
-
}
|
|
6273
|
-
}
|
|
6274
|
-
if (outerRight) {
|
|
6275
|
-
for (let row = 0; row < rows; row++) {
|
|
6276
|
-
const tile = tileGraphs[row][cols - 1];
|
|
6277
|
-
const tileR = findRegionBySuffix(tile, "v:R");
|
|
6278
|
-
const baseR = generateViaTopologyRegions(inputViaTile, {
|
|
6279
|
-
graphSize: tileSize,
|
|
6280
|
-
idPrefix: "v"
|
|
6281
|
-
}).regions.find((r) => r.regionId === "v:R");
|
|
6282
|
-
const rightSegs = getBoundarySegments(baseR.d.polygon, "right", half);
|
|
6283
|
-
for (const seg of rightSegs) {
|
|
6284
|
-
const tileCenterY = gridMinY + row * tileSize + half;
|
|
6285
|
-
allPorts.push(
|
|
6286
|
-
...createBoundaryPorts(
|
|
6287
|
-
`outer:R-tile${row}`,
|
|
6288
|
-
outerRight,
|
|
6289
|
-
tileR,
|
|
6290
|
-
"vertical",
|
|
6291
|
-
gridMaxX,
|
|
6292
|
-
seg.from + tileCenterY,
|
|
6293
|
-
seg.to + tileCenterY,
|
|
6294
|
-
portPitch
|
|
6295
|
-
)
|
|
6296
|
-
);
|
|
6297
|
-
}
|
|
6298
|
-
}
|
|
6299
|
-
}
|
|
6300
|
-
if (outerLeft) {
|
|
6301
|
-
const baseGraph = generateViaTopologyRegions(inputViaTile, {
|
|
6302
|
-
graphSize: tileSize,
|
|
6303
|
-
idPrefix: "v"
|
|
6304
|
-
});
|
|
6305
|
-
const baseT = baseGraph.regions.find((r) => r.regionId === "v:T");
|
|
6306
|
-
const baseB = baseGraph.regions.find((r) => r.regionId === "v:B");
|
|
6307
|
-
const tLeftSegs = getBoundarySegments(baseT.d.polygon, "left", -half);
|
|
6308
|
-
const bLeftSegs = getBoundarySegments(baseB.d.polygon, "left", -half);
|
|
6309
|
-
for (let row = 0; row < rows; row++) {
|
|
6310
|
-
const tile = tileGraphs[row][0];
|
|
6311
|
-
const tileT = findRegionBySuffix(tile, "v:T");
|
|
6312
|
-
const tileB = findRegionBySuffix(tile, "v:B");
|
|
6313
|
-
const tileCenterY = gridMinY + row * tileSize + half;
|
|
6314
|
-
for (const seg of tLeftSegs) {
|
|
6315
|
-
allPorts.push(
|
|
6316
|
-
...createBoundaryPorts(
|
|
6317
|
-
`outer:L-tileT${row}`,
|
|
6318
|
-
outerLeft,
|
|
6319
|
-
tileT,
|
|
6320
|
-
"vertical",
|
|
6321
|
-
gridMinX,
|
|
6322
|
-
seg.from + tileCenterY,
|
|
6323
|
-
seg.to + tileCenterY,
|
|
6324
|
-
portPitch
|
|
6325
|
-
)
|
|
6326
|
-
);
|
|
6327
|
-
}
|
|
6328
|
-
for (const seg of bLeftSegs) {
|
|
6329
|
-
allPorts.push(
|
|
6330
|
-
...createBoundaryPorts(
|
|
6331
|
-
`outer:L-tileB${row}`,
|
|
6332
|
-
outerLeft,
|
|
6333
|
-
tileB,
|
|
6334
|
-
"vertical",
|
|
6335
|
-
gridMinX,
|
|
6336
|
-
seg.from + tileCenterY,
|
|
6337
|
-
seg.to + tileCenterY,
|
|
6338
|
-
portPitch
|
|
6339
|
-
)
|
|
6340
|
-
);
|
|
6341
|
-
}
|
|
6342
|
-
}
|
|
6343
|
-
}
|
|
6344
|
-
if (outerRight) {
|
|
6345
|
-
const baseGraph = generateViaTopologyRegions(inputViaTile, {
|
|
6346
|
-
graphSize: tileSize,
|
|
6347
|
-
idPrefix: "v"
|
|
6348
|
-
});
|
|
6349
|
-
const baseT = baseGraph.regions.find((r) => r.regionId === "v:T");
|
|
6350
|
-
const baseB = baseGraph.regions.find((r) => r.regionId === "v:B");
|
|
6351
|
-
const tRightSegs = getBoundarySegments(baseT.d.polygon, "right", half);
|
|
6352
|
-
const bRightSegs = getBoundarySegments(baseB.d.polygon, "right", half);
|
|
6353
|
-
for (let row = 0; row < rows; row++) {
|
|
6354
|
-
const tile = tileGraphs[row][cols - 1];
|
|
6355
|
-
const tileT = findRegionBySuffix(tile, "v:T");
|
|
6356
|
-
const tileB = findRegionBySuffix(tile, "v:B");
|
|
6357
|
-
const tileCenterY = gridMinY + row * tileSize + half;
|
|
6358
|
-
for (const seg of tRightSegs) {
|
|
6359
|
-
allPorts.push(
|
|
6360
|
-
...createBoundaryPorts(
|
|
6361
|
-
`outer:R-tileT${row}`,
|
|
6362
|
-
outerRight,
|
|
6363
|
-
tileT,
|
|
6364
|
-
"vertical",
|
|
6365
|
-
gridMaxX,
|
|
6366
|
-
seg.from + tileCenterY,
|
|
6367
|
-
seg.to + tileCenterY,
|
|
6368
|
-
portPitch
|
|
6369
|
-
)
|
|
6370
|
-
);
|
|
6371
|
-
}
|
|
6372
|
-
for (const seg of bRightSegs) {
|
|
6373
|
-
allPorts.push(
|
|
6374
|
-
...createBoundaryPorts(
|
|
6375
|
-
`outer:R-tileB${row}`,
|
|
6376
|
-
outerRight,
|
|
6377
|
-
tileB,
|
|
6378
|
-
"vertical",
|
|
6379
|
-
gridMaxX,
|
|
6380
|
-
seg.from + tileCenterY,
|
|
6381
|
-
seg.to + tileCenterY,
|
|
6382
|
-
portPitch
|
|
6383
|
-
)
|
|
6384
|
-
);
|
|
6385
|
-
}
|
|
6386
|
-
}
|
|
6387
|
-
}
|
|
6388
|
-
} else {
|
|
6389
|
-
if (outerTop && outerBottom) {
|
|
6390
|
-
}
|
|
6391
|
-
if (outerLeft && outerRight) {
|
|
6392
|
-
}
|
|
6393
|
-
}
|
|
6394
|
-
return {
|
|
6395
|
-
regions: allRegions,
|
|
6396
|
-
ports: allPorts,
|
|
6397
|
-
viaTile,
|
|
6398
|
-
tileCount: { rows, cols }
|
|
6399
|
-
};
|
|
6400
|
-
}
|
|
6401
|
-
|
|
6402
5775
|
// lib/ViaGraphSolver/defaultTopology.ts
|
|
6403
5776
|
function generateDefaultViaTopologyRegions(opts) {
|
|
6404
5777
|
return generateViaTopologyRegions(via_tile_4_regions_default, opts);
|
|
6405
5778
|
}
|
|
6406
|
-
function generateDefaultViaTopologyGrid(opts) {
|
|
6407
|
-
return generateViaTopologyGrid({
|
|
6408
|
-
...opts,
|
|
6409
|
-
viaTile: via_tile_4_regions_default
|
|
6410
|
-
});
|
|
6411
|
-
}
|
|
6412
5779
|
|
|
6413
5780
|
// lib/ViaGraphSolver/polygonPerimeterUtils.ts
|
|
6414
5781
|
function computeDifferentNetCrossingsForPolygon(region, port1, port2) {
|
|
@@ -16296,7 +15663,7 @@ function projectOntoSegment(p, a, b) {
|
|
|
16296
15663
|
const distance3 = Math.sqrt((p.x - closestX) ** 2 + (p.y - closestY) ** 2);
|
|
16297
15664
|
return { t, distance: distance3 };
|
|
16298
15665
|
}
|
|
16299
|
-
function
|
|
15666
|
+
function rangeOverlap(t1Start, t1End, t2Start, t2End) {
|
|
16300
15667
|
const min1 = Math.min(t1Start, t1End);
|
|
16301
15668
|
const max1 = Math.max(t1Start, t1End);
|
|
16302
15669
|
const min2 = Math.min(t2Start, t2End);
|
|
@@ -16318,7 +15685,7 @@ function findSharedEdges(polygon1, polygon2, tolerance = 0.01) {
|
|
|
16318
15685
|
const proj1 = projectOntoSegment(b1, a1, a2);
|
|
16319
15686
|
const proj2 = projectOntoSegment(b2, a1, a2);
|
|
16320
15687
|
if (proj1.distance > tolerance || proj2.distance > tolerance) continue;
|
|
16321
|
-
const overlap =
|
|
15688
|
+
const overlap = rangeOverlap(0, 1, proj1.t, proj2.t);
|
|
16322
15689
|
if (!overlap) continue;
|
|
16323
15690
|
const dx = a2.x - a1.x;
|
|
16324
15691
|
const dy = a2.y - a1.y;
|
|
@@ -16356,9 +15723,7 @@ function createPortsAlongEdge(edge, portPitch = 0.4) {
|
|
|
16356
15723
|
}
|
|
16357
15724
|
|
|
16358
15725
|
// lib/ViaGraphSolver/via-graph-generator/generateConvexViaTopologyRegions.ts
|
|
16359
|
-
var
|
|
16360
|
-
var DEFAULT_TILE_WIDTH = 3.727;
|
|
16361
|
-
var DEFAULT_TILE_HEIGHT = 4.03;
|
|
15726
|
+
var DEFAULT_PORT_PITCH = 0.4;
|
|
16362
15727
|
var DEFAULT_CLEARANCE = 0.1;
|
|
16363
15728
|
function deduplicateConsecutivePoints(points, tolerance = 1e-3) {
|
|
16364
15729
|
if (points.length <= 1) return points;
|
|
@@ -16502,7 +15867,7 @@ function translateVias(vias, dx, dy, prefix) {
|
|
|
16502
15867
|
}
|
|
16503
15868
|
}));
|
|
16504
15869
|
}
|
|
16505
|
-
function
|
|
15870
|
+
function translateRouteSegments(routeSegments, dx, dy, prefix) {
|
|
16506
15871
|
return routeSegments.map((segment2) => ({
|
|
16507
15872
|
routeId: `${prefix}:${segment2.routeId}`,
|
|
16508
15873
|
fromPort: `${prefix}:${segment2.fromPort}`,
|
|
@@ -16515,9 +15880,14 @@ function translateRouteSegments2(routeSegments, dx, dy, prefix) {
|
|
|
16515
15880
|
}));
|
|
16516
15881
|
}
|
|
16517
15882
|
function generateConvexViaTopologyRegions(opts) {
|
|
16518
|
-
const tileWidth = opts.tileWidth ?? opts.tileSize ??
|
|
16519
|
-
const tileHeight = opts.tileHeight ?? opts.tileSize ??
|
|
16520
|
-
|
|
15883
|
+
const tileWidth = opts.tileWidth ?? opts.tileSize ?? opts.viaTile.tileWidth;
|
|
15884
|
+
const tileHeight = opts.tileHeight ?? opts.tileSize ?? opts.viaTile.tileHeight;
|
|
15885
|
+
if (tileWidth === void 0 || tileHeight === void 0) {
|
|
15886
|
+
throw new Error(
|
|
15887
|
+
"tileWidth and tileHeight must be provided either in opts or in viaTile"
|
|
15888
|
+
);
|
|
15889
|
+
}
|
|
15890
|
+
const portPitch = opts.portPitch ?? DEFAULT_PORT_PITCH;
|
|
16521
15891
|
const clearance = opts.clearance ?? DEFAULT_CLEARANCE;
|
|
16522
15892
|
const concavityTolerance = opts.concavityTolerance ?? 0;
|
|
16523
15893
|
const { bounds, viaTile: inputViaTile } = opts;
|
|
@@ -16565,7 +15935,7 @@ function generateConvexViaTopologyRegions(opts) {
|
|
|
16565
15935
|
allRegions.push(viaRegion);
|
|
16566
15936
|
}
|
|
16567
15937
|
viaTile.routeSegments.push(
|
|
16568
|
-
...
|
|
15938
|
+
...translateRouteSegments(
|
|
16569
15939
|
routeSegments,
|
|
16570
15940
|
tileCenterX,
|
|
16571
15941
|
tileCenterY,
|
|
@@ -16718,8 +16088,8 @@ function createConvexViaGraphFromXYConnections(xyConnections, viaTile = via_tile
|
|
|
16718
16088
|
} = generateConvexViaTopologyRegions({
|
|
16719
16089
|
viaTile,
|
|
16720
16090
|
bounds,
|
|
16721
|
-
tileWidth: opts?.tileWidth,
|
|
16722
|
-
tileHeight: opts?.tileHeight,
|
|
16091
|
+
tileWidth: opts?.tileWidth ?? viaTile.tileWidth,
|
|
16092
|
+
tileHeight: opts?.tileHeight ?? viaTile.tileHeight,
|
|
16723
16093
|
tileSize: opts?.tileSize,
|
|
16724
16094
|
portPitch: opts?.portPitch,
|
|
16725
16095
|
clearance: opts?.clearance,
|
|
@@ -16736,48 +16106,6 @@ function createConvexViaGraphFromXYConnections(xyConnections, viaTile = via_tile
|
|
|
16736
16106
|
tileCount
|
|
16737
16107
|
};
|
|
16738
16108
|
}
|
|
16739
|
-
|
|
16740
|
-
// lib/ViaGraphSolver/via-graph-generator/createViaGraphFromXYConnections.ts
|
|
16741
|
-
function calculateBoundsFromConnections2(xyConnections) {
|
|
16742
|
-
if (xyConnections.length === 0) {
|
|
16743
|
-
throw new Error("Cannot calculate bounds from empty connections array");
|
|
16744
|
-
}
|
|
16745
|
-
let minX = Infinity;
|
|
16746
|
-
let maxX = -Infinity;
|
|
16747
|
-
let minY = Infinity;
|
|
16748
|
-
let maxY = -Infinity;
|
|
16749
|
-
for (const conn of xyConnections) {
|
|
16750
|
-
minX = Math.min(minX, conn.start.x, conn.end.x);
|
|
16751
|
-
maxX = Math.max(maxX, conn.start.x, conn.end.x);
|
|
16752
|
-
minY = Math.min(minY, conn.start.y, conn.end.y);
|
|
16753
|
-
maxY = Math.max(maxY, conn.start.y, conn.end.y);
|
|
16754
|
-
}
|
|
16755
|
-
return { minX, maxX, minY, maxY };
|
|
16756
|
-
}
|
|
16757
|
-
function createViaGraphFromXYConnections(xyConnections, viaTile, opts) {
|
|
16758
|
-
const bounds = calculateBoundsFromConnections2(xyConnections);
|
|
16759
|
-
const {
|
|
16760
|
-
regions,
|
|
16761
|
-
ports,
|
|
16762
|
-
viaTile: generatedViaTile,
|
|
16763
|
-
tileCount
|
|
16764
|
-
} = generateViaTopologyGrid({
|
|
16765
|
-
viaTile,
|
|
16766
|
-
bounds,
|
|
16767
|
-
tileSize: opts?.tileSize,
|
|
16768
|
-
portPitch: opts?.portPitch
|
|
16769
|
-
});
|
|
16770
|
-
const baseGraph = { regions, ports };
|
|
16771
|
-
const graphWithConnections = createViaGraphWithConnections(
|
|
16772
|
-
baseGraph,
|
|
16773
|
-
xyConnections
|
|
16774
|
-
);
|
|
16775
|
-
return {
|
|
16776
|
-
...graphWithConnections,
|
|
16777
|
-
viaTile: generatedViaTile,
|
|
16778
|
-
tileCount
|
|
16779
|
-
};
|
|
16780
|
-
}
|
|
16781
16109
|
export {
|
|
16782
16110
|
ConnectBuilder,
|
|
16783
16111
|
HyperGraphSolver,
|
|
@@ -16795,14 +16123,11 @@ export {
|
|
|
16795
16123
|
convertHyperGraphToSerializedHyperGraph,
|
|
16796
16124
|
createConvexViaGraphFromXYConnections,
|
|
16797
16125
|
createGraphWithConnectionsFromBaseGraph,
|
|
16798
|
-
createViaGraphFromXYConnections,
|
|
16799
16126
|
createViaGraphWithConnections,
|
|
16800
16127
|
generateConvexViaTopologyRegions,
|
|
16801
|
-
generateDefaultViaTopologyGrid,
|
|
16802
16128
|
generateDefaultViaTopologyRegions,
|
|
16803
16129
|
generateJumperGrid,
|
|
16804
16130
|
generateJumperX4Grid,
|
|
16805
|
-
generateViaTopologyGrid,
|
|
16806
16131
|
generateViaTopologyRegions,
|
|
16807
16132
|
rotateGraph90Degrees,
|
|
16808
16133
|
via_tile_4_regions_default as viaTile
|