59 m_bridgeRule.m_Name =
_(
"board setup solder mask min width" );
64 virtual bool Run()
override;
66 virtual const wxString
GetName()
const override {
return wxT(
"solder_mask_issues" ); };
138 ZONE* zone =
static_cast<ZONE*
>( aItem );
147 clearance +=
static_cast<PAD*
>( aItem )->GetSolderMaskExpansion( layer );
175 const size_t progressDelta = 500;
233 const size_t progressDelta = 250;
264 item,
nullptr, maskLayer );
281 drce->SetErrorDetail(
formatMsg(
_(
"(%s clearance %s; actual %s)" ),
287 drce->SetItems( item );
336 return maskLayers.count() > 0 && copperLayers.count() == 0;
360 int encounteredItemNet = -1;
375 alreadyEncounteredItem = ii->second.first;
376 encounteredItemNet = ii->second.second;
383 if( encounteredItemNet == aTestNet && aTestNet >= 0 )
397 padA =
static_cast<PAD*
>( alreadyEncounteredItem );
400 padB =
static_cast<PAD*
>( aTestItem );
408 if( padToNetTieGroupMap.contains( padA->
GetNumber() ) )
413 if( padToNetTieGroupMap.contains( padB->
GetNumber() ) )
418 *aCollidingItem = alreadyEncounteredItem;
428 if( fp->AllowSolderMaskBridges() )
435 std::map<wxString, int> padNumberToGroupIdxMap = fp->MapPadNumbersToNetTieGroups();
436 int groupIdx = padNumberToGroupIdxMap[
pad->GetNumber() ];
443 if(
pad->GetNetCode() == aTestNet )
446 for(
PAD* other : fp->GetNetTiePads(
pad ) )
448 if( other->GetNetCode() == aTestNet )
467 std::optional<DRC_CONSTRAINT> itemConstraint;
475 m_itemTree->QueryColliding( aItem, aRefLayer, aTargetLayer,
486 if( otherNet > 0 && otherNet == itemNet )
497 if( board->GetDesignSettings().m_AllowSoldermaskBridgesInFPs )
506 if(
pad && otherPad && (
pad->SameLogicalPadAs( otherPad )
507 ||
pad->SharesNetTieGroup( otherPad ) ) )
516 if( otherNet < 0 || nets.count( otherNet ) )
522 const std::set<int>& nets = otherFP->GetNetTieCache( other );
524 if( itemNet < 0 || nets.count( itemNet ) )
532 if(
static_cast<void*
>( a ) >
static_cast<void*
>( b ) )
539 if( it !=
m_checkedPairs.end() && it->second.test( aTargetLayer ) )
579 else if(
via && !
via->IsTented( aRefLayer ) )
586 else if( otherVia && !otherVia->
IsTented( aTargetLayer ) )
588 else if( otherShape )
591 if( itemShape->Collide( otherItemShape.get(),
clearance, &
actual, &pos ) )
593 if( !itemConstraint.has_value() )
604 || ( itemConstraintIgnored && otherConstraintIgnored ) )
612 if( aTargetLayer ==
F_Mask )
613 msg =
_(
"Front solder mask aperture bridges items with different nets" );
615 msg =
_(
"Rear solder mask aperture bridges items with different nets" );
646 drce->SetErrorMessage( msg );
647 drce->SetItems( aItem, other );
677 if( zoneNet == connectedItem->
GetNetCode() && zoneNet > 0 )
681 BOX2I inflatedBBox( aItemBBox );
685 clearance +=
pad->GetSolderMaskExpansion( aTargetLayer );
686 else if(
via && !
via->IsTented( aTargetLayer ) )
708 if( aMaskLayer ==
F_Mask )
709 msg =
_(
"Front solder mask aperture bridges items with different nets" );
711 msg =
_(
"Rear solder mask aperture bridges items with different nets" );
721 drce->SetErrorMessage( msg );
722 drce->SetItems( aItem, colliding, zone );
731 drce->SetErrorMessage( msg );
732 drce->SetItems( aItem, zone );
747 std::atomic<int> count = 0;
748 std::vector<BOARD_ITEM*> test_items;
753 test_items.push_back( item );
759 auto returns =
tp.submit_loop( 0, test_items.size(),
760 [&](
size_t i ) ->
bool
762 BOARD_ITEM* item = test_items[ i ];
764 if( m_drcEngine->IsErrorLimitExceeded( DRCE_SOLDERMASK_BRIDGE ) )
767 BOX2I itemBBox = item->GetBoundingBox();
769 if( item->IsOnLayer( F_Mask ) && !isNullAperture( item ) )
772 testItemAgainstItems( item, itemBBox, F_Mask, F_Mask );
775 testMaskItemAgainstZones( item, itemBBox, F_Mask, F_Cu );
780 testItemAgainstItems( item, itemBBox, F_Cu, F_Mask );
794 testItemAgainstItems( item, itemBBox, B_Cu, B_Mask );
802 for(
auto& ret : returns )
807 while( ret.wait_for( std::chrono::milliseconds( 100 ) ) == std::future_status::timeout )
808 reportProgress( count, test_items.size() );
813 std::set<std::tuple<BOARD_ITEM*, BOARD_ITEM*, BOARD_ITEM*>> reportedTriplets;
815 for(
const MASK_APERTURE_COLLISION& collision : m_pendingCollisions )
823 std::vector<std::pair<BOARD_ITEM*, int>> itemsInAperture;
826 std::lock_guard<std::mutex> lock( m_netMapMutex );
827 auto it = m_maskApertureNetMapAll.find( key );
829 if( it != m_maskApertureNetMapAll.end() )
830 itemsInAperture = it->second;
835 if( collision.layer ==
F_Mask )
836 msg =
_(
"Front solder mask aperture bridges items with different nets" );
838 msg =
_(
"Rear solder mask aperture bridges items with different nets" );
840 bool reportedAnyTrack =
false;
842 for(
auto& [firstNetItem, firstNet] : itemsInAperture )
845 if( firstNet == collision.collidingNet )
849 auto tripletKey = std::make_tuple( collision.aperture, firstNetItem, collision.collidingItem );
851 if( reportedTriplets.count( tripletKey ) )
854 reportedTriplets.insert( tripletKey );
857 reportedTriplets.insert( std::make_tuple( collision.aperture, collision.collidingItem, firstNetItem ) );
863 if( m_drcEngine->GetReportAllTrackErrors() || !reportedAnyTrack )
867 drce->SetErrorMessage( msg );
868 drce->SetItems( collision.aperture, firstNetItem, collision.collidingItem );
869 drce->SetViolatingRule( &m_bridgeRule );
870 reportViolation( drce, collision.pos, collision.layer );
871 reportedAnyTrack =
true;
878 drce->SetErrorMessage( msg );
879 drce->SetItems( collision.aperture, firstNetItem, collision.collidingItem );
880 drce->SetViolatingRule( &m_bridgeRule );
881 reportViolation( drce, collision.pos, collision.layer );
893 REPORT_AUX( wxT(
"Solder mask violations ignored. Tests not run." ) );
902 auto updateLargestClearance =
903 [&](
int aClearance )
910 for(
PAD*
pad : footprint->Pads() )
913 for(
BOARD_ITEM* item : footprint->GraphicalItems() )
916 updateLargestClearance(
static_cast<PCB_SHAPE*
>( item )->GetSolderMaskExpansion() );
921 updateLargestClearance( track->GetSolderMaskExpansion() );
926 updateLargestClearance(
static_cast<PCB_SHAPE*
>( item )->GetSolderMaskExpansion() );
937 m_board->GetDesignSettings().m_SolderMaskToCopperClearance );
954 if( !
reportPhase(
_(
"Checking solder mask to silk clearance..." ) ) )
959 if( !
reportPhase(
_(
"Checking solder mask web integrity..." ) ) )
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
virtual void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the item shape to a closed polygon.
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 const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Information pertinent to a Pcbnew printed circuit board.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr bool Intersects(const BOX2< Vec > &aRect) const
SEVERITY GetSeverity() const
const MINOPTMAX< int > & GetValue() const
DRC_RULE * GetParentRule() 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.
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.
virtual const wxString GetName() const override
std::mutex m_collisionMutex
void testMaskItemAgainstZones(BOARD_ITEM *item, const BOX2I &itemBBox, PCB_LAYER_ID refLayer, PCB_LAYER_ID targetLayer)
virtual ~DRC_TEST_PROVIDER_SOLDER_MASK()=default
bool checkMaskAperture(BOARD_ITEM *aMaskItem, BOARD_ITEM *aTestItem, PCB_LAYER_ID aTestLayer, int aTestNet, BOARD_ITEM **aCollidingItem)
std::unique_ptr< DRC_RTREE > m_itemTree
void addItemToRTrees(BOARD_ITEM *aItem)
std::unique_ptr< DRC_RTREE > m_fullSolderMaskRTree
void testSilkToMaskClearance()
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
std::unordered_map< PTR_PTR_CACHE_KEY, LSET > m_checkedPairs
bool checkItemMask(BOARD_ITEM *aItem, int aTestNet)
std::mutex m_checkedPairsMutex
DRC_TEST_PROVIDER_SOLDER_MASK()
std::unordered_map< PTR_LAYER_CACHE_KEY, std::pair< BOARD_ITEM *, int > > m_maskApertureNetMap
void testItemAgainstItems(BOARD_ITEM *aItem, const BOX2I &aItemBBox, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer)
std::vector< MASK_APERTURE_COLLISION > m_pendingCollisions
std::unordered_map< PTR_LAYER_CACHE_KEY, std::vector< std::pair< BOARD_ITEM *, int > > > m_maskApertureNetMapAll
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 reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer, const std::function< void(PCB_MARKER *)> &aPathGenerator=[](PCB_MARKER *){})
static std::vector< KICAD_T > s_allBasicItems
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)
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
KICAD_T Type() const
Returns the type of object.
LSET is a set of PCB_LAYER_IDs.
static LSET AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
const wxString & GetNumber() const
bool SameLogicalPadAs(const PAD *aOther) const
Before we had custom pad shapes it was common to have multiple overlapping pads to represent a more c...
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
bool SharesNetTieGroup(const PAD *aOther) const
int GetSolderMaskExpansion() const
bool IsTented(PCB_LAYER_ID aLayer) const override
Checks if the given object is tented (its copper shape is covered by solder mask) on a given side of ...
int GetSolderMaskExpansion() const
Represent a set of closed polygons.
void RemoveAllContours()
Remove all outlines & holes (clears) the polygon set.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
void Simplify()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
void Deflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
Handle a list of polygons defining a copper zone.
void CacheTriangulation(PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Create a list of triangles that "fill" the solid areas used for instance to draw these solid areas on...
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
const BOX2I GetBoundingBox() const override
void SetFillFlag(PCB_LAYER_ID aLayer, bool aFlag)
SHAPE_POLY_SET * GetFill(PCB_LAYER_ID aLayer)
void SetIsFilled(bool isFilled)
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
@ CHAMFER_ALL_CORNERS
All angles are chamfered.
@ DRCE_SILK_MASK_CLEARANCE
@ BRIDGED_MASK_CONSTRAINT
@ SILK_CLEARANCE_CONSTRAINT
bool isMaskAperture(BOARD_ITEM *aItem)
bool isNullAperture(BOARD_ITEM *aItem)
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
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
BOARD_ITEM * collidingItem
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::priority_thread_pool thread_pool
@ 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_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ 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