56 virtual bool Run()
override;
58 virtual const wxString
GetName()
const override
60 return wxT(
"edge_clearance" );
65 return wxT(
"Tests items vs board edge clearance" );
83 std::shared_ptr<SHAPE> shape;
97 if( itemShape->
Collide( shape.get(), minClearance, &actual, &pos ) )
100 if( minClearance > 0 && actual == minClearance )
108 if( castellatedPad->GetEffectiveHoleShape()->Collide( pos ) )
116 if( minClearance > 0 )
118 wxString msg =
formatMsg(
_(
"(%s clearance %s; actual %s)" ),
119 constraint.GetName(),
123 drce->SetErrorMessage( drce->GetErrorText() + wxS(
" " ) + msg );
127 drce->SetViolatingRule( constraint.GetParentRule() );
150 if( !
reportPhase(
_(
"Checking copper to board edge clearances..." ) ) )
155 if( !
reportPhase(
_(
"Checking silk to board edge clearances..." ) ) )
160 reportAux( wxT(
"Edge clearance violations ignored. Tests not run." ) );
177 std::vector<std::unique_ptr<PCB_SHAPE>> edges;
194 edges.back()->SetShape( SHAPE_T::SEGMENT );
195 edges.back()->SetEndX( shape->
GetStartX() );
196 edges.back()->SetStroke( stroke );
197 edges.back()->SetParentGroup(
nullptr );
199 edges.back()->SetShape( SHAPE_T::SEGMENT );
200 edges.back()->SetEndY( shape->
GetStartY() );
201 edges.back()->SetStroke( stroke );
202 edges.back()->SetParentGroup(
nullptr );
204 edges.back()->SetShape( SHAPE_T::SEGMENT );
205 edges.back()->SetStartX( shape->
GetEndX() );
206 edges.back()->SetStroke( stroke );
207 edges.back()->SetParentGroup(
nullptr );
209 edges.back()->SetShape( SHAPE_T::SEGMENT );
210 edges.back()->SetStartY( shape->
GetEndY() );
211 edges.back()->SetStroke( stroke );
212 edges.back()->SetParentGroup(
nullptr );
224 edges.back()->SetShape( SHAPE_T::SEGMENT );
225 edges.back()->SetStart( seg.
A );
226 edges.back()->SetEnd( seg.
B );
227 edges.back()->SetStroke( stroke );
228 edges.back()->SetParentGroup(
nullptr );
234 edges.back()->SetStroke( stroke );
235 edges.back()->SetParentGroup(
nullptr );
241 for(
const std::unique_ptr<PCB_SHAPE>& edge : edges )
245 if( edge->IsOnLayer( layer ) )
252 for(
PAD*
pad : footprint->Pads() )
254 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH &&
pad->HasHole() )
258 if(
pad->GetDrillSizeX() !=
pad->GetDrillSizeY() )
262 if(
pad->GetProperty() == PAD_PROP::CASTELLATED )
270 const int progressDelta = 200;
287 if( !testCopper && !testSilk )
298 PAD* pad = static_cast<PAD*>( item );
300 if( pad->GetProperty() == PAD_PROP::CASTELLATED
301 || pad->GetAttribute() == PAD_ATTRIB::CONN )
307 std::vector<PCB_LAYER_ID> layersToTest;
309 switch( item->
Type() )
312 layersToTest = static_cast<PAD*>( item )->Padstack().UniqueLayers();
316 layersToTest = static_cast<PCB_VIA*>( item )->Padstack().UniqueLayers();
320 layersToTest = { UNDEFINED_LAYER };
325 const std::shared_ptr<SHAPE>& itemShape = item->GetEffectiveShape( shapeLayer );
329 if( testCopper && item->IsOnCopperLayer() )
331 edgesTree.QueryColliding( item, shapeLayer, testLayer, nullptr,
332 [&]( BOARD_ITEM* edge ) -> bool
334 return testAgainstEdge( item, itemShape.get(), edge,
335 EDGE_CLEARANCE_CONSTRAINT,
336 DRCE_EDGE_CLEARANCE );
338 m_largestEdgeClearance );
341 if( testSilk && ( item->IsOnLayer(
F_SilkS ) || item->IsOnLayer(
B_SilkS ) ) )
343 if( edgesTree.QueryColliding( item, shapeLayer, testLayer,
nullptr,
346 return testAgainstEdge( item, itemShape.get(), edge,
347 SILK_CLEARANCE_CONSTRAINT,
348 DRCE_SILK_EDGE_CLEARANCE );
350 m_largestEdgeClearance ) )
365 reportRuleStatistics();
367 return !m_drcEngine->IsCancelled();
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
const FOOTPRINTS & Footprints() const
const MINOPTMAX< int > & GetValue() const
bool GetReportAllTrackErrors() const
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)
bool QueryWorstConstraint(DRC_CONSTRAINT_T aRuleId, DRC_CONSTRAINT &aConstraint)
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Implement an R-tree for fast spatial and layer indexing of connectable items.
void Insert(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer, int aWorstClearance=0)
Insert an item into the tree on a particular layer with an optional worst clearance.
DRC_TEST_PROVIDER_EDGE_CLEARANCE()
virtual const wxString GetDescription() const override
int m_largestEdgeClearance
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
virtual ~DRC_TEST_PROVIDER_EDGE_CLEARANCE()
virtual const wxString GetName() const override
std::vector< PAD * > m_castellatedPads
bool testAgainstEdge(BOARD_ITEM *item, SHAPE *itemShape, BOARD_ITEM *other, DRC_CONSTRAINT_T aConstraintType, PCB_DRC_CODE aErrorCode)
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, double aConstraint, double aActual)
static std::vector< KICAD_T > s_allBasicItemsButZones
virtual bool reportPhase(const wxString &aStageName)
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
bool isInvisibleText(const BOARD_ITEM *aItem) const
void reportAux(const wxString &aMsg)
virtual bool reportProgress(size_t aCount, size_t aSize, size_t aDelta=1)
KICAD_T Type() const
Returns the type of object.
SHAPE_POLY_SET & GetPolyShape()
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
STROKE_PARAMS GetStroke() const override
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual size_t GetSegmentCount() const override
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
An abstract shape on 2D plane.
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
@ DRCE_SILK_EDGE_CLEARANCE
@ EDGE_CLEARANCE_CONSTRAINT
PCB_LAYER_ID
A quick note on layer IDs:
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)