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.
This commit is contained in:
jean-pierre charras 2019-03-21 15:27:05 +01:00
parent 4c7672b581
commit aa5a2225e7
3 changed files with 26 additions and 6 deletions

View File

@ -680,6 +680,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
@ -754,6 +767,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

View File

@ -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<int> m_islands;
};

View File

@ -99,9 +99,16 @@ bool ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
if( m_commit )
m_commit->Modify( zone );
// Remove existing fill first to prevent drawing invalid polygons
zone->UnFill();
// 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();
}
if( m_progressReporter )
@ -202,7 +209,7 @@ bool ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> 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;
}