Left some fixes out of previous commit.

This commit is contained in:
Jeff Young 2023-05-29 16:22:06 +01:00
parent 9633c8af22
commit f5791f5dc6
12 changed files with 44 additions and 40 deletions

View File

@ -621,7 +621,7 @@ void VIEW::SetCenter( const VECTOR2D& aCenter, const std::vector<BOX2D>& obscuri
while( !unobscuredPoly.IsEmpty() )
{
unobscuredCenter = unobscuredPoly.BBox().Centre();
unobscuredPoly.Deflate( step, 4 );
unobscuredPoly.Deflate( step, SHAPE_POLY_SET::ALLOW_ACUTE_CORNERS, ARC_LOW_DEF );
}
SetCenter( aCenter - ToWorld( unobscuredCenter - screenRect.Centre(), false ) );

View File

@ -1024,7 +1024,8 @@ public:
* polygons are also polygons with linked holes to main outlines. For \a aFastMode
* meaning, see function booleanOp .
*/
void InflateWithLinkedHoles( int aFactor, int aCircleSegmentsCount, POLYGON_MODE aFastMode );
void InflateWithLinkedHoles( int aFactor, CORNER_STRATEGY aCornerStrategy, int aMaxError,
POLYGON_MODE aFastMode );
/// Convert a set of polygons with holes to a single outline with "slits"/"fractures"
/// connecting the outer ring to the inner holes

View File

@ -892,11 +892,12 @@ void SHAPE_POLY_SET::BooleanIntersection( const SHAPE_POLY_SET& a, const SHAPE_P
}
void SHAPE_POLY_SET::InflateWithLinkedHoles( int aFactor, int aCircleSegmentsCount,
POLYGON_MODE aFastMode )
void SHAPE_POLY_SET::InflateWithLinkedHoles( int aFactor,
SHAPE_POLY_SET::CORNER_STRATEGY aCornerStrategy,
int aMaxError, POLYGON_MODE aFastMode )
{
Unfracture( aFastMode );
Inflate( aFactor, aCircleSegmentsCount );
Inflate( aFactor, aCornerStrategy, aMaxError );
Fracture( aFastMode );
}

View File

@ -127,7 +127,7 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run()
// they will be exactly touching along the entire exclusion border.
SHAPE_POLY_SET areaPoly = ruleArea->Outline()->CloneDropTriangulation();
areaPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
areaPoly.Deflate( epsilon, 0, SHAPE_POLY_SET::ALLOW_ACUTE_CORNERS );
areaPoly.Deflate( epsilon, SHAPE_POLY_SET::ALLOW_ACUTE_CORNERS, ARC_LOW_DEF );
DRC_RTREE* zoneRTree = board->m_CopperZoneRTreeCache[ copperZone ].get();

View File

@ -225,10 +225,10 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::buildRTrees()
solderMask->GetFill( F_Mask )->Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
solderMask->GetFill( B_Mask )->Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
int numSegs = GetArcToSegmentCount( m_webWidth / 2, m_maxError, FULL_CIRCLE );
solderMask->GetFill( F_Mask )->Deflate( m_webWidth / 2, numSegs );
solderMask->GetFill( B_Mask )->Deflate( m_webWidth / 2, numSegs );
solderMask->GetFill( F_Mask )->Deflate( m_webWidth / 2, SHAPE_POLY_SET::CHAMFER_ALL_CORNERS,
m_maxError );
solderMask->GetFill( B_Mask )->Deflate( m_webWidth / 2, SHAPE_POLY_SET::CHAMFER_ALL_CORNERS,
m_maxError );
solderMask->SetFillFlag( F_Mask, true );
solderMask->SetFillFlag( B_Mask, true );

View File

@ -169,7 +169,8 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run()
holeCount += outlineGlyph->HoleCount( ii );
SHAPE_POLY_SET poly = outlineGlyph->CloneDropTriangulation();
poly.Deflate( constraint.Value().Min() / 2, 16 );
poly.Deflate( constraint.Value().Min() / 2,
SHAPE_POLY_SET::CHAMFER_ALL_CORNERS, ARC_LOW_DEF );
poly.Simplify( SHAPE_POLY_SET::PM_FAST );
int resultingOutlineCount = poly.OutlineCount();

View File

@ -513,7 +513,7 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID
try
{
itemPoly.Deflate( step, 4, SHAPE_POLY_SET::CHAMFER_ACUTE_CORNERS );
itemPoly.Deflate( step, SHAPE_POLY_SET::ALLOW_ACUTE_CORNERS, ARC_LOW_DEF );
}
catch( const ClipperLib::clipperException& exc )
{

View File

@ -413,8 +413,8 @@ bool collidesWithArea( BOARD_ITEM* aItem, PCB_EXPR_CONTEXT* aCtx, ZONE* aArea )
// This is particularly important for detecting copper fills as they will be exactly
// touching along the entire exclusion border.
SHAPE_POLY_SET areaOutline = aArea->Outline()->CloneDropTriangulation();
areaOutline.Deflate( board->GetDesignSettings().GetDRCEpsilon(), 0,
SHAPE_POLY_SET::ALLOW_ACUTE_CORNERS );
areaOutline.Deflate( board->GetDesignSettings().GetDRCEpsilon(),
SHAPE_POLY_SET::ALLOW_ACUTE_CORNERS, ARC_LOW_DEF );
if( aItem->GetFlags() & HOLE_PROXY )
{

View File

@ -1507,14 +1507,14 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
if( margin.x < 0 ) // The poly shape must be deflated
{
int numSegs = GetArcToSegmentCount( -margin.x, m_maxError, FULL_CIRCLE );
SHAPE_POLY_SET outline;
outline.NewOutline();
for( int ii = 0; ii < poly->PointCount(); ++ii )
outline.Append( poly->CPoint( ii ) );
outline.Deflate( -margin.x, numSegs );
outline.Deflate( -margin.x, SHAPE_POLY_SET::CHAMFER_ALL_CORNERS,
m_maxError );
m_gal->DrawPolygon( outline );
}

View File

@ -271,6 +271,7 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
const PCB_PLOT_PARAMS& aPlotOpt )
{
BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
int maxError = aBoard->GetDesignSettings().m_MaxError;
itemplotter.SetLayerSet( aLayerMask );
@ -435,9 +436,8 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
// Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate()
// which can create bad shapes if margin.x is < 0
int maxError = aBoard->GetDesignSettings().m_MaxError;
int numSegs = GetArcToSegmentCount( mask_clearance, maxError, FULL_CIRCLE );
outline.InflateWithLinkedHoles( mask_clearance, numSegs,
outline.InflateWithLinkedHoles( mask_clearance,
SHAPE_POLY_SET::ROUND_ALL_CORNERS, maxError,
SHAPE_POLY_SET::PM_FAST );
dummy.DeletePrimitivesList();
dummy.AddPrimitivePoly( outline, 0, true );
@ -483,11 +483,10 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
dummy.SetPosition( VECTOR2I( 0, 0 ) );
dummy.SetOrientation( ANGLE_0 );
SHAPE_POLY_SET outline;
int maxError = aBoard->GetDesignSettings().m_MaxError;
int numSegs = GetArcToSegmentCount( mask_clearance, maxError, FULL_CIRCLE );
dummy.TransformShapeToPolygon( outline, UNDEFINED_LAYER, 0, maxError,
ERROR_INSIDE );
outline.InflateWithLinkedHoles( mask_clearance, numSegs,
outline.InflateWithLinkedHoles( mask_clearance,
SHAPE_POLY_SET::ROUND_ALL_CORNERS, maxError,
SHAPE_POLY_SET::PM_FAST );
// Initialize the dummy pad shape:
@ -518,9 +517,9 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
// Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate()
// which can create bad shapes if margin.x is < 0
int maxError = aBoard->GetDesignSettings().m_MaxError;
int numSegs = GetArcToSegmentCount( mask_clearance, maxError, FULL_CIRCLE );
shape.InflateWithLinkedHoles( mask_clearance, numSegs, SHAPE_POLY_SET::PM_FAST );
shape.InflateWithLinkedHoles( mask_clearance,
SHAPE_POLY_SET::ROUND_ALL_CORNERS, maxError,
SHAPE_POLY_SET::PM_FAST );
dummy.DeletePrimitivesList();
dummy.AddPrimitivePoly( shape, 0, true );
@ -971,12 +970,10 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
}
}
int numSegs = GetArcToSegmentCount( inflate, maxError, FULL_CIRCLE );
// Merge all polygons: After deflating, not merged (not overlapping) polygons will have the
// initial shape (with perhaps small changes due to deflating transform)
areas.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
areas.Deflate( inflate, numSegs );
areas.Deflate( inflate, SHAPE_POLY_SET::CHAMFER_ALL_CORNERS, maxError );
// To avoid a lot of code, use a ZONE to handle and plot polygons, because our polygons look
// exactly like filled areas in zones.

View File

@ -1329,12 +1329,14 @@ void ZONE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer
SHAPE_POLY_SET temp_buf = m_FilledPolysList.at( aLayer )->CloneDropTriangulation();
// Rebuild filled areas only if clearance is not 0
int numSegs = GetArcToSegmentCount( aClearance, aError, FULL_CIRCLE );
if( aClearance > 0 || aErrorLoc == ERROR_OUTSIDE )
{
if( aErrorLoc == ERROR_OUTSIDE )
aClearance += aError;
temp_buf.InflateWithLinkedHoles( aClearance, numSegs, SHAPE_POLY_SET::PM_FAST );
temp_buf.InflateWithLinkedHoles( aClearance, SHAPE_POLY_SET::ROUND_ALL_CORNERS, aError,
SHAPE_POLY_SET::PM_FAST );
}
aBuffer.Append( temp_buf );
}

View File

@ -1938,6 +1938,7 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer
int linethickness = thickness - aZone->GetMinThickness();
int gridsize = thickness + aZone->GetHatchGap();
int maxError = m_board->GetDesignSettings().m_MaxError;
SHAPE_POLY_SET filledPolys = aFillPolys.CloneDropTriangulation();
// Use a area that contains the rotated bbox by orientation, and after rotate the result
@ -1999,7 +2000,7 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer
smooth_value = std::min( smooth_value, aZone->GetHatchGap() / 2 );
// the error to approximate a circle by segments when smoothing corners by a arc
int error_max = std::max( pcbIUScale.mmToIU( 0.01 ), smooth_value / 20 );
maxError = std::max( maxError * 2, smooth_value / 20 );
switch( smooth_level )
{
@ -2011,9 +2012,9 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer
default:
if( aZone->GetHatchSmoothingLevel() > 2 )
error_max /= 2; // Force better smoothing
maxError /= 2; // Force better smoothing
hole_base = smooth_hole.Fillet( smooth_value, error_max ).Outline( 0 );
hole_base = smooth_hole.Fillet( smooth_value, maxError ).Outline( 0 );
break;
case 0:
@ -2062,12 +2063,13 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer
// The fill has already been deflated to ensure GetMinThickness() so we just have to
// account for anything beyond that.
SHAPE_POLY_SET deflatedFilledPolys = aFillPolys.CloneDropTriangulation();
deflatedFilledPolys.Deflate( outline_margin - aZone->GetMinThickness(), 16 );
deflatedFilledPolys.Deflate( outline_margin - aZone->GetMinThickness(),
SHAPE_POLY_SET::CHAMFER_ALL_CORNERS, maxError );
holes.BooleanIntersection( deflatedFilledPolys, SHAPE_POLY_SET::PM_FAST );
DUMP_POLYS_TO_COPPER_LAYER( holes, In11_Cu, wxT( "fill-clipped-hatch-holes" ) );
SHAPE_POLY_SET deflatedOutline = aZone->Outline()->CloneDropTriangulation();
deflatedOutline.Deflate( outline_margin, 16 );
deflatedOutline.Deflate( outline_margin, SHAPE_POLY_SET::CHAMFER_ALL_CORNERS, maxError );
holes.BooleanIntersection( deflatedOutline, SHAPE_POLY_SET::PM_FAST );
DUMP_POLYS_TO_COPPER_LAYER( holes, In12_Cu, wxT( "outline-clipped-hatch-holes" ) );
@ -2094,7 +2096,7 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer
int r = std::max( min_apron_radius,
via->GetDrillValue() / 2 + outline_margin );
TransformCircleToPolygon( aprons, via->GetPosition(), r, ARC_HIGH_DEF,
TransformCircleToPolygon( aprons, via->GetPosition(), r, maxError,
ERROR_OUTSIDE );
}
}
@ -2120,7 +2122,7 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer
outline_margin - min_annular_ring_width );
clearance = std::max( 0, clearance - linethickness / 2 );
pad->TransformShapeToPolygon( aprons, aLayer, clearance, ARC_HIGH_DEF,
pad->TransformShapeToPolygon( aprons, aLayer, clearance, maxError,
ERROR_OUTSIDE );
}
}