当前位置: 首页>>代码示例>>C++>>正文


C++ ZONE_CONTAINER::GetFilledPolysList方法代码示例

本文整理汇总了C++中ZONE_CONTAINER::GetFilledPolysList方法的典型用法代码示例。如果您正苦于以下问题:C++ ZONE_CONTAINER::GetFilledPolysList方法的具体用法?C++ ZONE_CONTAINER::GetFilledPolysList怎么用?C++ ZONE_CONTAINER::GetFilledPolysList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZONE_CONTAINER的用法示例。


在下文中一共展示了ZONE_CONTAINER::GetFilledPolysList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: export_vrml_zones

static void export_vrml_zones( MODEL_VRML& aModel, BOARD* aPcb )
{

    double scale = aModel.scale;
    double x, y;

    for( int ii = 0; ii < aPcb->GetAreaCount(); ii++ )
    {
        ZONE_CONTAINER* zone = aPcb->GetArea( ii );

        VRML_LAYER* vl;

        if( !GetLayer( aModel, zone->GetLayer(), &vl ) )
            continue;

        if( !zone->IsFilled() )
        {
            zone->SetFillMode( 0 ); // use filled polygons
            zone->BuildFilledSolidAreasPolygons( aPcb );
        }
        const CPOLYGONS_LIST& poly = zone->GetFilledPolysList();

        int nvert = poly.GetCornersCount();
        int i = 0;

        while( i < nvert )
        {
            int seg = vl->NewContour();
            bool first = true;

            if( seg < 0 )
                break;

            while( i < nvert )
            {
                x = poly.GetX(i) * scale;
                y = -(poly.GetY(i) * scale);

                if( poly.IsEndContour(i) )
                    break;

                if( !vl->AddVertex( seg, x, y ) )
                    throw( std::runtime_error( vl->GetError() ) );

                ++i;
            }

            // KiCad ensures that the first polygon is the outline
            // and all others are holes
             vl->EnsureWinding( seg, first ? false : true );

            if( first )
                first = false;

            ++i;
        }
    }
}
开发者ID:LDavis4559,项目名称:kicad-source-mirror,代码行数:58,代码来源:export_vrml.cpp

示例2: Fill

