PrecisionConfusion = 1e-07
+# Salome notebook variable separator
+variable_separator = ":"
+
def IsEqual(val1, val2, tol=PrecisionConfusion):
if abs(val1 - val2) < tol:
return True
## 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:
## 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:
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
# @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:
# @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:
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
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)