Commit 2455a6cc authored by Marco Mattila's avatar Marco Mattila
Browse files

Do some ZONE_CONTAINED encapsulation.

parent 57acee0d
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
            if( curr_zone->m_FillMode == 0 )
            {
                // solid polygons only are used to fill areas
                if( curr_zone->m_FilledPolysList.size() > 3 )
                if( curr_zone->GetFilledPolysList().size() > 3 )
                {
                    Draw3D_SolidPolygonsInZones( curr_zone );
                }
@@ -286,14 +286,16 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
        {
            ZONE_CONTAINER* zone = pcb->GetArea( ii );

            if( zone->m_FilledPolysList.size() == 0 )
            std::vector<CPolyPt> polysList = zone->GetFilledPolysList();

            if( polysList.size() == 0 )
                continue;

            if( zone->m_ZoneMinThickness <= 1 )
                continue;

            int      imax = zone->m_FilledPolysList.size() - 1;
            CPolyPt* firstcorner = &zone->m_FilledPolysList[0];
            int      imax = polysList.size() - 1;
            CPolyPt* firstcorner = &polysList[0];
            CPolyPt* begincorner = firstcorner;
            SEGZONE  dummysegment( pcb );
            dummysegment.SetLayer( zone->GetLayer() );
@@ -301,7 +303,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()

            for( int ic = 1; ic <= imax; ic++ )
            {
                CPolyPt* endcorner = &zone->m_FilledPolysList[ic];
                CPolyPt* endcorner = &polysList[ic];

                if( begincorner->utility == 0 )
                {
@@ -330,7 +332,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
                    ic++;

                    if( ic < imax - 1 )
                        begincorner = firstcorner = &zone->m_FilledPolysList[ic];
                        begincorner = firstcorner = &polysList[ic];
                }
                else
                {
@@ -440,7 +442,8 @@ void EDA_3D_CANVAS::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone )
    // Draw solid areas contained in this zone
    int StartContour = 1;

    for( unsigned ii = 0; ii < aZone->m_FilledPolysList.size(); ii++ )
    std::vector<CPolyPt> polysList = aZone->GetFilledPolysList();
    for( unsigned ii = 0; ii < polysList.size(); ii++ )
    {
        if( StartContour == 1 )
        {
@@ -449,11 +452,11 @@ void EDA_3D_CANVAS::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone )
            StartContour = 0;
        }

        v_data[0] = aZone->m_FilledPolysList[ii].x * g_Parm_3D_Visu.m_BoardScale;
        v_data[1] = -aZone->m_FilledPolysList[ii].y * g_Parm_3D_Visu.m_BoardScale;
        gluTessVertex( tess, v_data, &aZone->m_FilledPolysList[ii] );
        v_data[0] = polysList[ii].x * g_Parm_3D_Visu.m_BoardScale;
        v_data[1] = -polysList[ii].y * g_Parm_3D_Visu.m_BoardScale;
        gluTessVertex( tess, v_data, &polysList[ii] );

        if( aZone->m_FilledPolysList[ii].end_contour == 1 )
        if( polysList[ii].end_contour == 1 )
        {
            gluTessEndContour( tess );
            gluTessEndPolygon( tess );
+38 −10
Original line number Diff line number Diff line
@@ -457,6 +457,34 @@ public:
     */
    bool IsSame( const ZONE_CONTAINER &aZoneToCompare );

   /**
     * Function ClearFilledPolysList
     * clears the list of filled polygons.
     */
    void ClearFilledPolysList()
    {
        m_FilledPolysList.clear();
    }

   /**
     * Function GetFilledPolysList
     * returns a reference to the list of filled polygons.
     * @return Reference to the list of filled polygons.
     */
    const std::vector<CPolyPt>& GetFilledPolysList() const
    {
        return m_FilledPolysList;
    }

   /**
     * Function AddFilledPolysList
     * sets the list of filled polygons.
     */
    void AddFilledPolysList( std::vector<CPolyPt>& aPolysList )
    {
        m_FilledPolysList = aPolysList;
    }

    /**
     * Function GetSmoothedPoly
     * returns a pointer to the corner-smoothed version of
@@ -522,16 +550,6 @@ public:
    // true when a zone was filled, false after deleting the filled areas
    bool                  m_IsFilled;

    /* set of filled polygons used to draw a zone as a filled area.
     * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
     * (they are* all in one piece)  In very simple cases m_FilledPolysList is same
     * as m_Poly.  In less simple cases (when m_Poly has holes) m_FilledPolysList is
     * a polygon equivalent to m_Poly, without holes but with extra outline segment
     * connecting "holes" with external main outline.  In complex cases an outline
     * described by m_Poly can have many filled areas
     */
    std::vector <CPolyPt> m_FilledPolysList;

    /* set of segments used to fill area, when fill zone by segment is used.
     *  ( m_FillMode == 1 )
     *  in this case segments have m_ZoneMinThickness width
@@ -549,6 +567,16 @@ private:
    // if priorities are equal, a DRC error is set
    unsigned              m_priority;
    ZoneConnection        m_PadConnection;

    /* set of filled polygons used to draw a zone as a filled area.
     * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
     * (they are* all in one piece)  In very simple cases m_FilledPolysList is same
     * as m_Poly.  In less simple cases (when m_Poly has holes) m_FilledPolysList is
     * a polygon equivalent to m_Poly, without holes but with extra outline segment
     * connecting "holes" with external main outline.  In complex cases an outline
     * described by m_Poly can have many filled areas
     */
    std::vector <CPolyPt> m_FilledPolysList;
};


+1 −1
Original line number Diff line number Diff line
@@ -579,7 +579,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
        {
            // Remove filled areas in zone
            ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii );
            zone_container->m_FilledPolysList.clear();
            zone_container->ClearFilledPolysList();
        }

        SetCurItem( NULL );        // CurItem might be deleted by this command, clear the pointer
+1 −1
Original line number Diff line number Diff line
@@ -970,7 +970,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, OUTPUTFORMATTER* aFormatter, int aNe
    }

    // Save the PolysList
    const std::vector< CPolyPt >& fv = aZone->m_FilledPolysList;
    const std::vector< CPolyPt >& fv = aZone->GetFilledPolysList();

    if( fv.size() )
    {
+4 −2
Original line number Diff line number Diff line
@@ -2258,6 +2258,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
        else if( TESTLINE( "$POLYSCORNERS" ) )
        {
            // Read the PolysList (polygons used for fill areas in the zone)
            std::vector<CPolyPt> polysList;

            while( READLINE( m_reader ) )
            {
@@ -2273,8 +2274,9 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
                bool    end_contour = intParse( data, &data );  // end_countour was a bool when file saved, so '0' or '1' here
                int     utility     = intParse( data );

                zc->m_FilledPolysList.push_back( CPolyPt( x, y, end_contour, utility ) );
               polysList.push_back( CPolyPt( x, y, end_contour, utility ) );
            }
            zc->AddFilledPolysList( polysList );
        }

        else if( TESTLINE( "$FILLSEGMENTS" ) )
@@ -3569,7 +3571,7 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
    }

    // Save the PolysList
    const CPOLY_PTS& fv = me->m_FilledPolysList;
    const CPOLY_PTS& fv = me->GetFilledPolysList();
    if( fv.size() )
    {
        fprintf( m_fp, "$POLYSCORNERS\n" );
Loading