void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones )
{
    std::vector<CN_ZONE_ISOLATED_ISLAND_LIST> toFill;
    auto connectivity = m_board->GetConnectivity();

    connectivity->Lock();

    // Remove segment zones
    m_board->m_Zone.DeleteAll();

    for( auto zone : aZones )
    {
        // Keepout zones are not filled
        if( zone->GetIsKeepout() )
            continue;

        CN_ZONE_ISOLATED_ISLAND_LIST l;
        l.m_zone = zone;
        toFill.push_back( l );
    }

    for( unsigned i = 0; i < toFill.size(); i++ )
    {
        if( m_commit )
        {
            m_commit->Modify( toFill[i].m_zone );
        }
    }

    if( m_progressReporter )
    {
        m_progressReporter->Report( _( "Calculating zone fills..." ) );
        m_progressReporter->SetMaxProgress( toFill.size() );
    }


    #ifdef USE_OPENMP
        #pragma omp parallel
    #endif
    {
        #ifdef USE_OPENMP
            #pragma omp master
            if( m_progressReporter )
            {
                m_progressReporter->KeepRefreshing( true );
            }
        #endif

        #ifdef USE_OPENMP
            #pragma omp for schedule(dynamic)
        #endif
        for( unsigned i = 0; i < toFill.size(); i++ )
        {
            SHAPE_POLY_SET rawPolys, finalPolys;
            ZONE_SEGMENT_FILL segFill;
            fillSingleZone( toFill[i].m_zone, rawPolys, finalPolys );

            toFill[i].m_zone->SetRawPolysList( rawPolys );
            toFill[i].m_zone->SetFilledPolysList( finalPolys );
            toFill[i].m_zone->SetIsFilled( true );

            if( m_progressReporter )
            {
                m_progressReporter->AdvanceProgress();
            }
        }
    }

    // Now remove insulated copper islands
    if( m_progressReporter )
    {
        m_progressReporter->AdvancePhase();
        m_progressReporter->Report( _( "Removing insulated copper islands..." ) );
    }

    connectivity->SetProgressReporter( m_progressReporter );
    connectivity->FindIsolatedCopperIslands( toFill );

    for( auto& zone : toFill )
    {
        std::sort( zone.m_islands.begin(), zone.m_islands.end(), std::greater<int>() );
        SHAPE_POLY_SET poly = zone.m_zone->GetFilledPolysList();

        for( auto idx : zone.m_islands )
        {
            poly.DeletePolygon( idx );
        }

        zone.m_zone->SetFilledPolysList( poly );
    }

    if( m_progressReporter )
    {
        m_progressReporter->AdvancePhase();
        m_progressReporter->Report( _( "Caching polygon triangulations..." ) );
        m_progressReporter->SetMaxProgress( toFill.size() );
    }
    #ifdef USE_OPENMP
        #pragma omp parallel
    #endif
//.........这里部分代码省略.........
开发者ID:cpavlina,项目名称:kicad,代码行数:101,代码来源:zone_filler.cpp

示例3: Test_Connections_To_Copper_Areas

/**
 * Function Test_Connection_To_Copper_Areas
 * init .m_ZoneSubnet parameter in tracks and pads according to the connections to areas found
 * @param aNetcode = netcode to analyse. if -1, analyse all nets
 */
void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
{
    // list of pads and tracks candidates on this layer and on this net.
    // It is static to avoid multiple memory realloc.
    static std::vector <BOARD_CONNECTED_ITEM*> candidates;

    // clear .m_ZoneSubnet parameter for pads
    for( MODULE* module = m_Modules;  module;  module = module->Next() )
    {
        for( D_PAD* pad = module->Pads();  pad;  pad = pad->Next() )
            if( aNetcode < 0 || aNetcode == pad->GetNetCode() )
                pad->SetZoneSubNet( 0 );
    }

    // clear .m_ZoneSubnet parameter for tracks and vias
    for( TRACK* track = m_Track;  track;  track = track->Next() )
    {
        if( aNetcode < 0 || aNetcode == track->GetNetCode() )
            track->SetZoneSubNet( 0 );
    }

    // examine all zones, net by net:
    int subnet = 0;

    // Build zones candidates list
    std::vector<ZONE_CONTAINER*> zones_candidates;

    zones_candidates.reserve( GetAreaCount() );

    for( int index = 0; index < GetAreaCount(); index++ )
    {
        ZONE_CONTAINER* zone = GetArea( index );

        if( !zone->IsOnCopperLayer() )
            continue;

        if( aNetcode >= 0 &&  aNetcode != zone->GetNetCode() )
            continue;

        if( zone->GetFilledPolysList().GetCornersCount() == 0 )
            continue;

        zones_candidates.push_back( zone );
    }

    // sort them by netcode then vertices count.
    // For a given net, examine the smaller zones first slightly speed up calculation
    // (25% faster)
    // this is only noticeable with very large boards and depends on board zones topology
    // This is due to the fact some items are connected by small zones ares,
    // before examining large zones areas and these items are not tested after a connection is found
    sort( zones_candidates.begin(), zones_candidates.end(), sort_areas );

    int oldnetcode = -1;
    for( unsigned idx = 0; idx < zones_candidates.size(); idx++ )
    {
        ZONE_CONTAINER* zone = zones_candidates[idx];

        int netcode = zone->GetNetCode();

        // Build a list of candidates connected to the net:
        // At this point, layers are not considered, because areas on different layers can
        // be connected by a via or a pad.
        // (because zones are sorted by netcode, there is made only once per net)
        NETINFO_ITEM* net = FindNet( netcode );

        wxASSERT( net );
        if( net == NULL )
            continue;

        if( oldnetcode != netcode )
        {
            oldnetcode = netcode;
            candidates.clear();

            // Build the list of pads candidates connected to the net:
            candidates.reserve( net->m_PadInNetList.size() );

            for( unsigned ii = 0; ii < net->m_PadInNetList.size(); ii++ )
                candidates.push_back( net->m_PadInNetList[ii] );

            // Build the list of track candidates connected to the net:
            TRACK* track = m_Track.GetFirst()->GetStartNetCode( netcode );

            for( ; track; track = track->Next() )
            {
                if( track->GetNetCode() != netcode )
                    break;

                candidates.push_back( track );
            }
        }

        // test if a candidate is inside a filled area of this zone
        unsigned indexstart = 0, indexend;
//.........这里部分代码省略.........
开发者ID:Elphel,项目名称:kicad-source-mirror,代码行数:101,代码来源:zones_polygons_test_connections.cpp


注:本文中的ZONE_CONTAINER::GetFilledPolysList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。