Track polygon clearance: use the new TransformOvalClearanceToPolygon function, to avoid underestimation of clearance areas.

(issue already found for oval pads)
Add some comments.
This commit is contained in:
jean-pierre charras 2018-01-21 11:32:37 +01:00
parent 2fd00b1d23
commit 81642dddd1
3 changed files with 16 additions and 10 deletions

View File

@ -74,6 +74,12 @@ void TransformOvalClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
// so, later, we will clamp the polygonal shape with the bounding box // so, later, we will clamp the polygonal shape with the bounding box
// of the segment. // of the segment.
int radius = aWidth / 2; int radius = aWidth / 2;
// Note if we want to compensate the radius reduction of a circle due to
// the segment approx, aCorrectionFactor must be calculated like this:
// For a circle the min radius is radius * cos( 2PI / s_CircleToSegmentsCount / 2)
// aCorrectionFactor is 1 /cos( PI/s_CircleToSegmentsCount )
radius = radius * aCorrectionFactor; // make segments outside the circles radius = radius * aCorrectionFactor; // make segments outside the circles
// end point is the coordinate relative to aStart // end point is the coordinate relative to aStart

View File

@ -510,8 +510,8 @@ void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerB
break; break;
case S_SEGMENT: case S_SEGMENT:
TransformRoundedEndsSegmentToPolygon( aCornerBuffer, m_Start, m_End, TransformOvalClearanceToPolygon( aCornerBuffer, m_Start, m_End, linewidth,
aCircleToSegmentsCount, linewidth ); aCircleToSegmentsCount, aCorrectionFactor );
break; break;
case S_POLYGON: case S_POLYGON:
@ -589,9 +589,9 @@ void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerB
* to the real clearance value (usually near from 1.0) * to the real clearance value (usually near from 1.0)
*/ */
void TRACK::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, void TRACK::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
int aClearanceValue, int aClearanceValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) const double aCorrectionFactor ) const
{ {
switch( Type() ) switch( Type() )
{ {
@ -604,10 +604,10 @@ void TRACK::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
break; break;
default: default:
TransformRoundedEndsSegmentToPolygon( aCornerBuffer, TransformOvalClearanceToPolygon( aCornerBuffer, m_Start, m_End,
m_Start, m_End, m_Width + ( 2 * aClearanceValue),
aCircleToSegmentsCount, aCircleToSegmentsCount,
m_Width + ( 2 * aClearanceValue) ); aCorrectionFactor );
break; break;
} }
} }

View File

@ -282,7 +282,7 @@ void ZONE_FILLER::buildZoneFeatureHoleList( const ZONE_CONTAINER* aZone,
/* calculates the coeff to compensate radius reduction of holes clearance /* calculates the coeff to compensate radius reduction of holes clearance
* due to the segment approx. * due to the segment approx.
* For a circle the min radius is radius * cos( 2PI / s_CircleToSegmentsCount / 2) * For a circle the min radius is radius * cos( 2PI / s_CircleToSegmentsCount / 2)
* s_Correction is 1 /cos( PI/s_CircleToSegmentsCount ) * correctionFactor is 1 /cos( PI/s_CircleToSegmentsCount )
*/ */
correctionFactor = 1.0 / cos( M_PI / (double) segsPerCircle ); correctionFactor = 1.0 / cos( M_PI / (double) segsPerCircle );