54 virtual bool Run()
override;
56 virtual const wxString
GetName()
const override {
return wxT(
"annular_width" ); };
64 REPORT_AUX( wxT(
"Annular width violations ignored. Skipping check." ) );
68 const int progressDelta = 500;
72 REPORT_AUX( wxT(
"No annular width constraints found. Tests not run." ) );
76 if( !
reportPhase(
_(
"Checking pad & via annular rings..." ) ) )
82 switch( item->Type() )
91 if( !
pad->HasHole() ||
pad->GetAttribute() != PAD_ATTRIB::PTH )
96 pad->Padstack().ForEachUniqueLayer(
101 switch(
pad->GetShape( aLayer ) )
103 case PAD_SHAPE::CHAMFERED_RECT:
104 if(
pad->GetChamferRectRatio( aLayer ) > 0.30 )
109 case PAD_SHAPE::CIRCLE:
110 case PAD_SHAPE::OVAL:
111 case PAD_SHAPE::RECTANGLE:
112 case PAD_SHAPE::ROUNDRECT:
132 auto checkPadAnnularWidth =
134 const std::vector<const PAD*>& sameNumPads,
135 int* aMinAnnularWidth,
int* aMaxAnnularWidth )
137 int annularWidth = 0;
138 bool handled =
false;
144 switch(
pad->GetShape( aLayer ) )
146 case PAD_SHAPE::CIRCLE:
147 annularWidth = ( padSize.
x -
pad->GetDrillSizeX() ) / 2;
151 handled = sameNumPads.empty();
155 case PAD_SHAPE::CHAMFERED_RECT:
156 if(
pad->GetChamferRectRatio( aLayer ) > 0.30 )
161 case PAD_SHAPE::OVAL:
162 case PAD_SHAPE::RECTANGLE:
163 case PAD_SHAPE::ROUNDRECT:
164 annularWidth = std::min( padSize.
x -
pad->GetDrillSizeX(),
165 padSize.
y -
pad->GetDrillSizeY() ) / 2;
169 handled = sameNumPads.empty();
181 int maxError =
pad->GetBoard()->GetDesignSettings().m_MaxError;
184 std::shared_ptr<SHAPE_SEGMENT> slot =
pad->GetEffectiveHoleShape();
186 pad->TransformShapeToPolygon( padOutline, aLayer, 0, maxError,
ERROR_INSIDE );
188 if( sameNumPads.empty() )
190 if( !padOutline.
Collide(
pad->GetPosition() ) )
201 annularWidth = sqrt( dist_sq ) - slot->GetWidth() / 2;
204 else if( constraint.Value().HasMin()
205 && ( annularWidth < constraint.Value().Min() ) )
213 for(
const PAD* sameNumPad : sameNumPads )
216 sameNumPad->TransformShapeToPolygon( aggregatePadOutline,
220 sameNumPad->TransformHoleToPolygon( otherPadHoles, 0, maxError,
226 if( !aggregatePadOutline.
Collide(
pad->GetPosition() ) )
234 for(
int ii = 0; ii < aggregatePadOutline.
OutlineCount(); ++ii )
238 annularWidth = sqrt( dist_sq ) - slot->GetWidth() / 2;
243 *aMaxAnnularWidth = std::max( *aMaxAnnularWidth, annularWidth );
244 *aMinAnnularWidth = std::min( *aMinAnnularWidth, annularWidth );
247 auto checkAnnularWidth =
256 int minAnnularWidth = INT_MAX;
257 int maxAnnularWidth = 0;
260 bool fail_min =
false;
261 bool fail_max =
false;
263 switch( item->Type() )
268 int drill =
via->GetDrillValue();
270 via->Padstack().ForEachUniqueLayer(
273 int layerWidth = (
via->GetWidth( aLayer ) - drill ) / 2;
274 minAnnularWidth = std::min( minAnnularWidth, layerWidth );
275 maxAnnularWidth = std::max( maxAnnularWidth, layerWidth );
284 if( !
pad->HasHole() ||
pad->GetAttribute() != PAD_ATTRIB::PTH )
287 std::vector<const PAD*> sameNumPads;
290 sameNumPads = fp->GetPads(
pad->GetNumber(),
pad );
292 pad->Padstack().ForEachUniqueLayer(
295 checkPadAnnularWidth(
pad, aLayer, constraint, sameNumPads,
296 &minAnnularWidth, &maxAnnularWidth );
309 if( constraint.Value().HasMin() )
311 v_min = constraint.Value().Min();
312 fail_min = minAnnularWidth < v_min;
315 if( constraint.Value().HasMax() )
317 v_max = constraint.Value().Max();
318 fail_max = maxAnnularWidth > v_max;
321 if( fail_min || fail_max )
328 msg =
formatMsg(
_(
"(%s min annular width %s; actual %s)" ),
329 constraint.GetName(),
336 msg =
formatMsg(
_(
"(%s max annular width %s; actual %s)" ),
337 constraint.GetName(),
342 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
343 drcItem->SetItems( item );
344 drcItem->SetViolatingRule( constraint.GetParentRule() );
357 total += calcEffort( item );
361 for(
PAD*
pad : footprint->Pads() )
362 total += calcEffort(
pad );
367 ii += calcEffort( item );
372 if( !checkAnnularWidth( item ) )
378 for(
PAD*
pad : footprint->Pads() )
380 ii += calcEffort(
pad );
385 if( !checkAnnularWidth(
pad ) )
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
bool HasRulesForConstraintType(DRC_CONSTRAINT_T constraintID)
bool IsErrorLimitExceeded(int error_code)
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
DRC_TEST_PROVIDER_ANNULAR_WIDTH()
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
virtual ~DRC_TEST_PROVIDER_ANNULAR_WIDTH()=default
virtual const wxString GetName() const override
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out DRC_ITEM and posi...
virtual bool reportPhase(const wxString &aStageName)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer, DRC_CUSTOM_MARKER_HANDLER *aCustomHandler=nullptr)
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, double aConstraint, double aActual, EDA_DATA_TYPE aDataType=EDA_DATA_TYPE::DISTANCE)
virtual bool reportProgress(size_t aCount, size_t aSize, size_t aDelta=1)
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
VECTOR2I::extended_type ecoord
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
Represent a set of closed polygons.
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
SEG::ecoord SquaredDistanceToSeg(const SEG &aSegment, VECTOR2I *aNearest=nullptr) const
Compute the minimum distance squared between aSegment and all the polygons in the set.
int OutlineCount() const
Return the number of outlines in the set.
void TransformToPolygon(SHAPE_POLY_SET &aBuffer, int aError, ERROR_LOC aErrorLoc) const override
Fills a SHAPE_POLY_SET with a polygon representation of this shape.
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
@ ANNULAR_WIDTH_CONSTRAINT
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_PAD_T
class PAD, a pad in a footprint
VECTOR2< int32_t > VECTOR2I