]> SALOME platform Git repositories - modules/smesh.git/blobdiff - src/SMESH_SWIG/smeshDC.py
Salome HOME
Implementation notebook in the SMESH module.
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.py
index d6e2f2ae9c188b1aa8d1e9a9edcb9aa7b228bef2..cf62433791f534605581b0114eab0660e5c8d45d 100644 (file)
@@ -155,6 +155,9 @@ DefaultSize, DefaultGeom, Custom = 0,0,1
 
 PrecisionConfusion = 1e-07
 
+# Salome notebook variable separator
+variable_separator = ":"
+
 def IsEqual(val1, val2, tol=PrecisionConfusion):
     if abs(val1 - val2) < tol:
         return True
@@ -164,8 +167,6 @@ NO_NAME = "NoName"
 
 ## Gets object name
 def GetName(obj):
-    if isinstance(obj, BaseWrapper):
-        obj = obj.GetAlgorithm()
     ior  = salome.orb.object_to_string(obj)
     sobj = salome.myStudy.FindObjectIOR(ior)
     if sobj is None:
@@ -176,8 +177,6 @@ def GetName(obj):
 
 ## Sets a name to the object
 def SetName(obj, name):
-    if isinstance(obj, BaseWrapper):
-        obj = obj.GetAlgorithm()
     ior  = salome.orb.object_to_string(obj)
     sobj = salome.myStudy.FindObjectIOR(ior)
     if not sobj is None:
@@ -348,17 +347,6 @@ class smeshDC(SMESH._objref_SMESH_Gen):
         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
         return aMesh
 
-    ## Create hyporthesis
-    #  @return an instance of hypothesis
-    #  @ingroup l2_impexp
-    def CreateHypothesis(self, hyp, so):
-        hypo = SMESH._objref_SMESH_Gen.CreateHypothesis(self, hyp, so)
-        if hyp == "LocalLength":
-            hypo = LocalLength(hypo)
-            
-        return hypo
-        
-
     ## Creates a Mesh object(s) importing data from the given MED file
     #  @return a list of Mesh class instances
     #  @ingroup l2_impexp
@@ -957,7 +945,7 @@ class Mesh:
     #  @return SMESH.Hypothesis_Status
     #  @ingroup l2_hypotheses
     def AddHypothesis(self, hyp, geom=0):
-        if isinstance( hyp, Mesh_Algorithm ) or isinstance( hyp, BaseWrapper):
+        if isinstance( hyp, Mesh_Algorithm ):
             hyp = hyp.GetAlgorithm()
             pass
         if not geom:
@@ -976,7 +964,7 @@ class Mesh:
     #  @return SMESH.Hypothesis_Status
     #  @ingroup l2_hypotheses
     def RemoveHypothesis(self, hyp, geom=0):
-        if isinstance( hyp, Mesh_Algorithm ) or isinstance( hyp, BaseWrapper):
+        if isinstance( hyp, Mesh_Algorithm ):
             hyp = hyp.GetAlgorithm()
             pass
         if not geom:
@@ -2889,12 +2877,7 @@ class Mesh_Algorithm:
                 pass
             SetName(hypo, hyp + a)
             pass
-        bhypo = None
-        if isinstance(hypo,BaseWrapper):
-            bhypo = hypo.GetAlgorithm()
-        else:
-            bhypo = hypo
-        status = self.mesh.mesh.AddHypothesis(self.geom, bhypo)
+        status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
         TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
         return hypo
 
@@ -4034,67 +4017,44 @@ class Mesh_UseExisting(Mesh_Algorithm):
             self.Create(mesh, geom, "UseExisting_2D")
 
 
+import salome_notebook
+notebook = salome_notebook.notebook
 
-
-from salome_notebook import *
-
-##Base class for wrap all StdMeshers interfaces
-class BaseWrapper:
-    
-    ##Return instance of a _objref_StdMeshers hypothesis
-    def GetAlgorithm(self):
-        return self.hypo
-
-    ##Return values of the notebook variables
-    def ParseParameters(self, params ,nbParams, nbParam, arg):
-        result = None
-        strResult = ""
-        isVar = False
-        if isinstance(arg, str):
-            if notebook.isVariable(arg):
-                result = notebook.get(arg)
-                isVar = True
+##Return values of the notebook variables
+def ParseParameters(last, nbParams,nbParam, value):
+    result = None
+    strResult = ""
+    counter = 0
+    listSize = len(last)
+    for n in range(0,nbParams):
+        if n+1 != nbParam:
+            if counter < listSize:
+                strResult = strResult + last[counter]
+            else:
+                strResult = strResult + ""
         else:
-            result = arg
-
-        isEmpty = True
-        paramsList = []
-        if len(params) > 0:
-            paramsList = params.split(":")
-            isEmpty = False
-            
-        for n in range(1,nbParams+1):
-            if n != nbParam and not isEmpty and len(paramsList[n-1])> 0:
-                strResult = paramsList[n-1] + ":"
-                pass
-            if isVar and n == nbParam:
-                if len(strResult) == 0 and nbParam != 1:
-                    strResult = strResult + ":"
-                    pass
-                strResult = strResult+arg
-                if n != nbParams:
-                    strResult = strResult + ":"
-                    
-        return result, strResult
-            
-       
-#Wrapper class for StdMeshers_LocalLength hypothesis
-class LocalLength(BaseWrapper):
-    def __init__(self, hypo):
-        self.hypo = hypo
-
+            if isinstance(value, str) and notebook.isVariable(value):
+                result = notebook.get(value)
+                strResult=strResult+value 
+            else:
+                strResult=strResult+str(value)
+                result = value
+        if nbParams - 1 != counter:
+            strResult=strResult+variable_separator #":"
+        counter = counter+1
+    return result, strResult
+
+class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
+        
     def SetLength(self, length):
-        length,parameters = self.ParseParameters(self.hypo.GetParameters(),2,1,length)
-        self.hypo.SetParameters(parameters)
-        self.hypo.SetLength(length)
+        length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
+        StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
+        StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
 
     def SetPrecision(self, precision):
-        precision,parameters = self.ParseParameters(self.hypo.GetParameters(),2,2,precision)
-        self.hypo.SetParameters(parameters)
-        self.hypo.SetPrecision(precision)
-
-    def GetLength(self):
-        return self.hypo.GetLength()
+        precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
+        StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
+        StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
 
-    def GetPrecision(self):
-        return self.hypo.GetLength()
+#Registering the new proxy for LocalLength
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)