2020-07-27 13:33:06 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2020 KiCad Developers.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2020-06-19 21:34:19 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <class_pad.h>
|
2020-09-15 19:13:45 +00:00
|
|
|
#include <class_track.h>
|
2020-07-22 23:05:37 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
2020-09-11 15:04:11 +00:00
|
|
|
#include <drc/drc_engine.h>
|
|
|
|
#include <drc/drc_item.h>
|
|
|
|
#include <drc/drc_rule.h>
|
2020-09-11 16:24:27 +00:00
|
|
|
#include <drc/drc_test_provider_clearance_base.h>
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-07-27 13:33:06 +00:00
|
|
|
/*
|
|
|
|
Holes clearance test. Checks pad and via holes for their mechanical clearances.
|
|
|
|
Generated errors:
|
|
|
|
- DRCE_HOLE_CLEARANCE
|
|
|
|
|
|
|
|
TODO: vias-in-smd-pads check
|
|
|
|
*/
|
|
|
|
|
2020-06-19 21:34:19 +00:00
|
|
|
class DRC_TEST_PROVIDER_HOLE_CLEARANCE : public DRC_TEST_PROVIDER_CLEARANCE_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DRC_TEST_PROVIDER_HOLE_CLEARANCE () :
|
2020-07-31 01:46:05 +00:00
|
|
|
DRC_TEST_PROVIDER_CLEARANCE_BASE(),
|
|
|
|
m_board( nullptr ),
|
|
|
|
m_largestRadius( 0 )
|
2020-06-19 21:34:19 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-31 01:46:05 +00:00
|
|
|
virtual ~DRC_TEST_PROVIDER_HOLE_CLEARANCE()
|
2020-06-19 21:34:19 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool Run() override;
|
|
|
|
|
2020-07-31 01:46:05 +00:00
|
|
|
virtual const wxString GetName() const override
|
2020-06-19 21:34:19 +00:00
|
|
|
{
|
2020-07-31 01:46:05 +00:00
|
|
|
return "hole_clearance";
|
2020-06-19 21:34:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual const wxString GetDescription() const override
|
|
|
|
{
|
|
|
|
return "Tests clearance of holes (via/pad drills)";
|
|
|
|
}
|
|
|
|
|
2020-09-13 10:37:20 +00:00
|
|
|
virtual std::set<DRC_CONSTRAINT_TYPE_T> GetConstraintTypes() const override;
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
int GetNumPhases() const override;
|
|
|
|
|
2020-06-19 21:34:19 +00:00
|
|
|
private:
|
2020-07-27 13:33:06 +00:00
|
|
|
void addHole( const VECTOR2I& aLocation, int aRadius, BOARD_ITEM* aOwner );
|
2020-07-15 16:23:56 +00:00
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
void buildDrilledHoleList();
|
2020-07-27 13:33:06 +00:00
|
|
|
void testHoles2Holes();
|
|
|
|
void testPads2Holes();
|
2020-07-15 16:23:56 +00:00
|
|
|
|
2020-09-16 09:15:04 +00:00
|
|
|
/**
|
|
|
|
* Test clearance of a pad hole with the pad hole of other pads.
|
|
|
|
* @param aSortedPadsList is the sorted by X pos of all pads
|
|
|
|
* @param aRefPadIdx is the index of pad to test inside aSortedPadsList
|
|
|
|
* @param aX_limit is the max X pos of others pads that need to be tested
|
2020-10-13 15:31:36 +00:00
|
|
|
* To speed up the test, aSortedPadsList is a pad list sorted by X position, and only pads
|
|
|
|
* after the pad to test are tested, so this function must be called for each pad for the
|
|
|
|
* first in list to the last in list
|
2020-09-16 09:15:04 +00:00
|
|
|
*/
|
|
|
|
bool doPadToPadHoleDrc( int aRefPadIdx, std::vector<D_PAD*>& aSortedPadsList, int aX_limit );
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-07-15 16:23:56 +00:00
|
|
|
struct DRILLED_HOLE
|
|
|
|
{
|
2020-09-11 21:50:53 +00:00
|
|
|
VECTOR2I m_location;
|
2020-07-15 16:23:56 +00:00
|
|
|
int m_drillRadius = 0;
|
|
|
|
BOARD_ITEM* m_owner = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
BOARD* m_board;
|
2020-09-11 16:24:27 +00:00
|
|
|
std::vector<DRILLED_HOLE> m_drilledHoles;
|
2020-07-15 16:23:56 +00:00
|
|
|
int m_largestRadius;
|
|
|
|
|
2020-06-19 21:34:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-09-11 21:50:53 +00:00
|
|
|
bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::Run()
|
2020-06-19 21:34:19 +00:00
|
|
|
{
|
|
|
|
m_board = m_drcEngine->GetBoard();
|
2020-06-30 08:42:43 +00:00
|
|
|
|
|
|
|
m_largestClearance = 0;
|
2020-07-27 13:33:06 +00:00
|
|
|
m_largestRadius = 0;
|
2020-06-30 08:42:43 +00:00
|
|
|
|
2020-08-11 22:17:43 +00:00
|
|
|
DRC_CONSTRAINT worstClearanceConstraint;
|
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
if( m_drcEngine->QueryWorstConstraint( DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE,
|
2020-09-11 15:04:11 +00:00
|
|
|
worstClearanceConstraint, DRCCQ_LARGEST_MINIMUM ) )
|
2020-06-30 08:42:43 +00:00
|
|
|
{
|
2020-08-11 22:17:43 +00:00
|
|
|
m_largestClearance = worstClearanceConstraint.GetValue().Min();
|
2020-09-14 17:54:14 +00:00
|
|
|
reportAux( "Worst hole clearance : %d nm", m_largestClearance );
|
2020-06-30 08:42:43 +00:00
|
|
|
}
|
2020-08-11 22:17:43 +00:00
|
|
|
else
|
|
|
|
{
|
2020-09-14 17:54:14 +00:00
|
|
|
reportAux( "No hole clearance constraints found..." );
|
2020-08-11 22:17:43 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
buildDrilledHoleList();
|
2020-07-27 13:33:06 +00:00
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
if( !reportPhase( _( "Checking hole to pad clearances..." ) ) )
|
|
|
|
return false;
|
|
|
|
|
2020-07-27 13:33:06 +00:00
|
|
|
testPads2Holes();
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
if( !reportPhase( _( "Checking hole to hole clearances..." ) ) )
|
|
|
|
return false;
|
|
|
|
|
2020-07-27 13:33:06 +00:00
|
|
|
testHoles2Holes();
|
|
|
|
|
|
|
|
reportRuleStatistics();
|
2020-06-19 21:34:19 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-07-27 13:33:06 +00:00
|
|
|
|
2020-09-11 21:50:53 +00:00
|
|
|
void DRC_TEST_PROVIDER_HOLE_CLEARANCE::buildDrilledHoleList()
|
2020-07-27 13:33:06 +00:00
|
|
|
{
|
2020-09-11 16:24:27 +00:00
|
|
|
m_drilledHoles.clear();
|
2020-07-27 13:33:06 +00:00
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
for( MODULE* module : m_board->Modules() )
|
2020-07-27 13:33:06 +00:00
|
|
|
{
|
2020-09-11 16:24:27 +00:00
|
|
|
for( D_PAD* pad : module->Pads() )
|
2020-07-27 13:33:06 +00:00
|
|
|
{
|
|
|
|
int holeSize = std::min( pad->GetDrillSize().x, pad->GetDrillSize().y );
|
|
|
|
|
|
|
|
if( holeSize == 0 )
|
|
|
|
continue;
|
2020-07-31 01:46:05 +00:00
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
// Milled holes (slots) aren't required to meet the minimum hole-to-hole
|
|
|
|
// distance, so we only have to collect the drilled holes.
|
2020-07-27 13:33:06 +00:00
|
|
|
if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
|
|
|
|
addHole( pad->GetPosition(), pad->GetDrillSize().x / 2, pad );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
for( TRACK* track : m_board->Tracks() )
|
2020-07-27 13:33:06 +00:00
|
|
|
{
|
2020-09-11 21:50:53 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
2020-07-27 13:33:06 +00:00
|
|
|
{
|
2020-09-11 16:24:27 +00:00
|
|
|
VIA* via = static_cast<VIA*>( track );
|
2020-07-27 13:33:06 +00:00
|
|
|
addHole( via->GetPosition(), via->GetDrillValue() / 2, via );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
reportAux( "Total drilled holes : %d", m_drilledHoles.size());
|
2020-07-27 13:33:06 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
|
2020-09-11 21:50:53 +00:00
|
|
|
void DRC_TEST_PROVIDER_HOLE_CLEARANCE::testPads2Holes()
|
2020-06-19 21:34:19 +00:00
|
|
|
{
|
2020-09-17 13:36:34 +00:00
|
|
|
const int delta = 25; // This is the number of tests between 2 calls to the progress bar
|
2020-09-11 16:24:27 +00:00
|
|
|
std::vector<D_PAD*> sortedPads;
|
2020-06-19 21:34:19 +00:00
|
|
|
|
|
|
|
m_board->GetSortedPadListByXthenYCoord( sortedPads );
|
|
|
|
|
|
|
|
if( sortedPads.empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// find the max size of the pads (used to stop the pad-to-pad tests)
|
|
|
|
int max_size = 0;
|
|
|
|
|
|
|
|
for( D_PAD* pad : sortedPads )
|
|
|
|
{
|
|
|
|
// GetBoundingRadius() is the radius of the minimum sized circle fully containing the pad
|
|
|
|
int radius = pad->GetBoundingRadius();
|
|
|
|
|
|
|
|
if( radius > max_size )
|
|
|
|
max_size = radius;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Better to be fast than accurate; this keeps us from having to look up / calculate the
|
|
|
|
// actual clearances
|
|
|
|
max_size += m_largestClearance;
|
|
|
|
|
|
|
|
// Test the pads
|
2020-09-17 13:36:34 +00:00
|
|
|
for( int idx = 0; idx < (int) sortedPads.size(); idx++ )
|
2020-06-19 21:34:19 +00:00
|
|
|
{
|
2020-09-16 09:15:04 +00:00
|
|
|
D_PAD* pad = sortedPads[idx];
|
|
|
|
int x_limit = pad->GetPosition().x + pad->GetBoundingRadius() + max_size;
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-09-17 16:32:42 +00:00
|
|
|
drc_dbg( 10, "-> %p\n", pad );
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
if( !reportProgress( idx, sortedPads.size(), delta ) )
|
|
|
|
break;
|
2020-09-17 13:36:34 +00:00
|
|
|
|
2020-09-16 09:15:04 +00:00
|
|
|
doPadToPadHoleDrc( idx, sortedPads, x_limit );
|
2020-06-19 21:34:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-16 09:15:04 +00:00
|
|
|
bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::doPadToPadHoleDrc( int aRefPadIdx,
|
|
|
|
std::vector<D_PAD*>& aSortedPadsList,
|
|
|
|
int aX_limit )
|
2020-06-19 21:34:19 +00:00
|
|
|
{
|
|
|
|
const static LSET all_cu = LSET::AllCuMask();
|
|
|
|
|
2020-09-16 09:15:04 +00:00
|
|
|
D_PAD* refPad = aSortedPadsList[aRefPadIdx];
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-09-16 09:15:04 +00:00
|
|
|
for( int idx = aRefPadIdx; idx < (int)aSortedPadsList.size(); ++idx )
|
2020-06-19 21:34:19 +00:00
|
|
|
{
|
2020-09-16 09:15:04 +00:00
|
|
|
D_PAD* pad = aSortedPadsList[idx];
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-09-29 12:07:55 +00:00
|
|
|
if( pad == refPad || pad->SameLogicalPadAs( refPad ) )
|
2020-06-19 21:34:19 +00:00
|
|
|
continue;
|
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
// drc_dbg(10," chk against -> %p\n", pad);
|
2020-07-31 01:46:05 +00:00
|
|
|
|
2020-09-16 09:15:04 +00:00
|
|
|
// We can stop the test when pad->GetPosition().x > aX_limit because the list is
|
|
|
|
// sorted by X positions, and other pads are too far.
|
|
|
|
if( pad->GetPosition().x > aX_limit )
|
2020-06-19 21:34:19 +00:00
|
|
|
break;
|
|
|
|
|
2020-09-17 16:32:42 +00:00
|
|
|
drc_dbg( 10, " chk1 against -> %p x0 %d x2 %d\n",
|
2020-09-16 09:15:04 +00:00
|
|
|
pad, pad->GetDrillSize().x, refPad->GetDrillSize().x );
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
if( pad->GetDrillSize().x && ( refPad->GetLayerSet() & all_cu ).any() )
|
2020-06-19 21:34:19 +00:00
|
|
|
{
|
2020-10-13 15:31:36 +00:00
|
|
|
// pad has a hole and refPad is on copper
|
2020-07-15 16:23:56 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE,
|
|
|
|
refPad, pad );
|
|
|
|
int minClearance = constraint.GetValue().Min();
|
|
|
|
int actual;
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
drc_dbg( 10, "check pad %p rule '%s' cl %d\n",
|
|
|
|
pad, constraint.GetParentRule()->m_Name, minClearance );
|
2020-07-15 16:23:56 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
accountCheck( constraint.GetParentRule() );
|
2020-07-27 13:33:06 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
const std::shared_ptr<SHAPE>& refPadShape = refPad->GetEffectiveShape();
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
// fixme: pad stacks...
|
|
|
|
if( refPadShape->Collide( pad->GetEffectiveHoleShape(), minClearance, &actual ) )
|
|
|
|
{
|
|
|
|
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-10-20 19:05:04 +00:00
|
|
|
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(%s clearance %s; actual %s)" ),
|
2020-10-13 15:31:36 +00:00
|
|
|
constraint.GetName(),
|
|
|
|
MessageTextFromValue( userUnits(), minClearance ),
|
|
|
|
MessageTextFromValue( userUnits(), actual ) );
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
drcItem->SetErrorMessage( m_msg );
|
|
|
|
drcItem->SetItems( pad, refPad );
|
|
|
|
drcItem->SetViolatingRule( constraint.GetParentRule() );
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
reportViolation( drcItem, pad->GetPosition() );
|
|
|
|
return false;
|
2020-06-19 21:34:19 +00:00
|
|
|
}
|
2020-10-13 15:31:36 +00:00
|
|
|
}
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
if( refPad->GetDrillSize().x && ( pad->GetLayerSet() & all_cu ).any() )
|
|
|
|
{
|
|
|
|
// refPad has a hole and pad is on copper
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE,
|
|
|
|
refPad, pad );
|
|
|
|
int minClearance = constraint.GetValue().Min();
|
|
|
|
int actual;
|
2020-07-31 01:46:05 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
accountCheck( constraint.GetParentRule() );
|
2020-07-15 16:23:56 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
drc_dbg( 10,"check pad %p rule '%s' cl %d\n", refPad,
|
|
|
|
constraint.GetParentRule()->m_Name, minClearance );
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
const std::shared_ptr<SHAPE>& padShape = pad->GetEffectiveShape();
|
|
|
|
|
|
|
|
if( padShape->Collide( refPad->GetEffectiveHoleShape(), minClearance, &actual ) )
|
|
|
|
{
|
|
|
|
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-10-20 19:05:04 +00:00
|
|
|
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(%s clearance %s; actual %s)" ),
|
2020-10-13 15:31:36 +00:00
|
|
|
constraint.GetName(),
|
|
|
|
MessageTextFromValue( userUnits(), minClearance ),
|
|
|
|
MessageTextFromValue( userUnits(), actual ) );
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
drcItem->SetErrorMessage( m_msg );
|
|
|
|
drcItem->SetItems( refPad, pad );
|
|
|
|
drcItem->SetViolatingRule( constraint.GetParentRule() );
|
2020-06-19 21:34:19 +00:00
|
|
|
|
2020-10-13 15:31:36 +00:00
|
|
|
reportViolation( drcItem, pad->GetPosition() );
|
|
|
|
return false;
|
2020-06-19 21:34:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-07-27 13:33:06 +00:00
|
|
|
|
2020-09-11 21:50:53 +00:00
|
|
|
void DRC_TEST_PROVIDER_HOLE_CLEARANCE::addHole( const VECTOR2I& aLocation, int aRadius,
|
2020-09-11 16:24:27 +00:00
|
|
|
BOARD_ITEM* aOwner )
|
2020-07-27 13:33:06 +00:00
|
|
|
{
|
|
|
|
DRILLED_HOLE hole;
|
|
|
|
|
|
|
|
hole.m_location = aLocation;
|
|
|
|
hole.m_drillRadius = aRadius;
|
|
|
|
hole.m_owner = aOwner;
|
|
|
|
|
|
|
|
m_largestRadius = std::max( m_largestRadius, aRadius );
|
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
m_drilledHoles.push_back( hole );
|
2020-07-27 13:33:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-11 21:50:53 +00:00
|
|
|
void DRC_TEST_PROVIDER_HOLE_CLEARANCE::testHoles2Holes()
|
2020-07-27 13:33:06 +00:00
|
|
|
{
|
2020-09-17 13:36:34 +00:00
|
|
|
const int delta = 50; // This is the number of tests between 2 calls to the progress bar
|
|
|
|
|
2020-07-27 13:33:06 +00:00
|
|
|
// Sort holes by X for performance. In the nested iteration we then need to look at
|
|
|
|
// following holes only while they are within the refHole's neighborhood as defined by
|
|
|
|
// the refHole radius + the minimum hole-to-hole clearance + the largest radius any of
|
|
|
|
// the following holes can have.
|
2020-09-11 16:24:27 +00:00
|
|
|
std::sort( m_drilledHoles.begin(), m_drilledHoles.end(),
|
2020-07-27 13:33:06 +00:00
|
|
|
[]( const DRILLED_HOLE& a, const DRILLED_HOLE& b )
|
|
|
|
{
|
|
|
|
if( a.m_location.x == b.m_location.x )
|
|
|
|
return a.m_location.y < b.m_location.y;
|
|
|
|
else
|
|
|
|
return a.m_location.x < b.m_location.x;
|
|
|
|
} );
|
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
for( size_t ii = 0; ii < m_drilledHoles.size(); ++ii )
|
2020-07-27 13:33:06 +00:00
|
|
|
{
|
2020-09-18 19:57:54 +00:00
|
|
|
if( !reportProgress( ii, m_drilledHoles.size(), delta ) )
|
|
|
|
break;
|
2020-09-17 13:36:34 +00:00
|
|
|
|
2020-09-12 19:28:22 +00:00
|
|
|
if( m_drcEngine->IsErrorLimitExceeded( DRCE_DRILLED_HOLES_TOO_CLOSE ) )
|
|
|
|
break;
|
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
DRILLED_HOLE& refHole = m_drilledHoles[ ii ];
|
2020-07-27 13:33:06 +00:00
|
|
|
int neighborhood = refHole.m_drillRadius + m_largestClearance + m_largestRadius;
|
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
for( size_t jj = ii + 1; jj < m_drilledHoles.size(); ++jj )
|
2020-07-27 13:33:06 +00:00
|
|
|
{
|
2020-09-12 19:28:22 +00:00
|
|
|
if( m_drcEngine->IsErrorLimitExceeded( DRCE_DRILLED_HOLES_TOO_CLOSE ) )
|
|
|
|
break;
|
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
DRILLED_HOLE& checkHole = m_drilledHoles[ jj ];
|
2020-07-27 13:33:06 +00:00
|
|
|
|
|
|
|
if( refHole.m_location.x + neighborhood < checkHole.m_location.x )
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Holes with identical locations are allowable
|
|
|
|
if( checkHole.m_location == refHole.m_location )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
int actual = ( checkHole.m_location - refHole.m_location ).EuclideanNorm();
|
|
|
|
actual = std::max( 0, actual - checkHole.m_drillRadius - refHole.m_drillRadius );
|
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE,
|
|
|
|
refHole.m_owner, checkHole.m_owner );
|
|
|
|
int minClearance = constraint.GetValue().Min();
|
2020-07-31 01:46:05 +00:00
|
|
|
|
2020-08-11 22:17:43 +00:00
|
|
|
accountCheck( constraint.GetParentRule() );
|
2020-07-27 13:33:06 +00:00
|
|
|
|
|
|
|
if( actual < minClearance )
|
|
|
|
{
|
2020-09-11 16:24:27 +00:00
|
|
|
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_DRILLED_HOLES_TOO_CLOSE );
|
2020-07-27 13:33:06 +00:00
|
|
|
|
2020-10-20 19:05:04 +00:00
|
|
|
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(%s clearance %s; actual %s)" ),
|
2020-09-11 16:24:27 +00:00
|
|
|
constraint.GetName(),
|
2020-10-02 20:51:24 +00:00
|
|
|
MessageTextFromValue( userUnits(), minClearance ),
|
|
|
|
MessageTextFromValue( userUnits(), actual ) );
|
2020-07-27 13:33:06 +00:00
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
drcItem->SetErrorMessage( m_msg );
|
2020-07-27 13:33:06 +00:00
|
|
|
drcItem->SetItems( refHole.m_owner, checkHole.m_owner );
|
2020-09-11 16:24:27 +00:00
|
|
|
drcItem->SetViolatingRule( constraint.GetParentRule() );
|
2020-07-27 13:33:06 +00:00
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
reportViolation( drcItem, (wxPoint) refHole.m_location );
|
2020-07-27 13:33:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
int DRC_TEST_PROVIDER_HOLE_CLEARANCE::GetNumPhases() const
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-13 10:37:20 +00:00
|
|
|
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_HOLE_CLEARANCE::GetConstraintTypes() const
|
2020-06-19 21:34:19 +00:00
|
|
|
{
|
2020-09-13 10:37:20 +00:00
|
|
|
return { DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE };
|
2020-06-19 21:34:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace detail
|
|
|
|
{
|
2020-09-11 21:50:53 +00:00
|
|
|
static DRC_REGISTER_TEST_PROVIDER<DRC_TEST_PROVIDER_HOLE_CLEARANCE> dummy;
|
2020-07-31 01:46:05 +00:00
|
|
|
}
|