mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-06 23:00:34 +05:00
protect from errors when working w/o study
This commit is contained in:
parent
1d5a7c2d76
commit
8a5a32d1a4
@ -256,7 +256,9 @@ def TreatHypoStatus(status, hypName, geomName, isAlgo):
|
|||||||
def AssureGeomPublished(mesh, geom, name=''):
|
def AssureGeomPublished(mesh, geom, name=''):
|
||||||
if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
|
if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
|
||||||
return
|
return
|
||||||
if not geom.IsSame( mesh.geom ) and not geom.GetStudyEntry():
|
if not geom.IsSame( mesh.geom ) and \
|
||||||
|
not geom.GetStudyEntry() and \
|
||||||
|
mesh.smeshpyD.GetCurrentStudy():
|
||||||
## set the study
|
## set the study
|
||||||
studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
|
studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
|
||||||
if studyID != mesh.geompyD.myStudyId:
|
if studyID != mesh.geompyD.myStudyId:
|
||||||
@ -965,7 +967,7 @@ class Mesh:
|
|||||||
if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
|
if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
|
||||||
self.geom = obj
|
self.geom = obj
|
||||||
# publish geom of mesh (issue 0021122)
|
# publish geom of mesh (issue 0021122)
|
||||||
if not self.geom.GetStudyEntry():
|
if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy():
|
||||||
studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
|
studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
|
||||||
if studyID != geompyD.myStudyId:
|
if studyID != geompyD.myStudyId:
|
||||||
geompyD.init_geom( smeshpyD.GetCurrentStudy())
|
geompyD.init_geom( smeshpyD.GetCurrentStudy())
|
||||||
@ -1220,7 +1222,7 @@ class Mesh:
|
|||||||
print '"' + GetName(self.mesh) + '"',"has not been computed."
|
print '"' + GetName(self.mesh) + '"',"has not been computed."
|
||||||
pass
|
pass
|
||||||
pass
|
pass
|
||||||
if salome.sg.hasDesktop():
|
if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
|
||||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||||
smeshgui.Init(self.mesh.GetStudyId())
|
smeshgui.Init(self.mesh.GetStudyId())
|
||||||
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
|
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
|
||||||
@ -4069,6 +4071,7 @@ class Mesh_Algorithm:
|
|||||||
# @return SMESH.SMESH_Algo
|
# @return SMESH.SMESH_Algo
|
||||||
def FindAlgorithm (self, algoname, smeshpyD):
|
def FindAlgorithm (self, algoname, smeshpyD):
|
||||||
study = smeshpyD.GetCurrentStudy()
|
study = smeshpyD.GetCurrentStudy()
|
||||||
|
if not study: return None
|
||||||
#to do: find component by smeshpyD object, not by its data type
|
#to do: find component by smeshpyD object, not by its data type
|
||||||
scomp = study.FindComponent(smeshpyD.ComponentDataType())
|
scomp = study.FindComponent(smeshpyD.ComponentDataType())
|
||||||
if scomp is not None:
|
if scomp is not None:
|
||||||
@ -4207,15 +4210,10 @@ class Mesh_Algorithm:
|
|||||||
|
|
||||||
## Returns entry of the shape to mesh in the study
|
## Returns entry of the shape to mesh in the study
|
||||||
def MainShapeEntry(self):
|
def MainShapeEntry(self):
|
||||||
entry = ""
|
if not self.mesh or not self.mesh.GetMesh(): return ""
|
||||||
if not self.mesh or not self.mesh.GetMesh(): return entry
|
if not self.mesh.GetMesh().HasShapeToMesh(): return ""
|
||||||
if not self.mesh.GetMesh().HasShapeToMesh(): return entry
|
shape = self.mesh.GetShape()
|
||||||
study = self.mesh.smeshpyD.GetCurrentStudy()
|
return shape.GetStudyEntry()
|
||||||
ior = salome.orb.object_to_string( self.mesh.GetShape() )
|
|
||||||
sobj = study.FindObjectIOR(ior)
|
|
||||||
if sobj: entry = sobj.GetID()
|
|
||||||
if not entry: return ""
|
|
||||||
return entry
|
|
||||||
|
|
||||||
## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
|
## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
|
||||||
# near mesh boundary. This hypothesis can be used by several 3D algorithms:
|
# near mesh boundary. This hypothesis can be used by several 3D algorithms:
|
||||||
|
Loading…
Reference in New Issue
Block a user