From 0a4c8cd45c002cc3fbb5d9d05a573cde1a08feaa Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Fri, 3 Jul 2020 18:37:08 +0200 Subject: [PATCH] drc_proto: import latest Jeff & Jon's changes + update copyright headers --- qa/drc_proto/drc_engine.h | 3 +- qa/drc_proto/drc_item.h | 2 +- qa/drc_proto/drc_proto_test.cpp | 23 ++++++++ qa/drc_proto/drc_provider.h | 3 +- .../drc_test_provider_clearance_base.cpp | 56 ++++++++++++++----- .../drc_test_provider_clearance_base.h | 8 ++- .../drc_test_provider_copper_clearance.cpp | 26 +++++---- 7 files changed, 89 insertions(+), 32 deletions(-) diff --git a/qa/drc_proto/drc_engine.h b/qa/drc_proto/drc_engine.h index d15d090948..481b9e32c7 100644 --- a/qa/drc_proto/drc_engine.h +++ b/qa/drc_proto/drc_engine.h @@ -1,8 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2007-2016 Dick Hollenbeck, dick@softplc.com - * Copyright (C) 2017-2019 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/qa/drc_proto/drc_item.h b/qa/drc_proto/drc_item.h index bc9bd013fb..6430093edf 100644 --- a/qa/drc_proto/drc_item.h +++ b/qa/drc_proto/drc_item.h @@ -57,7 +57,7 @@ public: * Function GetErrorText * returns the string form of a drc error code. */ - ::wxString GetErrorText( int aErrorCode = -1, bool aTranslate = true ) const override { return ""; } // fixme + ::wxString GetErrorText( int aErrorCode = -1, bool aTranslate = true ) const { return ""; } // fixme /** * Function ShowHtml diff --git a/qa/drc_proto/drc_proto_test.cpp b/qa/drc_proto/drc_proto_test.cpp index 78f3ae656a..3a817d081c 100644 --- a/qa/drc_proto/drc_proto_test.cpp +++ b/qa/drc_proto/drc_proto_test.cpp @@ -1,3 +1,26 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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 + */ + #include #include diff --git a/qa/drc_proto/drc_provider.h b/qa/drc_proto/drc_provider.h index ebd67faa75..6e731c66d4 100644 --- a/qa/drc_proto/drc_provider.h +++ b/qa/drc_proto/drc_provider.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,7 +21,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - #ifndef DRC_PROVIDER__H #define DRC_PROVIDER__H diff --git a/qa/drc_proto/drc_test_provider_clearance_base.cpp b/qa/drc_proto/drc_test_provider_clearance_base.cpp index 958d96e820..cbf9a6f2a3 100644 --- a/qa/drc_proto/drc_test_provider_clearance_base.cpp +++ b/qa/drc_proto/drc_test_provider_clearance_base.cpp @@ -1,3 +1,27 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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 + */ + + #include #include #include @@ -21,11 +45,14 @@ wxPoint test::DRC_TEST_PROVIDER_CLEARANCE_BASE::getLocation( TRACK* aTrack, ZONE { SHAPE_POLY_SET* conflictOutline; + PCB_LAYER_ID l = aTrack->GetLayer(); + if( aConflictZone->IsFilled() ) - conflictOutline = const_cast( &aConflictZone->GetFilledPolysList() ); + conflictOutline = const_cast( &aConflictZone->GetFilledPolysList( l ) ); else conflictOutline = aConflictZone->Outline(); + wxPoint pt1 = aTrack->GetPosition(); wxPoint pt2 = aTrack->GetEnd(); @@ -118,7 +145,7 @@ bool test::DRC_TEST_PROVIDER_CLEARANCE_BASE::checkClearanceSegmToPad( const SEG& SHAPE_RECT padShape( padBBox.GetPosition(), padBBox.GetWidth(), padBBox.GetHeight() ); int actual; - if( padShape.DoCollide( refSeg, minClearance + widths, &actual ) ) + if( padShape.Collide( refSeg, minClearance + widths, &actual ) ) { *aActualDist = std::max( 0, actual - widths ); return false; @@ -158,27 +185,25 @@ bool test::DRC_TEST_PROVIDER_CLEARANCE_BASE::checkClearancePadToPad( D_PAD* aRef if( center2center - aRefPad->GetBoundingRadius() - aPad->GetBoundingRadius() >= aMinClearance ) return true; - // JEY TODO: - // TOM TODO: MTV only works as a proxy for actual-distance for convex shapes - - VECTOR2I mtv; - VECTOR2I maxMtv( 0, 0 ); + int actual = INT_MAX; for( const std::shared_ptr& aShape : aRefPad->GetEffectiveShapes() ) { for( const std::shared_ptr& bShape : aPad->GetEffectiveShapes() ) { - if( aShape->Collide( bShape.get(), aMinClearance, mtv ) ) - { - if( mtv.SquaredEuclideanNorm() > maxMtv.SquaredEuclideanNorm() ) - maxMtv = mtv; - } + int this_dist; + + if( aShape->Collide( bShape.get(), aMinClearance, &this_dist ) ) + actual = std::min( actual, this_dist ); } } - if( maxMtv.x > 0 || maxMtv.y > 0 ) + if( actual < INT_MAX ) { - *aActual = std::max( 0, aMinClearance - maxMtv.EuclideanNorm() ); + // returns the actual clearance (clearance < aMinClearance) for diags: + if( aActual ) + *aActual = std::max( 0, actual ); + return false; } @@ -186,6 +211,7 @@ bool test::DRC_TEST_PROVIDER_CLEARANCE_BASE::checkClearancePadToPad( D_PAD* aRef } + bool test::DRC_TEST_PROVIDER_CLEARANCE_BASE::poly2segmentDRC( wxPoint* aTref, int aTrefCount, wxPoint aSegStart, wxPoint aSegEnd, int aDist, int* aActual ) { @@ -222,6 +248,7 @@ bool test::DRC_TEST_PROVIDER_CLEARANCE_BASE::poly2segmentDRC( wxPoint* aTref, in } +#if 0 /** * compare 2 convex polygons and return true if distance > aDist (if no error DRC) * i.e if for each edge of the first polygon distance from each edge of the other polygon @@ -274,3 +301,4 @@ bool test::DRC_TEST_PROVIDER_CLEARANCE_BASE::poly2polyDRC( wxPoint* aTref, int a return true; } +#endif \ No newline at end of file diff --git a/qa/drc_proto/drc_test_provider_clearance_base.h b/qa/drc_proto/drc_test_provider_clearance_base.h index e98ed3136b..b8ee633997 100644 --- a/qa/drc_proto/drc_test_provider_clearance_base.h +++ b/qa/drc_proto/drc_test_provider_clearance_base.h @@ -1,7 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com + * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -55,8 +57,8 @@ protected: bool checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, int aMinClearance, int* aActual ); bool poly2segmentDRC( wxPoint* aTref, int aTrefCount, wxPoint aSegStart, wxPoint aSegEnd, int aDist, int* aActual ); - bool poly2polyDRC( wxPoint* aTref, int aTrefCount, wxPoint* aTtest, int aTtestCount, - int aAllowedDist, int* actualDist ); + //bool poly2polyDRC( wxPoint* aTref, int aTrefCount, wxPoint* aTtest, int aTtestCount, + // int aAllowedDist, int* actualDist ); wxPoint getLocation( TRACK* aTrack, const SEG& aConflictSeg ); wxPoint getLocation( TRACK* aTrack, ZONE_CONTAINER* aConflictZone ); diff --git a/qa/drc_proto/drc_test_provider_copper_clearance.cpp b/qa/drc_proto/drc_test_provider_copper_clearance.cpp index 4adf7202f9..59711b922d 100644 --- a/qa/drc_proto/drc_test_provider_copper_clearance.cpp +++ b/qa/drc_proto/drc_test_provider_copper_clearance.cpp @@ -551,21 +551,26 @@ void test::DRC_TEST_PROVIDER_COPPER_CLEARANCE::doTrackDrc( TRACK* aRefSeg, TRACK for( ZONE_CONTAINER* zone : m_board->Zones() ) { - if( zone->GetFilledPolysList().IsEmpty() || zone->GetIsKeepout() ) + if( !( refLayerSet & zone->GetLayerSet() ).any() || zone->GetIsKeepout() ) continue; - if( !( refLayerSet & zone->GetLayerSet() ).any() ) - continue; + for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() ) + { + if( zone->GetFilledPolysList( layer ).IsEmpty() ) + continue; - if( zone->GetNetCode() && zone->GetNetCode() == aRefSeg->GetNetCode() ) - continue; + if( zone->GetNetCode() && zone->GetNetCode() == aRefSeg->GetNetCode() ) + continue; - auto rule = m_drcEngine->EvalRulesForItems( test::DRC_RULE_ID_T::DRC_RULE_ID_CLEARANCE, aRefSeg, zone ); - auto minClearance = rule->GetConstraint().GetValue().Min(); + // fixme: per-layer onLayer() property - int widths = refSegWidth / 2; - int center2centerAllowed = minClearance + widths; - SHAPE_POLY_SET* outline = const_cast( &zone->GetFilledPolysList() ); + auto rule = m_drcEngine->EvalRulesForItems( test::DRC_RULE_ID_T::DRC_RULE_ID_CLEARANCE, aRefSeg, zone ); + auto minClearance = rule->GetConstraint().GetValue().Min(); + + int widths = refSegWidth / 2; + int center2centerAllowed = minClearance + widths; + SHAPE_POLY_SET* outline = + const_cast( &zone->GetFilledPolysList( layer ) ); SEG::ecoord center2center_squared = outline->SquaredDistance( testSeg ); @@ -592,6 +597,7 @@ void test::DRC_TEST_PROVIDER_COPPER_CLEARANCE::doTrackDrc( TRACK* aRefSeg, TRACK ReportWithMarker( drcItem, getLocation( aRefSeg, zone ) ); } } + } } // fixme: board edge clearance to another rule