61 int aClearance,
int* aDistance =
nullptr,
VECTOR2I* aPt1 =
nullptr )
67 int dist = std::numeric_limits<int>::max();
100 int* aDistance =
nullptr,
VECTOR2I* aPt1 =
nullptr )
104 int tmp = std::numeric_limits<int>::max();
125 for(
int j = 0; j < aLhs.
HoleCount( i ); i++ )
127 if(
collide( aLhs.
CHole( i, j ), aRhs, aClearance, &tmp, &pt1 ) )
160 virtual bool Run()
override;
162 virtual const wxString
GetName()
const override
164 return wxT(
"annular_width" );
169 return wxT(
"Tests pad/via annular rings" );
178 reportAux( wxT(
"Annular width violations ignored. Skipping check." ) );
182 const int progressDelta = 500;
186 reportAux( wxT(
"No annular width constraints found. Tests not run." ) );
190 if( !
reportPhase(
_(
"Checking pad & via annular rings..." ) ) )
198 switch( item->Type() )
208 if( !
pad->HasHole() ||
pad->GetAttribute() != PAD_ATTRIB::PTH )
215 case PAD_SHAPE::CHAMFERED_RECT:
221 case PAD_SHAPE::CIRCLE:
222 case PAD_SHAPE::OVAL:
223 case PAD_SHAPE::RECTANGLE:
224 case PAD_SHAPE::ROUNDRECT:
240 auto checkAnnularWidth =
250 int annularWidth = 0;
253 bool fail_min =
false;
254 bool fail_max =
false;
257 switch( item->Type() )
270 bool handled =
false;
272 if( !
pad->HasHole() ||
pad->GetAttribute() != PAD_ATTRIB::PTH )
275 std::vector<const PAD*> sameNumPads;
286 case PAD_SHAPE::CIRCLE:
287 annularWidth = (
pad->GetSizeX() -
pad->GetDrillSizeX() ) / 2;
291 if( sameNumPads.empty() )
296 case PAD_SHAPE::CHAMFERED_RECT:
302 case PAD_SHAPE::OVAL:
303 case PAD_SHAPE::RECTANGLE:
304 case PAD_SHAPE::ROUNDRECT:
305 annularWidth = std::min(
pad->GetSizeX() -
pad->GetDrillSizeX(),
306 pad->GetSizeY() -
pad->GetDrillSizeY() ) / 2;
310 if( sameNumPads.empty() )
325 std::shared_ptr<SHAPE_SEGMENT> slot =
pad->GetEffectiveHoleShape();
331 if( sameNumPads.empty() )
333 if( !padOutline.
Collide(
pad->GetPosition() ) )
344 annularWidth = sqrt( dist_sq ) - slot->GetWidth() / 2;
347 else if( constraint.Value().HasMin()
348 && ( annularWidth < constraint.Value().Min() ) )
355 for(
const PAD* sameNumPad : sameNumPads )
358 sameNumPad->TransformShapeToPolygon( otherPadOutline,
362 sameNumPad->TransformHoleToPolygon( otherPadOutline, 0, maxError,
368 bool intersects =
false;
370 for(
int i = 0; i < otherPadOutline.
OutlineCount() && !intersects; i++ )
376 for(
int j = 0; j < otherPadOutline.
HoleCount( i ) && !intersects; j++ )
389 int effectiveWidth = std::numeric_limits<int>::max();
392 effectiveWidth, &effectiveWidth ) )
394 if( effectiveWidth > annularWidth )
395 annularWidth = effectiveWidth;
411 if( constraint.Value().HasMin() )
413 v_min = constraint.Value().Min();
414 fail_min = annularWidth < v_min;
417 if( constraint.Value().HasMax() )
419 v_max = constraint.Value().Max();
420 fail_max = annularWidth > v_max;
423 if( fail_min || fail_max )
430 msg =
formatMsg(
_(
"(%s min annular width %s; actual %s)" ),
431 constraint.GetName(),
438 msg =
formatMsg(
_(
"(%s max annular width %s; actual %s)" ),
439 constraint.GetName(),
444 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
445 drcItem->SetItems( item );
446 drcItem->SetViolatingRule( constraint.GetParentRule() );
459 total += calcEffort( item );
463 for(
PAD*
pad : footprint->Pads() )
464 total += calcEffort(
pad );
469 ii += calcEffort( item );
474 if( !checkAnnularWidth( item ) )
480 for(
PAD*
pad : footprint->Pads() )
482 ii += calcEffort(
pad );
487 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
BOARD_DESIGN_SETTINGS & GetDesignSettings() 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()
virtual const wxString GetDescription() const override
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...
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, double aConstraint, double aActual)
virtual bool reportPhase(const wxString &aStageName)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
void reportAux(const wxString &aMsg)
virtual void reportRuleStatistics()
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
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
bool Intersects(const SHAPE_LINE_CHAIN &aChain) const
int PointCount() const
Return the number of points (vertices) in this line chain.
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if point aP lies closer to us than aClearance.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
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,...
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
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.
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
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.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
@ ANNULAR_WIDTH_CONSTRAINT
static bool collide(const SHAPE_LINE_CHAIN &aLhs, const SHAPE_LINE_CHAIN &aRhs, int aClearance, int *aDistance=nullptr, VECTOR2I *aPt1=nullptr)
Find the nearest collision point between two shape line chains.
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