Footprint disallow layer checking needs to be based on courtyards.

Fixes https://gitlab.com/kicad/code/kicad/issues/7620
This commit is contained in:
Jeff Young 2021-02-20 13:25:16 +00:00
parent 0337c42d25
commit e89f9db438
7 changed files with 35 additions and 21 deletions

View File

@ -380,7 +380,7 @@ public:
return bbox; return bbox;
} }
void GenerateBBoxCache() void GenerateBBoxCache() const
{ {
m_bbox.Compute( m_points ); m_bbox.Compute( m_points );
@ -787,7 +787,7 @@ private:
int m_width; int m_width;
/// cached bounding box /// cached bounding box
BOX2I m_bbox; mutable BOX2I m_bbox;
}; };

View File

@ -1141,7 +1141,7 @@ public:
* @note These caches **must** be built before a group of calls to Contains(). They are * @note These caches **must** be built before a group of calls to Contains(). They are
* **not** kept up-to-date by editing actions. * **not** kept up-to-date by editing actions.
*/ */
void BuildBBoxCaches(); void BuildBBoxCaches() const;
const BOX2I BBoxFromCaches() const; const BOX2I BBoxFromCaches() const;

View File

@ -1525,14 +1525,14 @@ bool SHAPE_POLY_SET::CollideEdge( const VECTOR2I& aPoint,
} }
void SHAPE_POLY_SET::BuildBBoxCaches() void SHAPE_POLY_SET::BuildBBoxCaches() const
{ {
for( int polygonIdx = 0; polygonIdx < OutlineCount(); polygonIdx++ ) for( int polygonIdx = 0; polygonIdx < OutlineCount(); polygonIdx++ )
{ {
Outline( polygonIdx ).GenerateBBoxCache(); COutline( polygonIdx ).GenerateBBoxCache();
for( int holeIdx = 0; holeIdx < HoleCount( polygonIdx ); holeIdx++ ) for( int holeIdx = 0; holeIdx < HoleCount( polygonIdx ); holeIdx++ )
Hole( polygonIdx, holeIdx ).GenerateBBoxCache(); CHole( polygonIdx, holeIdx ).GenerateBBoxCache();
} }
} }

View File

@ -32,6 +32,7 @@
#include <drc/drc_rule_condition.h> #include <drc/drc_rule_condition.h>
#include <drc/drc_test_provider.h> #include <drc/drc_test_provider.h>
#include <track.h> #include <track.h>
#include <footprint.h>
#include <geometry/shape.h> #include <geometry/shape.h>
#include <geometry/shape_segment.h> #include <geometry/shape_segment.h>
#include <geometry/shape_null.h> #include <geometry/shape_null.h>
@ -867,7 +868,20 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintId, const BOAR
return false; return false;
} }
if( !( c->layerTest & a->GetLayerSet() ).any() ) LSET itemLayers = a->GetLayerSet();
if( a->Type() == PCB_FOOTPRINT_T )
{
const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( a );
if( !footprint->GetPolyCourtyardFront().IsEmpty() )
itemLayers |= LSET::FrontMask();
if( !footprint->GetPolyCourtyardBack().IsEmpty() )
itemLayers |= LSET::BackMask();
}
if( !( c->layerTest & itemLayers ).any() )
{ {
if( implicit ) if( implicit )
{ {

View File

@ -141,8 +141,8 @@ void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances()
break; break;
FOOTPRINT* footprint = *it1; FOOTPRINT* footprint = *it1;
SHAPE_POLY_SET& footprintFront = footprint->GetPolyCourtyardFront(); const SHAPE_POLY_SET& footprintFront = footprint->GetPolyCourtyardFront();
SHAPE_POLY_SET& footprintBack = footprint->GetPolyCourtyardBack(); const SHAPE_POLY_SET& footprintBack = footprint->GetPolyCourtyardBack();
if( footprintFront.OutlineCount() == 0 && footprintBack.OutlineCount() == 0 ) if( footprintFront.OutlineCount() == 0 && footprintBack.OutlineCount() == 0 )
continue; // No courtyards defined continue; // No courtyards defined
@ -156,8 +156,8 @@ void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances()
for( auto it2 = it1 + 1; it2 != m_board->Footprints().end(); it2++ ) for( auto it2 = it1 + 1; it2 != m_board->Footprints().end(); it2++ )
{ {
FOOTPRINT* test = *it2; FOOTPRINT* test = *it2;
SHAPE_POLY_SET& testFront = test->GetPolyCourtyardFront(); const SHAPE_POLY_SET& testFront = test->GetPolyCourtyardFront();
SHAPE_POLY_SET& testBack = test->GetPolyCourtyardBack(); const SHAPE_POLY_SET& testBack = test->GetPolyCourtyardBack();
DRC_CONSTRAINT constraint; DRC_CONSTRAINT constraint;
int clearance; int clearance;
int actual; int actual;

View File

@ -184,7 +184,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
{ {
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_COURTYARD ); gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_COURTYARD );
SHAPE_POLY_SET& courtyard = onBack ? footprint->GetPolyCourtyardBack() const SHAPE_POLY_SET& courtyard = onBack ? footprint->GetPolyCourtyardBack()
: footprint->GetPolyCourtyardFront(); : footprint->GetPolyCourtyardFront();
for( int ii = 0; ii < courtyard.OutlineCount(); ii++ ) for( int ii = 0; ii < courtyard.OutlineCount(); ii++ )

View File

@ -673,8 +673,8 @@ public:
* *
* @return the courtyard polygon. * @return the courtyard polygon.
*/ */
SHAPE_POLY_SET& GetPolyCourtyardFront() { return m_poly_courtyard_front; } const SHAPE_POLY_SET& GetPolyCourtyardFront() const { return m_poly_courtyard_front; }
SHAPE_POLY_SET& GetPolyCourtyardBack() { return m_poly_courtyard_back; } const SHAPE_POLY_SET& GetPolyCourtyardBack() const { return m_poly_courtyard_back; }
/** /**
* Build complex polygons of the courtyard areas from graphic items on the courtyard layers. * Build complex polygons of the courtyard areas from graphic items on the courtyard layers.