mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-27 18:00:34 +05:00
PR: true singleton instance of smesh
This commit is contained in:
parent
76775f17ac
commit
74ba6feb24
@ -87,28 +87,28 @@ if smesh:
|
|||||||
|
|
||||||
print """
|
print """
|
||||||
===============================================================================
|
===============================================================================
|
||||||
WARNING: |
|
WARNING:
|
||||||
Usage of smesh.py is deprecated in SALOME V7.2! |
|
Usage of smesh.py is deprecated in SALOME V7.2!
|
||||||
smesh.py will be removed in a future version! |
|
smesh.py will be removed in a future version!
|
||||||
TODO: |
|
TODO:
|
||||||
The following changes in your scripts are required to avoid this message: |
|
The following changes in your scripts are required to avoid this message:
|
||||||
|
|
|
||||||
replace |
|
replace
|
||||||
------- |
|
-------
|
||||||
|
|
|
||||||
import smesh, SMESH, SALOMEDS |
|
import smesh, SMESH, SALOMEDS
|
||||||
smesh.SetCurrentStudy(theStudy) |
|
smesh.SetCurrentStudy(theStudy)
|
||||||
|
|
|
||||||
with |
|
with
|
||||||
---- |
|
----
|
||||||
|
|
|
||||||
import SMESH, SALOMEDS |
|
import SMESH, SALOMEDS
|
||||||
from salome.smesh import smeshBuilder |
|
from salome.smesh import smeshBuilder
|
||||||
smesh = smeshBuilder.New(theStudy) |
|
smesh = smeshBuilder.New(theStudy)
|
||||||
|
|
|
||||||
you also need to modify some lines where smeshBuilder is used instead of smesh|
|
you also need to modify some lines where smeshBuilder is used instead of smesh
|
||||||
|
|
|
||||||
algo=smesh.xxxx ==> algo.smeshBuilder.xxxx |
|
algo=smesh.xxxx ==> algo.smeshBuilder.xxxx
|
||||||
|
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
"""
|
"""
|
||||||
|
@ -285,6 +285,7 @@ def FirstVertexOnCurve(edge):
|
|||||||
smeshInst = None
|
smeshInst = None
|
||||||
engine = None
|
engine = None
|
||||||
doLcc = False
|
doLcc = False
|
||||||
|
created = False
|
||||||
|
|
||||||
## This class allows to create, load or manipulate meshes
|
## 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.
|
# 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 engine
|
||||||
global smeshInst
|
global smeshInst
|
||||||
global doLcc
|
global doLcc
|
||||||
#print "__new__", engine, smeshInst, doLcc
|
#print "==== __new__", engine, smeshInst, doLcc
|
||||||
|
|
||||||
if smeshInst is None:
|
if smeshInst is None:
|
||||||
# smesh engine is either retrieved from engine, or created
|
# smesh engine is either retrieved from engine, or created
|
||||||
@ -327,26 +328,30 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen):
|
|||||||
# FindOrLoadComponent called:
|
# FindOrLoadComponent called:
|
||||||
# 1. CORBA resolution of server
|
# 1. CORBA resolution of server
|
||||||
# 2. the __new__ method is called again
|
# 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" )
|
smeshInst = salome.lcc.FindOrLoadComponent( "FactoryServer", "SMESH" )
|
||||||
else:
|
else:
|
||||||
# FindOrLoadComponent not called
|
# FindOrLoadComponent not called
|
||||||
if smeshInst is None:
|
if smeshInst is None:
|
||||||
# smeshBuilder instance is created from lcc.FindOrLoadComponent
|
# 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)
|
smeshInst = super(smeshBuilder,cls).__new__(cls)
|
||||||
else:
|
else:
|
||||||
# smesh engine not created: existing engine found
|
# smesh engine not created: existing engine found
|
||||||
#print "existing ", engine, smeshInst, doLcc
|
#print "==== existing ", engine, smeshInst, doLcc
|
||||||
pass
|
pass
|
||||||
|
#print "====1 ", smeshInst
|
||||||
return smeshInst
|
return smeshInst
|
||||||
|
|
||||||
|
#print "====2 ", smeshInst
|
||||||
return smeshInst
|
return smeshInst
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
#print "__init__"
|
global created
|
||||||
SMESH._objref_SMESH_Gen.__init__(self)
|
#print "--------------- smeshbuilder __init__ ---", created
|
||||||
|
if not created:
|
||||||
|
created = True
|
||||||
|
SMESH._objref_SMESH_Gen.__init__(self)
|
||||||
|
|
||||||
## Dump component to the Python script
|
## Dump component to the Python script
|
||||||
# This method overrides IDL function to allow default values for the parameters.
|
# This method overrides IDL function to allow default values for the parameters.
|
||||||
|
Loading…
Reference in New Issue
Block a user