Salome HOME
NRI : Change lGeometryClient by lGEOMClient.
[modules/smesh.git] / src / SMESH_I / smeshpy.py
1
2 import salome
3 import SMESH
4
5 from SALOME_utilities import *
6
7 #=============================================================================
8
9 class smeshpy:
10     _geom = None
11     _smesh = None
12     _studyId = None
13
14     #--------------------------------------------------------------------------
15
16     def __init__(self):
17         try:
18             self._geom = salome.lcc.FindOrLoadComponent("FactoryServer","Geometry")
19             self._smesh = salome.lcc.FindOrLoadComponent("FactoryServer","SMESH")
20         except:
21             MESSAGE( "exception in smeshpy:__init__" )
22         self._studyId = salome.myStudyId
23
24     #--------------------------------------------------------------------------
25
26     def Init(self, shapeId):
27         try:
28             shape = salome.IDToObject(shapeId)
29             aMesh = self._smesh.Init(self._geom, self._studyId, shape)
30             return aMesh
31         except:
32             MESSAGE( "exception in smeshpy:Init" )
33             return None
34
35     #--------------------------------------------------------------------------
36
37     def CreateHypothesis(self, name):
38         try:
39             hyp = self._smesh.CreateHypothesis(name,self._studyId)
40             return hyp
41         except:
42             MESSAGE( "exception in smeshpy:CreateHypothesis" )
43             return None    
44
45     #--------------------------------------------------------------------------
46
47     def Compute(self, mesh, shapeId):
48         try:
49             shape = salome.IDToObject(shapeId)
50             ret=self._smesh.Compute(mesh, shape)
51             return ret
52         except:
53             MESSAGE( "exception in smeshpy:Compute" )
54             return 0    
55
56 #=============================================================================
57 ##    #--------------------------------------------------------------------------
58
59 ##def SmeshInit(shapeId):
60 ##    import salome
61 ##    import SMESH
62 ##    geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
63 ##    smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
64 ##    shape = salome.IDToObject(shapeId)
65 ##    studyId = salome.myStudyId
66 ##    MESSAGE( str(studyId) )
67 ##    aMesh = smesh.Init(geom, studyId, shape)
68 ##    return aMesh
69
70 ##    #--------------------------------------------------------------------------