+
+void HYDROData_PriorityQueue::DumpRulesToPython( const TDF_Label& theRulesLab,
+ const QString& theCalcCaseName,
+ QStringList& theScript )
+{
+ HYDROData_ListOfRules aRules = GetRules( theRulesLab );
+ HYDROData_ListOfRules::const_iterator anIt = aRules.begin(), aLast = aRules.end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ QString anObj1 = anIt->Object1->GetObjPyName();
+ QString anObj2 = anIt->Object2->GetObjPyName();
+ QString aPriority = anIt->Priority == LESS ? "LESS" : "GREATER";
+ QString aMergeType;
+
+ HYDROData_CalculationCase::DataTag aDataTag = HYDROData_CalculationCase::DataTag_CustomRules;
+
+ switch( anIt->MergeType )
+ {
+ case HYDROData_Zone::Merge_UNKNOWN:
+ aMergeType = "HYDROData_Zone.Merge_UNKNOWN";
+ break;
+ case HYDROData_Zone::Merge_ZMIN:
+ aMergeType = "HYDROData_Zone.Merge_ZMIN";
+ break;
+ case HYDROData_Zone::Merge_ZMAX:
+ aMergeType = "HYDROData_Zone.Merge_ZMAX";
+ break;
+ case HYDROData_Zone::Merge_Object:
+ aMergeType = "HYDROData_Zone.Merge_Object";
+ break;
+ }
+
+ QString aRule = QString( "%0.AddRule( %1, %2, %3, %4, %5 )" ).
+ arg( theCalcCaseName ).arg( anObj1 ).arg( aPriority ).arg( anObj2 ).arg( aMergeType ).arg( aDataTag );
+
+ theScript << aRule;
+ }
+}
+
+bool HYDROData_PriorityQueue::GetRule( const TDF_Label& theRulesLab,
+ int theIndex,
+ Handle(HYDROData_Entity)& theObject1,
+ HYDROData_PriorityType& thePriority,
+ Handle(HYDROData_Entity)& theObject2,
+ HYDROData_Zone::MergeType& theMergeType )
+{
+ TDF_Label aRuleLabel = theRulesLab.FindChild( theIndex );
+
+ Handle(TDataStd_ReferenceList) aRefs1, aRefs2;
+ Handle(TDataStd_Integer) aPriorityAttr, aMergeAttr;
+
+ bool isObj1OK = aRuleLabel.FindChild ( Object1_Tag ). FindAttribute( TDataStd_ReferenceList::GetID(), aRefs1 );
+ bool isPriorityOK = aRuleLabel.FindChild( Priority_Tag ).FindAttribute( TDataStd_Integer::GetID(), aPriorityAttr );
+ bool isObj2OK = aRuleLabel.FindChild ( Object2_Tag ). FindAttribute( TDataStd_ReferenceList::GetID(), aRefs2 );
+ bool isMergeOK = aRuleLabel.FindChild ( Merge_Tag ). FindAttribute( TDataStd_Integer::GetID(), aMergeAttr );
+
+ bool isOK = isObj1OK && isPriorityOK && isObj2OK && isMergeOK;
+ if( isOK )
+ {
+ theObject1 = HYDROData_Iterator::Object( aRefs1->First() );
+ thePriority = ( HYDROData_PriorityType ) aPriorityAttr->Get();
+ theObject2 = HYDROData_Iterator::Object( aRefs2->First() );
+ theMergeType = ( HYDROData_Zone::MergeType ) aMergeAttr->Get();
+ }
+ return isOK;
+}