diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index da6f3eb650..6aea303adb 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -1167,20 +1167,42 @@ void ZONE_CONTAINER::GetColinearCorners( BOARD* aBoard, std::set& aCor { int epsilon = Millimeter2iu( 0.001 ); + // Things get messy when zone of different nets intersect. To do it right we'd need to + // run our colinear test with the final filled regions rather than the outline regions. + // However, since there's no order dependance the only way to do that is to iterate + // through successive zone fills until the results are no longer changing -- and that's + // not going to happen. So we punt and ignore any "messy" corners. + std::set colinearCorners; + std::set messyCorners; + for( ZONE_CONTAINER* candidate : aBoard->Zones() ) { - if( candidate != this - && candidate->GetNetCode() == GetNetCode() - && candidate->GetLayerSet() == GetLayerSet() - && candidate->GetIsKeepout() == GetIsKeepout() ) + if( candidate == this ) + continue; + + if( candidate->GetLayerSet() != GetLayerSet() ) + continue; + + if( candidate->GetIsKeepout() != GetIsKeepout() ) + continue; + + for( auto iter = m_Poly->CIterate(); iter; iter++ ) { - for( auto iter = m_Poly->CIterate(); iter; iter++ ) + if( candidate->m_Poly->Collide( iter.Get(), epsilon ) ) { - if( candidate->m_Poly->Collide( iter.Get(), epsilon ) ) - aCorners.insert( VECTOR2I( iter.Get() ) ); + if( candidate->GetNetCode() == GetNetCode() ) + colinearCorners.insert( VECTOR2I( iter.Get() ) ); + else + messyCorners.insert( VECTOR2I( iter.Get() ) ); } } } + + for( VECTOR2I corner : colinearCorners ) + { + if( messyCorners.count( corner ) == 0 ) + aCorners.insert( corner ); + } } diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 9168e188f0..22f7b000d9 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -260,7 +260,7 @@ public: * merged due to other parameters such as fillet radius. The copper pour will end up * effectively merged though, so we want to keep the corners of such intersections sharp. */ - void GetColinearCorners( BOARD* aBoard, std::set& aCorners ); + void GetColinearCorners( BOARD* aBoard, std::set& colinearCorners ); /** * Function TransformSolidAreasShapesToPolygonSet