From fdfe5eabfb4558e4ca4d84b47cb3b89e77ddcabf Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 21 Mar 2019 15:27:05 +0100 Subject: [PATCH] Fix incorrect detection of filled zones changes in DRC check. Commit 6006703798 fixed a crash but broke the filled zones changes detection. Filled zones were always seen as not up to date due to the fact the filled areas were cleared too early. The up to date detection is also optimized: the old filled polygons are no longer stored. Instead of, the MD5_HASH is calculated and stored before clearing the filled polygons. --- pcbnew/class_zone.h | 15 +++++++++++++++ pcbnew/connectivity/connectivity_data.h | 4 +--- pcbnew/zone_filler.cpp | 11 +++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 97968dcb02..37feec3aef 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -696,6 +696,19 @@ public: bool GetHV45() const { return m_hv45; } void SetHV45( bool aConstrain ) { m_hv45 = aConstrain; } + /** @return the hash value previously calculated by BuildHashValue(). + * used in zone filling calculations + */ + MD5_HASH GetHashValue() { return m_filledPolysHash; } + + /** Build the hash value of m_FilledPolysList, and store it internally + * in m_filledPolysHash. + * Used in zone filling calculations, to know if m_FilledPolysList is up to date. + */ + void BuildHashValue() { m_filledPolysHash = m_FilledPolysList.GetHash(); } + + + #if defined(DEBUG) virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } #endif @@ -776,6 +789,8 @@ private: */ SHAPE_POLY_SET m_FilledPolysList; SHAPE_POLY_SET m_RawPolysList; + MD5_HASH m_filledPolysHash; // A hash value used in zone filling calculations + // to see if the filled areas are up to date HATCH_STYLE m_hatchStyle; // hatch style, see enum above int m_hatchPitch; // for DIAGONAL_EDGE, distance between 2 hatch lines diff --git a/pcbnew/connectivity/connectivity_data.h b/pcbnew/connectivity/connectivity_data.h index 51575b438c..dca307904e 100644 --- a/pcbnew/connectivity/connectivity_data.h +++ b/pcbnew/connectivity/connectivity_data.h @@ -61,12 +61,10 @@ struct CN_DISJOINT_NET_ENTRY struct CN_ZONE_ISOLATED_ISLAND_LIST { CN_ZONE_ISOLATED_ISLAND_LIST( ZONE_CONTAINER* aZone ) : - m_zone( aZone ), - m_lastPolys( aZone->GetFilledPolysList() ) + m_zone( aZone ) {} ZONE_CONTAINER* m_zone; - const SHAPE_POLY_SET m_lastPolys; std::vector m_islands; }; diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index 8c37ec6983..47371533e3 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -99,9 +99,16 @@ bool ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) if( m_commit ) m_commit->Modify( zone ); + // calculate the hash value for filled areas. it will be used later + // to know if the current filled areas are up to date + zone->BuildHashValue(); + + // Add the zone to the list of zones to test or refill + toFill.emplace_back( CN_ZONE_ISOLATED_ISLAND_LIST(zone) ); + // Remove existing fill first to prevent drawing invalid polygons + // on some platforms zone->UnFill(); - toFill.emplace_back( CN_ZONE_ISOLATED_ISLAND_LIST(zone) ); } if( m_progressReporter ) @@ -202,7 +209,7 @@ bool ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) zone.m_zone->SetFilledPolysList( poly ); - if( aCheck && zone.m_lastPolys.GetHash() != poly.GetHash() ) + if( aCheck && zone.m_zone->GetHashValue() != poly.GetHash() ) outOfDate = true; }