]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
methods for getting rules are implemented
authorasl <asl@opencascade.com>
Tue, 14 Oct 2014 11:50:39 +0000 (11:50 +0000)
committerasl <asl@opencascade.com>
Tue, 14 Oct 2014 11:50:39 +0000 (11:50 +0000)
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_PriorityQueue.cxx
src/HYDROData/HYDROData_PriorityQueue.h

index bceb9f81ef488b5d9687ce65e054768c5a1440d5..732e218a316406ef16d0853dcd19dce0fe70bf2e 100644 (file)
@@ -1139,3 +1139,20 @@ void HYDROData_CalculationCase::SetWarning( HYDROData_WarningType theType, const
   myLastWarning.Type = theType;
   myLastWarning.Data = theData;
 }
+
+int HYDROData_CalculationCase::GetRulesCount() const
+{
+  TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
+  return HYDROData_PriorityQueue::GetRulesCount( aRulesLab );
+}
+
+bool HYDROData_CalculationCase::GetRule( int theIndex, 
+                                         Handle(HYDROData_Object)&           theObject1,
+                                         HYDROData_PriorityType&             thePriority,
+                                         Handle(HYDROData_Object)&           theObject2,
+                                         HYDROData_Zone::MergeAltitudesType& theMergeType ) const
+{
+  TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
+  return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
+    theObject1, thePriority, theObject2, theMergeType );
+}
index ec3f2976ae36b80df7c718b30bad87ac6d4ffbb2..e0b0789239962dedd53d4fe709cda706c8180e69 100644 (file)
@@ -297,6 +297,12 @@ public:
                                  HYDROData_PriorityType             thePriority,
                                  const Handle(HYDROData_Object)&    theObject2,
                                  HYDROData_Zone::MergeAltitudesType theMergeType );
+  HYDRODATA_EXPORT int GetRulesCount() const;
+  HYDRODATA_EXPORT bool GetRule( int theIndex, 
+                                 Handle(HYDROData_Object)&           theObject1,
+                                 HYDROData_PriorityType&             thePriority,
+                                 Handle(HYDROData_Object)&           theObject2,
+                                 HYDROData_Zone::MergeAltitudesType& theMergeType ) const;
 
   HYDRODATA_EXPORT QString DumpRules() const;
 
index e3c5a133a680af460763d85a3f537ea4094c1a6e..52ba2b2ebd2321930f687a31f00055149da5d98b 100644 (file)
@@ -216,3 +216,36 @@ void HYDROData_PriorityQueue::DumpRulesToPython( const TDF_Label& theRulesLab,
     theScript << aRule;
   }
 }
+
+int HYDROData_PriorityQueue::GetRulesCount( const TDF_Label& theRulesLab )
+{
+  return theRulesLab.NbChildren();
+}
+
+bool HYDROData_PriorityQueue::GetRule( const TDF_Label& theRulesLab,
+                                       int theIndex, 
+                                       Handle(HYDROData_Object)&           theObject1,
+                                       HYDROData_PriorityType&             thePriority,
+                                       Handle(HYDROData_Object)&           theObject2,
+                                       HYDROData_Zone::MergeAltitudesType& 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   = Handle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs1->First() ) );
+    thePriority  = ( HYDROData_PriorityType ) aPriorityAttr->Get();
+    theObject2   = Handle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs2->First() ) );
+    theMergeType = ( HYDROData_Zone::MergeAltitudesType ) aMergeAttr->Get();
+  }
+  return isOK;
+}
index bb11ef63a1b02a5a7e86c640e78f67c47e9c1f9c..0864ee5a175ec58c0ec69b21e1c0d94cde364f9f 100644 (file)
@@ -48,7 +48,13 @@ public:
   static void DumpRulesToPython( const TDF_Label& theRulesLab,
                                  const QString& theCalcCaseName,
                                  QStringList& theScript );
-
+  static int GetRulesCount( const TDF_Label& theRulesLab );
+  static bool GetRule( const TDF_Label& theRulesLab,
+                       int theIndex, 
+                       Handle(HYDROData_Object)&           theObject1,
+                       HYDROData_PriorityType&             thePriority,
+                       Handle(HYDROData_Object)&           theObject2,
+                       HYDROData_Zone::MergeAltitudesType& theMergeType );
 private:
   typedef QMap<QString, Handle(HYDROData_Object)> MapNameToObject;