00001 # -*- coding: iso-8859-1 -*- 00002 # Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE 00003 # 00004 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, 00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 00006 # 00007 # This library is free software; you can redistribute it and/or 00008 # modify it under the terms of the GNU Lesser General Public 00009 # License as published by the Free Software Foundation; either 00010 # version 2.1 of the License. 00011 # 00012 # This library is distributed in the hope that it will be useful, 00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 # Lesser General Public License for more details. 00016 # 00017 # You should have received a copy of the GNU Lesser General Public 00018 # License along with this library; if not, write to the Free Software 00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 # 00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com 00022 # 00023 00024 # SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses 00025 # File : smeshpy.py 00026 # Module : SMESH 00027 # 00028 import salome 00029 import SMESH 00030 00031 from SALOME_utilities import * 00032 00033 #============================================================================= 00034 00035 class smeshpy: 00036 _geom = None 00037 _smesh = None 00038 _studyId = None 00039 00040 #-------------------------------------------------------------------------- 00041 00042 def __init__(self): 00043 try: 00044 self._geom = salome.lcc.FindOrLoadComponent("FactoryServer","GEOM") 00045 self._smesh = salome.lcc.FindOrLoadComponent("FactoryServer","SMESH") 00046 except: 00047 MESSAGE( "exception in smeshpy:__init__" ) 00048 self._study = salome.myStudy 00049 self._smesh.SetCurrentStudy(self._study) 00050 00051 #-------------------------------------------------------------------------- 00052 00053 def CreateMesh(self, shapeId): 00054 try: 00055 shape = salome.IDToObject(shapeId) 00056 aMesh = self._smesh.CreateMesh(shape) 00057 return aMesh 00058 except: 00059 MESSAGE( "exception in smeshpy:Init" ) 00060 return None 00061 00062 #-------------------------------------------------------------------------- 00063 00064 def CreateHypothesis(self, name, libname): 00065 try: 00066 hyp = self._smesh.CreateHypothesis(name, libname) 00067 return hyp 00068 except: 00069 MESSAGE( "exception in smeshpy:CreateHypothesis" ) 00070 return None 00071 00072 #-------------------------------------------------------------------------- 00073 00074 def Compute(self, mesh, shapeId): 00075 try: 00076 shape = salome.IDToObject(shapeId) 00077 ret=self._smesh.Compute(mesh, shape) 00078 return ret 00079 except: 00080 MESSAGE( "exception in smeshpy:Compute" ) 00081 return 0 00082 00083 #============================================================================= 00084 ## #-------------------------------------------------------------------------- 00085 00086 ##def SmeshInit(shapeId): 00087 ## import salome 00088 ## import SMESH 00089 ## geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") 00090 ## smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") 00091 ## shape = salome.IDToObject(shapeId) 00092 ## studyId = salome.myStudyId 00093 ## MESSAGE( str(studyId) ) 00094 ## aMesh = smesh.Init(geom, studyId, shape) 00095 ## return aMesh 00096 00097 ## #--------------------------------------------------------------------------