55 virtual bool Run()
override;
57 virtual const wxString
GetName()
const override 59 return "hole_clearance";
64 return "Tests hole to hole spacing";
83 VIA* via = static_cast<VIA*>( aItem );
88 PAD* pad = static_cast<PAD*>( aItem );
92 return std::make_shared<SHAPE_CIRCLE>(
VECTOR2I( 0, 0 ), 0 );
100 reportAux(
"Hole-to-hole violations ignored. Tests not run." );
115 reportAux(
"No hole to hole constraints found. Skipping check." );
119 if( !
reportPhase(
_(
"Checking hole to hole clearances..." ) ) )
123 const size_t delta = 50;
148 PAD* pad = static_cast<PAD*>( item );
156 VIA* via = static_cast<VIA*>( item );
172 std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>,
int> checkedPairs;
179 VIA* via = static_cast<VIA*>( track );
198 if( static_cast<void*>( a ) > static_cast<void*>( b ) )
201 if( checkedPairs.count( { a, b } ) )
207 checkedPairs[ { a, b } ] = 1;
220 checkedPairs.clear();
224 for(
PAD* pad : footprint->Pads() )
230 if( pad->GetDrillSize().x && pad->GetDrillSize().x == pad->GetDrillSize().y )
243 if( static_cast<void*>( a ) > static_cast<void*>( b ) )
246 if( checkedPairs.count( { a, b } ) )
252 checkedPairs[ { a, b } ] = 1;
281 if( aHole->
GetCenter() == otherHole->GetCenter() )
285 actual = std::max( 0, actual - aHole->
GetRadius() - otherHole->GetRadius() );
291 if( minClearance >= 0 && actual < minClearance )
295 m_msg.Printf(
_(
"(%s min %s; actual %s)" ),
296 constraint.GetName(),
300 drce->SetErrorMessage( drce->GetErrorText() + wxS(
" " ) +
m_msg );
301 drce->SetItems( aItem, aOther );
302 drce->SetViolatingRule( constraint.GetParentRule() );
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
virtual const wxString GetName() const override
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
virtual std::set< DRC_CONSTRAINT_T > GetConstraintTypes() const override
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULUS > dummy
bool IsErrorLimitExceeded(int error_code)
virtual bool reportProgress(int aCount, int aSize, int aDelta)
class PAD, a pad in a footprint
const VECTOR2I GetCenter() const
virtual void reportRuleStatistics()
void Insert(BOARD_ITEM *aItem, int aWorstClearance=0, int aLayer=UNDEFINED_LAYER)
Function Insert() Inserts an item into the tree.
int GetNumPhases() const override
const wxSize & GetDrillSize() const
bool QueryWorstConstraint(DRC_CONSTRAINT_T aRuleId, DRC_CONSTRAINT &aConstraint)
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
virtual bool reportPhase(const wxString &aStageName)
virtual const wxString GetDescription() const override
FOOTPRINTS & Footprints()
void clear()
Function RemoveAll() Removes all items from the RTree.
virtual wxPoint GetCenter() const
This defaults to the center of the bounding box if not overridden.
static LSET AllLayersMask()
EDA_UNITS userUnits() const
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintId, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
bool testHoleAgainstHole(BOARD_ITEM *aItem, SHAPE_CIRCLE *aHole, BOARD_ITEM *aOther)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, wxPoint aMarkerPos)
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
virtual ~DRC_TEST_PROVIDER_HOLE_CLEARANCE()
const MINOPTMAX< int > & GetValue() const
wxPoint GetPosition() const override
Information pertinent to a Pcbnew printed circuit board.
VIATYPE GetViaType() const
virtual bool Run() override
Runs this provider against the given PCB with configured options (if any).
static std::shared_ptr< SHAPE_CIRCLE > getDrilledHoleShape(BOARD_ITEM *aItem)
class VIA, a via (like a track segment on a copper layer)
DRC_RTREE - Implements an R-tree for fast spatial and layer indexing of connectable items.
DRC_TEST_PROVIDER_HOLE_CLEARANCE()
virtual void reportAux(wxString fmt,...)
KICAD_T Type() const
Returns the type of object.
int QueryColliding(BOARD_ITEM *aRefItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer, std::function< bool(BOARD_ITEM *)> aFilter=nullptr, std::function< bool(BOARD_ITEM *)> aVisitor=nullptr, int aClearance=0) const
This is a fast test which essentially does bounding-box overlap given a worst-case clearance.