Back to index

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