Work around a round-off bug in Clipper.

Fixes https://gitlab.com/kicad/code/kicad/issues/6260
This commit is contained in:
Jeff Young 2020-11-02 17:42:47 +00:00
parent ae9afdd169
commit 55c25f3cc4
3 changed files with 11 additions and 1 deletions

View File

@ -604,6 +604,10 @@ void SHAPE_POLY_SET::Inflate( int aAmount, int aCircleSegmentsCount,
if( aCircleSegmentsCount < 6 ) // avoid incorrect aCircleSegmentsCount values
aCircleSegmentsCount = 6;
// Clipper has a bug where round-off error is accumulated into the last segment. Increasing
// the segment count by one probably accounts for this, but we increment by 2 to be safe.
aCircleSegmentsCount += 2;
double coeff;
if( aCircleSegmentsCount > SEG_CNT_MAX || arc_tolerance_factor[aCircleSegmentsCount] == 0 )

View File

@ -627,7 +627,11 @@ void D_PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
{
int numSegs = std::max( GetArcToSegmentCount( aClearanceValue, aError, 360.0 ),
pad_min_seg_per_circle_count );
int clearance = aClearanceValue + GetCircleToPolyCorrection( aError );
int clearance = aClearanceValue;
if( aErrorLoc == ERROR_OUTSIDE )
clearance += GetCircleToPolyCorrection( aError );
outline.Inflate( clearance, numSegs );
}

View File

@ -753,6 +753,8 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA
else
gap = evalRulesForItems( CLEARANCE_CONSTRAINT, aZone, aPad, aLayer );
gap += extra_margin;
addKnockout( aPad, aLayer, gap, aHoles );
}
};