Back to index

salome-smesh  6.5.0
smesh.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  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 #  File   : smesh.py
00025 #  Author : Francis KLOSS, OCC
00026 #  Module : SMESH
00027 #
00028 """@package smesh
00029  \brief Module smesh
00030 """
00031 
00032 import salome
00033 from salome import *
00034 
00035 import geompy
00036 import smeshDC
00037 from smeshDC import *
00038 
00039 # get instance of class smeshDC
00040 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
00041 smesh.init_smesh(salome.myStudy,geompy.geom)
00042 
00043 # load plugins
00044 from smeshDC import Mesh, algoCreator
00045 for pluginName in os.environ["SMESH_MeshersList"].split(":"):
00046 
00047   pluginName += "DC"
00048   try:
00049     exec("from %s import *" % pluginName )
00050   except Exception, e:
00051     print "Exception while loading %s: %s" % ( pluginName, e )
00052     continue
00053   exec("import %s" % pluginName )
00054   plugin = eval(pluginName)
00055 
00056   # add methods creating algorithms to Mesh
00057   for k in dir(plugin):
00058     if k[0] == '_':continue
00059     algo = getattr(plugin,k)
00060     if type( algo ).__name__ == 'classobj' and hasattr( algo, "meshMethod"):
00061       if not hasattr( Mesh, algo.meshMethod ):
00062         setattr( Mesh, algo.meshMethod, algoCreator())
00063       getattr( Mesh, algo.meshMethod ).add( algo )
00064 
00065 # Export the methods of smeshDC
00066 for k in dir(smesh):
00067   if k[0] == '_':continue
00068   globals()[k]=getattr(smesh,k)
00069 del k