Get rid of an extraneous layer parameter.

Also adds a bit of nullptr safety.
This commit is contained in:
Jeff Young 2021-08-23 12:29:38 +01:00
parent 6f5e602df9
commit fec34e8dd8
9 changed files with 23 additions and 22 deletions

View File

@ -652,7 +652,7 @@ void PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
case PAD_SHAPE::CUSTOM:
{
SHAPE_POLY_SET outline;
MergePrimitivesAsPolygon( &outline, aLayer, aErrorLoc );
MergePrimitivesAsPolygon( &outline, aErrorLoc );
outline.Rotate( -DECIDEG2RAD( m_orient ) );
outline.Move( VECTOR2I( m_pos ) );

View File

@ -1400,7 +1400,7 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK()
if( m_dummyPad->GetShape() == PAD_SHAPE::CUSTOM )
{
SHAPE_POLY_SET mergedPolygon;
m_dummyPad->MergePrimitivesAsPolygon( &mergedPolygon, UNDEFINED_LAYER );
m_dummyPad->MergePrimitivesAsPolygon( &mergedPolygon );
if( mergedPolygon.OutlineCount() > 1 )
error_msgs.Add( _( "Error: Custom pad shape must resolve to a single polygon." ) );

View File

@ -404,7 +404,7 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aItem
int actual;
VECTOR2I pos;
if( testClearance )
if( zoneTree && testClearance )
{
constraint = m_drcEngine->EvalRules( CLEARANCE_CONSTRAINT, aItem, zone, aLayer );
clearance = constraint.GetValue().Min();

View File

@ -609,7 +609,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
fprintf( aFile, " POLYGON %g\n", pad->GetDrillSize().x / SCALE_FACTOR );
SHAPE_POLY_SET outline;
pad->MergePrimitivesAsPolygon( &outline, UNDEFINED_LAYER );
pad->MergePrimitivesAsPolygon( &outline );
for( int jj = 0; jj < outline.OutlineCount(); ++jj )
{

View File

@ -278,13 +278,12 @@ public:
* @note The results are relative to the pad position, orientation 0.
*
* @param aMergedPolygon will store the final polygon
* @param aLayer is the layer to take in account, as the exact shape can depend on the layer
* @param aErrorLoc is used when a circle (or arc) is approximated by segments
* = ERROR_INSIDE to build a polygon inside the arc/circle (usual shape to raw/plot)
* = ERROR_OUIDE to build a polygon outside the arc/circle
* (for instance when building a clearance area)
*/
void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer,
void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon,
ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
/**
@ -667,8 +666,8 @@ public:
private:
void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer,
int aError, ERROR_LOC aErrorLoc ) const;
void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError,
ERROR_LOC aErrorLoc ) const;
private:
wxString m_name; // Pad name (pin number in schematic)
@ -677,7 +676,7 @@ private:
wxPoint m_pos; // Pad Position on board
PAD_SHAPE m_padShape; // Shape: PAD_SHAPE::CIRCLE, PAD_SHAPE::RECT,
PAD_SHAPE m_padShape; // Shape: PAD_SHAPE::CIRCLE, PAD_SHAPE::RECT,
// PAD_SHAPE::OVAL, PAD_SHAPE::TRAPEZOID,
// PAD_SHAPE::ROUNDRECT, PAD_SHAPE_POLYGON
/*
@ -719,8 +718,8 @@ private:
// size, default 0.25
int m_chamferPositions; // The positions of the chamfers (at orient 0)
PAD_SHAPE m_anchorPadShape; // For custom shaped pads: shape of pad anchor,
// PAD_SHAPE::RECT, PAD_SHAPE::CIRCLE
PAD_SHAPE m_anchorPadShape; // For custom shaped pads: shape of pad anchor,
// PAD_SHAPE::RECT, PAD_SHAPE::CIRCLE
/*
* Most of the time the hole is the center of the shape (m_Offset = 0). But some designers
@ -743,7 +742,7 @@ private:
PAD_ATTRIB m_attribute; // PAD_ATTRIB_NORMAL, PAD_ATTRIB::SMD, PAD_ATTRIB::CONN,
// PAD_ATTRIB::NPTH
PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
double m_orient; // in 1/10 degrees

View File

@ -185,13 +185,16 @@ void PAD::DeletePrimitivesList()
}
void PAD::addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer,
int aError, ERROR_LOC aErrorLoc ) const
void PAD::addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError,
ERROR_LOC aErrorLoc ) const
{
SHAPE_POLY_SET polyset;
for( const std::shared_ptr<PCB_SHAPE>& primitive : m_editPrimitives )
primitive->TransformShapeWithClearanceToPolygon( polyset, aLayer, 0, aError, aErrorLoc );
{
primitive->TransformShapeWithClearanceToPolygon( polyset, UNDEFINED_LAYER, 0, aError,
aErrorLoc );
}
polyset.Simplify( SHAPE_POLY_SET::PM_FAST );
@ -203,8 +206,7 @@ void PAD::addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_I
}
}
void PAD::MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer,
ERROR_LOC aErrorLoc ) const
void PAD::MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, ERROR_LOC aErrorLoc ) const
{
const BOARD* board = GetBoard();
int maxError = board ? board->GetDesignSettings().m_MaxError : ARC_HIGH_DEF;
@ -229,14 +231,14 @@ void PAD::MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID
break;
}
addPadPrimitivesToPolygon( aMergedPolygon, aLayer, maxError, aErrorLoc );
addPadPrimitivesToPolygon( aMergedPolygon, maxError, aErrorLoc );
}
bool PAD::GetBestAnchorPosition( VECTOR2I& aPos )
{
SHAPE_POLY_SET poly;
addPadPrimitivesToPolygon( &poly, UNDEFINED_LAYER, ARC_LOW_DEF, ERROR_INSIDE );
addPadPrimitivesToPolygon( &poly, ARC_LOW_DEF, ERROR_INSIDE );
if( poly.OutlineCount() > 1 )
return false;

View File

@ -449,7 +449,7 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
// so build a similar pad shape, and inflate/deflate the polygonal shape
PAD dummy( *pad );
SHAPE_POLY_SET shape;
pad->MergePrimitivesAsPolygon( &shape, UNDEFINED_LAYER );
pad->MergePrimitivesAsPolygon( &shape );
// Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate()
// which can create bad shapes if margin.x is < 0

View File

@ -2340,7 +2340,7 @@ bool FABMASTER::loadFootprints( BOARD* aBoard )
}
SHAPE_POLY_SET mergedPolygon;
newpad->MergePrimitivesAsPolygon( &mergedPolygon, UNDEFINED_LAYER );
newpad->MergePrimitivesAsPolygon( &mergedPolygon );
if( mergedPolygon.OutlineCount() > 1 )
{

View File

@ -551,7 +551,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, PAD* aPad )
{
std::vector<wxPoint> polygonal_shape;
SHAPE_POLY_SET pad_shape;
aPad->MergePrimitivesAsPolygon( &pad_shape, UNDEFINED_LAYER );
aPad->MergePrimitivesAsPolygon( &pad_shape );
#ifdef EXPORT_CUSTOM_PADS_CONVEX_HULL
BuildConvexHull( polygonal_shape, pad_shape );