From 686f1b878bbf07f07927834596f1344d04848287 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 14 May 2018 09:25:26 -0700 Subject: [PATCH] Prevent re-testing DRC on zones We only need to test zone connections once, so we skip the double-check from the nested loop unless we are only checking a single zone. Then the second loop needs to iterate over the full list of zones. --- pcbnew/drc.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index 9b4591f273..75fb5f495a 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -216,13 +216,19 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ) BOARD_COMMIT commit( m_pcbEditorFrame ); int nerrors = 0; + std::vector smoothed_polys; + smoothed_polys.resize( board->GetAreaCount() ); + + for( int ia = 0; ia < board->GetAreaCount(); ia++ ) + { + ZONE_CONTAINER* zoneRef = board->GetArea( ia ); + zoneRef->BuildSmoothedPoly( smoothed_polys[ia] ); + } + // iterate through all areas for( int ia = 0; ia < board->GetAreaCount(); ia++ ) { ZONE_CONTAINER* zoneRef = board->GetArea( ia ); - SHAPE_POLY_SET refSmoothedPoly; - - zoneRef->BuildSmoothedPoly( refSmoothedPoly ); if( !zoneRef->IsOnCopperLayer() ) continue; @@ -231,12 +237,11 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ) if( aZone && ( aZone != zoneRef) ) continue; - for( int ia2 = 0; ia2 < board->GetAreaCount(); ia2++ ) + // If we are testing a single zone, then iterate through all other zones + // Otherwise, we have already tested the zone combination + for( int ia2 = ( aZone ? 0 : ia + 1 ); ia2 < board->GetAreaCount(); ia2++ ) { ZONE_CONTAINER* zoneToTest = board->GetArea( ia2 ); - SHAPE_POLY_SET testSmoothedPoly; - - zoneToTest->BuildSmoothedPoly( testSmoothedPoly ); if( zoneRef == zoneToTest ) continue; @@ -270,12 +275,12 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ) zone2zoneClearance = 1; // test for some corners of zoneRef inside zoneToTest - for( auto iterator = refSmoothedPoly.IterateWithHoles(); iterator; iterator++ ) + for( auto iterator = smoothed_polys[ia].IterateWithHoles(); iterator; iterator++ ) { VECTOR2I currentVertex = *iterator; wxPoint pt( currentVertex.x, currentVertex.y ); - if( testSmoothedPoly.Contains( currentVertex ) ) + if( smoothed_polys[ia2].Contains( currentVertex ) ) { if( aCreateMarkers ) commit.Add( newMarker( pt, zoneRef, zoneToTest, DRCE_ZONES_INTERSECT ) ); @@ -285,12 +290,12 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ) } // test for some corners of zoneToTest inside zoneRef - for( auto iterator = testSmoothedPoly.IterateWithHoles(); iterator; iterator++ ) + for( auto iterator = smoothed_polys[ia2].IterateWithHoles(); iterator; iterator++ ) { VECTOR2I currentVertex = *iterator; wxPoint pt( currentVertex.x, currentVertex.y ); - if( refSmoothedPoly.Contains( currentVertex ) ) + if( smoothed_polys[ia].Contains( currentVertex ) ) { if( aCreateMarkers ) commit.Add( newMarker( pt, zoneToTest, zoneRef, DRCE_ZONES_INTERSECT ) ); @@ -302,13 +307,13 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ) // Iterate through all the segments of refSmoothedPoly std::set conflictPoints; - for( auto refIt = refSmoothedPoly.IterateSegmentsWithHoles(); refIt; refIt++ ) + for( auto refIt = smoothed_polys[ia].IterateSegmentsWithHoles(); refIt; refIt++ ) { // Build ref segment SEG refSegment = *refIt; - // Iterate through all the segments in testSmoothedPoly - for( auto testIt = testSmoothedPoly.IterateSegmentsWithHoles(); testIt; testIt++ ) + // Iterate through all the segments in smoothed_polys[ia2] + for( auto testIt = smoothed_polys[ia2].IterateSegmentsWithHoles(); testIt; testIt++ ) { // Build test segment SEG testSegment = *testIt;