X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FSwig%2FCaseWriter.py;h=c8f4f74a3e368d0b2876a2acf529da645f17b179;hb=06b22e5321361b9c5fdfdbf4fd81e12d37ead050;hp=cb80579b5d855e421da7c11fead49a2115bad24e;hpb=242bed6361d2165733aa20dab027c4b637c732f3;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/Swig/CaseWriter.py b/src/MEDLoader/Swig/CaseWriter.py index cb80579b5..c8f4f74a3 100644 --- a/src/MEDLoader/Swig/CaseWriter.py +++ b/src/MEDLoader/Swig/CaseWriter.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2015 CEA/DEN, EDF R&D +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -28,7 +28,7 @@ import sys,re,os,mmap class CaseWriter(CaseIO): """ Converting MED file format in memory to a the Case file format (Ensight). - A new file with the same base name and the .case extension is created with its depencies (.geo ...). + A new file with the same base name and the .case extension is created with its dependencies (.geo ...). """ header="""FORMAT @@ -158,7 +158,7 @@ time values: typ=MEDCouplingMesh.GetCorrespondingPolyType(typ) pass mp=m[i:i+nbelem] - mm.write(self.__str80(self.dictMCTyp[typ])) + mm.write(self.__str80(self.dictMCTyp_str[typ])) a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(1,)) a[0]=nbelem ; a.flush() ; mm.seek(mm.tell()+4) if typ!=NORM_POLYHED and typ!=NORM_POLYGON: @@ -172,7 +172,7 @@ time values: c=mp.computeNbOfFacesPerCell() a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(nbelem,)) a[:]=c.toNumPyArray(); a.flush() ; mm.seek(mm.tell()+nbelem*4) - c=mp.getNodalConnectivity()[:] ; c.pushBackSilent(-1) ; c[mp.getNodalConnectivityIndex()[:-1]]=-1 ; ids=c.getIdsEqual(-1) ; nbOfNodesPerFace=ids.deltaShiftIndex()-1 + c=mp.getNodalConnectivity()[:] ; c.pushBackSilent(-1) ; c[mp.getNodalConnectivityIndex()[:-1]]=-1 ; ids=c.findIdsEqual(-1) ; nbOfNodesPerFace=ids.deltaShiftIndex()-1 a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(len(nbOfNodesPerFace),)) a[:]=nbOfNodesPerFace.toNumPyArray() ; a.flush() ; mm.seek(mm.tell()+len(nbOfNodesPerFace)*4) ids2=ids.buildComplement(ids.back()+1) @@ -201,7 +201,7 @@ time values: self._ze_top_dict={} its,areForgottenTS=mdfs.getCommonIterations() if areForgottenTS: - print "WARNING : some iterations are NOT present in all fields ! Kept iterations are : %s !"%(str(its)) + print(("WARNING : some iterations are NOT present in all fields ! Kept iterations are : %s !"%(str(its)))) pass TimeValues="" for it in its: @@ -211,12 +211,12 @@ time values: for mdf in mdfs: nbCompo=mdf.getNumberOfComponents() if nbCompo not in self.dictCompo: - l=filter(lambda x:x-nbCompo>0,self.dictCompo.keys()) + l = [x for x in self.dictCompo if x - nbCompo > 0] if len(l)==0: - print "Field \"%s\" will be ignored because number of components (%i) is too big to be %s supported by case files !"%(mdf.getName(),nbCompo,str(self.dictCompo.keys())) + print(("Field \"%s\" will be ignored because number of components (%i) is too big to be %s supported by case files !"%(mdf.getName(),nbCompo,str(list(self.dictCompo.keys()))))) continue pass - print "WARNING : Field \"%s\" will have its number of components (%i) set to %i, in order to be supported by case files (must be in %s) !"%(mdf.getName(),nbCompo,l[0],str(self.dictCompo.keys())) + print(("WARNING : Field \"%s\" will have its number of components (%i) set to %i, in order to be supported by case files (must be in %s) !"%(mdf.getName(),nbCompo,l[0],str(list(self.dictCompo.keys()))))) nbCompo=l[0] pass if nbCompo in dictVars: @@ -229,7 +229,7 @@ time values: for mdf in mdfs: nbCompo=mdf.getNumberOfComponents() if nbCompo not in self.dictCompo: - l=filter(lambda x:x-nbCompo>0,self.dictCompo.keys()) + l = [x for x in self.dictCompo if x - nbCompo > 0] if len(l)==0: continue; nbCompo=l[0] @@ -270,13 +270,13 @@ time values: if typ==curTyp: arr=ff.getUndergroundDataArray()[bg:end].changeNbOfComponents(nbCompo,0.) ; arr=arr.toNoInterlace() if typ==ON_CELLS: - mm.write(self.__str80(self.dictMCTyp[geo])) + mm.write(self.__str80(self.dictMCTyp_str[geo])) pass elif typ==ON_NODES: mm.write(self.__str80("coordinates")) pass else: - print "UnManaged type of field for field \"%s\" !"%(mdf.getName()) + print(("UnManaged type of field for field \"%s\" !"%(mdf.getName()))) pass a=np.memmap(f,dtype='float32',mode='w+',offset=mm.tell(),shape=(nbCompo,end-bg)) b=arr.toNumPyArray() ; b=b.reshape(nbCompo,end-bg) @@ -319,7 +319,7 @@ time values: def __str80(cls,st): if len(st)>79: raise Exception("String \"%s\" is too long (>79) !"%(st)) - return st.ljust(79)+"\n" + return bytes(str(st).ljust(79)+"\n", "ascii") def __computeSizeOfGeoFile(self,listOfMeshes,nn): sz=0