Commit 3aa880de authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

fix pcb_parser for new board, coding standards

parent 06bf0821
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -251,6 +251,7 @@ void CONNECTIONS::BuildTracksCandidatesList( TRACK * aBegin, TRACK * aEnd)
    m_firstTrack = m_lastTrack = aBegin;

    unsigned ii = 0;

    // Count candidates ( i.e. end points )
    for( const TRACK* track = aBegin; track; track = track->Next() )
    {
@@ -260,14 +261,17 @@ void CONNECTIONS::BuildTracksCandidatesList( TRACK * aBegin, TRACK * aEnd)
            ii += 2;

        m_lastTrack = track;

        if( track == aEnd )
            break;
    }

    // Build candidate list
    m_candidates.reserve( ii );
    for( TRACK* track = aBegin; track; track = track->Next() )
    {
        CONNECTED_POINT candidate( track, track->GetStart() );

        m_candidates.push_back( candidate );
        if( track->Type() != PCB_VIA_T )
        {
@@ -285,6 +289,7 @@ void CONNECTIONS::BuildTracksCandidatesList( TRACK * aBegin, TRACK * aEnd)
    sort( m_candidates.begin(), m_candidates.end(), sortConnectedPointByXthenYCoordinates );
}


/* Populates .m_connected with tracks/vias connected to aTrack
 * param aTrack = track or via to use as reference
 * For calculation time reason, an exhaustive search cannot be made
@@ -308,7 +313,9 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
    int dist_max = aTrack->GetWidth() / 2;
    static std::vector<CONNECTED_POINT*> tracks_candidates;
#endif

    wxPoint position = aTrack->GetStart();

    for( int kk = 0; kk < 2; kk++ )
    {
#ifndef USE_EXTENDED_SEARCH
@@ -321,8 +328,10 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
            {
                if( m_candidates[ii].GetTrack() == aTrack )
                    continue;

                if( m_candidates[ii].GetPoint() != position )
                    break;

                if( ( m_candidates[ii].GetTrack()->GetLayerSet() & layerMask ).any() )
                    m_connected.push_back( m_candidates[ii].GetTrack() );
            }
@@ -332,15 +341,20 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
            {
                if( m_candidates[ii].GetTrack() == aTrack )
                    continue;

                if( m_candidates[ii].GetPoint() != position )
                    break;

                if( ( m_candidates[ii].GetTrack()->GetLayerSet() & layerMask ).any() )
                    m_connected.push_back( m_candidates[ii].GetTrack() );
            }
        }
#else

        tracks_candidates.clear();

        CollectItemsNearTo( tracks_candidates, position, dist_max );

        for( unsigned ii = 0; ii < tracks_candidates.size(); ii++ )
        {
            TRACK* ctrack = tracks_candidates[ii]->GetTrack();
@@ -354,6 +368,7 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
            // We have a good candidate: calculate the actual distance
            // between ends, which should be <= dist max.
            wxPoint delta = tracks_candidates[ii]->GetPoint() - position;

            int dist = KiROUND( EuclideanNorm( delta ) );

            if( dist > dist_max )
+40 −34
Original line number Diff line number Diff line
@@ -734,6 +734,7 @@ void PCB_PARSER::parseLayer( LAYER* aLayer ) throw( IO_ERROR, PARSE_ERROR )
}



void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
{
    wxCHECK_RET( CurTok() == T_layers,
@@ -752,19 +753,17 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )

        parseLayer( &layer );

        if( layer.m_type != LT_UNDEFINED )     // it's a copper layer
        {
            cu.push_back( layer );
        if( layer.m_type == LT_UNDEFINED )     // it's a non-copper layer
            break;

            //DBG( printf( "cop m_visible:%s\n", cu.back().m_visible ? "true" : "false" );)
        cu.push_back( layer );      // it's copper
    }
        else    // all non-copper are fixed names, simply look up LAYER_ID.
        {
            // This is an edge triggered one shot if( test ) that happens on
            // the first non copper layer, which follow all the Cu layers.
            // This is the feature that the original *.kicad_pcb file format and
            // the inverted Cu stack format had in common and is therefore a trick
            // used to handle either.  The layer number in the (layers ..)

    // All Cu layers are parsed, but not the non-cu layers here.

    // The original *.kicad_pcb file format and the inverted
    // Cu stack format both have all the Cu layers first, so use this
    // trick to handle either. The layer number in the (layers ..)
    // s-expression element are ignored.
    if( cu.size() )
    {
@@ -793,10 +792,17 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
        }

        copperLayerCount = cu.size();

                cu.clear();     // this marks the list as "one time processed".
    }

    if( token != T_RIGHT )
    {
        // read any non-copper layers
        for( token = NextTok(); token != T_RIGHT;  token = NextTok() )
        {
            LAYER   layer;

            parseLayer( &layer );

            LAYER_ID_MAP::const_iterator it = m_layerIndices.find( UTF8( layer.m_name ) );

            if( it == m_layerIndices.end() )