Back to index

salome-med  6.5.0
TestMedCorba4.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 BASE = os.environ["MED_ROOT_DIR"]
00026 BASE = os.path.join( BASE, 'share', 'salome', 'resources', 'med' )
00027 
00028 fileName = os.path.join( BASE, 'pointe.med' )
00029 fileName = os.path.join( BASE, 'carre_en_quad4_seg2.med' )
00030 
00031 # MED Mesh read from a (local) file
00032 
00033 from libMEDMEM_Swig import *
00034 
00035 md = MED()
00036 
00037 mdDriver = MED_MED_RDONLY_DRIVER(fileName, md)
00038 
00039 mdDriver.open()
00040 mdDriver.readFileStruct()
00041 mdDriver.close()
00042 
00043 mLocal = md.getMesh(md.getMeshName(0))
00044 mLocal.read()
00045 
00046 # MED Mesh recieved from a distant component (via CORBA)
00047 
00048 from omniORB import CORBA
00049 from LifeCycleCORBA import *
00050 from libSALOME_Swig import *
00051 
00052 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
00053 lcc = LifeCycleCORBA(orb)
00054 
00055 C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
00056 C.Initialise(fileName)
00057 
00058 mDistant = C.Calcul1()
00059 
00060 
00061 print "Name              : ", mDistant.getName()
00062 
00063 
00064 for i in [MED_CELL,
00065           MED_FACE,
00066           MED_EDGE,
00067           MED_NODE,
00068           MED_ALL_ENTITIES ]:
00069 
00070     n1 = mLocal.getNumberOfTypes(i);
00071     n2 = mDistant.getNumberOfTypes(i);
00072 
00073     if (n1 != n2):
00074         raise RuntimeError, "MESH::getNumberOfTypes()"
00075 
00076     if ((n1 > 0) & (i != MED_NODE)):
00077         T1 = mLocal.getTypes(i);
00078         T2 = mDistant.getTypes(i);
00079         print "types (local)   : ", i, " : ", T1;
00080         print "types (distant) : ", i, " : ", T2;
00081 
00082         if (n2 !=  len(T2)):
00083             raise RuntimeError, \
00084                   "len(MESH::getTypes()) <> MESH::getNumberOfTypes()"
00085 
00086         for j in range(n2):
00087             if (T1[j] != eval(T2[j].__str__())):
00088                 raise RuntimeError, "MESH::getTypes()"
00089 
00090             e1 = mLocal.getNumberOfElements(i, T1[j]);
00091             e2 = mDistant.getNumberOfElements(i, T2[j]);
00092 
00093             print "elements (local)   : ", T1[j], " : ", e1;
00094             print "elements (distant) : ", T2[j], " : ", e2;
00095 
00096             if (e1 != e2):
00097                 raise RuntimeError, "MESH::getNumberOfElements"
00098         
00099 print
00100 print "All tests passed"