]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
PR: true singleton instance of smesh
authorprascle <prascle>
Wed, 10 Apr 2013 16:33:43 +0000 (16:33 +0000)
committerprascle <prascle>
Wed, 10 Apr 2013 16:33:43 +0000 (16:33 +0000)
src/SMESH_SWIG/smesh.py
src/SMESH_SWIG/smeshBuilder.py

index 9cfc32f086efad3cab08eb5de5de77d7c0a285a9..ab061e4c63eab5232418bfa595e2ee1c3db73d5f 100644 (file)
@@ -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 
+
 ===============================================================================
 """
index 25bf8e9e0e1d0393af5ba052ecd1d4b30cc98277..5c9c581b94faca566f071917be0627ef282ca197 100644 (file)
@@ -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.