From f0e4448a9d85a4def1aa1055df5e9790ee7aea07 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 18 Feb 2022 09:29:00 -0800 Subject: [PATCH] Remove broken call to normalize outlines We should never be editing the user's outlines for them. This creates broken zones that are hard to repair. In this case, there was also a secondary zone with no outline that would crash the system Fixes https://gitlab.com/kicad/code/kicad/issues/10904 (cherry picked from commit f0d7a09af9cc5d2b7699bf51f7935d007db42a22) --- pcbnew/board.cpp | 48 ------------------------------------ pcbnew/board.h | 25 ------------------- pcbnew/edit_zone_helpers.cpp | 24 ------------------ 3 files changed, 97 deletions(-) diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 42c1df5a09..2311f0f87b 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -1922,54 +1922,6 @@ ZONE* BOARD::AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ } -bool BOARD::NormalizeAreaPolygon( PICKED_ITEMS_LIST * aNewZonesList, ZONE* aCurrArea ) -{ - // mark all areas as unmodified except this one, if modified - for( ZONE* zone : m_zones ) - zone->SetLocalFlags( 0 ); - - aCurrArea->SetLocalFlags( 1 ); - - if( aCurrArea->Outline()->IsSelfIntersecting() ) - { - aCurrArea->UnHatchBorder(); - - // Normalize copied area and store resulting number of polygons - int n_poly = aCurrArea->Outline()->NormalizeAreaOutlines(); - - // If clipping has created some polygons, we must add these new copper areas. - if( n_poly > 1 ) - { - ZONE* NewArea; - - // Move the newly created polygons to new areas, removing them from the current area - for( int ip = 1; ip < n_poly; ip++ ) - { - // Create new copper area and copy poly into it - SHAPE_POLY_SET* new_p = new SHAPE_POLY_SET( aCurrArea->Outline()->UnitSet( ip ) ); - NewArea = AddArea( aNewZonesList, aCurrArea->GetNetCode(), aCurrArea->GetLayer(), - VECTOR2I( 0, 0 ), aCurrArea->GetHatchStyle() ); - - // remove the poly that was automatically created for the new area - // and replace it with a poly from NormalizeAreaOutlines - delete NewArea->Outline(); - NewArea->SetOutline( new_p ); - NewArea->HatchBorder(); - NewArea->SetLocalFlags( 1 ); - } - - SHAPE_POLY_SET* new_p = new SHAPE_POLY_SET( aCurrArea->Outline()->UnitSet( 0 ) ); - delete aCurrArea->Outline(); - aCurrArea->SetOutline( new_p ); - } - } - - aCurrArea->HatchBorder(); - - return true; -} - - bool BOARD::GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines, OUTLINE_ERROR_HANDLER* aErrorHandler ) { diff --git a/pcbnew/board.h b/pcbnew/board.h index 610526a5d2..5342320a94 100644 --- a/pcbnew/board.h +++ b/pcbnew/board.h @@ -874,31 +874,6 @@ public: ZONE* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer, VECTOR2I aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch ); - /** - * Process an area that has been modified, by normalizing its polygon against itself. - * i.e. convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s) - * - * This may change the number and order of copper areas in the net. - * - * @param aNewZonesList is a PICKED_ITEMS_LIST where to store new created areas pickers. - * @param aCurrArea is the zone to process. - * @return true if changes are made. - */ - bool NormalizeAreaPolygon( PICKED_ITEMS_LIST* aNewZonesList, ZONE* aCurrArea ); - - /** - * Process an area that has been modified, by normalizing its polygon - * and merging the intersecting polygons for any other areas on the same net. - * - * This may change the number and order of copper areas in the net. - * - * @param aModifiedZonesList is a #PICKED_ITEMS_LIST where to store deleted or added areas - * (useful in undo commands can be NULL). - * @param modified_area is the area to test. - * @return true if some areas modified. - */ - bool OnAreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList, ZONE* modified_area ); - /** * Test for intersection of 2 copper areas. * diff --git a/pcbnew/edit_zone_helpers.cpp b/pcbnew/edit_zone_helpers.cpp index ad61f0a5a2..926bd0a7a3 100644 --- a/pcbnew/edit_zone_helpers.cpp +++ b/pcbnew/edit_zone_helpers.cpp @@ -101,9 +101,6 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE* aZone ) if( net ) // net == NULL should not occur aZone->SetNetCode( net->GetNetCode() ); - // Combine zones if possible - GetBoard()->OnAreaPolygonModified( &deletedList, aZone ); - UpdateCopyOfZonesList( pickedList, deletedList, GetBoard() ); // refill zones with the new properties applied @@ -150,27 +147,6 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE* aZone ) } -bool BOARD::OnAreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList, ZONE* modified_area ) -{ - // clip polygon against itself - bool modified = NormalizeAreaPolygon( aModifiedZonesList, modified_area ); - - // Test for bad areas: all zones must have more than 2 corners: - // Note: should not happen, but just in case. - for( ZONE* zone : m_zones ) - { - if( zone->GetNumCorners() < 3 ) - { - ITEM_PICKER picker( nullptr, zone, UNDO_REDO::DELETED ); - aModifiedZonesList->PushItem( picker ); - zone->SetFlags( STRUCT_DELETED ); - } - } - - return modified; -} - - bool BOARD::TestZoneIntersection( ZONE* aZone1, ZONE* aZone2 ) { // see if areas are on same layer