From b564d0713c50e50282a0545ee23bb3ec51906cfd Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 12 Nov 2023 20:19:09 +0100 Subject: [PATCH] DRC: fix one of some things that can create false positive. in bool shapeNeedsUpdate(), if a shape is a rectangle and the other is a polygon, we need to try to convert the polygon to a rectangle for comparison, because some transforms ( and especially PCB_SHAPE::Normalize() ) can convert a polygon to a rectangle So a poly and a rectangle can be in fact the same shape Partial fix of bug 16075. --- .../drc/drc_test_provider_library_parity.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pcbnew/drc/drc_test_provider_library_parity.cpp b/pcbnew/drc/drc_test_provider_library_parity.cpp index f1b8dbdac5..9c6c847180 100644 --- a/pcbnew/drc/drc_test_provider_library_parity.cpp +++ b/pcbnew/drc/drc_test_provider_library_parity.cpp @@ -352,6 +352,27 @@ bool padNeedsUpdate( const PAD* a, const PAD* b, REPORTER* aReporter ) bool shapeNeedsUpdate( const PCB_SHAPE* a, const PCB_SHAPE* b ) { + // Preliminary test: if a shape is a rectangle and the other is a polygon, + // try to convert the polygon to a rectangle for comparison, because some transforms + // ( and especially PCB_SHAPE::Normalize() ) can convert a polygon to a rectangle + // So a poly and a rectangle can be in fact the same shape + if( a->GetShape() == SHAPE_T::POLY && b->GetShape() == SHAPE_T::RECTANGLE ) + { + PCB_SHAPE rect_test( *a ); + rect_test.Normalize(); + + if( rect_test.GetShape() == SHAPE_T::RECTANGLE ) + return shapeNeedsUpdate( &rect_test, b ); + } + else if( a->GetShape() == SHAPE_T::RECTANGLE && b->GetShape() == SHAPE_T::POLY ) + { + PCB_SHAPE rect_test( *b ); + rect_test.Normalize(); + + if( rect_test.GetShape() == SHAPE_T::RECTANGLE ) + return shapeNeedsUpdate( a, &rect_test ); + } + REPORTER* aReporter = nullptr; bool diff = false;