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 );
302 return static_cast<PAD*
>( aItem )->IsNPTHWithNoCopper();
324 return maskLayers.count() > 0 && copperLayers.count() == 0;
348 int encounteredItemNet = -1;
363 alreadyEncounteredItem = ii->second.first;
364 encounteredItemNet = ii->second.second;
371 if( encounteredItemNet == aTestNet && aTestNet >= 0 )
385 padA =
static_cast<PAD*
>( alreadyEncounteredItem );
388 padB =
static_cast<PAD*
>( aTestItem );
396 if( padToNetTieGroupMap.contains( padA->
GetNumber() ) )
401 if( padToNetTieGroupMap.contains( padB->
GetNumber() ) )
406 *aCollidingItem = alreadyEncounteredItem;
416 if( fp->AllowSolderMaskBridges() )
423 std::map<wxString, int> padNumberToGroupIdxMap = fp->MapPadNumbersToNetTieGroups();
424 int groupIdx = padNumberToGroupIdxMap[
pad->GetNumber() ];
431 if(
pad->GetNetCode() == aTestNet )
434 for(
PAD* other : fp->GetNetTiePads(
pad ) )
436 if( other->GetNetCode() == aTestNet )
455 std::optional<DRC_CONSTRAINT> itemConstraint;
463 m_itemTree->QueryColliding( aItem, aRefLayer, aTargetLayer,
474 if( otherNet > 0 && otherNet == itemNet )
485 if( board->GetDesignSettings().m_AllowSoldermaskBridgesInFPs )
494 if(
pad && otherPad && (
pad->SameLogicalPadAs( otherPad )
495 ||
pad->SharesNetTieGroup( otherPad ) ) )
504 if( otherNet < 0 || nets.count( otherNet ) )
510 const std::set<int>& nets = otherFP->GetNetTieCache( other );
512 if( itemNet < 0 || nets.count( itemNet ) )
520 if(
static_cast<void*
>( a ) >
static_cast<void*
>( b ) )
527 if( it !=
m_checkedPairs.end() && it->second.test( aTargetLayer ) )
567 else if(
via && !
via->IsTented( aRefLayer ) )
574 else if( otherVia && !otherVia->
IsTented( aTargetLayer ) )
576 else if( otherShape )
579 if( itemShape->Collide( otherItemShape.get(),
clearance, &
actual, &pos ) )
581 if( !itemConstraint.has_value() )
592 || ( itemConstraintIgnored && otherConstraintIgnored ) )
600 if( aTargetLayer ==
F_Mask )
601 msg =
_(
"Front solder mask aperture bridges items with different nets" );
603 msg =
_(
"Rear solder mask aperture bridges items with different nets" );
634 drce->SetErrorMessage( msg );
635 drce->SetItems( aItem, other );
665 if( zoneNet == connectedItem->
GetNetCode() && zoneNet > 0 )
669 BOX2I inflatedBBox( aItemBBox );
673 clearance +=
pad->GetSolderMaskExpansion( aTargetLayer );
674 else if(
via && !
via->IsTented( aTargetLayer ) )
696 if( aMaskLayer ==
F_Mask )
697 msg =
_(
"Front solder mask aperture bridges items with different nets" );
699 msg =
_(
"Rear solder mask aperture bridges items with different nets" );
709 drce->SetErrorMessage( msg );
710 drce->SetItems( aItem, colliding, zone );
719 drce->SetErrorMessage( msg );
720 drce->SetItems( aItem, zone );
735 std::atomic<int> count = 0;
736 std::vector<BOARD_ITEM*> test_items;
741 test_items.push_back( item );
747 auto returns =
tp.submit_loop( 0, test_items.size(),
748 [&](
size_t i ) ->
bool
750 BOARD_ITEM* item = test_items[ i ];
752 if( m_drcEngine->IsErrorLimitExceeded( DRCE_SOLDERMASK_BRIDGE ) )
755 BOX2I itemBBox = item->GetBoundingBox();
757 if( item->IsOnLayer( F_Mask ) && !isNPTHPadWithNoCopper( item ) )
760 testItemAgainstItems( item, itemBBox, F_Mask, F_Mask );
763 testMaskItemAgainstZones( item, itemBBox, F_Mask, F_Cu );
768 testItemAgainstItems( item, itemBBox, F_Cu, F_Mask );
782 testItemAgainstItems( item, itemBBox, B_Cu, B_Mask );
790 for(
auto& ret : returns )
795 while( ret.wait_for( std::chrono::milliseconds( 100 ) ) == std::future_status::timeout )
796 reportProgress( count, test_items.size() );
801 std::set<std::tuple<BOARD_ITEM*, BOARD_ITEM*, BOARD_ITEM*>> reportedTriplets;
803 for(
const MASK_APERTURE_COLLISION& collision : m_pendingCollisions )
811 std::vector<std::pair<BOARD_ITEM*, int>> itemsInAperture;
814 std::lock_guard<std::mutex> lock( m_netMapMutex );
815 auto it = m_maskApertureNetMapAll.find( key );
817 if( it != m_maskApertureNetMapAll.end() )
818 itemsInAperture = it->second;
823 if( collision.layer ==
F_Mask )
824 msg =
_(
"Front solder mask aperture bridges items with different nets" );
826 msg =
_(
"Rear solder mask aperture bridges items with different nets" );
828 bool reportedAnyTrack =
false;
830 for(
auto& [firstNetItem, firstNet] : itemsInAperture )
833 if( firstNet == collision.collidingNet )
837 auto tripletKey = std::make_tuple( collision.aperture, firstNetItem, collision.collidingItem );
839 if( reportedTriplets.count( tripletKey ) )
842 reportedTriplets.insert( tripletKey );
845 reportedTriplets.insert( std::make_tuple( collision.aperture, collision.collidingItem, firstNetItem ) );
851 if( m_drcEngine->GetReportAllTrackErrors() || !reportedAnyTrack )
855 drce->SetErrorMessage( msg );
856 drce->SetItems( collision.aperture, firstNetItem, collision.collidingItem );
857 drce->SetViolatingRule( &m_bridgeRule );
858 reportViolation( drce, collision.pos, collision.layer );
859 reportedAnyTrack =
true;
866 drce->SetErrorMessage( msg );
867 drce->SetItems( collision.aperture, firstNetItem, collision.collidingItem );
868 drce->SetViolatingRule( &m_bridgeRule );
869 reportViolation( drce, collision.pos, collision.layer );
881 REPORT_AUX( wxT(
"Solder mask violations ignored. Tests not run." ) );
890 auto updateLargestClearance =
891 [&](
int aClearance )
898 for(
PAD*
pad : footprint->Pads() )
901 for(
BOARD_ITEM* item : footprint->GraphicalItems() )
904 updateLargestClearance(
static_cast<PCB_SHAPE*
>( item )->GetSolderMaskExpansion() );
909 updateLargestClearance( track->GetSolderMaskExpansion() );
914 updateLargestClearance(
static_cast<PCB_SHAPE*
>( item )->GetSolderMaskExpansion() );
925 m_board->GetDesignSettings().m_SolderMaskToCopperClearance );
942 if( !
reportPhase(
_(
"Checking solder mask to silk clearance..." ) ) )
947 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 isNPTHPadWithNoCopper(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
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