Commit 06bf0821 authored by Dick Hollenbeck's avatar Dick Hollenbeck

fix LSET() constructors, formatting

parent add4d5eb
...@@ -30,14 +30,16 @@ ...@@ -30,14 +30,16 @@
#include <class_board.h> #include <class_board.h>
LSET::LSET( const LAYER_ID* aArray, unsigned aCount ) LSET::LSET( const LAYER_ID* aArray, unsigned aCount ) :
BASE_SET()
{ {
for( unsigned i=0; i<aCount; ++i ) for( unsigned i=0; i<aCount; ++i )
set( aArray[i] ); set( aArray[i] );
} }
LSET::LSET( unsigned aIdCount, LAYER_ID aFirst, ... ) LSET::LSET( unsigned aIdCount, LAYER_ID aFirst, ... ) :
BASE_SET()
{ {
// The constructor, without the mandatory aFirst argument, could have been confused // The constructor, without the mandatory aFirst argument, could have been confused
// by the compiler with the LSET( LAYER_ID ). With aFirst, that ambiguity is not // by the compiler with the LSET( LAYER_ID ). With aFirst, that ambiguity is not
......
...@@ -241,7 +241,8 @@ public: ...@@ -241,7 +241,8 @@ public:
* *
* for an empty set. * for an empty set.
*/ */
LSET( LAYER_ID aLayer ) // LAYER_ID deliberately exludes int and relatives LSET( LAYER_ID aLayer ) : // LAYER_ID deliberately exludes int and relatives
BASE_SET()
{ {
set( aLayer ); set( aLayer );
} }
...@@ -379,6 +380,11 @@ public: ...@@ -379,6 +380,11 @@ public:
private: private:
/// Take this off the market, it may not be used because of LSET( LAYER_ID ).
LSET( unsigned long __val )
{
// not usable, it's private.
}
}; };
......
...@@ -303,6 +303,7 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack ) ...@@ -303,6 +303,7 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
// Search for connections to starting point: // Search for connections to starting point:
#define USE_EXTENDED_SEARCH #define USE_EXTENDED_SEARCH
#ifdef USE_EXTENDED_SEARCH #ifdef USE_EXTENDED_SEARCH
int dist_max = aTrack->GetWidth() / 2; int dist_max = aTrack->GetWidth() / 2;
static std::vector<CONNECTED_POINT*> tracks_candidates; static std::vector<CONNECTED_POINT*> tracks_candidates;
...@@ -312,26 +313,28 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack ) ...@@ -312,26 +313,28 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
{ {
#ifndef USE_EXTENDED_SEARCH #ifndef USE_EXTENDED_SEARCH
int idx = searchEntryPointInCandidatesList( position ); int idx = searchEntryPointInCandidatesList( position );
if ( idx >= 0 )
if( idx >= 0 )
{ {
// search after: // search after:
for ( unsigned ii = idx; ii < m_candidates.size(); ii ++ ) for( unsigned ii = idx; ii < m_candidates.size(); ii ++ )
{ {
if( m_candidates[ii].GetTrack() == aTrack ) if( m_candidates[ii].GetTrack() == aTrack )
continue; continue;
if( m_candidates[ii].GetPoint() != position ) if( m_candidates[ii].GetPoint() != position )
break; break;
if( m_candidates[ii].GetTrack()->GetLayerSet() & layerMask ) if( ( m_candidates[ii].GetTrack()->GetLayerSet() & layerMask ).any() )
m_connected.push_back( m_candidates[ii].GetTrack() ); m_connected.push_back( m_candidates[ii].GetTrack() );
} }
// search before: // search before:
for ( int ii = idx-1; ii >= 0; ii -- ) for( int ii = idx-1; ii >= 0; ii -- )
{ {
if( m_candidates[ii].GetTrack() == aTrack ) if( m_candidates[ii].GetTrack() == aTrack )
continue; continue;
if( m_candidates[ii].GetPoint() != position ) if( m_candidates[ii].GetPoint() != position )
break; break;
if( m_candidates[ii].GetTrack()->GetLayerSet() & layerMask ) if( ( m_candidates[ii].GetTrack()->GetLayerSet() & layerMask ).any() )
m_connected.push_back( m_candidates[ii].GetTrack() ); m_connected.push_back( m_candidates[ii].GetTrack() );
} }
} }
...@@ -370,7 +373,8 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack ) ...@@ -370,7 +373,8 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
return count; return count;
} }
int CONNECTIONS::searchEntryPointInCandidatesList( const wxPoint & aPoint)
int CONNECTIONS::searchEntryPointInCandidatesList( const wxPoint& aPoint )
{ {
// Search the aPoint coordinates in m_Candidates // Search the aPoint coordinates in m_Candidates
// m_Candidates is sorted by X then Y values, and a fast binary search is used // m_Candidates is sorted by X then Y values, and a fast binary search is used
...@@ -379,15 +383,18 @@ int CONNECTIONS::searchEntryPointInCandidatesList( const wxPoint & aPoint) ...@@ -379,15 +383,18 @@ int CONNECTIONS::searchEntryPointInCandidatesList( const wxPoint & aPoint)
int delta = m_candidates.size(); int delta = m_candidates.size();
int idx = 0; // Starting index is the beginning of list int idx = 0; // Starting index is the beginning of list
while( delta ) while( delta )
{ {
// Calculate half size of remaining interval to test. // Calculate half size of remaining interval to test.
// Ensure the computed value is not truncated (too small) // Ensure the computed value is not truncated (too small)
if( (delta & 1) && ( delta > 1 ) ) if( ( delta & 1 ) && ( delta > 1 ) )
delta++; delta++;
delta /= 2; delta /= 2;
CONNECTED_POINT & candidate = m_candidates[idx]; CONNECTED_POINT& candidate = m_candidates[idx];
if( candidate.GetPoint() == aPoint ) // candidate found if( candidate.GetPoint() == aPoint ) // candidate found
{ {
return idx; return idx;
...@@ -607,6 +614,7 @@ void CONNECTIONS::Propagate_SubNets() ...@@ -607,6 +614,7 @@ void CONNECTIONS::Propagate_SubNets()
for( unsigned ii = 0; ii < curr_track->m_TracksConnected.size(); ii++ ) for( unsigned ii = 0; ii < curr_track->m_TracksConnected.size(); ii++ )
{ {
BOARD_CONNECTED_ITEM* track = curr_track->m_TracksConnected[ii]; BOARD_CONNECTED_ITEM* track = curr_track->m_TracksConnected[ii];
if( curr_track->GetSubNet() ) // The current track is already a cluster member if( curr_track->GetSubNet() ) // The current track is already a cluster member
{ {
// The other track is already a cluster member, so we can merge the 2 clusters // The other track is already a cluster member, so we can merge the 2 clusters
...@@ -616,8 +624,8 @@ void CONNECTIONS::Propagate_SubNets() ...@@ -616,8 +624,8 @@ void CONNECTIONS::Propagate_SubNets()
} }
else else
{ {
/* The other track is not yet attached to a cluster , so we can add this // The other track is not yet attached to a cluster , so we can add this
* other track to the cluster */ // other track to the cluster
track->SetSubNet( curr_track->GetSubNet() ); track->SetSubNet( curr_track->GetSubNet() );
} }
} }
...@@ -631,8 +639,8 @@ void CONNECTIONS::Propagate_SubNets() ...@@ -631,8 +639,8 @@ void CONNECTIONS::Propagate_SubNets()
} }
else else
{ {
/* it is connected to an other segment not in a cluster, so we must // it is connected to an other segment not in a cluster, so we must
* create a new cluster (only with the 2 track segments) */ // create a new cluster (only with the 2 track segments)
sub_netcode++; sub_netcode++;
curr_track->SetSubNet( sub_netcode ); curr_track->SetSubNet( sub_netcode );
track->SetSubNet( curr_track->GetSubNet() ); track->SetSubNet( curr_track->GetSubNet() );
...@@ -648,10 +656,12 @@ void CONNECTIONS::Propagate_SubNets() ...@@ -648,10 +656,12 @@ void CONNECTIONS::Propagate_SubNets()
// sub_netcodes to intersecting pads // sub_netcodes to intersecting pads
for( unsigned ii = 0; ii < m_sortedPads.size(); ii++ ) for( unsigned ii = 0; ii < m_sortedPads.size(); ii++ )
{ {
D_PAD * curr_pad = m_sortedPads[ii]; D_PAD* curr_pad = m_sortedPads[ii];
for( unsigned jj = 0; jj < curr_pad->m_PadsConnected.size(); jj++ ) for( unsigned jj = 0; jj < curr_pad->m_PadsConnected.size(); jj++ )
{ {
D_PAD * pad = curr_pad->m_PadsConnected[jj]; D_PAD* pad = curr_pad->m_PadsConnected[jj];
if( curr_pad->GetSubNet() ) // the current pad is already attached to a cluster if( curr_pad->GetSubNet() ) // the current pad is already attached to a cluster
{ {
if( pad->GetSubNet() > 0 ) if( pad->GetSubNet() > 0 )
...@@ -660,8 +670,10 @@ void CONNECTIONS::Propagate_SubNets() ...@@ -660,8 +670,10 @@ void CONNECTIONS::Propagate_SubNets()
// Store the initial subnets, which will be modified by Merge_PadsSubNets // Store the initial subnets, which will be modified by Merge_PadsSubNets
int subnet1 = pad->GetSubNet(); int subnet1 = pad->GetSubNet();
int subnet2 = curr_pad->GetSubNet(); int subnet2 = curr_pad->GetSubNet();
// merge subnets of pads only, even those not connected by tracks // merge subnets of pads only, even those not connected by tracks
Merge_PadsSubNets( subnet1, subnet2 ); Merge_PadsSubNets( subnet1, subnet2 );
// merge subnets of tracks (and pads, which are already merged) // merge subnets of tracks (and pads, which are already merged)
Merge_SubNets( subnet1, subnet2 ); Merge_SubNets( subnet1, subnet2 );
} }
...@@ -716,12 +728,15 @@ void PCB_BASE_FRAME::TestConnections() ...@@ -716,12 +728,15 @@ void PCB_BASE_FRAME::TestConnections()
// note some nets can have no tracks, and pads intersecting // note some nets can have no tracks, and pads intersecting
// so Build_CurrNet_SubNets_Connections must be called for each net // so Build_CurrNet_SubNets_Connections must be called for each net
CONNECTIONS connections( m_Pcb ); CONNECTIONS connections( m_Pcb );
int last_net_tested = 0; int last_net_tested = 0;
int current_net_code = 0; int current_net_code = 0;
for( TRACK* track = m_Pcb->m_Track; track; ) for( TRACK* track = m_Pcb->m_Track; track; )
{ {
// At this point, track is the first track of a given net // At this point, track is the first track of a given net
current_net_code = track->GetNetCode(); current_net_code = track->GetNetCode();
// Get last track of the current net // Get last track of the current net
TRACK* lastTrack = track->GetEndNetCode( current_net_code ); TRACK* lastTrack = track->GetEndNetCode( current_net_code );
...@@ -780,6 +795,7 @@ void PCB_BASE_FRAME::TestNetConnection( wxDC* aDC, int aNetCode ) ...@@ -780,6 +795,7 @@ void PCB_BASE_FRAME::TestNetConnection( wxDC* aDC, int aNetCode )
if( m_Pcb->m_Track ) if( m_Pcb->m_Track )
{ {
CONNECTIONS connections( m_Pcb ); CONNECTIONS connections( m_Pcb );
TRACK* firstTrack; TRACK* firstTrack;
TRACK* lastTrack = NULL; TRACK* lastTrack = NULL;
firstTrack = m_Pcb->m_Track.GetFirst()->GetStartNetCode( aNetCode ); firstTrack = m_Pcb->m_Track.GetFirst()->GetStartNetCode( aNetCode );
...@@ -887,8 +903,10 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode() ...@@ -887,8 +903,10 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode()
for( curr_track = m_Pcb->m_Track; curr_track; curr_track = curr_track->Next() ) for( curr_track = m_Pcb->m_Track; curr_track; curr_track = curr_track->Next() )
{ {
int netcode = curr_track->GetNetCode(); int netcode = curr_track->GetNetCode();
if( netcode == 0 ) if( netcode == 0 )
{ // try to find a connected item having a netcode {
// try to find a connected item having a netcode
for( unsigned kk = 0; kk < curr_track->m_TracksConnected.size(); kk++ ) for( unsigned kk = 0; kk < curr_track->m_TracksConnected.size(); kk++ )
{ {
int altnetcode = curr_track->m_TracksConnected[kk]->GetNetCode(); int altnetcode = curr_track->m_TracksConnected[kk]->GetNetCode();
...@@ -901,8 +919,10 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode() ...@@ -901,8 +919,10 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode()
} }
} }
} }
if( netcode ) // this track has a netcode if( netcode ) // this track has a netcode
{ // propagate this netcode to connected tracks having no netcode {
// propagate this netcode to connected tracks having no netcode
for( unsigned kk = 0; kk < curr_track->m_TracksConnected.size(); kk++ ) for( unsigned kk = 0; kk < curr_track->m_TracksConnected.size(); kk++ )
{ {
int altnetcode = curr_track->m_TracksConnected[kk]->GetNetCode(); int altnetcode = curr_track->m_TracksConnected[kk]->GetNetCode();
......
...@@ -114,7 +114,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) ...@@ -114,7 +114,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
LSET layers_filter = LSET().set(); LSET layers_filter = LSET().set();
if( m_rbLayersOption->GetSelection() != 0 ) // Use current layer only if( m_rbLayersOption->GetSelection() != 0 ) // Use current layer only
layers_filter = LSET( m_currentLayer ); layers_filter = LSET( ToLAYER_ID( m_currentLayer ) );
if( m_DelZones->GetValue() ) if( m_DelZones->GetValue() )
{ {
......
...@@ -536,6 +536,7 @@ void DRC::testUnconnected() ...@@ -536,6 +536,7 @@ void DRC::testUnconnected()
D_PAD* padEnd = rat.m_PadEnd; D_PAD* padEnd = rat.m_PadEnd;
msg = padStart->GetSelectMenuText() + wxT( " net " ) + padStart->GetNetname(); msg = padStart->GetSelectMenuText() + wxT( " net " ) + padStart->GetNetname();
DRC_ITEM* uncItem = new DRC_ITEM( DRCE_UNCONNECTED_PADS, DRC_ITEM* uncItem = new DRC_ITEM( DRCE_UNCONNECTED_PADS,
msg, msg,
padEnd->GetSelectMenuText(), padEnd->GetSelectMenuText(),
......
...@@ -311,4 +311,3 @@ void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC ) ...@@ -311,4 +311,3 @@ void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC )
GetBoard()->m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE; GetBoard()->m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE;
} }
} }
...@@ -121,7 +121,7 @@ void MIN_SPAN_TREE::updateDistances( int target ) ...@@ -121,7 +121,7 @@ void MIN_SPAN_TREE::updateDistances( int target )
void MIN_SPAN_TREE::BuildTree() void MIN_SPAN_TREE::BuildTree()
{ {
/* Add the first node to the tree */ // Add the first node to the tree
inTree[0] = 1; inTree[0] = 1;
updateDistances( 0 ); updateDistances( 0 );
...@@ -129,6 +129,7 @@ void MIN_SPAN_TREE::BuildTree() ...@@ -129,6 +129,7 @@ void MIN_SPAN_TREE::BuildTree()
{ {
// Find the node with the smallest distance to the tree // Find the node with the smallest distance to the tree
int min = -1; int min = -1;
for( int ii = 0; ii < m_Size; ++ii ) for( int ii = 0; ii < m_Size; ++ii )
{ {
if( !inTree[ii] ) if( !inTree[ii] )
......
...@@ -85,12 +85,25 @@ void PCB_PARSER::init() ...@@ -85,12 +85,25 @@ void PCB_PARSER::init()
for( int i=1; i<=14; ++i ) for( int i=1; i<=14; ++i )
{ {
char tmp[60]; std::string key = StrPrintf( "Inner%d", i );
sprintf( tmp, "Inner%d", i ); m_layerMasks[ key ] = LSET( LAYER_ID( In15_Cu - i ) );
}
#if defined(DEBUG) && 0
printf( "m_layerMasks:\n" );
for( LSET_MAP::const_iterator it = m_layerMasks.begin(); it != m_layerMasks.end(); ++it )
{
printf( " [%s] == 0x%s\n", it->first.c_str(), it->second.FmtHex().c_str() );
}
m_layerMasks[ tmp ] = LSET( In15_Cu - i ); printf( "m_layerIndices:\n" );
for( LAYER_ID_MAP::const_iterator it = m_layerIndices.begin(); it != m_layerIndices.end(); ++it )
{
printf( " [%s] == %d\n", it->first.c_str(), it->second );
} }
#endif
} }
...@@ -776,7 +789,7 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR ) ...@@ -776,7 +789,7 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
UTF8 name = it->m_name; UTF8 name = it->m_name;
m_layerIndices[ name ] = LAYER_ID( it->m_number ); m_layerIndices[ name ] = LAYER_ID( it->m_number );
m_layerMasks[ name ] = LSET( it->m_number ); m_layerMasks[ name ] = LSET( LAYER_ID( it->m_number ) );
} }
copperLayerCount = cu.size(); copperLayerCount = cu.size();
...@@ -1806,9 +1819,8 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR ...@@ -1806,9 +1819,8 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR
default: default:
module->GraphicalItems().PushBack( text ); module->GraphicalItems().PushBack( text );
} }
break;
} }
break;
case T_fp_arc: case T_fp_arc:
case T_fp_circle: case T_fp_circle:
...@@ -1820,18 +1832,19 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR ...@@ -1820,18 +1832,19 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR
em->SetParent( module.get() ); em->SetParent( module.get() );
em->SetDrawCoord(); em->SetDrawCoord();
module->GraphicalItems().PushBack( em ); module->GraphicalItems().PushBack( em );
break;
} }
break;
case T_pad: case T_pad:
{ {
D_PAD* pad = parseD_PAD( module.get() ); D_PAD* pad = parseD_PAD( module.get() );
wxPoint pt = pad->GetPos0(); wxPoint pt = pad->GetPos0();
RotatePoint( &pt, module->GetOrientation() ); RotatePoint( &pt, module->GetOrientation() );
pad->SetPosition( pt + module->GetPosition() ); pad->SetPosition( pt + module->GetPosition() );
module->AddPad( pad ); module->AddPad( pad );
break;
} }
break;
case T_model: case T_model:
module->Add3DModel( parse3DModel() ); module->Add3DModel( parse3DModel() );
...@@ -2112,6 +2125,7 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) throw( IO_ERROR, PARSE_ERROR ) ...@@ -2112,6 +2125,7 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) throw( IO_ERROR, PARSE_ERROR )
wxSize sz; wxSize sz;
wxPoint pt; wxPoint pt;
std::auto_ptr< D_PAD > pad( new D_PAD( aParent ) ); std::auto_ptr< D_PAD > pad( new D_PAD( aParent ) );
NeedSYMBOLorNUMBER(); NeedSYMBOLorNUMBER();
...@@ -2214,8 +2228,8 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) throw( IO_ERROR, PARSE_ERROR ) ...@@ -2214,8 +2228,8 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) throw( IO_ERROR, PARSE_ERROR )
delta.SetHeight( parseBoardUnits( "rectangle delta height" ) ); delta.SetHeight( parseBoardUnits( "rectangle delta height" ) );
pad->SetDelta( delta ); pad->SetDelta( delta );
NeedRIGHT(); NeedRIGHT();
break;
} }
break;
case T_drill: case T_drill:
{ {
...@@ -2248,8 +2262,8 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) throw( IO_ERROR, PARSE_ERROR ) ...@@ -2248,8 +2262,8 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) throw( IO_ERROR, PARSE_ERROR )
drillSize.SetHeight( parseBoardUnits() ); drillSize.SetHeight( parseBoardUnits() );
} }
break;
} }
break;
case T_offset: case T_offset:
pt.x = parseBoardUnits( "drill offset x" ); pt.x = parseBoardUnits( "drill offset x" );
...@@ -2272,8 +2286,8 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) throw( IO_ERROR, PARSE_ERROR ) ...@@ -2272,8 +2286,8 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) throw( IO_ERROR, PARSE_ERROR )
else else
pad->SetDrillSize( wxSize( 0, 0 ) ); pad->SetDrillSize( wxSize( 0, 0 ) );
break;
} }
break;
case T_layers: case T_layers:
{ {
......
...@@ -370,7 +370,7 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() ...@@ -370,7 +370,7 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
for( int i = 0; i<LAYER_ID_COUNT; ++i ) for( int i = 0; i<LAYER_ID_COUNT; ++i )
{ {
wxString vn = wxString::Format( wxString vn = wxString::Format(
wxT( "ColorPCBLayer:%s" ), wxT( "ColorPCBLayer_%s" ),
LSET::Name( LAYER_ID( i ) ) ); LSET::Name( LAYER_ID( i ) ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, vn, LOC_COLOR( i ), cds.m_LayersColors[i] ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, vn, LOC_COLOR( i ), cds.m_LayersColors[i] ) );
......
...@@ -154,7 +154,7 @@ void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, LAYER_NUM aLayer, ...@@ -154,7 +154,7 @@ void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, LAYER_NUM aLayer,
// Specify that the contents of the "Edges Pcb" layer are to be plotted // Specify that the contents of the "Edges Pcb" layer are to be plotted
// in addition to the contents of the currently specified layer. // in addition to the contents of the currently specified layer.
LSET layer_mask( aLayer ); LSET layer_mask( ToLAYER_ID( aLayer ) );
if( !aPlotOpt.GetExcludeEdgeLayer() ) if( !aPlotOpt.GetExcludeEdgeLayer() )
layer_mask.set( Edge_Cuts ); layer_mask.set( Edge_Cuts );
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
#include <minimun_spanning_tree.h> #include <minimun_spanning_tree.h>
/** /**
* @brief class MIN_SPAN_TREE_PADS (derived from MIN_SPAN_TREE) specialize * @brief class MIN_SPAN_TREE_PADS (derived from MIN_SPAN_TREE) specializes
* the basic class to calculate a minimum spanning tree from a list of pads, * the base class to calculate a minimum spanning tree from a list of pads,
* and to add this tree as ratsnest to the main ratsnest list. * and to add this tree as ratsnest to the main ratsnest list.
*/ */
class MIN_SPAN_TREE_PADS: public MIN_SPAN_TREE class MIN_SPAN_TREE_PADS: public MIN_SPAN_TREE
...@@ -52,9 +52,9 @@ public: ...@@ -52,9 +52,9 @@ public:
* Function AddTreeToRatsnest * Function AddTreeToRatsnest
* Adds the current minimum spanning tree as ratsnest items * Adds the current minimum spanning tree as ratsnest items
* to the main ratsnest list * to the main ratsnest list
* @param aRatsnestList = the main ratsnest list * @param aRatsnestList = a ratsnest list to add to
*/ */
void AddTreeToRatsnest( std::vector<RATSNEST_ITEM> &aRatsnestList ); void AddTreeToRatsnest( std::vector<RATSNEST_ITEM>* aRatsnestList );
/** /**
* Function GetWeight * Function GetWeight
...@@ -68,13 +68,15 @@ public: ...@@ -68,13 +68,15 @@ public:
}; };
void MIN_SPAN_TREE_PADS::AddTreeToRatsnest( std::vector<RATSNEST_ITEM> &aRatsnestList ) void MIN_SPAN_TREE_PADS::AddTreeToRatsnest( std::vector<RATSNEST_ITEM>* aRatsnestList )
{ {
std::vector<D_PAD*>& padsBuffer = *m_PadsList; std::vector<D_PAD*>& padsBuffer = *m_PadsList;
if( padsBuffer.empty() ) if( padsBuffer.empty() )
return; return;
int netcode = padsBuffer[0]->GetNetCode(); int netcode = padsBuffer[0]->GetNetCode();
// Note: to get edges in minimum spanning tree, // Note: to get edges in minimum spanning tree,
// the index value 0 is not used: it is just // the index value 0 is not used: it is just
// the entry point of the minimum spanning tree. // the entry point of the minimum spanning tree.
...@@ -83,12 +85,14 @@ void MIN_SPAN_TREE_PADS::AddTreeToRatsnest( std::vector<RATSNEST_ITEM> &aRatsnes ...@@ -83,12 +85,14 @@ void MIN_SPAN_TREE_PADS::AddTreeToRatsnest( std::vector<RATSNEST_ITEM> &aRatsnes
{ {
// Create the new ratsnest // Create the new ratsnest
RATSNEST_ITEM net; RATSNEST_ITEM net;
net.SetNet( netcode ); net.SetNet( netcode );
net.m_Status = CH_ACTIF | CH_VISIBLE; net.m_Status = CH_ACTIF | CH_VISIBLE;
net.m_Lenght = GetDist(ii); net.m_Lenght = GetDist(ii);
net.m_PadStart = padsBuffer[ii]; net.m_PadStart = padsBuffer[ii];
net.m_PadEnd = padsBuffer[ GetWhoTo(ii) ]; net.m_PadEnd = padsBuffer[ GetWhoTo(ii) ];
aRatsnestList.push_back( net );
aRatsnestList->push_back( net );
} }
} }
...@@ -110,13 +114,13 @@ int MIN_SPAN_TREE_PADS::GetWeight( int aItem1, int aItem2 ) ...@@ -110,13 +114,13 @@ int MIN_SPAN_TREE_PADS::GetWeight( int aItem1, int aItem2 )
if( pad1 == pad2 ) if( pad1 == pad2 )
return 0; return 0;
int weight = abs( pad2->GetPosition().x - pad1->GetPosition().x ) + int weight = abs( pad2->GetPosition().x - pad1->GetPosition().x ) +
abs( pad2->GetPosition().y - pad1->GetPosition().y ); abs( pad2->GetPosition().y - pad1->GetPosition().y );
return weight + 1; return weight + 1;
} }
/* Note about the ratsnest computation: /* Note about the ratsnest computation:
* Building the general ratsnest: * Building the general ratsnest:
* For each net, the ratsnest is the set of lines connecting pads, * For each net, the ratsnest is the set of lines connecting pads,
...@@ -230,6 +234,7 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest() ...@@ -230,6 +234,7 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest()
// (net_code = 0 -> no connect) // (net_code = 0 -> no connect)
noconn = 0; noconn = 0;
MIN_SPAN_TREE_PADS min_spanning_tree; MIN_SPAN_TREE_PADS min_spanning_tree;
for( ; current_net_code < m_Pcb->GetNetCount(); current_net_code++ ) for( ; current_net_code < m_Pcb->GetNetCount(); current_net_code++ )
{ {
NETINFO_ITEM* net = m_Pcb->FindNet( current_net_code ); NETINFO_ITEM* net = m_Pcb->FindNet( current_net_code );
...@@ -245,7 +250,7 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest() ...@@ -245,7 +250,7 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest()
min_spanning_tree.MSP_Init( &net->m_PadInNetList ); min_spanning_tree.MSP_Init( &net->m_PadInNetList );
min_spanning_tree.BuildTree(); min_spanning_tree.BuildTree();
min_spanning_tree.AddTreeToRatsnest( m_Pcb->m_FullRatsnest ); min_spanning_tree.AddTreeToRatsnest( &m_Pcb->m_FullRatsnest );
net->m_RatsnestEndIdx = m_Pcb->GetRatsnestsCount(); net->m_RatsnestEndIdx = m_Pcb->GetRatsnestsCount();
} }
...@@ -255,7 +260,7 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest() ...@@ -255,7 +260,7 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest()
// Update the ratsnest display option (visible/invisible) flag // Update the ratsnest display option (visible/invisible) flag
for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ )
{ {
if( !GetBoard()->IsElementVisible(RATSNEST_VISIBLE) ) // Clear VISIBLE flag if( !GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) // Clear VISIBLE flag
m_Pcb->m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE; m_Pcb->m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE;
} }
} }
...@@ -532,14 +537,13 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) ...@@ -532,14 +537,13 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
*/ */
if( (m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) == 0 ) if( (m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) == 0 )
{ {
/* Compute the "internal" ratsnest, i.e the links between the current // Compute the "internal" ratsnest, i.e the links between the current
* footprint pads // footprint pads
*/
localPadList.clear(); localPadList.clear();
m_Pcb->m_LocalRatsnest.clear(); m_Pcb->m_LocalRatsnest.clear();
// collect active pads of the module: // collect active pads of the module:
for( pad_ref = aModule->Pads(); pad_ref != NULL; pad_ref = pad_ref->Next() ) for( pad_ref = aModule->Pads(); pad_ref; pad_ref = pad_ref->Next() )
{ {
if( pad_ref->GetNetCode() == NETINFO_LIST::UNCONNECTED ) if( pad_ref->GetNetCode() == NETINFO_LIST::UNCONNECTED )
continue; continue;
...@@ -602,6 +606,7 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) ...@@ -602,6 +606,7 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
MIN_SPAN_TREE_PADS min_spanning_tree; MIN_SPAN_TREE_PADS min_spanning_tree;
std::vector<D_PAD*> padsBuffer; // contains pads of only one net std::vector<D_PAD*> padsBuffer; // contains pads of only one net
for( unsigned ii = 0; ii < pads_module_count; ii++ ) for( unsigned ii = 0; ii < pads_module_count; ii++ )
{ {
// Search the end of pad list relative to the current net // Search the end of pad list relative to the current net
...@@ -616,16 +621,20 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) ...@@ -616,16 +621,20 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
break; break;
} }
for(unsigned kk = ii; kk < jj; kk++ ) for( unsigned kk = ii; kk < jj; kk++ )
padsBuffer.push_back( localPadList[kk] ); padsBuffer.push_back( localPadList[kk] );
min_spanning_tree.MSP_Init( &padsBuffer ); min_spanning_tree.MSP_Init( &padsBuffer );
min_spanning_tree.BuildTree(); min_spanning_tree.BuildTree();
min_spanning_tree.AddTreeToRatsnest( m_Pcb->m_LocalRatsnest ); min_spanning_tree.AddTreeToRatsnest( &m_Pcb->m_LocalRatsnest );
padsBuffer.clear(); padsBuffer.clear();
ii = jj; ii = jj;
if( ii < localPadList.size() ) if( ii < localPadList.size() )
current_net_code = localPadList[ii]->GetNetCode(); current_net_code = localPadList[ii]->GetNetCode();
} }
internalRatsCount = m_Pcb->m_LocalRatsnest.size(); internalRatsCount = m_Pcb->m_LocalRatsnest.size();
// set the flag LOCAL_RATSNEST_ITEM of the ratsnest status: // set the flag LOCAL_RATSNEST_ITEM of the ratsnest status:
...@@ -647,6 +656,7 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) ...@@ -647,6 +656,7 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
* so, for each net, only one rats nest item is created * so, for each net, only one rats nest item is created
*/ */
RATSNEST_ITEM local_rats; RATSNEST_ITEM local_rats;
local_rats.m_Lenght = INT_MAX; local_rats.m_Lenght = INT_MAX;
local_rats.m_Status = 0; local_rats.m_Status = 0;
bool addRats = false; bool addRats = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment