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-13 23:28:08 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <class_board.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_shape.h>
|
2020-06-13 23:28:08 +00:00
|
|
|
#include <class_pad.h>
|
2020-09-15 19:13:45 +00:00
|
|
|
#include <class_track.h>
|
2020-06-13 23:28:08 +00:00
|
|
|
|
|
|
|
#include <geometry/seg.h>
|
|
|
|
#include <geometry/shape_poly_set.h>
|
|
|
|
#include <geometry/shape_rect.h>
|
2020-07-15 16:23:56 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
2020-10-27 20:15:54 +00:00
|
|
|
#include <geometry/shape_null.h>
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
#include <drc/drc_engine.h>
|
2020-10-27 17:09:27 +00:00
|
|
|
#include <drc/drc_rtree.h>
|
2020-09-11 15:04:11 +00:00
|
|
|
#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-09-19 11:47:43 +00:00
|
|
|
#include <class_dimension.h>
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-07-27 13:33:06 +00:00
|
|
|
/*
|
|
|
|
Copper clearance test. Checks all copper items (pads, vias, tracks, drawings, zones) for their electrical clearance.
|
|
|
|
Errors generated:
|
|
|
|
- DRCE_CLEARANCE
|
|
|
|
- DRCE_TRACKS_CROSSING
|
|
|
|
- DRCE_ZONES_INTERSECT
|
2020-08-25 17:42:52 +00:00
|
|
|
- DRCE_SHORTING_ITEMS
|
2020-07-27 13:33:06 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-19 21:34:19 +00:00
|
|
|
class DRC_TEST_PROVIDER_COPPER_CLEARANCE : public DRC_TEST_PROVIDER_CLEARANCE_BASE
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-06-19 21:34:19 +00:00
|
|
|
DRC_TEST_PROVIDER_COPPER_CLEARANCE () :
|
2020-11-01 11:39:14 +00:00
|
|
|
DRC_TEST_PROVIDER_CLEARANCE_BASE(),
|
|
|
|
m_drcEpsilon( 0 )
|
2020-09-11 16:24:27 +00:00
|
|
|
{
|
|
|
|
}
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-08-11 23:50:56 +00:00
|
|
|
virtual ~DRC_TEST_PROVIDER_COPPER_CLEARANCE()
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool Run() override;
|
|
|
|
|
2020-08-11 23:50:56 +00:00
|
|
|
virtual const wxString GetName() const override
|
2020-06-19 21:34:19 +00:00
|
|
|
{
|
2020-08-11 23:50:56 +00:00
|
|
|
return "clearance";
|
2020-06-19 21:34:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual const wxString GetDescription() const override
|
|
|
|
{
|
|
|
|
return "Tests copper item clearance";
|
|
|
|
}
|
|
|
|
|
2020-09-13 10:37:20 +00:00
|
|
|
virtual std::set<DRC_CONSTRAINT_TYPE_T> GetConstraintTypes() const override;
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
int GetNumPhases() const override;
|
|
|
|
|
2020-06-13 23:28:08 +00:00
|
|
|
private:
|
2020-10-28 12:24:10 +00:00
|
|
|
bool testTrackAgainstItem( TRACK* track, SHAPE* trackShape, PCB_LAYER_ID layer,
|
|
|
|
BOARD_ITEM* other );
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
void testTrackClearances();
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-10-28 12:24:10 +00:00
|
|
|
bool testPadAgainstItem( D_PAD* pad, SHAPE* padShape, PCB_LAYER_ID layer, BOARD_ITEM* other );
|
2020-10-27 17:09:27 +00:00
|
|
|
|
|
|
|
void testPadClearances();
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-06-18 16:55:22 +00:00
|
|
|
void testZones();
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
void testItemAgainstZones( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer );
|
2020-10-27 17:09:27 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DRC_RTREE m_copperTree;
|
|
|
|
int m_drcEpsilon;
|
2020-10-28 17:55:57 +00:00
|
|
|
|
|
|
|
std::vector<ZONE_CONTAINER*> m_zones;
|
|
|
|
std::map<ZONE_CONTAINER*, std::unique_ptr<DRC_RTREE>> m_zoneTrees;
|
|
|
|
|
2020-06-13 23:28:08 +00:00
|
|
|
};
|
|
|
|
|
2020-06-17 22:36:54 +00:00
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run()
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
|
|
|
m_board = m_drcEngine->GetBoard();
|
2020-08-11 22:17:43 +00:00
|
|
|
DRC_CONSTRAINT worstClearanceConstraint;
|
2020-06-30 08:42:43 +00:00
|
|
|
|
2020-11-02 16:20:00 +00:00
|
|
|
if( m_drcEngine->QueryWorstConstraint( CLEARANCE_CONSTRAINT, worstClearanceConstraint ) )
|
2020-06-30 08:42:43 +00:00
|
|
|
{
|
2020-08-11 22:17:43 +00:00
|
|
|
m_largestClearance = worstClearanceConstraint.GetValue().Min();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-14 17:54:14 +00:00
|
|
|
reportAux( "No Clearance constraints found..." );
|
2020-08-11 22:17:43 +00:00
|
|
|
return false;
|
2020-06-30 08:42:43 +00:00
|
|
|
}
|
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
m_drcEpsilon = m_board->GetDesignSettings().GetDRCEpsilon();
|
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
m_zones.clear();
|
|
|
|
|
|
|
|
for( ZONE_CONTAINER* zone : m_board->Zones() )
|
|
|
|
{
|
|
|
|
if( !zone->GetIsRuleArea() )
|
|
|
|
m_zones.push_back( zone );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( MODULE* footprint : m_board->Modules() )
|
|
|
|
{
|
|
|
|
for( ZONE_CONTAINER* zone : footprint->Zones() )
|
|
|
|
{
|
|
|
|
if( !zone->GetIsRuleArea() )
|
|
|
|
m_zones.push_back( zone );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
reportAux( "Worst clearance : %d nm", m_largestClearance );
|
2020-06-30 08:42:43 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
// This is the number of tests between 2 calls to the progress bar
|
2020-10-28 17:55:57 +00:00
|
|
|
size_t delta = 50;
|
|
|
|
size_t count = 0;
|
|
|
|
size_t ii = 0;
|
2020-10-27 17:09:27 +00:00
|
|
|
|
2020-10-29 13:18:15 +00:00
|
|
|
m_copperTree.clear();
|
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
auto countItems =
|
|
|
|
[&]( BOARD_ITEM* item ) -> bool
|
|
|
|
{
|
|
|
|
++count;
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto addToCopperTree =
|
|
|
|
[&]( BOARD_ITEM* item ) -> bool
|
|
|
|
{
|
|
|
|
if( !reportProgress( ii++, count, delta ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
item->ClearFlags( SKIP_STRUCT );
|
|
|
|
|
|
|
|
if( item->Type() == PCB_FP_TEXT_T && !static_cast<FP_TEXT*>( item )->IsVisible() )
|
|
|
|
return true;
|
|
|
|
|
2020-11-01 14:03:13 +00:00
|
|
|
m_copperTree.Insert( item, m_largestClearance );
|
2020-10-27 17:09:27 +00:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
if( !reportPhase( _( "Gathering copper items..." ) ) )
|
2020-09-18 19:57:54 +00:00
|
|
|
return false;
|
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
static const std::vector<KICAD_T> itemTypes = {
|
|
|
|
PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_PAD_T, PCB_SHAPE_T, PCB_FP_SHAPE_T,
|
|
|
|
PCB_TEXT_T, PCB_FP_TEXT_T, PCB_DIMENSION_T, PCB_DIM_ALIGNED_T, PCB_DIM_LEADER_T,
|
|
|
|
PCB_DIM_CENTER_T, PCB_DIM_ORTHOGONAL_T
|
|
|
|
};
|
|
|
|
|
|
|
|
forEachGeometryItem( itemTypes, LSET::AllCuMask(), countItems );
|
|
|
|
forEachGeometryItem( itemTypes, LSET::AllCuMask(), addToCopperTree );
|
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
if( !reportPhase( _( "Tessellating copper zones..." ) ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
delta = 5;
|
|
|
|
ii = 0;
|
|
|
|
m_zoneTrees.clear();
|
|
|
|
|
|
|
|
for( ZONE_CONTAINER* zone : m_zones )
|
|
|
|
{
|
|
|
|
if( !reportProgress( ii++, m_zones.size(), delta ) )
|
|
|
|
break;
|
|
|
|
|
|
|
|
zone->CacheBoundingBox();
|
|
|
|
m_zoneTrees[ zone ] = std::make_unique<DRC_RTREE>();
|
2020-11-01 12:22:29 +00:00
|
|
|
|
|
|
|
for( int layer : zone->GetLayerSet().Seq() )
|
|
|
|
{
|
|
|
|
if( IsCopperLayer( layer ) )
|
2020-11-01 14:03:13 +00:00
|
|
|
m_zoneTrees[ zone ]->Insert( zone, layer );
|
2020-11-01 12:22:29 +00:00
|
|
|
}
|
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reportAux( "Testing %d copper items and %d zones...", count, m_zones.size() );
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
if( !reportPhase( _( "Checking track & via clearances..." ) ) )
|
|
|
|
return false;
|
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
testTrackClearances();
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
if( !reportPhase( _( "Checking pad clearances..." ) ) )
|
2020-09-18 19:57:54 +00:00
|
|
|
return false;
|
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
testPadClearances();
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
if( !reportPhase( _( "Checking copper zone clearances..." ) ) )
|
|
|
|
return false;
|
|
|
|
|
2020-06-18 16:55:22 +00:00
|
|
|
testZones();
|
2020-06-17 22:36:54 +00:00
|
|
|
|
2020-08-25 17:42:52 +00:00
|
|
|
reportRuleStatistics();
|
|
|
|
|
2020-06-17 22:36:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
static std::shared_ptr<SHAPE> getShape( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
if( aItem->Type() == PCB_PAD_T && !static_cast<D_PAD*>( aItem )->FlashLayer( aLayer ) )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
D_PAD* aPad = static_cast<D_PAD*>( aItem );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
if( aPad->GetAttribute() == PAD_ATTRIB_PTH )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = aPad->GetBoard()->GetDesignSettings();
|
|
|
|
|
|
|
|
// Note: drill size represents finish size, which means the actual holes size is the
|
|
|
|
// plating thickness larger.
|
|
|
|
auto hole = static_cast<SHAPE_SEGMENT*>( aPad->GetEffectiveHoleShape()->Clone() );
|
|
|
|
hole->SetWidth( hole->GetWidth() + bds.GetHolePlatingThickness() );
|
|
|
|
return std::make_shared<SHAPE_SEGMENT>( *hole );
|
2020-06-18 16:55:22 +00:00
|
|
|
}
|
2020-10-27 17:09:27 +00:00
|
|
|
|
|
|
|
return std::make_shared<SHAPE_NULL>();
|
2020-06-18 16:55:22 +00:00
|
|
|
}
|
2020-10-27 17:09:27 +00:00
|
|
|
|
|
|
|
return aItem->GetEffectiveShape( aLayer );
|
2020-06-18 16:55:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-28 12:24:10 +00:00
|
|
|
bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHAPE* trackShape,
|
|
|
|
PCB_LAYER_ID layer,
|
|
|
|
BOARD_ITEM* other )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
if( m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE ) )
|
|
|
|
return false;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-11-02 16:20:00 +00:00
|
|
|
auto constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, track, other,
|
|
|
|
layer );
|
2020-10-27 17:09:27 +00:00
|
|
|
int minClearance = constraint.GetValue().Min();
|
|
|
|
int actual;
|
|
|
|
VECTOR2I pos;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
accountCheck( constraint );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
// Special processing for track:track intersections
|
|
|
|
if( track->Type() == PCB_TRACE_T && other->Type() == PCB_TRACE_T )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
SEG trackSeg( track->GetStart(), track->GetEnd() );
|
|
|
|
SEG otherSeg( track->GetStart(), track->GetEnd() );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
if( OPT_VECTOR2I intersection = trackSeg.Intersect( otherSeg ) )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TRACKS_CROSSING );
|
|
|
|
drcItem->SetItems( track, other );
|
2020-08-11 22:17:43 +00:00
|
|
|
drcItem->SetViolatingRule( constraint.GetParentRule() );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
reportViolation( drcItem, (wxPoint) intersection.get() );
|
|
|
|
return true;
|
2020-06-18 16:55:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
std::shared_ptr<SHAPE> otherShape = getShape( other, layer );
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
if( trackShape->Collide( otherShape.get(), minClearance - m_drcEpsilon, &actual, &pos ) )
|
|
|
|
{
|
|
|
|
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
m_msg.Printf( _( "(%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-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg );
|
|
|
|
drce->SetItems( track, other );
|
|
|
|
drce->SetViolatingRule( constraint.GetParentRule() );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
reportViolation( drce, (wxPoint) pos );
|
2020-06-17 22:36:54 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
if( !m_drcEngine->GetReportAllTrackErrors() )
|
|
|
|
return false;
|
2020-06-17 22:36:54 +00:00
|
|
|
}
|
2020-10-27 17:09:27 +00:00
|
|
|
|
|
|
|
return true;
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 22:27:33 +00:00
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aItem,
|
|
|
|
PCB_LAYER_ID aLayer )
|
2020-06-17 22:36:54 +00:00
|
|
|
{
|
2020-10-28 17:55:57 +00:00
|
|
|
for( ZONE_CONTAINER* zone : m_zones )
|
2020-06-17 22:36:54 +00:00
|
|
|
{
|
2020-10-28 17:55:57 +00:00
|
|
|
if( m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE ) )
|
|
|
|
break;
|
2020-07-03 16:37:08 +00:00
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
if( !zone->GetLayerSet().test( aLayer ) )
|
|
|
|
continue;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
if( zone->GetNetCode() && aItem->IsConnected() )
|
|
|
|
{
|
|
|
|
if( zone->GetNetCode() == static_cast<BOARD_CONNECTED_ITEM*>( aItem )->GetNetCode() )
|
2020-09-17 16:32:42 +00:00
|
|
|
continue;
|
2020-10-28 17:55:57 +00:00
|
|
|
}
|
2020-09-17 16:32:42 +00:00
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
if( aItem->GetBoundingBox().Intersects( zone->GetCachedBoundingBox() ) )
|
|
|
|
{
|
2020-11-02 16:20:00 +00:00
|
|
|
auto constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, aItem, zone,
|
|
|
|
aLayer );
|
2020-10-28 17:55:57 +00:00
|
|
|
int clearance = constraint.GetValue().Min();
|
|
|
|
int actual;
|
|
|
|
VECTOR2I pos;
|
|
|
|
DRC_RTREE* zoneTree = m_zoneTrees[ zone ].get();
|
2020-10-20 10:33:20 +00:00
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
if( zoneTree->QueryColliding( aItem, aLayer, clearance - m_drcEpsilon, &actual, &pos ) )
|
2020-09-11 16:24:27 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
|
2020-06-17 22:36:54 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
|
2020-09-11 16:24:27 +00:00
|
|
|
constraint.GetName(),
|
2020-10-28 17:55:57 +00:00
|
|
|
MessageTextFromValue( userUnits(), clearance ),
|
2020-10-02 20:51:24 +00:00
|
|
|
MessageTextFromValue( userUnits(), actual ) );
|
2020-06-17 22:36:54 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg );
|
2020-10-28 17:55:57 +00:00
|
|
|
drce->SetItems( aItem, zone );
|
2020-10-27 17:09:27 +00:00
|
|
|
drce->SetViolatingRule( constraint.GetParentRule() );
|
2020-06-17 22:36:54 +00:00
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
reportViolation( drce, (wxPoint) pos );
|
2020-06-17 22:36:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-13 23:28:08 +00:00
|
|
|
|
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances()
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
// This is the number of tests between 2 calls to the progress bar
|
|
|
|
const int delta = 25;
|
|
|
|
int ii = 0;
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
reportAux( "Testing %d tracks & vias...", m_board->Tracks().size() );
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
for( TRACK* track : m_board->Tracks() )
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
if( !reportProgress( ii++, m_board->Tracks().size(), delta ) )
|
|
|
|
break;
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
for( PCB_LAYER_ID layer : track->GetLayerSet().Seq() )
|
|
|
|
{
|
|
|
|
std::shared_ptr<SHAPE> trackShape = track->GetEffectiveShape( layer );
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
m_copperTree.QueryColliding( track, layer, layer,
|
2020-11-02 16:20:00 +00:00
|
|
|
// Filter:
|
2020-10-27 17:09:27 +00:00
|
|
|
[&]( BOARD_ITEM* other ) -> bool
|
|
|
|
{
|
|
|
|
if( other->HasFlag( SKIP_STRUCT ) )
|
|
|
|
return false;
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
auto otherCItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( other );
|
2020-09-16 09:15:04 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
if( otherCItem && otherCItem->GetNetCode() == track->GetNetCode() )
|
|
|
|
return false;
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
return true;
|
|
|
|
},
|
2020-11-02 16:20:00 +00:00
|
|
|
// Visitor:
|
2020-10-28 13:52:30 +00:00
|
|
|
[&]( BOARD_ITEM* other ) -> bool
|
2020-10-27 17:09:27 +00:00
|
|
|
{
|
2020-10-28 12:24:10 +00:00
|
|
|
return testTrackAgainstItem( track, trackShape.get(), layer, other );
|
2020-10-27 17:09:27 +00:00
|
|
|
},
|
|
|
|
m_largestClearance );
|
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
testItemAgainstZones( track, layer );
|
2020-10-27 17:09:27 +00:00
|
|
|
}
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
track->SetFlags( SKIP_STRUCT );
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-12 19:28:22 +00:00
|
|
|
|
2020-10-28 12:24:10 +00:00
|
|
|
bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( D_PAD* pad, SHAPE* padShape,
|
|
|
|
PCB_LAYER_ID layer,
|
|
|
|
BOARD_ITEM* other )
|
2020-10-27 17:09:27 +00:00
|
|
|
{
|
|
|
|
bool testClearance = !m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE );
|
|
|
|
bool testShorting = !m_drcEngine->IsErrorLimitExceeded( DRCE_SHORTING_ITEMS );
|
|
|
|
bool testHoles = !m_drcEngine->IsErrorLimitExceeded( DRCE_HOLE_CLEARANCE );
|
2020-09-12 19:28:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
// Graphic items are allowed to act as net-ties within their own footprint
|
|
|
|
if( other->Type() == PCB_FP_SHAPE_T && pad->GetParent() == other->GetParent() )
|
|
|
|
testClearance = false;
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
if( !testClearance && !testShorting && !testHoles )
|
|
|
|
return false;
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
std::shared_ptr<SHAPE> otherShape = getShape( other, layer );
|
|
|
|
DRC_CONSTRAINT constraint;
|
|
|
|
int clearance;
|
|
|
|
int actual;
|
|
|
|
VECTOR2I pos;
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
if( other->Type() == PCB_PAD_T )
|
|
|
|
{
|
|
|
|
auto otherPad = static_cast<D_PAD*>( other );
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
// If pads are equivalent (ie: from the same footprint with the same pad number)...
|
2020-10-27 17:09:27 +00:00
|
|
|
if( pad->SameLogicalPadAs( otherPad ) )
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2020-09-11 16:24:27 +00:00
|
|
|
// ...and have nets, then they must be the same net
|
2020-10-27 17:09:27 +00:00
|
|
|
if( pad->GetNetCode() && otherPad->GetNetCode()
|
|
|
|
&& pad->GetNetCode() != otherPad->GetNetCode()
|
|
|
|
&& testShorting )
|
2020-07-30 20:41:52 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_SHORTING_ITEMS );
|
2020-07-30 20:41:52 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
m_msg.Printf( _( "(nets %s and %s)" ),
|
|
|
|
pad->GetNetname(),
|
|
|
|
otherPad->GetNetname() );
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg );
|
|
|
|
drce->SetItems( pad, otherPad );
|
2020-07-30 20:41:52 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
reportViolation( drce, otherPad->GetPosition());
|
2020-07-30 20:41:52 +00:00
|
|
|
}
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
return true;
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
if( testHoles )
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
if( ( pad->FlashLayer( layer ) && otherPad->GetDrillSize().x )
|
|
|
|
|| ( pad->GetDrillSize().x && otherPad->FlashLayer( layer ) ) )
|
|
|
|
{
|
2020-11-02 16:20:00 +00:00
|
|
|
constraint = m_drcEngine->EvalRulesForItems( HOLE_CLEARANCE_CONSTRAINT, pad,
|
|
|
|
otherPad );
|
2020-10-27 17:09:27 +00:00
|
|
|
clearance = constraint.GetValue().Min();
|
|
|
|
|
|
|
|
accountCheck( constraint.GetParentRule() );
|
|
|
|
|
|
|
|
if( padShape->Collide( otherShape.get(), clearance - m_drcEpsilon, &actual, &pos ) )
|
|
|
|
{
|
|
|
|
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
|
|
|
|
|
|
|
|
m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
|
|
|
|
constraint.GetName(),
|
|
|
|
MessageTextFromValue( userUnits(), clearance ),
|
|
|
|
MessageTextFromValue( userUnits(), actual ) );
|
|
|
|
|
|
|
|
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg );
|
|
|
|
drce->SetItems( pad, other );
|
|
|
|
drce->SetViolatingRule( constraint.GetParentRule() );
|
|
|
|
|
|
|
|
reportViolation( drce, (wxPoint) pos );
|
|
|
|
}
|
|
|
|
}
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
// Pads of the same (defined) net get a waiver on clearance tests
|
|
|
|
if( pad->GetNetCode() && otherPad->GetNetCode() == pad->GetNetCode() )
|
|
|
|
testClearance = false;
|
|
|
|
}
|
2020-09-17 16:32:42 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
if( testClearance )
|
|
|
|
{
|
2020-11-02 16:20:00 +00:00
|
|
|
constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, pad, other, layer );
|
2020-10-27 17:09:27 +00:00
|
|
|
clearance = constraint.GetValue().Min();
|
|
|
|
|
|
|
|
accountCheck( constraint );
|
|
|
|
|
|
|
|
if( padShape->Collide( otherShape.get(), clearance - m_drcEpsilon, &actual, &pos ) )
|
2020-09-11 16:24:27 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
|
2020-09-12 19:28:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
|
|
|
|
constraint.GetName(),
|
|
|
|
MessageTextFromValue( userUnits(), clearance ),
|
|
|
|
MessageTextFromValue( userUnits(), actual ) );
|
2020-09-07 12:31:19 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg );
|
|
|
|
drce->SetItems( pad, other );
|
|
|
|
drce->SetViolatingRule( constraint.GetParentRule() );
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
reportViolation( drce, (wxPoint) pos );
|
|
|
|
}
|
|
|
|
}
|
2020-09-29 17:18:19 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
2020-09-29 17:18:19 +00:00
|
|
|
|
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances( )
|
|
|
|
{
|
|
|
|
const int delta = 25; // This is the number of tests between 2 calls to the progress bar
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
size_t count = 0;
|
2020-07-22 23:05:37 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
for( MODULE* module : m_board->Modules() )
|
|
|
|
count += module->Pads().size();
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
reportAux( "Testing %d pads...", count );
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
int ii = 0;
|
|
|
|
|
|
|
|
for( MODULE* module : m_board->Modules() )
|
|
|
|
{
|
|
|
|
for( D_PAD* pad : module->Pads() )
|
|
|
|
{
|
|
|
|
if( !reportProgress( ii++, count, delta ) )
|
2020-09-12 19:28:22 +00:00
|
|
|
break;
|
2020-10-27 17:09:27 +00:00
|
|
|
|
|
|
|
for( PCB_LAYER_ID layer : pad->GetLayerSet().Seq() )
|
|
|
|
{
|
|
|
|
std::shared_ptr<SHAPE> padShape = getShape( pad, layer );
|
|
|
|
|
|
|
|
m_copperTree.QueryColliding( pad, layer, layer,
|
2020-11-02 16:20:00 +00:00
|
|
|
// Filter:
|
2020-10-27 17:09:27 +00:00
|
|
|
[&]( BOARD_ITEM* other ) -> bool
|
|
|
|
{
|
|
|
|
if( other->HasFlag( SKIP_STRUCT ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
2020-11-02 16:20:00 +00:00
|
|
|
// Visitor
|
2020-10-28 13:52:30 +00:00
|
|
|
[&]( BOARD_ITEM* other ) -> bool
|
2020-10-27 17:09:27 +00:00
|
|
|
{
|
2020-10-28 12:24:10 +00:00
|
|
|
return testPadAgainstItem( pad, padShape.get(), layer, other );
|
2020-10-27 17:09:27 +00:00
|
|
|
},
|
|
|
|
m_largestClearance );
|
2020-10-28 17:55:57 +00:00
|
|
|
|
|
|
|
testItemAgainstZones( pad, layer );
|
2020-09-11 16:24:27 +00:00
|
|
|
}
|
2020-10-27 17:09:27 +00:00
|
|
|
|
|
|
|
pad->SetFlags( SKIP_STRUCT );
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-11 16:24:27 +00:00
|
|
|
void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZones()
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-09-18 19:57:54 +00:00
|
|
|
const int delta = 50; // This is the number of tests between 2 calls to the progress bar
|
|
|
|
|
2020-10-10 22:09:00 +00:00
|
|
|
SHAPE_POLY_SET buffer;
|
|
|
|
SHAPE_POLY_SET* boardOutline = nullptr;
|
|
|
|
|
|
|
|
if( m_board->GetBoardPolygonOutlines( buffer ) )
|
|
|
|
boardOutline = &buffer;
|
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
for( int layer_id = F_Cu; layer_id <= B_Cu; ++layer_id )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-09-22 03:40:05 +00:00
|
|
|
PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( layer_id );
|
|
|
|
std::vector<SHAPE_POLY_SET> smoothed_polys;
|
2020-10-28 17:55:57 +00:00
|
|
|
smoothed_polys.resize( m_zones.size() );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// Skip over layers not used on the current board
|
|
|
|
if( !m_board->IsLayerEnabled( layer ) )
|
2020-06-18 16:55:22 +00:00
|
|
|
continue;
|
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
for( size_t ii = 0; ii < m_zones.size(); ii++ )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-10-28 17:55:57 +00:00
|
|
|
if( m_zones[ii]->IsOnLayer( layer ) )
|
|
|
|
m_zones[ii]->BuildSmoothedPoly( smoothed_polys[ii], layer, boardOutline );
|
2020-09-22 03:40:05 +00:00
|
|
|
}
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// iterate through all areas
|
2020-10-28 17:55:57 +00:00
|
|
|
for( size_t ia = 0; ia < m_zones.size(); ia++ )
|
2020-09-22 03:40:05 +00:00
|
|
|
{
|
2020-10-28 17:55:57 +00:00
|
|
|
if( !reportProgress( layer_id * m_zones.size() + ia, B_Cu * m_zones.size(), delta ) )
|
2020-09-22 03:40:05 +00:00
|
|
|
break;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
ZONE_CONTAINER* zoneRef = m_zones[ia];
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
if( !zoneRef->IsOnLayer( layer ) )
|
2020-06-18 16:55:22 +00:00
|
|
|
continue;
|
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// If we are testing a single zone, then iterate through all other zones
|
|
|
|
// Otherwise, we have already tested the zone combination
|
2020-10-28 17:55:57 +00:00
|
|
|
for( size_t ia2 = ia + 1; ia2 < m_zones.size(); ia2++ )
|
2020-09-22 03:40:05 +00:00
|
|
|
{
|
2020-10-28 17:55:57 +00:00
|
|
|
ZONE_CONTAINER* zoneToTest = m_zones[ia2];
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
if( zoneRef == zoneToTest )
|
|
|
|
continue;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// test for same layer
|
|
|
|
if( !zoneToTest->IsOnLayer( layer ) )
|
|
|
|
continue;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// Test for same net
|
|
|
|
if( zoneRef->GetNetCode() == zoneToTest->GetNetCode() && zoneRef->GetNetCode() >= 0 )
|
|
|
|
continue;
|
2020-09-07 12:31:19 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// test for different priorities
|
|
|
|
if( zoneRef->GetPriority() != zoneToTest->GetPriority() )
|
|
|
|
continue;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// test for different types
|
2020-09-21 23:32:07 +00:00
|
|
|
if( zoneRef->GetIsRuleArea() != zoneToTest->GetIsRuleArea() )
|
2020-09-22 03:40:05 +00:00
|
|
|
continue;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// Examine a candidate zone: compare zoneToTest to zoneRef
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// Get clearance used in zone to zone test.
|
2020-11-02 16:20:00 +00:00
|
|
|
auto constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, zoneRef,
|
|
|
|
zoneToTest );
|
2020-09-22 03:40:05 +00:00
|
|
|
int zone2zoneClearance = constraint.GetValue().Min();
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
accountCheck( constraint );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// Keepout areas have no clearance, so set zone2zoneClearance to 1
|
|
|
|
// ( zone2zoneClearance = 0 can create problems in test functions)
|
2020-09-21 23:32:07 +00:00
|
|
|
if( zoneRef->GetIsRuleArea() ) // fixme: really?
|
2020-09-22 03:40:05 +00:00
|
|
|
zone2zoneClearance = 1;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// test for some corners of zoneRef inside zoneToTest
|
|
|
|
for( auto iterator = smoothed_polys[ia].IterateWithHoles(); iterator; iterator++ )
|
|
|
|
{
|
|
|
|
VECTOR2I currentVertex = *iterator;
|
|
|
|
wxPoint pt( currentVertex.x, currentVertex.y );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
if( smoothed_polys[ia2].Contains( currentVertex ) )
|
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_ZONES_INTERSECT );
|
|
|
|
drce->SetItems( zoneRef, zoneToTest );
|
|
|
|
drce->SetViolatingRule( constraint.GetParentRule() );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
reportViolation( drce, pt );
|
2020-09-22 03:40:05 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// test for some corners of zoneToTest inside zoneRef
|
|
|
|
for( auto iterator = smoothed_polys[ia2].IterateWithHoles(); iterator; iterator++ )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-09-22 03:40:05 +00:00
|
|
|
VECTOR2I currentVertex = *iterator;
|
|
|
|
wxPoint pt( currentVertex.x, currentVertex.y );
|
|
|
|
|
|
|
|
if( smoothed_polys[ia].Contains( currentVertex ) )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_ZONES_INTERSECT );
|
|
|
|
drce->SetItems( zoneToTest, zoneRef );
|
|
|
|
drce->SetViolatingRule( constraint.GetParentRule() );
|
2020-09-22 03:40:05 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
reportViolation( drce, pt );
|
2020-06-18 16:55:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
// Iterate through all the segments of refSmoothedPoly
|
|
|
|
std::map<wxPoint, int> conflictPoints;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
for( auto refIt = smoothed_polys[ia].IterateSegmentsWithHoles(); refIt; refIt++ )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-09-22 03:40:05 +00:00
|
|
|
// Build ref segment
|
|
|
|
SEG refSegment = *refIt;
|
|
|
|
|
|
|
|
// Iterate through all the segments in smoothed_polys[ia2]
|
|
|
|
for( auto testIt = smoothed_polys[ia2].IterateSegmentsWithHoles(); testIt; testIt++ )
|
|
|
|
{
|
|
|
|
// Build test segment
|
|
|
|
SEG testSegment = *testIt;
|
|
|
|
wxPoint pt;
|
|
|
|
|
|
|
|
int ax1, ay1, ax2, ay2;
|
|
|
|
ax1 = refSegment.A.x;
|
|
|
|
ay1 = refSegment.A.y;
|
|
|
|
ax2 = refSegment.B.x;
|
|
|
|
ay2 = refSegment.B.y;
|
|
|
|
|
|
|
|
int bx1, by1, bx2, by2;
|
|
|
|
bx1 = testSegment.A.x;
|
|
|
|
by1 = testSegment.A.y;
|
|
|
|
bx2 = testSegment.B.x;
|
|
|
|
by2 = testSegment.B.y;
|
|
|
|
|
|
|
|
int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2,
|
|
|
|
0,
|
|
|
|
ax1, ay1, ax2, ay2,
|
|
|
|
0,
|
|
|
|
zone2zoneClearance,
|
|
|
|
&pt.x, &pt.y );
|
|
|
|
|
|
|
|
if( d < zone2zoneClearance )
|
|
|
|
{
|
|
|
|
if( conflictPoints.count( pt ) )
|
|
|
|
conflictPoints[ pt ] = std::min( conflictPoints[ pt ], d );
|
|
|
|
else
|
|
|
|
conflictPoints[ pt ] = d;
|
|
|
|
}
|
|
|
|
}
|
2020-06-18 16:55:22 +00:00
|
|
|
}
|
2020-09-22 03:40:05 +00:00
|
|
|
|
|
|
|
for( const std::pair<const wxPoint, int>& conflict : conflictPoints )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2020-09-22 03:40:05 +00:00
|
|
|
int actual = conflict.second;
|
2020-10-27 17:09:27 +00:00
|
|
|
std::shared_ptr<DRC_ITEM> drce;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-09-22 03:40:05 +00:00
|
|
|
if( actual <= 0 )
|
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
drce = DRC_ITEM::Create( DRCE_ZONES_INTERSECT );
|
2020-09-22 03:40:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-27 17:09:27 +00:00
|
|
|
drce = DRC_ITEM::Create( DRCE_CLEARANCE );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
|
2020-09-22 03:40:05 +00:00
|
|
|
constraint.GetName(),
|
2020-10-02 20:51:24 +00:00
|
|
|
MessageTextFromValue( userUnits(), zone2zoneClearance ),
|
|
|
|
MessageTextFromValue( userUnits(), conflict.second ) );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg );
|
2020-09-22 03:40:05 +00:00
|
|
|
}
|
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
drce->SetItems( zoneRef, zoneToTest );
|
|
|
|
drce->SetViolatingRule( constraint.GetParentRule() );
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2020-10-27 17:09:27 +00:00
|
|
|
reportViolation( drce, conflict.first );
|
2020-09-22 03:40:05 +00:00
|
|
|
}
|
2020-06-18 16:55:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
int DRC_TEST_PROVIDER_COPPER_CLEARANCE::GetNumPhases() const
|
|
|
|
{
|
2020-10-28 17:55:57 +00:00
|
|
|
return 5;
|
2020-09-14 17:54:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-13 10:37:20 +00:00
|
|
|
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_COPPER_CLEARANCE::GetConstraintTypes() const
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2020-11-02 16:20:00 +00:00
|
|
|
return { CLEARANCE_CONSTRAINT };
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
|
2020-06-17 22:36:54 +00:00
|
|
|
|
|
|
|
namespace detail
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2020-09-11 16:24:27 +00:00
|
|
|
static DRC_REGISTER_TEST_PROVIDER<DRC_TEST_PROVIDER_COPPER_CLEARANCE> dummy;
|
2020-07-15 16:23:56 +00:00
|
|
|
}
|