From: prascle Date: Wed, 10 Apr 2013 16:33:43 +0000 (+0000) Subject: PR: true singleton instance of smesh X-Git-Tag: V7_2_0rc1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=74ba6feb24da6b00d712ca90939e6dfc567ac69d PR: true singleton instance of smesh --- diff --git a/src/SMESH_SWIG/smesh.py b/src/SMESH_SWIG/smesh.py index 9cfc32f08..ab061e4c6 100644 --- a/src/SMESH_SWIG/smesh.py +++ b/src/SMESH_SWIG/smesh.py @@ -87,28 +87,28 @@ if smesh: print """ =============================================================================== -WARNING: | -Usage of smesh.py is deprecated in SALOME V7.2! | -smesh.py will be removed in a future version! | -TODO: | -The following changes in your scripts are required to avoid this message: | - | -replace | -------- | - | -import smesh, SMESH, SALOMEDS | -smesh.SetCurrentStudy(theStudy) | - | -with | ----- | - | -import SMESH, SALOMEDS | -from salome.smesh import smeshBuilder | -smesh = smeshBuilder.New(theStudy) | - | -you also need to modify some lines where smeshBuilder is used instead of smesh| - | -algo=smesh.xxxx ==> algo.smeshBuilder.xxxx | - | +WARNING: +Usage of smesh.py is deprecated in SALOME V7.2! +smesh.py will be removed in a future version! +TODO: +The following changes in your scripts are required to avoid this message: + +replace +------- + +import smesh, SMESH, SALOMEDS +smesh.SetCurrentStudy(theStudy) + +with +---- + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(theStudy) + +you also need to modify some lines where smeshBuilder is used instead of smesh + +algo=smesh.xxxx ==> algo.smeshBuilder.xxxx + =============================================================================== """ diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index 25bf8e9e0..5c9c581b9 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -285,6 +285,7 @@ def FirstVertexOnCurve(edge): smeshInst = None engine = None doLcc = False +created = False ## This class allows to create, load or manipulate meshes # It has a set of methods to create load or copy meshes, to combine several meshes. @@ -312,7 +313,7 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): global engine global smeshInst global doLcc - #print "__new__", engine, smeshInst, doLcc + #print "==== __new__", engine, smeshInst, doLcc if smeshInst is None: # smesh engine is either retrieved from engine, or created @@ -327,26 +328,30 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): # FindOrLoadComponent called: # 1. CORBA resolution of server # 2. the __new__ method is called again - #print "smeshInst = lcc.FindOrLoadComponent ", engine, smeshInst, doLcc + #print "==== smeshInst = lcc.FindOrLoadComponent ", engine, smeshInst, doLcc smeshInst = salome.lcc.FindOrLoadComponent( "FactoryServer", "SMESH" ) else: # FindOrLoadComponent not called if smeshInst is None: # smeshBuilder instance is created from lcc.FindOrLoadComponent - #print "smeshInst = super(smeshBuilder,cls).__new__(cls) ", engine, smeshInst, doLcc + #print "==== smeshInst = super(smeshBuilder,cls).__new__(cls) ", engine, smeshInst, doLcc smeshInst = super(smeshBuilder,cls).__new__(cls) else: # smesh engine not created: existing engine found - #print "existing ", engine, smeshInst, doLcc + #print "==== existing ", engine, smeshInst, doLcc pass - + #print "====1 ", smeshInst return smeshInst + #print "====2 ", smeshInst return smeshInst def __init__(self): - #print "__init__" - SMESH._objref_SMESH_Gen.__init__(self) + global created + #print "--------------- smeshbuilder __init__ ---", created + if not created: + created = True + SMESH._objref_SMESH_Gen.__init__(self) ## Dump component to the Python script # This method overrides IDL function to allow default values for the parameters.