From f0d7a09af9cc5d2b7699bf51f7935d007db42a22 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 --- 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 f348e4b01d..51cad13df7 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -1832,54 +1832,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(), - wxPoint(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 961418804e..76c6ff89e9 100644 --- a/pcbnew/board.h +++ b/pcbnew/board.h @@ -865,31 +865,6 @@ public: ZONE* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer, wxPoint 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 2a5222cbcb..8ee4d5a1eb 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 @@ -155,27 +152,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