From 2f24c05a72af0e05e45dc9674e89be1a68ef6f60 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Mon, 12 Apr 2021 23:34:55 +0200 Subject: [PATCH] Fix bug in Track::repair(), select the right segment to extend. --- katana/src/Track.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/katana/src/Track.cpp b/katana/src/Track.cpp index 46a7cf72..e9a949f7 100644 --- a/katana/src/Track.cpp +++ b/katana/src/Track.cpp @@ -44,6 +44,8 @@ namespace { inline size_t size () const; inline const vector< pair >& spans () const; + inline const pair& + span ( size_t ) const; inline DbU::Unit sourceU ( size_t ) const; inline DbU::Unit targetU ( size_t ) const; void merge ( size_t ); @@ -74,6 +76,12 @@ namespace { _spans.clear(); } + inline const pair& GapSet::span ( size_t i ) const + { + static pair nospan = make_pair(0,0); + return (i < _spans.size()) ? _spans[i] : nospan; + } + inline DbU::Unit GapSet::sourceU ( size_t i ) const { // if (_track->getSegment( _spans[i].first)->isNonPref()) { @@ -957,16 +965,18 @@ namespace Katana { DbU::Unit spacing = gapset.sourceU(j+1) - gapset.targetU(j); // cerr << "| spacing=" << DbU::getValueString(spacing) << endl; if (spacing < minSpacing) { - AutoSegment* first = _segments[j+1]->base(); - for ( AutoSegment* segment : _segments[j]->base()->getAligneds() ) { + AutoSegment* first = _segments[gapset.span(j+1).first]->base(); + for ( AutoSegment* segment : first->getAligneds() ) { if (segment->getSourcePosition() < first->getSourcePosition()) first = segment; } + //cerr << "spacing:" << DbU::getValueString(spacing) << " " << first << endl; first->setDuSource( first->getDuSource() - spacing ); ++gaps; cerr << Warning( " Track::repair(): Closing same net gap in %s near:\n %s" , getString(this).c_str() , getString(_segments[i-1]).c_str() ) << endl; + //cerr << first << endl; } } }