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 ); }