55 virtual bool Run()
override;
57 virtual const wxString
GetName()
const override {
return wxT(
"disallow" ); };
63 if( !
reportPhase(
_(
"Checking keepouts & disallow constraints..." ) ) )
72 std::vector<ZONE*> antiCopperKeepouts;
73 std::vector<ZONE*> copperZones;
74 std::vector<std::pair<ZONE*, ZONE*>> toCache;
75 std::atomic<size_t> done( 1 );
77 std::unique_ptr<DRC_RTREE> antiTrackKeepouts = std::make_unique<DRC_RTREE>();
82 ZONE* zone =
static_cast<ZONE*
>( item );
87 antiCopperKeepouts.push_back( zone );
92 antiTrackKeepouts->Insert( zone, layer );
97 copperZones.push_back( zone );
105 antiTrackKeepouts->Build();
107 for(
ZONE* ruleArea : antiCopperKeepouts )
109 for(
ZONE* copperZone : copperZones )
111 toCache.push_back( { ruleArea, copperZone } );
117 [&](
const int idx ) ->
size_t
121 const auto& areaZonePair = toCache[idx];
122 ZONE* ruleArea = areaZonePair.first;
123 ZONE* copperZone = areaZonePair.second;
126 bool isInside =
false;
141 for(
size_t ii = 0; ii < ruleArea->
GetLayerSet().size(); ++ii )
166 std::unique_lock<std::shared_mutex> writeLock( board->
m_CachesMutex );
176 auto futures =
tp.submit_loop( 0, toCache.size(), query_areas, toCache.size() );
178 for(
auto& ret : futures )
180 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
182 while( status != std::future_status::ready )
185 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
196 std::vector<BOARD_ITEM*> allItems;
201 allItems.push_back( item );
205 std::atomic<size_t> itemsDone( 0 );
206 size_t itemCount = allItems.size();
208 auto checkTextOnEdgeCuts =
223 [&](
const int idx ) ->
size_t
227 itemsDone.fetch_add( 1 );
234 if( !testTextOnEdge && !testDisallow )
236 itemsDone.fetch_add( 1 );
242 if( testTextOnEdge && checkTextOnEdgeCuts( item ) )
245 drc->SetItems( item );
253 ZONE* zone =
static_cast<ZONE*
>( item );
257 itemsDone.fetch_add( 1 );
269 antiTrackKeepouts->QueryColliding( track, layer, layer,
280 if(
static_cast<ZONE*
>( other )->Outline()->
Collide(
282 &dummyActual, &pos ) )
284 std::shared_ptr<DRC_ITEM> drcItem =
286 drcItem->SetItems( track );
303 auto reportDisallow =
306 DRC_RULE* rule = aConstraint.GetParentRule();
314 std::shared_ptr<DRC_ITEM> drcItem =
328 std::shared_ptr<SHAPE> shape =
332 keepout->Outline()->
Collide( shape.get(),
334 &dummyActual, &pos );
338 drcItem->SetErrorDetail(
339 wxString::Format( wxS(
"(%s)" ), aConstraint.GetName() ) );
340 drcItem->SetItems( item );
341 drcItem->SetViolatingRule( rule );
352 reportDisallow( constraint );
370 reportDisallow( constraint );
377 itemsDone.fetch_add( 1 );
381 auto itemFutures =
tp.submit_loop( 0, itemCount, processItem, itemCount );
383 while( itemsDone < itemCount )
389 for(
auto& f : itemFutures )
395 itemFutures.wait_for( std::chrono::milliseconds( 250 ) );
constexpr int ARC_LOW_DEF
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
int GetDRCEpsilon() const
Return an epsilon which accounts for rounding errors, etc.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
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 LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual bool HasHole() const
Information pertinent to a Pcbnew printed circuit board.
int m_DRCMaxPhysicalClearance
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::shared_mutex m_CachesMutex
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_IntersectsAreaCache
constexpr bool Intersects(const BOX2< Vec > &aRect) const
SEVERITY GetSeverity() 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.
BOARD_ITEM * m_ImplicitItem
virtual ~DRC_TEST_PROVIDER_DISALLOW()=default
DRC_TEST_PROVIDER_DISALLOW()
virtual const wxString GetName() const override
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
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 *){})
virtual bool reportProgress(size_t aCount, size_t aSize, size_t aDelta=1)
virtual VECTOR2I GetPosition() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
PCB_LAYER_ID ExtractLayer() const
Find the first set PCB_LAYER_ID.
static const LSET & AllLayersMask()
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Represent a set of closed polygons.
void Deflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
void Fracture(bool aSimplify=true)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
SHAPE_POLY_SET CloneDropTriangulation() const
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,...
Handle a list of polygons defining a copper zone.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
const BOX2I GetBoundingBox() const override
bool GetDoNotAllowTracks() const
SHAPE_POLY_SET * Outline()
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
bool HasKeepoutParametersSet() const
Accessor to determine if any keepout parameters are set.
bool GetDoNotAllowZoneFills() const
bool IsOnCopperLayer() const override
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
#define HOLE_PROXY
Indicates the BOARD_ITEM is a proxy for its hole.
PCB_LAYER_ID
A quick note on layer IDs:
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
static bool Collide(const SHAPE_CIRCLE &aA, const SHAPE_CIRCLE &aB, int aClearance, int *aActual, VECTOR2I *aLocation, VECTOR2I *aMTV)
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::priority_thread_pool thread_pool
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a 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_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< int32_t > VECTOR2I