Commit 5bfcc884 authored by charras's avatar charras
Browse files

Solved bug in zone filling by polygons: a forgotten conversion to double....

Solved bug in zone filling by polygons: a forgotten conversion to double. using int in calculations creates sometimes overflows and erroneous filling
Add patch to handle oblong pads
parent 062bbfe1
Loading
Loading
Loading
Loading
+89 −29
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ void AddTextBoxWithClearancePolygon( Bool_Engine* aBooleng,
// Local Variables:
/* how many segments are used to create a polygon from a circle: */
static int s_CircleToSegmentsCount = 16;   /* default value. the real value will be changed to 32
if g_Zone_Arc_Approximation == 1
                                             * if g_Zone_Arc_Approximation == 1
                                            */

/** function AddClearanceAreasPolygonsToPolysList
@@ -224,6 +224,64 @@ void AddPadWithClearancePolygon( Bool_Engine* aBooleng,
        break;

    case PAD_OVAL:
        angle = aPad.m_Orient;
        if( dy > dx )                                                   // Oval pad X/Y ratio for chooring translation axles
        {
            int     angle_pg;                                           //Polygon angle
            wxPoint shape_offset = wxPoint( 0, (dy - dx) );
            RotatePoint( &shape_offset, angle );                        //Rotating shape offset vector with component

            for( ii = 0; ii < s_CircleToSegmentsCount / 2 + 1; ii++ )   //Half circle end cap...
            {
                corner_position = wxPoint( dx, 0 );                     //Coordinate translation +dx
                RotatePoint( &corner_position, angle );
                angle_pg = ii * delta;
                RotatePoint( &corner_position, angle_pg );
                corner_position += PadShapePos - shape_offset;
                aBooleng->AddPoint( corner_position.x, corner_position.y );
            }

            for( ii = 0; ii < s_CircleToSegmentsCount / 2 + 1; ii++ )   //Second half circle end cap...
            {
                corner_position = wxPoint( -dx, 0 );                    //Coordinate translation -dx
                RotatePoint( &corner_position, angle );
                angle_pg = ii * delta;
                RotatePoint( &corner_position, angle_pg );
                corner_position += PadShapePos + shape_offset;
                aBooleng->AddPoint( corner_position.x, corner_position.y );
            }

            break;
        }
        else
        {
            int     angle_pg; //Polygon angle
            wxPoint shape_offset = wxPoint( (dy - dx), 0 );
            RotatePoint( &shape_offset, angle );

            for( ii = 0; ii < s_CircleToSegmentsCount / 2 + 1; ii++ )
            {
                corner_position = wxPoint( 0, dy );
                RotatePoint( &corner_position, angle );
                angle_pg = ii * delta;
                RotatePoint( &corner_position, angle_pg );
                corner_position += PadShapePos - shape_offset;
                aBooleng->AddPoint( corner_position.x, corner_position.y );
            }

            for( ii = 0; ii < s_CircleToSegmentsCount / 2 + 1; ii++ )
            {
                corner_position = wxPoint( 0, -dy );
                RotatePoint( &corner_position, angle );
                angle_pg = ii * delta;
                RotatePoint( &corner_position, angle_pg );
                corner_position += PadShapePos + shape_offset;
                aBooleng->AddPoint( corner_position.x, corner_position.y );
            }

            break;
        }

    case PAD_RECT:
        angle = aPad.m_Orient;
        corner_position = wxPoint( -dx, -dy );
@@ -295,6 +353,7 @@ void AddThermalReliefPadPolygon( Bool_Engine* aBooleng,
         * 3 ------ 2
         * holes 2, 3, 4 are the same as hole 1, rotated 90, 180, 270 deg
         */

        // Build the hole pattern, for the hole in the X >0, Y > 0 plane:
        std::vector <int> corners_buffer;

@@ -315,6 +374,7 @@ void AddThermalReliefPadPolygon( Bool_Engine* aBooleng,
            corners_buffer.push_back( corner.y );
            RotatePoint( &corner, delta );
        }

        corners_buffer.push_back( corner_end.x );
        corners_buffer.push_back( corner_end.y );

@@ -491,7 +551,7 @@ void AddRoundedEndsSegmentPolygon( Bool_Engine* aBooleng,
        startp = aEnd;
    }
    int delta_angle = ArcTangente( endp.y, endp.x );    // delta_angle is in 0.1 degrees
    seg_len = (int) sqrt( (endp.y * endp.y) + (endp.x * endp.x) );
    seg_len = (int) sqrt( ((double)endp.y * endp.y) + ((double)endp.x * endp.x) );

    if( !aBooleng->StartPolygonAdd( GROUP_B ) )
        return;                                 // error!