Back to index

salome-med  6.5.0
TestMedCorba6.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 import os
00025 
00026 ## ne fonctionne pas ?
00027 ## import salome
00028 
00029 BASE = os.environ["MED_ROOT_DIR"]
00030 BASE = os.path.join( BASE, 'share', 'salome', 'resources', 'med' )
00031 
00032 fileName = os.path.join( BASE, 'pointe.med' )
00033 fileName = os.path.join( BASE, 'carre_en_quad4_seg2.med' )
00034  
00035 
00036 def compare(x, y):
00037     if (len(x) != len(y)):
00038         return 0
00039     for i in xrange(len(x)):
00040         if x[i] != y[i]:
00041             return 0
00042     return 1
00043 
00044 # MED Mesh read from a (local) file
00045 
00046 from libMEDMEM_Swig import *
00047 
00048 md = MED()
00049 
00050 mdDriver = MED_MED_RDONLY_DRIVER(fileName, md)
00051 
00052 mdDriver.open()
00053 mdDriver.readFileStruct()
00054 mdDriver.close()
00055 
00056 mLocal = md.getMesh(md.getMeshName(0))
00057 mLocal.read()
00058 
00059 # MED Mesh received from a distant component (via CORBA)
00060 
00061 from omniORB import CORBA
00062 from LifeCycleCORBA import *
00063 from libSALOME_Swig import *
00064 from libMEDClient import *
00065 
00066 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
00067 lcc = LifeCycleCORBA(orb)
00068 
00069 C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
00070 C.Initialise(fileName)
00071 
00072 mDistant = C.Calcul1()
00073 mDistantCopy = MESHClient(mDistant)
00074 
00075 from libCompo2 import *
00076 C2 = Compo2()
00077 
00078 print "Local       ", C2.Calcul(mLocal)
00079 print "DistantCopy ", C2.Calcul(mDistantCopy)
00080 
00081 testDistant = 0;
00082 try:
00083     print "Distant     ", C2.Calcul(mDistant)
00084 except:
00085     print "an exception has been received, it's the normal behaviour"
00086     testDistant = 1
00087 
00088 if (testDistant == 0):
00089     raise RuntimeError, "no exception has been received, test failed"
00090 
00091 
00092 print
00093 print "All tests passed"