Salome HOME
Windows porting
[tools/medcoupling.git] / src / MEDLoader / Swig / VTKReader.py
index b541744599bcf7a7daeeaadb2bbacdbca9ceb75d..d66efe01b9f06dfec07e89e11828c0e8a5a83be9 100644 (file)
@@ -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
@@ -105,7 +105,7 @@ class PVTUReader:
                     self._tmp=3
                     return
                 if name=="PDataArray":
-                    if self._tmp in self._data_array.keys():
+                    if self._tmp in self._data_array:
                         self._data_array[self._tmp](attrs)
                         pass
                     return
@@ -162,9 +162,9 @@ class VTURawReader:
         offsets=np.memmap(fd,dtype=rd._type_off,mode='r',offset=ref+rd._off_off,shape=(rd._nb_cells,))
         offsets=self.__swapIfNecessary(rd._bo,offsets) ; connLgth=offsets[-1] ; offsets2=DataArrayInt(rd._nb_cells+1) ; offsets2.setIJ(0,0,0)
         offsets2[1:]=DataArrayInt(offsets)
-        offsets3=offsets2.deltaShiftIndex() ; offsets2=offsets3.deepCpy() ; offsets3+=1 ; offsets3.computeOffsets2()
+        offsets3=offsets2.deltaShiftIndex() ; offsets2=offsets3.deepCopy() ; offsets3+=1 ; offsets3.computeOffsetsFull()
         offsets=offsets3
-        tmp1=DataArrayInt(len(offsets2),2) ; tmp1[:,0]=1 ; tmp1[:,1]=offsets2 ; tmp1.rearrange(1) ; tmp1.computeOffsets2()
+        tmp1=DataArrayInt(len(offsets2),2) ; tmp1[:,0]=1 ; tmp1[:,1]=offsets2 ; tmp1.rearrange(1) ; tmp1.computeOffsetsFull()
         tmp1=DataArrayInt.Range(1,2*len(offsets2),2).buildExplicitArrByRanges(tmp1)
         conn=np.memmap(fd,dtype=rd._type_conn,mode='r',offset=ref+rd._off_conn,shape=(connLgth,))
         conn=self.__swapIfNecessary(rd._bo,conn)
@@ -173,7 +173,7 @@ class VTURawReader:
         conn2[offsets[0:-1]]=types
         conn2[tmp1]=DataArrayInt(conn)
         m.setConnectivity(conn2,offsets,True)
-        m.checkCoherency() ; mm=MEDFileUMesh() ; mm.setMeshAtLevel(0,m) ; ms.pushMesh(mm)
+        m.checkConsistencyLight() ; mm=MEDFileUMesh() ; mm.setMeshAtLevel(0,m) ; ms.pushMesh(mm)
         # Fields on nodes and on cells
         for spatialDisc,nbEnt,fields in [(ON_NODES,rd._nb_nodes,rd._node_fields),(ON_CELLS,rd._nb_cells,rd._cell_fields)]: 
             for name,typ,nbCompo,off in fields:
@@ -183,7 +183,7 @@ class VTURawReader:
                 vals=np.memmap(fd,dtype=typ,mode='r',offset=ref+off,shape=(nbEnt*nbCompo))
                 vals=self.__swapIfNecessary(rd._bo,vals)
                 arr=DataArrayDouble(np.array(vals,dtype='float64')) ; arr.rearrange(nbCompo)
-                f.setArray(arr) ; f.checkCoherency()
+                f.setArray(arr) ; f.checkConsistencyLight()
                 f.setTime(self._time[0],self._time[1],0)
                 ff.appendFieldNoProfileSBT(f)
                 fs.pushField(ff)
@@ -270,7 +270,7 @@ class VTURawReader:
         except self.NormalException as e:
             isOK=True
             fd.seek(0)
-            for i in xrange(e.getLineNb()): fd.readline()
+            for i in range(e.getLineNb()): fd.readline()
             ref=fd.tell()+5
             pass
         if not isOK:
@@ -285,11 +285,11 @@ class VTURawReader:
 
     def __init__(self,fileName,tim=(0.,0)):
         msg="The time specified in constructor as 2nd arg should be a tuple containing 2 values 1 float and 1 int !"
-        if type(tim)!=tuple:
+        if not isinstance(tim, tuple):
             raise Exception(msg)
         if len(tim)!=2:
             raise Exception(msg)
-        if type(tim[0])!=float or type(tim[1])!=int:
+        if not isinstance(tim[0], float) or not isinstance(tim[1], int):
             raise Exception(msg)
         self._fileName=fileName
         self._time=tim