From 80dcd264bb4c4c0b8b11f43dc5d0d8d57ac956d7 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Fri, 13 Apr 2018 15:00:57 +0200 Subject: [PATCH] Allow nearest Track selection in Katana::RoutingPlane::getTrackByPosition(). * Change: In Katana::RoutingPlane::getTrackByPosition(), when requesting a track less than *one pitch* beyond the last one, return the last one instead of NULL. Only if the mode allows it (i.e. Nearest or Inferior). --- katana/src/NegociateWindow.cpp | 6 +++++- katana/src/RoutingPlane.cpp | 13 ++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/katana/src/NegociateWindow.cpp b/katana/src/NegociateWindow.cpp index 63de0af2..43c894a6 100644 --- a/katana/src/NegociateWindow.cpp +++ b/katana/src/NegociateWindow.cpp @@ -327,11 +327,15 @@ namespace Katana { cdebug_log(159,0) << "* Nearest " << track << endl; + if (not track) + throw Error( "NegociateWindow::createTracksegment(): No track near axis of %s." + , getString(autoSegment).c_str() ); + if (track->getAxis() > uside.getVMax()) track = track->getPreviousTrack(); if (track->getAxis() < uside.getVMin()) track = track->getNextTrack(); if (not track) - throw Error( "NegociateWindow::createTracksegment(): No track near axis of %s." + throw Error( "NegociateWindow::createTracksegment(): No track near axis of %s (after adjust)." , getString(autoSegment).c_str() ); cdebug_log(159,0) << "* GCell U-side " << uside << endl; diff --git a/katana/src/RoutingPlane.cpp b/katana/src/RoutingPlane.cpp index 92f8bd32..ef6d702a 100644 --- a/katana/src/RoutingPlane.cpp +++ b/katana/src/RoutingPlane.cpp @@ -162,11 +162,14 @@ namespace Katana { Track* RoutingPlane::getTrackByPosition ( DbU::Unit axis, uint32_t mode ) const { - return getTrackByIndex( getLayerGauge()->getTrackIndex( getAxisMin() - , getAxisMax() - , axis - , mode - ) ); + size_t index = getLayerGauge()->getTrackIndex( getAxisMin(), getAxisMax(), axis, mode ); + if (index == getTracksSize()) { + if (not index) return NULL; + if ((mode == Constant::Superior) or (mode == Constant::Exact)) return NULL; + --index; + } + + return getTrackByIndex( index ); }