64 virtual bool Run()
override;
66 virtual const wxString
GetName()
const override {
return wxT(
"edge_clearance" ); }
99 disposition = elem_disposition;
101 else if( disposition != elem_disposition )
121 for(
int outlineIdx = 1; outlineIdx < aBoardOutline.
OutlineCount(); ++outlineIdx )
126 nearestEdgePt = otherEdgePt;
131 if( edge->HitTest( nearestEdgePt,
m_epsilon ) )
142 int minClearance = constraint.GetValue().Min();
149 if( minClearance > 0 )
151 drcItem->SetErrorDetail(
formatMsg(
_(
"(%s clearance %s; actual %s)" ),
152 constraint.GetName(),
157 drcItem->SetItems( nearestEdge->
m_Uuid, aItem->
m_Uuid );
158 drcItem->SetViolatingRule( constraint.GetParentRule() );
167 drcItem->SetErrorMessage(
_(
"Silkscreen outside board edge" ) );
169 drcItem->SetItems( aItem->
m_Uuid );
180 std::shared_ptr<SHAPE> shape;
188 int minClearance = constraint.GetValue().Min();
194 if( itemShape->
Collide( shape.get(), minClearance, &
actual, &pos ) )
197 if( minClearance > 0 &&
actual == minClearance )
205 if( castellatedPad->GetEffectiveHoleShape()->Collide( pos ) )
213 if( minClearance > 0 )
215 drcItem->SetErrorDetail(
formatMsg(
_(
"(%s clearance %s; actual %s)" ),
216 constraint.GetName(),
222 drcItem->SetViolatingRule( constraint.GetParentRule() );
243 if( !
reportPhase(
_(
"Checking copper to board edge clearances..." ) ) )
248 if( !
reportPhase(
_(
"Checking silk to board edge clearances..." ) ) )
253 REPORT_AUX( wxT(
"Edge clearance violations ignored. Tests not run." ) );
271 std::vector<std::unique_ptr<PCB_SHAPE>> edges;
293 edges.back()->SetStart( seg->GetStart() );
294 edges.back()->SetEnd( seg->GetEnd() );
295 edges.back()->SetStroke( stroke );
302 edges.back()->SetEndX( shape->
GetStartX() );
303 edges.back()->SetStroke( stroke );
306 edges.back()->SetEndY( shape->
GetStartY() );
307 edges.back()->SetStroke( stroke );
310 edges.back()->SetStartX( shape->
GetEndX() );
311 edges.back()->SetStroke( stroke );
314 edges.back()->SetStartY( shape->
GetEndY() );
315 edges.back()->SetStroke( stroke );
328 edges.back()->SetStart( seg.
A );
329 edges.back()->SetEnd( seg.
B );
330 edges.back()->SetStroke( stroke );
336 edges.back()->SetStroke( stroke );
342 for(
const std::unique_ptr<PCB_SHAPE>& edge : edges )
346 if( edge->IsOnLayer( layer ) )
353 for(
PAD*
pad : footprint->Pads() )
359 if(
pad->GetDrillSizeX() !=
pad->GetDrillSizeY() )
371 const int progressDelta = 200;
388 if( !testCopper && !testSilk )
405 std::vector<PCB_LAYER_ID> layersToTest;
407 switch( item->
Type() )
410 layersToTest =
static_cast<PAD*
>( item )->Padstack().UniqueLayers();
414 layersToTest =
static_cast<PCB_VIA*
>( item )->Padstack().UniqueLayers();
429 m_edgesTree.QueryColliding( item, shapeLayer, testLayer,
nullptr,
441 m_edgesTree.QueryColliding( item, shapeLayer, testLayer,
nullptr,
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual VECTOR2I GetCenter() const
This defaults to the center of the bounding box if not overridden.
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 bool IsOnCopperLayer() const
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
const MINOPTMAX< int > & GetValue() const
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.
DRC_TEST_PROVIDER_EDGE_CLEARANCE()
int m_largestEdgeClearance
void resolveSilkDisposition(BOARD_ITEM *aItem, const SHAPE *aItemShape, const SHAPE_POLY_SET &aBoardOutline)
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
virtual ~DRC_TEST_PROVIDER_EDGE_CLEARANCE()=default
std::map< BOARD_ITEM *, SILK_DISPOSITION > m_silkDisposition
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)
static std::vector< KICAD_T > s_allBasicItemsButZones
virtual bool reportPhase(const wxString &aStageName)
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, const LSET &aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
void reportTwoItemGeometry(std::shared_ptr< DRC_ITEM > &aDrcItem, const VECTOR2I &aMarkerPos, const BOARD_ITEM *aItem1, const BOARD_ITEM *aItem2, PCB_LAYER_ID aLayer, int aDistance)
void reportTwoPointGeometry(std::shared_ptr< DRC_ITEM > &aDrcItem, const VECTOR2I &aMarkerPos, const VECTOR2I &ptA, const VECTOR2I &ptB, PCB_LAYER_ID aLayer)
bool isInvisibleText(const BOARD_ITEM *aItem) const
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)
KICAD_T Type() const
Returns the type of object.
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
SHAPE_POLY_SET & GetPolyShape()
int GetCornerRadius() const
LSET is a set of PCB_LAYER_IDs.
static const 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.
SHAPE_TYPE Type() const
Return the type of the shape.
const std::vector< SHAPE * > & Shapes() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
virtual size_t GetSegmentCount() const override
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
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,...
virtual VECTOR2I Centre() const
Compute a center-of-mass of the shape.
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
constexpr extended_type SquaredDistance(const VECTOR2< T > &aVector) const
Compute the squared distance between two vectors.
@ DRCE_SILK_EDGE_CLEARANCE
@ SILK_CLEARANCE_CONSTRAINT
@ EDGE_CLEARANCE_CONSTRAINT
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
PCB_LAYER_ID
A quick note on layer IDs:
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ CONN
Like smd, does not appear on the solder paste layer (default) Note: also has a special attribute in G...
@ CASTELLATED
a pad with a castellated through hole
@ SH_COMPOUND
compound shape, consisting of multiple simple shapes
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ 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
@ 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)
VECTOR2< int32_t > VECTOR2I