mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
fix for issue 17429 - backported from master
- issue: https://gitlab.com/kicad/code/kicad/-/issues/17429 - fix makes RunOnUnconnectedEdges sort the unnconnected edges before running the passed in function on them - stable sort order keeps the algorith from having non-deterministic runs
This commit is contained in:
parent
799dadeeec
commit
7cbf86f864
@ -717,23 +717,37 @@ unsigned int CONNECTIVITY_DATA::GetPadCount( int aNet ) const
|
||||
return n;
|
||||
}
|
||||
|
||||
void sortEdgesOnSerializationForStableOrdering( std::vector<CN_EDGE>& edges )
|
||||
{
|
||||
std::sort(edges.begin(), edges.end(),
|
||||
[](const CN_EDGE& a, const CN_EDGE& b)
|
||||
{
|
||||
return a.SerializeToString() < b.SerializeToString();
|
||||
});
|
||||
}
|
||||
|
||||
void CONNECTIVITY_DATA::RunOnUnconnectedEdges( std::function<bool( CN_EDGE& )> aFunc )
|
||||
{
|
||||
std::vector<CN_EDGE> edges;
|
||||
|
||||
for( RN_NET* rnNet : m_nets )
|
||||
{
|
||||
if( rnNet )
|
||||
{
|
||||
for( CN_EDGE& edge : rnNet->GetEdges() )
|
||||
{
|
||||
if( !aFunc( edge ) )
|
||||
return;
|
||||
edges.push_back( edge );
|
||||
}
|
||||
}
|
||||
}
|
||||
sortEdgesOnSerializationForStableOrdering( edges );
|
||||
for( CN_EDGE& edge : edges )
|
||||
{
|
||||
if( !aFunc( edge ) )
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int getMinDist( BOARD_CONNECTED_ITEM* aItem, const VECTOR2I& aPoint )
|
||||
{
|
||||
switch( aItem->Type() )
|
||||
|
Loading…
x
Reference in New Issue
Block a user