Back to index

salome-med  6.5.0
Compo1.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 from libMEDMEM_Swig import *
00025 
00026 
00027 class Compo1:
00028 
00029     def __init__(self):
00030         print "Initialisation Compo1"
00031         self.mesh = None
00032         self.support = None
00033         self.md = None
00034         self.medFile = None
00035         
00036     def __del__(self):
00037         print "destruction Compo1"
00038 
00039     def Initialise(self, medFile):
00040         if ((self.medFile != medFile) | (self.md is None)):
00041             print "fichier MED monte"
00042             self.md = MED()
00043             mdDriver = MED_MED_RDONLY_DRIVER(medFile, self.md)
00044             mdDriver.open()
00045             mdDriver.readFileStruct()
00046             mdDriver.close()
00047             self.mesh = None
00048             self.support = None
00049             self.medFile = medFile
00050         else:
00051             print "fichier MED deja monte"
00052             
00053     def Test(self):
00054         if (self.md is None):
00055             raise RuntimeError, 'call Initialise first'
00056 
00057     def Calcul1(self):
00058 
00059         self.Test();
00060         if (self.mesh is None):
00061             self.mesh = self.md.getMesh(self.md.getMeshName(0))
00062             self.mesh.read()
00063             
00064         return self.mesh
00065 
00066     def Calcul2(self):
00067 
00068         self.Test();
00069         if (self.mesh is None):
00070             self.Calcul1()
00071             
00072         if (self.support is None):
00073             self.support = SUPPORT(self.mesh, "my_support", MED_CELL)
00074             self.support.setAll(1)
00075             
00076         return self.support