Back to index

salome-smesh  6.5.0
__init__.py
Go to the documentation of this file.
00001 # Copyright (C) 2011-2012  EDF R&D
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 # Author(s): Guillaume Boulant (23/03/2011)
00020 #
00021 
00022 # TODO: put all this stuff in the unitests package
00023 
00024 import os
00025 def getRootDir():
00026     '''
00027     This returns the root directory where the module SPADDER is
00028     installed. All test files are looked up from this location.
00029     '''
00030     return os.environ['SMESH_ROOT_DIR']
00031 
00032 def getTestDataDir():
00033     '''
00034     This function gives the absolute path to the directory containing
00035     the data files for test (realistic med files).
00036     '''
00037     datadir=os.path.join(getRootDir(),"share/salome/resources/smesh/padderexe")
00038     return datadir
00039 
00040 import MESHJOB # to get the enum constant values
00041 from MESHJOB import MeshJobParameter, MeshJobParameterList
00042 
00043 DEFAULT_CONCRETE_FILENAME=os.path.join(getTestDataDir(),'concrete.med')
00044 DEFAULT_STEELBAR_LISTFILENAME=[
00045     os.path.join(getTestDataDir(),'ferraill.med')
00046     ]
00047 
00048 def getMeshJobParameterList(concrete_filename=DEFAULT_CONCRETE_FILENAME,
00049                             steelbar_listfilename=DEFAULT_STEELBAR_LISTFILENAME):
00050     '''
00051     This helper function creates a complete set of parameters (a
00052     MeshJobParameterList) for a simple test case, i.e. a case with a
00053     concrete filename and a single steelbar filename.
00054     '''
00055     # Note that a CORBA sequence (MeshJobParameterList) is mapped on a
00056     # simple list in python
00057     meshJobParameterList = []
00058     # We can add some parameters
00059     param = MeshJobParameter(
00060         file_name  = concrete_filename,
00061         file_type  = MESHJOB.MED_CONCRETE,
00062         group_name = "concrete")
00063     meshJobParameterList.append(param)
00064 
00065     for steelbar_filename in steelbar_listfilename:
00066         param = MeshJobParameter(
00067             file_name  = steelbar_filename,
00068             file_type  = MESHJOB.MED_STEELBAR,
00069             group_name = "steelbar")
00070         meshJobParameterList.append(param)
00071 
00072     return meshJobParameterList
00073 
00074 
00075 def getSpadderCatalogFilename():
00076     filename=os.path.join(getRootDir(),"share/salome/resources/smesh/SPADDERCatalog.xml")
00077     return filename
00078 
00079 def loadSpadderCatalog():
00080     import salome
00081     salome.salome_init()
00082     obj = salome.naming_service.Resolve('Kernel/ModulCatalog')
00083     import SALOME_ModuleCatalog
00084     catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog)
00085     if not catalog:
00086         raise RuntimeError, "Can't accesss module catalog"
00087 
00088     filename = getSpadderCatalogFilename()
00089     catalog.ImportXmlCatalogFile(filename)
00090 
00091     from salome.kernel import services
00092     print "The list of SALOME components is now:" 
00093     print services.getComponentList()