From 15dcdd04df5341e75cb3f1e5cd33bc888a0e3da6 Mon Sep 17 00:00:00 2001 From: mzn Date: Fri, 19 Jun 2015 15:41:46 +0300 Subject: [PATCH] refs #570: fix priority queue. --- src/HYDROData/HYDROData_CalculationCase.cxx | 2 +- src/HYDROData/HYDROData_PriorityQueue.cxx | 21 ++++++++++++--------- src/HYDROData/HYDROData_PriorityQueue.h | 6 +++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 4fd97082..2a124fb5 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -345,7 +345,7 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume QMap aRegionsMap; //object name to region QMap aRegionNameToObjNameMap; QString aZonesPref = CALCULATION_ZONES_PREF; - HYDROData_PriorityQueue aPr( this, DataTag_CustomRules ); + HYDROData_PriorityQueue aPr( this, theLandCover ? DataTag_CustomLandCoverRules : DataTag_CustomRules ); // 1. First we create a default region for each object included into the calculation case HYDROData_SequenceOfObjects anObjects = theLandCover ? GetLandCovers() : GetGeometryObjects(); diff --git a/src/HYDROData/HYDROData_PriorityQueue.cxx b/src/HYDROData/HYDROData_PriorityQueue.cxx index 43d39df3..12d39ce6 100644 --- a/src/HYDROData/HYDROData_PriorityQueue.cxx +++ b/src/HYDROData/HYDROData_PriorityQueue.cxx @@ -27,10 +27,11 @@ HYDROData_PriorityQueue::HYDROData_PriorityQueue( HYDROData_CalculationCase* theCalcCase, Standard_Integer aTag ) { - myGeomObjects = theCalcCase->GetGeometryObjects(); - for( int i=myGeomObjects.Lower(), n=myGeomObjects.Upper(); i<=n; i++ ) + bool isLandCover = aTag == HYDROData_CalculationCase::DataTag_CustomLandCoverRules; + myObjects = isLandCover ? theCalcCase->GetLandCovers() : theCalcCase->GetGeometryObjects(); + for( int i=myObjects.Lower(), n=myObjects.Upper(); i<=n; i++ ) { - Handle(HYDROData_Entity) anObj = myGeomObjects.Value( i ); + Handle(HYDROData_Entity) anObj = myObjects.Value( i ); if( !anObj.IsNull() ) { QString anObjName = anObj->GetName(); @@ -49,9 +50,9 @@ Handle(HYDROData_Entity) HYDROData_PriorityQueue::GetMostPriorityObject( const Q HYDROData_Zone::MergeType& theMergeType ) const { QStringList aSortedZoneObjects; - for( int i=myGeomObjects.Lower(), n=myGeomObjects.Upper(); i<=n; i++ ) + for( int i=myObjects.Lower(), n=myObjects.Upper(); i<=n; i++ ) { - QString aName = myGeomObjects.Value( i )->GetName(); + QString aName = myObjects.Value( i )->GetName(); if( theZoneObjects.contains( aName ) ) aSortedZoneObjects.append( aName ); } @@ -105,14 +106,14 @@ bool HYDROData_PriorityQueue::IsMorePriority( const Handle(HYDROData_Entity)& th } // 2. If no custom rule found, the standard ordering list is applied - for( int i=myGeomObjects.Lower(), n=myGeomObjects.Upper(); i<=n; i++ ) + for( int i=myObjects.Lower(), n=myObjects.Upper(); i<=n; i++ ) { - if( myGeomObjects.Value( i )->Label() == theObj1->Label() ) + if( myObjects.Value( i )->Label() == theObj1->Label() ) { theMergeType = HYDROData_Zone::Merge_Object; return true; } - if( myGeomObjects.Value( i )->Label() == theObj2->Label() ) + if( myObjects.Value( i )->Label() == theObj2->Label() ) { theMergeType = HYDROData_Zone::Merge_Object; return false; @@ -200,7 +201,9 @@ HYDROData_ListOfRules HYDROData_PriorityQueue::GetRules( const TDF_Label& theRul QString HYDROData_PriorityQueue::DumpRules( const TDF_Label& theRulesLab ) { - QString aDump = "Rules:\n"; + bool isLandCover = theRulesLab.Tag() == HYDROData_CalculationCase::DataTag_CustomLandCoverRules; + QString aDump = isLandCover ? "Land Cover rules:\n" : "Rules:\n"; + HYDROData_ListOfRules aRules = GetRules( theRulesLab ); HYDROData_ListOfRules::const_iterator anIt = aRules.begin(), aLast = aRules.end(); for( ; anIt!=aLast; anIt++ ) diff --git a/src/HYDROData/HYDROData_PriorityQueue.h b/src/HYDROData/HYDROData_PriorityQueue.h index b9f64582..7983a1f7 100644 --- a/src/HYDROData/HYDROData_PriorityQueue.h +++ b/src/HYDROData/HYDROData_PriorityQueue.h @@ -75,9 +75,9 @@ public: private: typedef QMap MapNameToObject; - HYDROData_SequenceOfObjects myGeomObjects; ///< the ordered list of objects (default priority) - MapNameToObject myNames; ///< the map of name to object - HYDROData_ListOfRules myRules; ///< the list of rules + HYDROData_SequenceOfObjects myObjects; ///< the ordered list of objects (default priority) + MapNameToObject myNames; ///< the map of name to object + HYDROData_ListOfRules myRules; ///< the list of rules }; #endif -- 2.39.2