]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #570: fix priority queue.
authormzn <mzn@opencascade.com>
Fri, 19 Jun 2015 12:41:46 +0000 (15:41 +0300)
committermzn <mzn@opencascade.com>
Fri, 19 Jun 2015 12:41:46 +0000 (15:41 +0300)
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_PriorityQueue.cxx
src/HYDROData/HYDROData_PriorityQueue.h

index 4fd970820e2ee2b245857897ebefa33d19837b9f..2a124fb5d7fa0b79f988354b9e03d2d544b01280 100644 (file)
@@ -345,7 +345,7 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume
   QMap<QString, Handle(HYDROData_Region)> aRegionsMap; //object name to region
   QMap<QString, QString> 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();
index 43d39df35b5be6ffc1628113f280aaf03fa0ebd4..12d39ce61e005ebe64d848db4b84e81f70bded24 100644 (file)
 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++ )
index b9f645828794209fe84c5369e0747eb4100f451f..7983a1f783a0407a487d6f317dde205fbd5f92ab 100644 (file)
@@ -75,9 +75,9 @@ public:
 private:
   typedef QMap<QString, Handle(HYDROData_Entity)> 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