Commit c519eea1 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

3D viewer: fix (the fix is not perfect) a minor issue in zone rendering:...

3D viewer: fix (the fix is not perfect) a minor issue in zone rendering: copper thickness was not good when the option 'Show Holes in Zones" was OFF, and "Show Copper Thickness" ON.
Fix a few coverity minor warnings.
parent cec0a956
Loading
Loading
Loading
Loading
+23 −20
Original line number Original line Diff line number Diff line
@@ -793,7 +793,11 @@ void EDA_3D_CANVAS::buildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
            }
            }
        }
        }


        // Draw copper zones
        // Draw copper zones. Note:
        // * if the holes are removed from copper zones
        // the polygons are stored in bufferPolys (which contains all other polygons)
        // * if the holes are NOT removed from copper zones
        // the polygons are stored in bufferZonesPolys
        if( isEnabled( FL_ZONE ) )
        if( isEnabled( FL_ZONE ) )
        {
        {
            for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
            for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
@@ -844,13 +848,13 @@ void EDA_3D_CANVAS::buildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
        // Add polygons, without holes
        // Add polygons, without holes
        bufferPolys.ExportTo( currLayerPolyset );
        bufferPolys.ExportTo( currLayerPolyset );


        // Add holes in polygon list
        // Add through holes (created only once) in current polygon holes list
        currLayerHoles.Append( allLayerHoles );
        currLayerHoles.Append( allLayerHoles );


        if( currLayerHoles.GetCornersCount() > 0 )
        if( currLayerHoles.GetCornersCount() > 0 )
            currLayerHoles.ExportTo( polysetHoles );
            currLayerHoles.ExportTo( polysetHoles );


        // Merge polygons, remove holes
        // Merge polygons, and remove holes
        currLayerPolyset -= polysetHoles;
        currLayerPolyset -= polysetHoles;


        int thickness = GetPrm3DVisu().GetLayerObjectThicknessBIU( layer );
        int thickness = GetPrm3DVisu().GetLayerObjectThicknessBIU( layer );
@@ -866,41 +870,40 @@ void EDA_3D_CANVAS::buildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
            SetGLColor( color );
            SetGLColor( color );
        }
        }


        glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );

        bufferPolys.RemoveAllContours();
        bufferPolys.RemoveAllContours();
        bufferPolys.ImportFrom( currLayerPolyset );
        bufferPolys.ImportFrom( currLayerPolyset );
        Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
                                            thickness,
                                            GetPrm3DVisu().m_BiuTo3Dunits, useTextures );

        if( isEnabled( FL_USE_COPPER_THICKNESS ) == true )
        {
            thickness -= ( 0.04 * IU_PER_MM );
        }


        // If holes are removed from copper zones, bufferPolys contains all polygons
        // to draw (tracks+zones+texts).
        glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
        glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
        Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, thickness,
                                            GetPrm3DVisu().m_BiuTo3Dunits, useTextures );


        // If holes are not removed from copper zones (for calculation time reasons,
        // the zone polygons are stored in bufferZonesPolys and have to be drawn now:
        if( bufferZonesPolys.GetCornersCount() )
        if( bufferZonesPolys.GetCornersCount() )
            Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos,
        {
                                                thickness,
            glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
            Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos, thickness,
                                    GetPrm3DVisu().m_BiuTo3Dunits, useTextures );
                                    GetPrm3DVisu().m_BiuTo3Dunits, useTextures );
        }

        throughHolesListBuilt = true;
        throughHolesListBuilt = true;
    }
    }


    if ( !isEnabled( FL_SHOW_BOARD_BODY ) ||
    if( !isEnabled( FL_SHOW_BOARD_BODY ) || isEnabled( FL_USE_COPPER_THICKNESS ) )
          isEnabled( FL_USE_COPPER_THICKNESS ) )
    {
    {
        setGLCopperColor();
        setGLCopperColor();


        // Draw vias holes (vertical cylinders)
        // Draw vias holes (vertical cylinders)
        for( const TRACK* track = pcb->m_Track;  track;  track = track->Next() )
        for( const TRACK* track = pcb->m_Track;  track;  track = track->Next() )
        {
        {
            const VIA *via = dynamic_cast<const VIA*>(track);
            if( track->Type() == PCB_VIA_T )

            {
            if( via )
                const VIA *via = static_cast<const VIA*>(track);
                draw3DViaHole( via );
                draw3DViaHole( via );
            }
            }
        }


        // Draw pads holes (vertical cylinders)
        // Draw pads holes (vertical cylinders)
        for( const MODULE* module = pcb->m_Modules;  module;  module = module->Next() )
        for( const MODULE* module = pcb->m_Modules;  module;  module = module->Next() )
+3 −4
Original line number Original line Diff line number Diff line
@@ -245,12 +245,11 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
    gluDeleteTess( tess );
    gluDeleteTess( tess );


    if( aThickness == 0 )
    if( aThickness == 0 )
    {
        return;
        return;
    }


    // Build the 3D data : vertical side
    // Build the 3D data : vertical side
    Draw3D_VerticalPolygonalCylinder( polylist, aThickness, aZpos - (aThickness / 2.0), true, aBiuTo3DUnits );
    Draw3D_VerticalPolygonalCylinder( polylist, aThickness, aZpos - (aThickness / 2.0),
                                      true, aBiuTo3DUnits );
}
}




