+ ## Find hypothesis in study by its type name and parameters.
+ # Find only those hypothesis, which was created in smeshpyD engine.
+ def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
+ study = smeshpyD.GetCurrentStudy()
+ #to do: find component by smeshpyD object, not by its data type
+ scomp = study.FindComponent(smeshpyD.ComponentDataType())
+ if scomp is not None:
+ res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
+ # is hypotheses root label exists?
+ if res and hypRoot is not None:
+ iter = study.NewChildIterator(hypRoot)
+ # check all published hypotheses
+ while iter.More():
+ hypo_so_i = iter.Value()
+ attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
+ if attr is not None:
+ anIOR = attr.Value()
+ hypo_o_i = salome.orb.string_to_object(anIOR)
+ if hypo_o_i is not None:
+ # is hypothesis?
+ hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
+ if hypo_i is not None:
+ # belongs to this engine?
+ if smeshpyD.GetObjectId(hypo_i) > 0:
+ # is it the needed hypothesis?
+ if hypo_i.GetName() == hypname:
+ # check args
+ if CompareMethod(hypo_i, args):
+ # found!!!
+ return hypo_i
+ pass
+ pass
+ pass
+ pass
+ pass
+ iter.Next()
+ pass
+ pass
+ pass
+ return None
+
+ ## Find algorithm in study by its type name.
+ # Find only those algorithm, which was created in smeshpyD engine.
+ def FindAlgorithm (self, algoname, smeshpyD):
+ study = smeshpyD.GetCurrentStudy()
+ #to do: find component by smeshpyD object, not by its data type
+ scomp = study.FindComponent(smeshpyD.ComponentDataType())
+ if scomp is not None:
+ res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
+ # is algorithms root label exists?
+ if res and hypRoot is not None:
+ iter = study.NewChildIterator(hypRoot)
+ # check all published algorithms
+ while iter.More():
+ algo_so_i = iter.Value()
+ attr = algo_so_i.FindAttribute("AttributeIOR")[1]
+ if attr is not None:
+ anIOR = attr.Value()
+ algo_o_i = salome.orb.string_to_object(anIOR)
+ if algo_o_i is not None:
+ # is algorithm?
+ algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
+ if algo_i is not None:
+ # belongs to this engine?
+ if smeshpyD.GetObjectId(algo_i) > 0:
+ # is it the needed algorithm?
+ if algo_i.GetName() == algoname:
+ # found!!!
+ return algo_i
+ pass
+ pass
+ pass
+ pass
+ iter.Next()
+ pass
+ pass
+ pass
+ return None