56 virtual bool Run()
override;
58 virtual const wxString
GetName()
const override
60 return wxT(
"sliver checker" );
65 return wxT(
"Checks copper layers for slivers" );
84 if( !
reportPhase(
_(
"Running sliver detection on copper layers..." ) ) )
89 int testLength = widthTolerance / ( 2 * sin(
DEG2RAD( angleTolerance / 2 ) ) );
91 LSEQ copperLayers = copperLayerSet.
Seq();
92 int layerCount = copperLayers.size();
95 int zoneLayerCount = 0;
96 std::atomic<size_t> done( 1 );
102 if( !zone->GetIsRuleArea() && zone->IsOnLayer( layer ) )
112 std::vector<SHAPE_POLY_SET> layerPolys( layerCount );
114 auto build_layer_polys =
115 [&](
int layerIdx ) ->
size_t
128 if(
ZONE* zone =
dynamic_cast<ZONE*
>( item) )
130 if( !zone->GetIsRuleArea() )
132 fill = zone->GetFill( layer )->CloneDropTriangulation();
133 fill.Unfracture( SHAPE_POLY_SET::PM_FAST );
167 std::vector<std::future<size_t>> returns;
169 returns.reserve( copperLayers.size() );
171 for(
size_t ii = 0; ii < copperLayers.size(); ++ii )
172 returns.emplace_back(
tp.submit( build_layer_polys, ii ) );
174 for(
const std::future<size_t>& ret : returns )
176 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
178 while( status != std::future_status::ready )
182 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
187 for(
int ii = 0; ii < layerCount; ++ii )
205 int ptCount = pts.size();
207 for(
int kk = 0; kk < ptCount; ++kk )
210 VECTOR2I ptPrior = pts[ ( ptCount + kk - 1 ) % ptCount ];
213 if(
std::abs( vPrior.x ) < min_len &&
std::abs( vPrior.y ) < min_len && ptCount > 5)
215 ptPrior = pts[ ( ptCount + kk - 2 ) % ptCount ];
216 vPrior = ( ptPrior - pt );
219 VECTOR2I ptAfter = pts[ ( kk + 1 ) % ptCount ];
222 if(
std::abs( vAfter.x ) < min_len &&
std::abs( vAfter.y ) < min_len && ptCount > 5 )
224 ptAfter = pts[ ( kk + 2 ) % ptCount ];
225 vAfter = ( ptAfter - pt );
233 drce->SetErrorMessage( drce->GetErrorText() + wxS(
" " ) +
layerDesc( layer ) );
constexpr EDA_IU_SCALE pcbIUScale
constexpr int ARC_LOW_DEF
double m_SliverAngleTolerance
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
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.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
bool ReportProgress(double aProgress)
bool IsErrorLimitExceeded(int error_code)
PROGRESS_REPORTER * GetProgressReporter() const
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
wxString layerDesc(PCB_LAYER_ID aLayer)
virtual const wxString GetDescription() const override
virtual ~DRC_TEST_PROVIDER_SLIVER_CHECKER()
virtual const wxString GetName() const override
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
DRC_TEST_PROVIDER_SLIVER_CHECKER()
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out #DRC_ITEMs and po...
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)
static std::vector< KICAD_T > s_allBasicItems
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
A progress reporter interface for use in multi-threaded environments.
virtual bool IsCancelled() const =0
static SEG::ecoord Square(int a)
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
void Deflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
void Simplify(POLYGON_MODE aFastMode)
SHAPE_LINE_CHAIN & Outline(int aIndex)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Handle a list of polygons defining a copper zone.
PCB_LAYER_ID
A quick note on layer IDs:
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
constexpr int mmToIU(double mm) const
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::thread_pool thread_pool
double DEG2RAD(double deg)