Try harder to merge colinear tracks
Each time we iterator through the tracks list to merge, we change the connectivity system and can leave possible merges. By iterating, we keep merging until we cannot anymore. Fixes https://gitlab.com/kicad/code/kicad/issues/5020
This commit is contained in:
parent
51d7fea934
commit
d7a1a4f822
|
@ -383,6 +383,12 @@ void TRACKS_CLEANER::cleanupSegments()
|
|||
if( !m_dryRun )
|
||||
removeItems( toRemove );
|
||||
|
||||
bool merged = false;
|
||||
|
||||
do
|
||||
{
|
||||
m_brd->BuildConnectivity();
|
||||
|
||||
// Keep a duplicate deque to all deleting in the primary
|
||||
std::deque<TRACK*> temp_segments( m_brd->Tracks() );
|
||||
|
||||
|
@ -418,18 +424,19 @@ void TRACKS_CLEANER::cleanupSegments()
|
|||
continue;
|
||||
|
||||
if( segment->ApproxCollinear( *candidateSegment ) )
|
||||
mergeCollinearSegments( segment, candidateSegment );
|
||||
merged = mergeCollinearSegments( segment, candidateSegment );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while( merged );
|
||||
}
|
||||
|
||||
|
||||
void TRACKS_CLEANER::mergeCollinearSegments( TRACK* aSeg1, TRACK* aSeg2 )
|
||||
bool TRACKS_CLEANER::mergeCollinearSegments( TRACK* aSeg1, TRACK* aSeg2 )
|
||||
{
|
||||
if( aSeg1->IsLocked() || aSeg2->IsLocked() )
|
||||
return;
|
||||
return false;
|
||||
|
||||
auto connectivity = m_brd->GetConnectivity();
|
||||
|
||||
|
@ -463,13 +470,13 @@ void TRACKS_CLEANER::mergeCollinearSegments( TRACK* aSeg1, TRACK* aSeg2 )
|
|||
if( aSeg1->GetStart() != dummy_seg.GetStart() && aSeg1->GetStart() != dummy_seg.GetEnd() )
|
||||
{
|
||||
if( testTrackEndpointIsNode( aSeg1, true ) )
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( aSeg1->GetEnd() != dummy_seg.GetStart() && aSeg1->GetEnd() != dummy_seg.GetEnd() )
|
||||
{
|
||||
if( testTrackEndpointIsNode( aSeg1, false ) )
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_MERGE_TRACKS );
|
||||
|
@ -496,6 +503,8 @@ void TRACKS_CLEANER::mergeCollinearSegments( TRACK* aSeg1, TRACK* aSeg2 )
|
|||
m_brd->Remove( aSeg2 );
|
||||
m_commit.Removed( aSeg2 );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ private:
|
|||
* @param aSeg1 is the reference
|
||||
* @param aSeg2 is the candidate, and after merging, the removed segment
|
||||
*/
|
||||
void mergeCollinearSegments( TRACK* aSeg1, TRACK* aSeg2 );
|
||||
bool mergeCollinearSegments( TRACK* aSeg1, TRACK* aSeg2 );
|
||||
|
||||
/**
|
||||
* @return true if a track end position is a node, i.e. a end connected
|
||||
|
|
Loading…
Reference in New Issue