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
This commit is contained in:
charras 2008-10-13 18:39:38 +00:00
parent 062bbfe1c3
commit 5bfcc88433
1 changed files with 89 additions and 29 deletions

View File

@ -34,7 +34,7 @@ void AddTextBoxWithClearancePolygon( Bool_Engine* aBooleng,
// Local Variables: // Local Variables:
/* how many segments are used to create a polygon from a circle: */ /* 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 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 /** function AddClearanceAreasPolygonsToPolysList
@ -224,6 +224,64 @@ void AddPadWithClearancePolygon( Bool_Engine* aBooleng,
break; break;
case PAD_OVAL: 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: case PAD_RECT:
angle = aPad.m_Orient; angle = aPad.m_Orient;
corner_position = wxPoint( -dx, -dy ); corner_position = wxPoint( -dx, -dy );
@ -295,6 +353,7 @@ void AddThermalReliefPadPolygon( Bool_Engine* aBooleng,
* 3 ------ 2 * 3 ------ 2
* holes 2, 3, 4 are the same as hole 1, rotated 90, 180, 270 deg * 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: // Build the hole pattern, for the hole in the X >0, Y > 0 plane:
std::vector <int> corners_buffer; std::vector <int> corners_buffer;
@ -315,6 +374,7 @@ void AddThermalReliefPadPolygon( Bool_Engine* aBooleng,
corners_buffer.push_back( corner.y ); corners_buffer.push_back( corner.y );
RotatePoint( &corner, delta ); RotatePoint( &corner, delta );
} }
corners_buffer.push_back( corner_end.x ); corners_buffer.push_back( corner_end.x );
corners_buffer.push_back( corner_end.y ); corners_buffer.push_back( corner_end.y );
@ -491,7 +551,7 @@ void AddRoundedEndsSegmentPolygon( Bool_Engine* aBooleng,
startp = aEnd; startp = aEnd;
} }
int delta_angle = ArcTangente( endp.y, endp.x ); // delta_angle is in 0.1 degrees 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 ) ) if( !aBooleng->StartPolygonAdd( GROUP_B ) )
return; // error! return; // error!