1 // Copyright (C) 2017-2022 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Author : Anthony Geay (EDF R&D)
24 def ExtensionsStr(sz=60):
26 isOK=[(elt,tab[int(elt in ActiveExtensions())]) for elt in AllPossibleExtensions()]
27 return "\n".join([a+" "+('{:.>%d}'%(sz-len(a)-1)).format(' %s'%b) for a,b in isOK])
29 def ShowExtensions(sz=60):
30 print(ExtensionsStr(sz))
33 def AdvancedExtensionsStr(sz=60):
34 def SubExtension(allPossibilities,extensionsActivated,pad,tab, sts):
35 for elt2 in allPossibilities:
36 elt3="%s algorithm for %s"%(elt2,elt)
37 sts.append(pad+elt3+" "+('{:.>%d}'%(sz-len(pad)-len(elt3)-1)).format(' %s'%tab[int(elt2 in extensionsActivated)]))
42 aext=ActiveExtensions()
44 for elt in AllPossibleExtensions():
46 sts.append(elt+" "+('{:.>%d}'%(sz-len(elt)-1)).format(' %s'%tab[isOK]))
50 SubExtension(AllRenumberMethods(),RenumberAvailableMethods(),pad,tab, sts)
53 SubExtension(MEDPartitioner.AllAlgorithms(),MEDPartitioner.AvailableAlgorithms(),pad,tab, sts)
58 def ShowAdvancedExtensions(sz=60):
59 print(AdvancedExtensionsStr(sz))
61 def MEDCouplingWriterHelper(mci,fileName,medFunc):
63 fileWithoutExt,ext=os.path.splitext(fileName)
64 if ext in [".med",".rmed",""]:
67 outFileName=fileWithoutExt+".med"
69 medFunc(outFileName,mci,True)
72 raise InterpKernelException("Request for writing \"%s\" MED file, but MED file is not activated in your medcoupling !")
74 elif ext[:3]==".vt" and len(ext)==4:
75 mci.writeVTK(fileName)
77 raise InterpKernelException("The extension \"%s\" of input file \"%s\" is not recognized !"%(ext,fileName))
81 def MEDCouplingMesh_write(self,fileName):
82 MEDCouplingWriterHelper(self,fileName,WriteMesh)
84 def MEDCouplingField_write(self,fileName):
85 MEDCouplingWriterHelper(self,fileName,WriteField)
87 def MEDCouplingFieldT_copyTimeInfoFrom(self,mlf1ts):
88 assert(isinstance(mlf1ts,MEDFileAnyTypeField1TS))
89 a,b,c=mlf1ts.getTime()
93 MEDCouplingMesh.write=MEDCouplingMesh_write
94 del MEDCouplingMesh_write
95 MEDCouplingField.write=MEDCouplingField_write
96 del MEDCouplingField_write
97 MEDCouplingFieldDouble.copyTimeInfoFrom=MEDCouplingFieldT_copyTimeInfoFrom
98 MEDCouplingFieldInt.copyTimeInfoFrom=MEDCouplingFieldT_copyTimeInfoFrom
99 MEDCouplingFieldFloat.copyTimeInfoFrom=MEDCouplingFieldT_copyTimeInfoFrom
100 del MEDCouplingFieldT_copyTimeInfoFrom