Skip to content

Commit 1aebc0a

Browse files
committed
basic visualize functions
1 parent fd35506 commit 1aebc0a

File tree

2 files changed

+141
-2
lines changed

2 files changed

+141
-2
lines changed

lib/solvers/RouteStitchingSolver/MultipleHighDensityRouteStitchSolver.ts

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,88 @@ export class MultipleHighDensityRouteStitchSolver extends BaseSolver {
6262
})
6363
}
6464

65-
// visualize(): GraphicsObject {
65+
visualize(): GraphicsObject {
66+
const graphics: GraphicsObject = {
67+
points: [],
68+
lines: [],
69+
circles: [],
70+
title: "Multiple High Density Route Stitch Solver",
71+
}
72+
73+
// Visualize the active solver if one exists
74+
if (this.activeSolver) {
75+
// Combine visualizations from the active solver
76+
const activeSolverGraphics = this.activeSolver.visualize()
77+
78+
// Merge points
79+
if (activeSolverGraphics.points?.length) {
80+
graphics.points?.push(...activeSolverGraphics.points)
81+
}
6682

67-
// }
83+
// Merge lines
84+
if (activeSolverGraphics.lines?.length) {
85+
graphics.lines?.push(...activeSolverGraphics.lines)
86+
}
87+
88+
// Merge circles
89+
if (activeSolverGraphics.circles?.length) {
90+
graphics.circles?.push(...activeSolverGraphics.circles)
91+
}
92+
93+
// Merge rects if they exist
94+
if (activeSolverGraphics.rects?.length) {
95+
graphics.rects = activeSolverGraphics.rects
96+
}
97+
}
98+
99+
// Visualize all remaining unsolved routes - start/end points only
100+
for (const unsolvedRoute of this.unsolvedRoutes) {
101+
// Add start and end points for unsolved connections
102+
graphics.points?.push(
103+
{
104+
x: unsolvedRoute.start.x,
105+
y: unsolvedRoute.start.y,
106+
color: "lightgreen",
107+
label: `${unsolvedRoute.connectionName} Start`,
108+
},
109+
{
110+
x: unsolvedRoute.end.x,
111+
y: unsolvedRoute.end.y,
112+
color: "pink",
113+
label: `${unsolvedRoute.connectionName} End`,
114+
},
115+
)
116+
117+
// Add a light dashed line between start and end to show pending connections
118+
graphics.lines?.push({
119+
points: [
120+
{ x: unsolvedRoute.start.x, y: unsolvedRoute.start.y },
121+
{ x: unsolvedRoute.end.x, y: unsolvedRoute.end.y },
122+
],
123+
strokeColor: "gray",
124+
})
125+
126+
// Visualize HD routes associated with unsolved routes (faded)
127+
for (const hdRoute of unsolvedRoute.hdRoutes) {
128+
if (hdRoute.route.length > 1) {
129+
graphics.lines?.push({
130+
points: hdRoute.route.map((point) => ({ x: point.x, y: point.y })),
131+
strokeColor: "lightblue",
132+
})
133+
}
134+
135+
// Visualize vias
136+
for (const via of hdRoute.vias) {
137+
graphics.circles?.push({
138+
center: { x: via.x, y: via.y },
139+
radius: hdRoute.viaDiameter / 2,
140+
fill: "lavender",
141+
stroke: "lavender",
142+
})
143+
}
144+
}
145+
}
146+
147+
return graphics
148+
}
68149
}

lib/solvers/RouteStitchingSolver/SingleHighDensityRouteStitchSolver.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { HighDensityIntraNodeRoute } from "lib/types/high-density-types"
22
import { BaseSolver } from "../BaseSolver"
3+
import { GraphicsObject } from "graphics-debug"
34

45
export class SingleHighDensityRouteStitchSolver extends BaseSolver {
56
remainingHdRoutes: HighDensityIntraNodeRoute[]
@@ -18,4 +19,61 @@ export class SingleHighDensityRouteStitchSolver extends BaseSolver {
1819
}
1920

2021
_step() {}
22+
23+
visualize(): GraphicsObject {
24+
const graphics: GraphicsObject = {
25+
points: [],
26+
lines: [],
27+
circles: [],
28+
title: "Single High Density Route Stitch Solver",
29+
}
30+
31+
// Visualize start and end points
32+
graphics.points?.push(
33+
{
34+
x: this.start.x,
35+
y: this.start.y,
36+
color: "green",
37+
label: "Start",
38+
},
39+
{
40+
x: this.end.x,
41+
y: this.end.y,
42+
color: "red",
43+
label: "End",
44+
}
45+
)
46+
47+
// Visualize all HD routes
48+
for (const hdRoute of this.remainingHdRoutes) {
49+
if (hdRoute.route.length > 1) {
50+
// Create a line for the route
51+
graphics.lines?.push({
52+
points: hdRoute.route.map(point => ({ x: point.x, y: point.y })),
53+
stroke: "blue",
54+
})
55+
}
56+
57+
// Add points for each route node
58+
for (const point of hdRoute.route) {
59+
graphics.points?.push({
60+
x: point.x,
61+
y: point.y,
62+
color: "blue",
63+
})
64+
}
65+
66+
// Visualize vias
67+
for (const via of hdRoute.vias) {
68+
graphics.circles?.push({
69+
center: { x: via.x, y: via.y },
70+
radius: hdRoute.viaDiameter / 2,
71+
fill: "purple",
72+
stroke: "purple",
73+
})
74+
}
75+
}
76+
77+
return graphics
78+
}
2179
}

0 commit comments

Comments
 (0)