Fix bug in Track::repair(), select the right segment to extend.

This commit is contained in:
Jean-Paul Chaput 2021-04-12 23:34:55 +02:00
parent a66da90446
commit 2f24c05a72
1 changed files with 12 additions and 2 deletions

View File

@ -44,6 +44,8 @@ namespace {
inline size_t size () const; inline size_t size () const;
inline const vector< pair<size_t,size_t> >& inline const vector< pair<size_t,size_t> >&
spans () const; spans () const;
inline const pair<size_t,size_t>&
span ( size_t ) const;
inline DbU::Unit sourceU ( size_t ) const; inline DbU::Unit sourceU ( size_t ) const;
inline DbU::Unit targetU ( size_t ) const; inline DbU::Unit targetU ( size_t ) const;
void merge ( size_t ); void merge ( size_t );
@ -74,6 +76,12 @@ namespace {
_spans.clear(); _spans.clear();
} }
inline const pair<size_t,size_t>& GapSet::span ( size_t i ) const
{
static pair<size_t,size_t> nospan = make_pair(0,0);
return (i < _spans.size()) ? _spans[i] : nospan;
}
inline DbU::Unit GapSet::sourceU ( size_t i ) const inline DbU::Unit GapSet::sourceU ( size_t i ) const
{ {
// if (_track->getSegment( _spans[i].first)->isNonPref()) { // if (_track->getSegment( _spans[i].first)->isNonPref()) {
@ -957,16 +965,18 @@ namespace Katana {
DbU::Unit spacing = gapset.sourceU(j+1) - gapset.targetU(j); DbU::Unit spacing = gapset.sourceU(j+1) - gapset.targetU(j);
// cerr << "| spacing=" << DbU::getValueString(spacing) << endl; // cerr << "| spacing=" << DbU::getValueString(spacing) << endl;
if (spacing < minSpacing) { if (spacing < minSpacing) {
AutoSegment* first = _segments[j+1]->base(); AutoSegment* first = _segments[gapset.span(j+1).first]->base();
for ( AutoSegment* segment : _segments[j]->base()->getAligneds() ) { for ( AutoSegment* segment : first->getAligneds() ) {
if (segment->getSourcePosition() < first->getSourcePosition()) if (segment->getSourcePosition() < first->getSourcePosition())
first = segment; first = segment;
} }
//cerr << "spacing:" << DbU::getValueString(spacing) << " " << first << endl;
first->setDuSource( first->getDuSource() - spacing ); first->setDuSource( first->getDuSource() - spacing );
++gaps; ++gaps;
cerr << Warning( " Track::repair(): Closing same net gap in %s near:\n %s" cerr << Warning( " Track::repair(): Closing same net gap in %s near:\n %s"
, getString(this).c_str() , getString(this).c_str()
, getString(_segments[i-1]).c_str() ) << endl; , getString(_segments[i-1]).c_str() ) << endl;
//cerr << first << endl;
} }
} }
} }