@@ -1445,53 +1445,74 @@ std::set<odb::Line> DbNetDescriptor::convertGuidesToLines(
14451445 }
14461446 }
14471447
1448+ // Build gcell grid centers
1449+ std::vector<int > grid;
1450+ net->getBlock ()->getGCellGrid ()->getGridX (grid);
1451+ grid.push_back (net->getBlock ()->getDieArea ().xMax ());
1452+ std::vector<int > x_grid;
1453+ x_grid.reserve (grid.size () - 1 );
1454+ for (int i = 1 ; i < grid.size (); i++) {
1455+ x_grid.push_back ((grid[i - 1 ] + grid[i]) / 2 );
1456+ }
1457+
1458+ grid.clear ();
1459+ net->getBlock ()->getGCellGrid ()->getGridY (grid);
1460+ grid.push_back (net->getBlock ()->getDieArea ().yMax ());
1461+ std::vector<int > y_grid;
1462+ y_grid.reserve (grid.size () - 1 );
1463+ for (int i = 1 ; i < grid.size (); i++) {
1464+ y_grid.push_back ((grid[i - 1 ] + grid[i]) / 2 );
1465+ }
1466+
14481467 for (const auto * guide : guides) {
14491468 const auto & box = guide->getBox ();
1450- const auto center = box.center ();
1451- const int width_half = box.minDXDY () / 2 ;
1452- odb::Point p0, p1;
1453- switch (box.getDir ()) {
1454- case 0 : {
1455- // DX < DY
1456- p0 = odb::Point (center.x (), box.yMin () + width_half);
1457- p1 = odb::Point (center.x (), box.yMax () - width_half);
1458- break ;
1459- }
1460- case 1 : {
1461- p0 = odb::Point (box.xMin () + width_half, center.y ());
1462- p1 = odb::Point (box.xMax () - width_half, center.y ());
1463- break ;
1469+
1470+ std::vector<odb::Point> guide_pts;
1471+ for (const auto & x : x_grid) {
1472+ if (x < box.xMin ()) {
1473+ continue ;
14641474 }
1465- default : {
1466- p0 = center;
1467- p1 = center;
1475+ if (x > box.xMax ()) {
14681476 break ;
14691477 }
1470- }
1471- lines.emplace (p0, center);
1472- lines.emplace (center, p1);
1473-
1474- if (guide->isConnectedToTerm ()) {
1475- std::vector<odb::Point> anchors = {p0, center, p1};
1476-
1477- auto find_term_connection = [&anchors, &lines, &io_map, &sources, &sinks](
1478- odb::dbObject* dbterm,
1479- const odb::Point& term) {
1480- // draw shortest flywire
1481- std::stable_sort (anchors.begin (),
1482- anchors.end (),
1483- [&term](const odb::Point& pt0, const odb::Point& pt1) {
1484- return odb::Point::manhattanDistance (term, pt0)
1485- < odb::Point::manhattanDistance (term, pt1);
1486- });
1487- lines.emplace (term, anchors[0 ]);
1488- if (io_map[dbterm].is_sink ) {
1489- sinks[dbterm].insert (term);
1478+
1479+ for (const auto & y : y_grid) {
1480+ if (y < box.yMin ()) {
1481+ continue ;
14901482 }
1491- if (io_map[dbterm]. is_source ) {
1492- sources[dbterm]. insert (term) ;
1483+ if (y > box. yMax () ) {
1484+ break ;
14931485 }
1494- };
1486+
1487+ guide_pts.emplace_back (x, y);
1488+ }
1489+ }
1490+
1491+ std::sort (guide_pts.begin (), guide_pts.end ());
1492+ for (int i = 1 ; i < guide_pts.size (); i++) {
1493+ lines.emplace (guide_pts[i - 1 ], guide_pts[i]);
1494+ }
1495+
1496+ if (!guide_pts.empty () && guide->isConnectedToTerm ()) {
1497+ auto find_term_connection
1498+ = [&guide_pts, &lines, &io_map, &sources, &sinks](
1499+ odb::dbObject* dbterm, const odb::Point& term) {
1500+ // draw shortest flywire
1501+ std::stable_sort (
1502+ guide_pts.begin (),
1503+ guide_pts.end (),
1504+ [&term](const odb::Point& pt0, const odb::Point& pt1) {
1505+ return odb::Point::manhattanDistance (term, pt0)
1506+ < odb::Point::manhattanDistance (term, pt1);
1507+ });
1508+ lines.emplace (term, guide_pts[0 ]);
1509+ if (io_map[dbterm].is_sink ) {
1510+ sinks[dbterm].insert (term);
1511+ }
1512+ if (io_map[dbterm].is_source ) {
1513+ sources[dbterm].insert (term);
1514+ }
1515+ };
14951516
14961517 for (const auto & [obj, objbox] : terms[guide->getLayer ()]) {
14971518 std::vector<const odb::Rect*> candidates;
0 commit comments