+8 −7
Original line number Original line Diff line number Diff line
@@ -435,16 +435,15 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
    NETLIST_OBJECT* candidate;
    NETLIST_OBJECT* candidate;


    // Pass 1: find the best name for labelled nets:
    // Pass 1: find the best name for labelled nets:
    item = NULL;
    candidate = NULL;
    candidate = NULL;
    for( unsigned ii = 0; ii <= size(); ii++ )
    for( unsigned ii = 0; ii <= size(); ii++ )
    {
    {
        if( ii == size() ) // last item already found
        if( ii == size() ) // last item already tested
            netcode = -2;
            item = NULL;
        else
        else
            item = GetItem( ii );
            item = GetItem( ii );


        if( netcode != item->GetNet() )     // End of net found
        if( !item || netcode != item->GetNet() )     // End of net found
        {
        {
            if( candidate )         // One or more labels exists, find the best
            if( candidate )         // One or more labels exists, find the best
            {
            {
@@ -452,7 +451,7 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
                    GetItem( jj )->SetNetNameCandidate( candidate );
                    GetItem( jj )->SetNetNameCandidate( candidate );
            }
            }


            if( netcode == -2 )
            if( item == NULL )
                break;
                break;


            netcode = item->GetNet();
            netcode = item->GetNet();
@@ -512,8 +511,10 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
    {
    {
        if( ii < list.size() )
        if( ii < list.size() )
            item = list.GetItem( ii );
            item = list.GetItem( ii );
        else
            item = NULL;


        if( netcode != item->GetNet() || ii >= list.size() )     // End of net found
        if( !item || netcode != item->GetNet() )     // End of net found
        {
        {
            if( candidate )
            if( candidate )
            {
            {
@@ -524,7 +525,7 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
                }
                }
            }
            }


            if( ii >= list.size() )
            if( !item )
                break;
                break;


            netcode = item->GetNet();
            netcode = item->GetNet();
+1 −0
Original line number Original line Diff line number Diff line
@@ -260,6 +260,7 @@ public:
        m_foundIndex = 0;
        m_foundIndex = 0;
        SetForceSearch( false );
        SetForceSearch( false );
        m_sheetPath = NULL;
        m_sheetPath = NULL;
        m_lib_hash = 0;
    }
    }


    void Empty()
    void Empty()
+6 −0
Original line number Original line Diff line number Diff line
@@ -119,6 +119,12 @@ public:
class NETINFO_MAPPING
class NETINFO_MAPPING
{
{
public:
public:
    NETINFO_MAPPING()
    {
        m_board = NULL;
    }


    /**
    /**
     * Function SetBoard
     * Function SetBoard
     * Sets a BOARD object that is used to prepare the net code map.
     * Sets a BOARD object that is used to prepare the net code map.
Loading