Salome HOME
Porting to Python 3
authorGilles DAVID <gilles-g.david@edf.fr>
Fri, 24 Mar 2017 12:48:58 +0000 (13:48 +0100)
committerGilles DAVID <gilles-g.david@edf.fr>
Fri, 24 Mar 2017 12:48:58 +0000 (13:48 +0100)
bin/mg-tetra_hpc.py
doc/salome/gui/GHS3DPRLPLUGIN/input/ghs3dprl_hypo.doc
src/GHS3DPRLPlugin/GHS3DPRLPluginBuilder.py
src/tools/facespoints2mesh.py
src/tools/mesh2facespoints.py
src/tools/testMesh.py
src/tools/testMeshTest.py

index ca6f4edae54cae75be3726d758a52b0fa4b83375..e20f654bea0fad73e5c44f258e9c0b419d1a890b 100644 (file)
@@ -3,21 +3,21 @@
 
 # %% LICENSE_SALOME_CEA_BEGIN
 # Copyright (C) 2008-2016  CEA/DEN
-# 
+#
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
 # version 2.1 of the License, or (at your option) any later version.
-# 
+#
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU Lesser General Public
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-# 
+#
 # See http://www.salome-platform.org or email : webmaster.salome@opencascade.com
 # %% LICENSE_END
 
@@ -32,24 +32,26 @@ example linux usage:
 """
 
 import os
+import platform
 import sys
 import time
-import platform
+
 import argparse as AP
-import pprint as PP #pretty print
-import subprocess as SP #Popen
-import multiprocessing as MP #cpu_count
+import multiprocessing as MP  # cpu_count
+import pprint as PP  # pretty print
+import subprocess as SP  # Popen
+
 
 verbose = False
 
 OK = "ok"
 KO = "KO"
-OKSYS = 0 #for linux
-KOSYS = 1 #for linux
+OKSYS = 0  # for linux
+KOSYS = 1  # for linux
+
+NB_PROCS = MP.cpu_count()  # current cpu number of proc
+NAME_OS = platform.system()  # 'Linux' or 'Windows'
 
-NB_PROCS = MP.cpu_count()   #current cpu number of proc
-NAME_OS = platform.system() #'Linux' or 'Windows'
 
 ##########################################################################
 # utilities
@@ -57,10 +59,10 @@ NAME_OS = platform.system() #'Linux' or 'Windows'
 
 def okToSys(aResult, verbose=False):
   """to get windows or linux result of script"""
-  
+
   def extendList(alist):
     """utility extend list of lists of string results with ok or KO"""
-    #bad: list(itertools.chain.from_list(alist)) iterate on str
+    # bad: list(itertools.chain.from_list(alist)) iterate on str
     res = []
     if type(alist) != list:
       return [alist]
@@ -71,19 +73,19 @@ def okToSys(aResult, verbose=False):
         else:
            res.extend(extendList(i))
     return res
-      
+
   resList = extendList(aResult)
   if resList == []:
     if verbose: print("WARNING: result no clear: []")
     return KOSYS
-    
+
   rr = OK
   for ri in resList:
     if ri[0:2] != OK:
-      if verbose: print ri
+      if verbose: print(ri)
       rr = KO
 
-  if verbose: print("INFO: result: %s" % rr)
+  if verbose: print(("INFO: result: %s" % rr))
   if rr == OK:
     return OKSYS
   else:
@@ -116,22 +118,22 @@ class ArgRange(object):
 def exec_command(cmd, verbose=False):
   """Exec ONE command with popen"""
 
-  time.sleep(3) #wait for (MPI) flush files
-  if verbose: print("launch process:\n  %s" % cmd)
+  time.sleep(3)  # wait for (MPI) flush files
+  if verbose: print(("launch process:\n  %s" % cmd))
   try:
-    pipe = SP.Popen(cmd, shell=True, stdout=SP.PIPE, stderr=SP.PIPE )
+    pipe = SP.Popen(cmd, shell=True, stdout=SP.PIPE, stderr=SP.PIPE)
   except Exception as e:
     result = KO + " ERROR: we have a problem popen on: %s" % PP.pformat(cmd)
     return result
-  
+
   (out, error) = pipe.communicate()
   pipe.wait()
-  
+
   print(out)
   print(error)
+
   result = OK + " INFO: seems final ok for: %s" % PP.pformat(cmd)
-  time.sleep(3) #wait for (MPI) flush files
+  time.sleep(3)  # wait for (MPI) flush files
   return result
 
 
@@ -158,7 +160,7 @@ def force_DISTENE_LICENSE_FILE():
     #export PATH=/export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing/bin:$PATH
     #do not work prefer set before salome launch
     OPENMPI_INSTALL_DIR = "/export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing/bin"
-    sys.path.insert(0, OPENMPI_INSTALL_DIR) 
+    sys.path.insert(0, OPENMPI_INSTALL_DIR)
     #INSTALL_DIR = /export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing
     for i in sys.path[0:10]: print "PATH",i
     """
@@ -168,18 +170,18 @@ def force_DISTENE_LICENSE_FILE():
 
 ##########################################################################
 def launchMultithread(args):
-  if verbose: print("INFO: launchMultithread for %s" % NAME_OS)
-  
+  if verbose: print(("INFO: launchMultithread for %s" % NAME_OS))
+
   if NAME_OS == 'Linux':
-    #--out is ONE file: basename_tetra_hpc.mesh
-    outputMulti = os.path.splitext(args.inputFile)[0] + "_tetra_hpc.mesh" #only one file if Multithread
+    # --out is ONE file: basename_tetra_hpc.mesh
+    outputMulti = os.path.splitext(args.inputFile)[0] + "_tetra_hpc.mesh"  # only one file if Multithread
     outputs = os.path.splitext(args.outputFiles)[0]
-    outputMultiAsMpi = os.path.splitext(args.outputFiles)[0] + ".000001.mesh" #create one output file named as only one from mpi 
+    outputMultiAsMpi = os.path.splitext(args.outputFiles)[0] + ".000001.mesh"  # create one output file named as only one from mpi
     cmd = "mg-tetra_hpc.exe --max_number_of_threads %i --in %s --gradation %s --max_size %s --min_size %s; cp %s %s; ls -alt %s*; " % \
           (args.number, args.inputFile, args.gradation, args.max_size, args.min_size, outputMulti, outputMultiAsMpi, outputs)
   else:
-    return KO +  " ERROR: unknown operating system: %s" % NAME_OS
-  
+    return KO + " ERROR: unknown operating system: %s" % NAME_OS
+
   result = exec_command(cmd, verbose=True)
   return result
 
@@ -187,11 +189,11 @@ def launchMultithread(args):
 
 ##########################################################################
 def launchMpi(args):
-  if verbose: print("INFO: launchMpi for %s" % NAME_OS)
-  
-  if NAME_OS == 'Linux':  
-    cmd  = ""
-    
+  if verbose: print(("INFO: launchMpi for %s" % NAME_OS))
+
+  if NAME_OS == 'Linux':
+    cmd = ""
+
     """ compile libmeshgems_mpi.so: no needs
     COMPILDIR=os.getenv("MESHGEMSHOME") + "/stubs"
     TARGETDIR=os.getenv("MESHGEMSHOME") + "/lib/Linux_64"
@@ -203,8 +205,8 @@ def launchMpi(args):
     cmd += "mpirun -n %i mg-tetra_hpc_mpi.exe --in %s --out %s --gradation %s --max_size %s --min_size %s; ls -alt %s*; " % \
           (args.number, args.inputFile, args.outputFiles, args.gradation, args.max_size, args.min_size, outputs)
   else:
-    return KO +  " ERROR: unknown operating system: %s" % NAME_OS
-  
+    return KO + " ERROR: unknown operating system: %s" % NAME_OS
+
   result = exec_command(cmd, verbose=True)
   return result
 
@@ -215,15 +217,15 @@ def launchMpi(args):
 
 if __name__ == '__main__':
   parser = AP.ArgumentParser(description='launch tetra_hpc.exe or tetra_hpc_mpi.exe mesh computation', argument_default=None)
-  #./mg-tetra_hpc.py -n 3 --in=/tmp/GHS3DPRL.mesh --out=/tmp/GHS3DPRL_out.mesh --gradation=1.05 --min_size=0.001 --max_size=1.1 --multithread no > /tmp/tetrahpc.log
+  # ./mg-tetra_hpc.py -n 3 --in=/tmp/GHS3DPRL.mesh --out=/tmp/GHS3DPRL_out.mesh --gradation=1.05 --min_size=0.001 --max_size=1.1 --multithread no > /tmp/tetrahpc.log
 
   parser.add_argument(
-    '-v', '--verbose', 
+    '-v', '--verbose',
     help='set verbose, for debug',
     action='store_true',
   )
   parser.add_argument(
-    '-n', '--number', 
+    '-n', '--number',
     help='if multithread: number of threads, else distributed: number of processes MPI',
     choices=[ArgRange(1, 999999)],
     type=int,
@@ -231,13 +233,13 @@ if __name__ == '__main__':
     default=1,
   )
   parser.add_argument(
-    '-m', '--multithread', 
+    '-m', '--multithread',
     help='launch tetra_hpc multithread instead tetra_hpc distributed (MPI)',
     choices=["no", "yes"],
     default='no',
   )
   parser.add_argument(
-    '-g', '--gradation', 
+    '-g', '--gradation',
     help='size ratio adjacent cell, default 0 is 1.05',
     type=float,
     choices=[ArgRange(0.0, 3.0)],
@@ -245,7 +247,7 @@ if __name__ == '__main__':
     default='0'
   )
   parser.add_argument(
-    '-si', '--min_size', 
+    '-si', '--min_size',
     help='min size cell, default 0 is no constraint',
     type=float,
     choices=[ArgRange(0.0, 9e99)],
@@ -253,7 +255,7 @@ if __name__ == '__main__':
     default='0'
   )
   parser.add_argument(
-    '-sa', '--max_size', 
+    '-sa', '--max_size',
     help='max size cell, default 0 is no constraint',
     type=float,
     choices=[ArgRange(0.0, 9e99)],
@@ -261,20 +263,20 @@ if __name__ == '__main__':
     default='0'
   )
   parser.add_argument(
-    '-i', '--inputFile', 
+    '-i', '--inputFile',
     help='input file name',
-    #nargs='?',
+    # nargs='?',
     metavar='.../inputFile.mesh'
   )
   parser.add_argument(
-    '-o', '--outputFiles', 
+    '-o', '--outputFiles',
     help='output basename file(s) name',
-    #nargs='?',
+    # nargs='?',
     metavar='.../outputFile.mesh'
   )
   """
   parser.add_argument(
-    '-x', '--xoneargument', 
+    '-x', '--xoneargument',
     nargs='?',
     metavar='0|1',
     choices=['0', '1'],
@@ -282,39 +284,39 @@ if __name__ == '__main__':
     default='0'
   )
   """
-  
-    
+
+
   """
-  args is Namespace, may use it as global to store 
+  args is Namespace, may use it as global to store
   parameters, data, used arrays and results and other...
   """
   args = parser.parse_args()
-  
+
   verbose = args.verbose
-  if verbose: print("INFO: args:\n%s" % PP.pformat(args.__dict__))
+  if verbose: print(("INFO: args:\n%s" % PP.pformat(args.__dict__)))
 
-  if len(sys.argv) == 1: #no args as --help
+  if len(sys.argv) == 1:  # no args as --help
     parser.print_help()
     sys.exit(KOSYS)
 
   if args.inputFile == None:
-    print("\nERROR: Nothing to do: no input files\n\n%s\n" % PP.pformat(args))
+    print(("\nERROR: Nothing to do: no input files\n\n%s\n" % PP.pformat(args)))
     parser.print_help()
     sys.exit(KOSYS)
 
   if args.outputFiles == None:
     tmp, _ = os.path.splitext(args.inputFile)
     args.outputFiles = tmp + "_out.mesh"
-    print("\nWARNING: Default ouput files: %s" % args.outputFiles)
-   
+    print(("\nWARNING: Default ouput files: %s" % args.outputFiles))
+
   force_DISTENE_LICENSE_FILE()
 
-  print("INFO: mg-tetra_hpc.py assume licence file set:\n  DLIM8VAR=%s\n  DISTENE_LICENSE_FILE=%s" % \
-       (os.getenv("DLIM8VAR"), os.getenv("DISTENE_LICENSE_FILE")))
-  if args.multithread == "yes": 
+  print(("INFO: mg-tetra_hpc.py assume licence file set:\n  DLIM8VAR=%s\n  DISTENE_LICENSE_FILE=%s" % \
+       (os.getenv("DLIM8VAR"), os.getenv("DISTENE_LICENSE_FILE"))))
+
+  if args.multithread == "yes":
     result = launchMultithread(args)
   else:
     result = launchMpi(args)
   sys.exit(okToSys(result, verbose=True))
-  
+
index 90c9215a506382963584e48ca3fe38cb1d8ae92b..ba404144b51e495e86757e5353d4e279319ee561 100644 (file)
@@ -388,9 +388,9 @@ status = m.Compute()
 # ----------
 
 if os.access(results+".xml", os.F_OK):
-    print "Ok: tetra_hpc"
+    print("Ok: tetra_hpc")
 else:
-    print "KO: tetra_hpc"
+    print("KO: tetra_hpc")
 \endcode
 \n
 </li>
index c1f83c1e66f9a90872566721d6676184eb3133ea..89f4d84a5a74d61673ad36ba0b5995fbeecd2f0a 100644 (file)
@@ -72,7 +72,7 @@ class GHS3DPRL_Algorithm(Mesh_Algorithm):
     #              if it is @c 0 (default), the algorithm is assigned to the main shape
     def __init__(self, mesh, geom=0):
         Mesh_Algorithm.__init__(self)
-        if noGHS3DPRLPlugin: print "Warning: GHS3DPRLPlugin module unavailable"
+        if noGHS3DPRLPlugin: print("Warning: GHS3DPRLPlugin module unavailable")
         self.Create(mesh, geom, self.algoType, "libGHS3DPRLEngine.so")
         self.params = None
         pass
index 8eeb7b1b1e4e0dcfc6233782a52cbe7361e107f8..c6ebe6ab27275e1cccb35fe651225f0a29414dd7 100755 (executable)
@@ -18,7 +18,6 @@
 #
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
-
 """
 these file is using in GHS3DPRL Plugin
 to convert input files .faces and .points of Tepal V1
@@ -30,38 +29,37 @@ example of use (when Tepal V2):
   mesh2facespoints.py DOMAIN
 """
 
-import os
+import codecs
 import sys
 
-file_fp='GHS3DPRL'
-if len(sys.argv)==2:
-   file_fp=sys.argv[1]
 
-f1=file_fp+'.points'
-f2=file_fp+'.faces'
-f3=file_fp+'.mesh'
+file_fp = 'GHS3DPRL'
+if len(sys.argv) == 2:
+    file_fp = sys.argv[1]
+
+f1 = file_fp + '.points'
+f2 = file_fp + '.faces'
+f3 = file_fp + '.mesh'
 
-fs=open(f1, 'r')
-ft=open(f3, 'w')
-ft.write('MeshVersionFormatted 1\n')
-ft.write('\nDimension\n3\n')
-tmp=fs.readline()
-nb=int(tmp)
-ft.write('\nVertices\n')
-ft.write(tmp)
-for i in xrange(0,nb):
-  lig=fs.readline()
-  ft.write(lig)
-fs.close()
+with codecs.open(f3, 'w') as ft:
+    with codecs.open(f1, 'r') as fs:
+        ft.write('MeshVersionFormatted 1\n')
+        ft.write('\nDimension\n3\n')
+        tmp = fs.readline()
+        nb = int(tmp)
+        ft.write('\nVertices\n')
+        ft.write(tmp)
+        for i in range(nb):
+            lig = fs.readline()
+            ft.write(lig)
+    with codecs.open(f2, 'r') as fs:
+        lig = fs.readline()
+        nb = int(lig.split()[0])
+        ft.write('\nTriangles\n' + lig.split()[0] + '\n')
+        for i in range(nb):
+            lig = fs.readline()
+            lig = lig.split()
+            ft.write(lig[1] + ' ' + lig[2] + ' ' + lig[3] + ' ' + lig[4] + '\n')
+        ft.write('\nEnd\n')
 
-fs=open(f2, 'r')
-lig=fs.readline()
-nb=int(lig.split()[0])
-ft.write('\nTriangles\n'+lig.split()[0]+'\n')
-for i in xrange(0,nb):
-  lig=fs.readline()
-  lig=lig.split()
-  ft.write(lig[1]+' '+lig[2]+' '+lig[3]+' '+lig[4]+'\n')
-ft.write('\nEnd\n')
-ft.close()
-print 'facespoints2mesh creation of file '+f3
+print('facespoints2mesh creation of file ' + f3)
index 0f9f5dad68f28b2577d012e6931f5ac384932c96..19f0853c1d477833d345dfc0837be0068dea9aca 100755 (executable)
@@ -18,7 +18,6 @@
 #
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
-
 """
 these file is using in GHS3DPRL Plugin
 to convert output files .mesh of Tepal V2
@@ -30,106 +29,123 @@ example of use (when Tepal V2):
   mesh2facespoints.py DOMAIN
 """
 
+import codecs
+import fileinput
+import glob
 import os
+import shutil
 import sys
-import glob
-import fileinput
-import string
-
-file_m='GHS3DPRL'
-if len(sys.argv)==2:
-   file_m=sys.argv[1]
-   
-def find_cr_or_not(fs,tag):
-  """find number after tag with cr or sp"""
-  for line in fs:
-    if tag+'\n' in line:
-      #print tag+'<cr>'
-      res=fs.readline()
-      break
-    if tag+' ' in line:
-      #print 'vertices<sp>'
-      res=line.split()[1]
-      break
-  res=res.strip("\t\n ")
-  print tag+' '+res
-  return res
+
+
+file_m = 'GHS3DPRL'
+if len(sys.argv) == 2:
+    file_m = sys.argv[1]
+
+
+def find_cr_or_not(fs, tag):
+    """find number after tag with cr or sp"""
+    for line in fs:
+        if tag + '\n' in line:
+            # print tag+'<cr>'
+            res = fs.readline()
+            break
+        if tag + ' ' in line:
+            # print 'vertices<sp>'
+            res = line.split()[1]
+            break
+    res = res.strip("\t\n ")
+    print(tag + ' ' + res)
+    return res
+
 
 def m2fp(f1):
-  """convert .mesh file to .points and .faces and .noboite"""
-  print '\nconversion '+f1+' to .points and .faces and .noboite'
-  #fs=open(f1, 'r')
-  #fs=fileinput.FileInput(f1,mode='r') #mode not in v2.4.4
-  fs=fileinput.FileInput(f1)
-  (shortname, extension)=os.path.splitext(f1)
-  f2=shortname+'.points'
-  print 'creating',f2
-  fp=open(f2, 'w')
-  nb=find_cr_or_not(fs,'Vertices')
-  np=nb #for .noboite
-  fp.write(nb+'\n')
-  for i in xrange(0,int(nb)):
-    fp.write(fs.readline())
-  fp.close()
-  
-  f2=shortname+'.faces'
-  print 'creating',f2
-  ff=open(f2, 'w')
-  nb=find_cr_or_not(fs,'Triangles')
-  ff.write(nb+' 0\n')
-  for i in xrange(0,int(nb)):
-    ff.write('3 '+fs.readline().strip('\t\n ')+' 0 0 0\n')
-  ff.close()
-  
-  ne=find_cr_or_not(fs,'Tetrahedra')
-  f3=shortname+'.noboite'
-  fb=open(f3, 'w')
-  npfixe="0"
-  fb.write(ne+' '+np+' '+npfixe+' 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n')
-  for i in xrange(0,int(ne)):
-    lig=fs.readline().strip('\t\n ')
-    lig=lig.split()
-    fb.write(lig[0]+" "+lig[1]+" "+lig[2]+" "+lig[3]+" ")
-  fb.write('\n')
-  fs.close()
-  fs=fileinput.FileInput(shortname+'.points')
-  nb=fs.readline() #eqal to np
-  for i in xrange(0,int(nb)):
-    lig=fs.readline().strip('\t\n ')
-    lig=lig.split()
-    fb.write(lig[0]+" "+lig[1]+" "+lig[2]+" ")
-  fb.write('\n0\n') #subnumber
-  fs.close()
-  fb.close()
-
-def rename_tepal_v1(f1,imax):
-  """rename files as version v1 of tepal expect"""
-  (shortname, extension)=os.path.splitext(f1)
-  fs=os.path.splitext(shortname)
-  i=int(fs[1].strip('.'))
-  ff=fs[0]+'.'+str(imax)+'.'+string.zfill(str(i),len(str(imax)))
-  #noboite en ".32.02.noboite!"
-  mvcp='mv ' #ou 'cp '
-  f2=shortname+'.points' ; f3=ff+os.path.splitext(f2)[1]
-  print f2,'->',f3 ; os.system(mvcp+f2+' '+f3)
-  f2=shortname+'.faces' ; f3=ff+os.path.splitext(f2)[1]
-  print f2,'->',f3 ; os.system(mvcp+f2+' '+f3)
-  f2=shortname+'.noboite' ; f3=ff+os.path.splitext(f2)[1]
-  print f2,'->',f3 ; os.system(mvcp+f2+' '+f3)
-  f2=shortname+'.glo' ; f3=ff+os.path.splitext(f2)[1]
-  print f2,'->',f3 ; os.system(mvcp+f2+' '+f3)
-  f2=shortname+'.msg' ; f3=ff+os.path.splitext(f2)[1]
-  print f2,'->',f3 ; os.system(mvcp+f2+' '+f3)
-
-def my_test(a): return int(os.path.basename(a).split('.')[1])
-
-f0=file_m+'.?????.mesh'
-#print f0
-fics=glob.glob(f0)
-fics.sort(lambda a, b: cmp(my_test(b), my_test(a))) #tri ordre decroissant
-print 'conversion of files:\n',fics
-
-imax=len(fics)
+    """convert .mesh file to .points and .faces and .noboite"""
+    print('\nconversion ' + f1 + ' to .points and .faces and .noboite')
+    # fs=open(f1, 'r')
+    # fs=fileinput.FileInput(f1,mode='r') #mode not in v2.4.4
+    fs = fileinput.FileInput(f1)
+    shortname = os.path.splitext(f1)[0]
+    f2 = shortname + '.points'
+    print('creating', f2)
+    with codecs.open(f2, 'w') as fp:
+        nb = find_cr_or_not(fs, 'Vertices')
+        np = nb  # for .noboite
+        fp.write(nb + '\n')
+        for _ in range(int(nb)):
+            fp.write(fs.readline())
+
+    f2 = shortname + '.faces'
+    print('creating', f2)
+    with codecs.open(f2, 'w') as ff:
+        nb = find_cr_or_not(fs, 'Triangles')
+        ff.write(nb + ' 0\n')
+        for _ in range(int(nb)):
+            ff.write('3 ' + fs.readline().strip('\t\n ') + ' 0 0 0\n')
+
+    ne = find_cr_or_not(fs, 'Tetrahedra')
+    f3 = shortname + '.noboite'
+    with codecs.open(f3, 'w') as fb:
+        npfixe = "0"
+        fb.write(ne + ' ' + np + ' ' + npfixe + ' 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n')
+        for _ in range(int(ne)):
+            lig = fs.readline().strip('\t\n ')
+            lig = lig.split()
+            fb.write(lig[0] + " " + lig[1] + " " + lig[2] + " " + lig[3] + " ")
+        fb.write('\n')
+        fs.close()
+        fs = fileinput.FileInput(shortname + '.points')
+        nb = fs.readline()  # eqal to np
+        for _ in range(int(nb)):
+            lig = fs.readline().strip('\t\n ')
+            lig = lig.split()
+            fb.write(lig[0] + " " + lig[1] + " " + lig[2] + " ")
+        fb.write('\n0\n')  # subnumber
+        fs.close()
+
+
+def rename_tepal_v1(f1, imax):
+    """rename files as version v1 of tepal expect"""
+    shortname = os.path.splitext(f1)[0]
+    fs = os.path.splitext(shortname)
+    i = int(fs[1].strip('.'))
+    ff = fs[0] + '.' + str(imax) + '.' + str(i).zfill(len(str(imax)))
+    # noboite en ".32.02.noboite!"
+    f2 = shortname + '.points'
+    f3 = ff + os.path.splitext(f2)[1]
+    print(f2, '->', f3)
+    shutil.move(f2, f3)
+    f2 = shortname + '.faces'
+    f3 = ff + os.path.splitext(f2)[1]
+    print(f2, '->', f3)
+    shutil.move(f2, f3)
+    f2 = shortname + '.noboite'
+    f3 = ff + os.path.splitext(f2)[1]
+    print(f2, '->', f3)
+    shutil.move(f2, f3)
+    f2 = shortname + '.glo'
+    f3 = ff + os.path.splitext(f2)[1]
+    print(f2, '->', f3)
+    shutil.move(f2, f3)
+    f2 = shortname + '.msg'
+    f3 = ff + os.path.splitext(f2)[1]
+    print(f2, '->', f3)
+    shutil.move(f2, f3)
+
+
+def my_test(a):
+    return int(os.path.basename(a).split('.')[1])
+
+
+def cmp(a, b):
+    return (a > b) - (a < b)
+
+f0 = file_m + '.?????.mesh'
+# print f0
+fics = glob.glob(f0)
+fics.sort(lambda a, b: cmp(my_test(b), my_test(a)))  # tri ordre decroissant
+print('conversion of files:\n', fics)
+
+imax = len(fics)
 for f in fics:
-  m2fp(f)
-  rename_tepal_v1(f,imax)
+    m2fp(f)
+    rename_tepal_v1(f, imax)
index cf3a2062cc8577a752f2598d70c6675d3873e5d8..9d04974a4f7e6861997848b84c264896e42f3656 100644 (file)
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-\r
-# %% LICENSE_SALOME_CEA_BEGIN\r
-# Copyright (C) 2008-2016  CEA/DEN\r
-# \r
-# This library is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 2.1 of the License, or (at your option) any later version.\r
-# \r
-# This library is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
-# Lesser General Public License for more details.\r
-# \r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with this library; if not, write to the Free Software\r
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
-# \r
-# See http://www.salome-platform.org or email : webmaster.salome@opencascade.com\r
-# %% LICENSE_END\r
-\r
-\r
-"""\r
-run coherency tests on one and some mesh.\r
-initially used for test output(s) mg_tetra_hpc_mpi.exe\r
-\r
-WARNING: is for small meshes, obviously no optimisation.\r
-WARNING: printing and .mesh indices are 1 to n when stored list python 0 to n-1\r
-\r
-example linux usage:\r
-- simple run:\r
-  ./testMesh.py --verbose --testall --files ./GHS3DPRL_out.000001.mesh ./GHS3DPRL_out.000002.mesh\r
-  ./testMesh.py -a -f /tmp/GHS3DPRL_out.00000?.mesh\r
-"""\r
-\r
-import os\r
-import sys\r
-import platform\r
-import argparse as AP\r
-import pprint as PP #pretty print\r
-\r
-verbose = False\r
-\r
-OK = "ok"\r
-KO = "KO"\r
-OKSYS = 0 #for linux\r
-KOSYS = 1 #for linux\r
-\r
-\r
-#########################################\r
-# utilities\r
-\r
-def okToSys(aResult, verbose=False):\r
-  """to get windows or linux result of script"""\r
-  
+
+# %% LICENSE_SALOME_CEA_BEGIN
+# Copyright (C) 2008-2016  CEA/DEN
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org or email : webmaster.salome@opencascade.com
+# %% LICENSE_END
+
+
+"""
+run coherency tests on one and some mesh.
+initially used for test output(s) mg_tetra_hpc_mpi.exe
+
+WARNING: is for small meshes, obviously no optimisation.
+WARNING: printing and .mesh indices are 1 to n when stored list python 0 to n-1
+
+example linux usage:
+- simple run:
+  ./testMesh.py --verbose --testall --files ./GHS3DPRL_out.000001.mesh ./GHS3DPRL_out.000002.mesh
+  ./testMesh.py -a -f /tmp/GHS3DPRL_out.00000?.mesh
+"""
+
+import os
+import sys
+
+import argparse as AP
+import pprint as PP  # pretty print
+
+
+verbose = False
+
+OK = "ok"
+KO = "KO"
+OKSYS = 0  # for linux
+KOSYS = 1  # for linux
+
+
+#########################################
+# utilities
+
+def okToSys(aResult, verbose=False):
+  """to get windows or linux result of script"""
+
   def extendList(alist):
-    """utility extend list of lists of string results with ok or KO"""\r
-    #bad: list(itertools.chain.from_list(alist)) iterate on str\r
-    res = []\r
-    if type(alist) != list:\r
-      return [alist]\r
-    else:\r
-      for i in alist:\r
-        if type(i) == str:\r
-           res.append(i)\r
-        else:\r
-           res.extend(extendList(i))\r
-    return res\r
-      \r
-  resList = extendList(aResult)\r
-  if resList == []:\r
-    if verbose: print("WARNING: result no clear: []")\r
-    return KOSYS\r
-    \r
-  rr = OK\r
-  for ri in resList:\r
-    if ri[0:2] != OK:\r
-      if verbose: print ri\r
-      rr = KO\r
-\r
-  if verbose: print("INFO: result: %s" % rr)\r
-  if rr == OK:\r
-    return OKSYS\r
-  else:\r
-    return KOSYS\r
-\r
-def getDirAndName(datafile):\r
-  path, namefile = os.path.split(os.path.realpath(datafile))\r
-  rootpath = os.getcwd()\r
-  return (path, rootpath, namefile)\r
-\r
-def resumeList(aList):\r
-  if len(aList) == 0: \r
-    return []\r
-  if len(aList) < 3:\r
-    return aList\r
-  res = [aList[0], "...", aList[-1]]\r
-  return res\r
-\r
-def resumeLines(aList, ilines):\r
-  if verbose: print("INFO: resumeLines", ilines)\r
-  if len(aList) == 0: \r
-    return []\r
-  if len(aList) < 3:\r
-    return aList\r
-  res = []\r
+    """utility extend list of lists of string results with ok or KO"""
+    # bad: list(itertools.chain.from_list(alist)) iterate on str
+    res = []
+    if type(alist) != list:
+      return [alist]
+    else:
+      for i in alist:
+        if type(i) == str:
+           res.append(i)
+        else:
+           res.extend(extendList(i))
+    return res
+
+  resList = extendList(aResult)
+  if resList == []:
+    if verbose: print("WARNING: result no clear: []")
+    return KOSYS
+
+  rr = OK
+  for ri in resList:
+    if ri[0:2] != OK:
+      if verbose: print(ri)
+      rr = KO
+
+  if verbose: print("INFO: result: %s" % rr)
+  if rr == OK:
+    return OKSYS
+  else:
+    return KOSYS
+
+def getDirAndName(datafile):
+  path, namefile = os.path.split(os.path.realpath(datafile))
+  rootpath = os.getcwd()
+  return (path, rootpath, namefile)
+
+def resumeList(aList):
+  if len(aList) == 0:
+    return []
+  if len(aList) < 3:
+    return aList
+  res = [aList[0], "...", aList[-1]]
+  return res
+
+def resumeLines(aList, ilines):
+  if verbose: print("INFO: resumeLines", ilines)
+  if len(aList) == 0:
+    return []
+  if len(aList) < 3:
+    return aList
+  res = []
   for i in ilines:
-    if i != None: # if not existing tetrahedra for example\r
-      resi = [ii.strip("\n") for ii in aList[i:i+4]]\r
-      resi.append("...")\r
-      res.append(resi)\r
-  return res\r
-\r
-\r
-#########################################\r
-class XXVert(object): \r
-  """Vertices, Nodes"""\r
-  def __init__(self, x, y, z, color=0, indexglobal=0):\r
-    self.x = x\r
-    self.y = y\r
-    self.z = z\r
-    self.color = color\r
-    self.indexglobal = indexglobal\r
-\r
-  def compare(self, vb, args, withAll=True):\r
-    if self.x != vb.x: return False\r
-    if self.y != vb.y: return False\r
-    if self.z != vb.z: return False\r
-    if withAll:\r
-      if args.withColor:\r
-        if self.color != vb.color: return False\r
-      if args.withIndex:\r
-        if self.indexglobal != vb.indexglobal: return False\r
-    return True\r
-\r
-  def __eq__(self, vb):\r
-    """equality test without color or indexglobal"""\r
-    #print "vertice equality"\r
-    if self.x != vb.x: return False\r
-    if self.y != vb.y: return False\r
-    if self.z != vb.z: return False\r
-    return True\r
-\r
-  def __ne__(self, vb):\r
-    """inequality test without color or indexglobal"""\r
-    #print "vertice inequality"\r
-    if self.x == vb.x and self.y == vb.y and self.z != vb.z: \r
-      return True\r
-    return False\r
-\r
-  def __repr__(self):\r
-    return "XXVert(%.4f %.4f %.4f (%i %i))" % \\r
-           (self.x, self.y, self.z, self.color, self.indexglobal)\r
-\r
-  def __str__(self):\r
-    return "(%s %s %s (%i %i))" % \\r
-           (self.x, self.y, self.z, self.color, self.indexglobal)\r
-\r
-  def dist(self, vb):\r
-    res = (self.x - vb.x)**2 + (self.y - vb.y)**2 + (self.z -vb.z)**2\r
-    return res**.5\r
-\r
-\r
-\r
-#########################################\r
-class XXEdge(object):\r
-  """Edges, 2 Nodes"""\r
-  def __init__(self, a, b, color=0, indexglobal=0):\r
-    self.a = a\r
-    self.b = b\r
-    self.color = color\r
-    self.indexglobal = indexglobal\r
-\r
-  def compare(self, eb, args):\r
-    res = self.a.compare(eb.a, args) and \\r
-          self.b.compare(eb.b, args)\r
-    if res:\r
-      if args.withColor:\r
-        if self.color != eb.color: return False\r
-      if args.withIndex:\r
-        if self.indexglobal != eb.indexglobal: return False\r
-    return res\r
-\r
-  def __repr__(self):\r
-    return "XXEdge(%i %i (%i %i))" % \\r
-           (self.a, self.b, self.color, self.indexglobal)\r
-\r
-  def __str__(self):\r
-    return "(%i %i (%i %i))" % \\r
-           (self.a, self.b, self.color, self.indexglobal)\r
-\r
-  def inTria(self, tria, args):\r
-    t = [tria.a, tria.b, tria.c]\r
-    if not self.a in t: return False\r
-    if not self.b in t: return False\r
-    return True\r
-\r
-  def getVertices(self, mesh):\r
-    v1 = mesh.verts[self.a - 1]\r
-    v2 = mesh.verts[self.b - 1]\r
-    return [v1, v2]\r
-\r
-\r
-#########################################\r
-class XXTria(object):\r
-  """Triangles, Faces, 3 nodes"""\r
-  def __init__(self, a, b, c, color=0, indexglobal=0):\r
-    self.a = a\r
-    self.b = b\r
-    self.c = c\r
-    self.color = color\r
-    self.indexglobal = indexglobal\r
-\r
-  def compare(self, trb, args):\r
-    res = self.a.compare(trb.a, args) and \\r
-          self.b.compare(trb.b, args) and \\r
-          self.c.compare(trb.c, args)\r
-    if res:\r
-      if args.withColor:\r
-        if self.color != trb.color: return False\r
-      if args.withIndex:\r
-        if self.indexglobal != trb.indexglobal: return False\r
-    return res\r
-\r
-  def __repr__(self):\r
-    return "XXTria(%i %i %i (%i %i))" % \\r
-           (self.a, self.b, self.c, self.color, self.indexglobal)\r
-\r
-  def __str__(self):\r
-    return "(%i %i %i (%i %i))" % \\r
-           (self.a, self.b, self.c, self.color, self.indexglobal)\r
-\r
-  def inTetra(self, tetra, args):\r
-    t = [tetra.a, tetra.b, tetra.c, tetra.d]\r
-    if not self.a in t: return False\r
-    if not self.b in t: return False\r
-    if not self.c in t: return False\r
-    return True\r
-\r
-  def getVertices(self, mesh):\r
-    v1 = mesh.verts[self.a - 1]\r
-    v2 = mesh.verts[self.b - 1]\r
-    v3 = mesh.verts[self.c - 1]\r
-    return [v1, v2, v3]\r
-\r
-\r
-\r
-#########################################\r
-class XXTetra(object):\r
-  """Tetra, 4 nodes"""\r
-  def __init__(self, a, b, c, d, color=0, indexglobal=0):\r
-    self.a = a\r
-    self.b = b\r
-    self.c = c\r
-    self.d = d\r
-    self.color = color\r
-    self.indexglobal = indexglobal\r
-\r
-  def compare(self, teb, args):\r
-    res = self.a.compare(teb.a, args) and \\r
-          self.b.compare(teb.b, args) and \\r
-          self.c.compare(teb.c, args) and \\r
-          self.d.compare(teb.d, args)\r
-    if res:\r
-      if args.withColor:\r
-        if self.color != teb.color: return False\r
-      if args.withIndex:\r
-        if self.indexglobal != teb.indexglobal: return False\r
-    return res\r
-\r
-  def __repr__(self):\r
-    return "XXTetra(%i %i %i %i (%i %i))" % \\r
-           (self.a, self.b, self.c, self.d, self.color, self.indexglobal)\r
-\r
-  def __str__(self):\r
-    return "(%i %i %i %i (%i %i))" % \\r
-           (self.a, self.b, self.c, self.d, self.color, self.indexglobal)\r
-\r
-  def getVertices(self, mesh):\r
-    v1 = mesh.verts[self.a - 1]\r
-    v2 = mesh.verts[self.b - 1]\r
-    v3 = mesh.verts[self.c - 1]\r
-    v4 = mesh.verts[self.d - 1]\r
-    return [v1, v2, v3, v4]\r
-\r
-\r
-#########################################\r
-class XXMesh(object):\r
-  """Mesh: vertices, edges, triangles, tetrahedra"""\r
-  def __init__(self):\r
-    self.nameFile = ""\r
-    self.verts = []\r
-    self.edges = []\r
-    self.trias = []\r
-    self.tetras = []\r
-\r
-  def initFromFileMesh(self, fileName, args, withGlobal=True):\r
-    if not os.path.isfile(fileName):\r
-      raise Exception("ERROR: inexisting file '%s'" % fileName)\r
-    with open(fileName, "r") as f:\r
-      lines = f.readlines()\r
-    iverts, iedges, itrias, itetras = self.getIndexInMeshFile(lines)\r
-    self.verts = self.getMeshVerts(lines, iverts)\r
-    self.edges = self.getMeshEdges(lines, iedges)\r
-    self.trias = self.getMeshTrias(lines, itrias)\r
-    self.tetras = self.getMeshTetras(lines, itetras)\r
-    self.nameFile = fileName\r
-    if args.globalNumerotation == True and withGlobal==True:\r
-      self.initFromFileGlobal(fileName, args)\r
-    if verbose: \r
-      print("\nINFO: initFromFileMesh: read file: %s" % str(self))\r
-      print(self.strResume())\r
-      print(PP.pformat(resumeLines(lines, [iverts, iedges, itrias, itetras])))\r
-\r
-  def initFromFileGlobal(self, fileNameMeshOrGlobal, args):\r
-    shortname, extension = os.path.splitext(fileNameMeshOrGlobal)\r
-    if extension == ".mesh":\r
-      fileName = shortname +  ".global"\r
-    elif extension == "global":\r
-      fileName = fileNameMeshOrGlobal\r
-    else:\r
-      raise Exception("ERROR: initFromFileGlobal: unexpected file '%s'" % fileName)\r
-    if not os.path.isfile(fileName):\r
-      raise Exception("ERROR: initFromFileGlobal: inexisting file '%s'" % fileName)\r
-    \r
-    with open(fileName, "r") as f:\r
-      lines = f.readlines()\r
-    nbverts, nbedges, nbtrias, nbtetras = [int(i) for i in lines[0].split()]\r
-    if verbose:\r
-      print("\nINFO: initFromFileGlobal: read file: %s" % str(self))\r
-      print("  nbverts %i\n  nbedges %i\n  nbtrias %i\n  nbtetras %i" % (nbverts, nbedges, nbtrias, nbtetras))\r
-    if nbverts != len(self.verts): \r
-      raise Exception("ERROR: in file '%s' unexpected number of Vertices %i<>%i" % (fileName, nbverts, len(self.verts)))\r
-    if nbedges != len(self.edges): \r
-      raise Exception("ERROR: in file '%s' unexpected number of Edges %i<>%i" % (fileName, nbedges, len(self.edges)))\r
-    if nbtrias != len(self.trias): \r
-      raise Exception("ERROR: in file '%s' unexpected number of Triangles %i<>%i" % (fileName, nbtrias, len(self.trias)))\r
-    if nbtetras != len(self.tetras): \r
-      raise Exception("ERROR: in file '%s' unexpected number of Tetrahedra %i<>%i" % (fileName, nbtetras, len(self.tetras)))\r
-    i = 1 #begin index line 1\r
-    for ii in range(nbverts):\r
-      self.verts[ii].indexglobal = long(lines[i])\r
-      i +=1\r
-    for ii in range(nbedges):\r
-      self.edges[ii].indexglobal = long(lines[i])\r
-      i +=1\r
-    for ii in range(nbtrias):\r
-      self.trias[ii].indexglobal = long(lines[i])\r
-      i +=1\r
-    for ii in range(nbtetras):\r
-      self.tetras[ii].indexglobal = long(lines[i])\r
-      i +=1\r
-\r
-\r
-  def __repr__(self):\r
-    return "XXMesh(nameFile='%s', nbverts=%i, nbedges=%i, nbtrias=%i, nbtetras=%i)" % \\r
-           (self.nameFile, len(self.verts), len(self.edges), len(self.trias), len(self.tetras))\r
-\r
-  def strResume(self):\r
-    res = str(self)\r
-    contents = {\r
-      "Vertices": resumeList(self.verts),\r
-      "Edges": resumeList(self.edges),\r
-      "Triangles": resumeList(self.trias),\r
-      "Tetrahedra": resumeList(self.tetras),\r
-    }\r
-    res = res + "\n" + PP.pformat(contents)\r
-    return res\r
-\r
-  def getIndexInMeshFile(self, lines):\r
-    res = []\r
-    for s in ["Vertices", "Edges", "Triangles", "Tetrahedra"]:\r
-      try:\r
-        i = lines.index(s+"\n")\r
-      except:\r
-        i = None\r
-      res.append(i)\r
-    return res\r
-\r
-  def getMeshVerts(self, lines, i):\r
-    res=[]\r
-    try:\r
-      idep = i+2\r
-      ilen = int(lines[i+1])\r
-      ifin =  idep+ilen\r
-      for line in lines[idep:ifin]:\r
-        li = line.split(" ")\r
-        x, y, z, color = float(li[0]), float(li[1]), float(li[2]), int(li[3])\r
-        res.append(XXVert(x, y, z, color))\r
-      return res\r
-    except:\r
-      return res\r
-\r
-  def getMeshEdges(self, lines, i):\r
-    res=[]\r
-    try:\r
-      idep = i+2\r
-      ilen = int(lines[i+1])\r
-      ifin =  idep+ilen\r
-      for line in lines[idep:ifin]:\r
-        li = line.split(" ")\r
-        a, b, color = int(li[0]), int(li[1]), int(li[2])\r
-        res.append(XXEdge(a, b, color))\r
-      return res\r
-    except:\r
-      return res\r
-\r
-  def getMeshTrias(self, lines, i):\r
-    res=[]\r
-    try:\r
-      idep = i+2\r
-      ilen = int(lines[i+1])\r
-      ifin =  idep+ilen\r
-      for line in lines[idep:ifin]:\r
-        li = line.split(" ")\r
-        a, b, c, color = int(li[0]), int(li[1]), int(li[2]), int(li[3])\r
-        res.append(XXTria(a, b, c, color))\r
-      return res\r
-    except:\r
-      return res\r
-\r
-  def getMeshTetras(self, lines, i):\r
-    res=[]\r
-    try:\r
-      idep = i+2\r
-      ilen = int(lines[i+1])\r
-      ifin =  idep+ilen\r
-      for line in lines[idep:ifin]:\r
-        li = line.split(" ")\r
-        a, b, c, d, color = int(li[0]), int(li[1]), int(li[2]), int(li[3]), int(li[4])\r
-        res.append(XXTetra(a, b, c, d, color))\r
-      return res\r
-    except:\r
-      return res\r
-\r
-  def haveVertsDistinct(self, args):\r
-    """stop a first KO"""\r
-    i = 0\r
-    verts = self.verts\r
-    for v1 in verts[:-1]:\r
-      i += 1\r
-      j = i\r
-      for v2 in verts[i:]:\r
-        j += 1\r
-        if v1.compare(v2, args):\r
-          #printing indices 1 to n\r
-          print("ERROR: %s vert[%i] equal vert[%i]: v1=%s v2=%s" % (self.nameFile, i, j, v1, v2))\r
-          return KO + " ERROR: %s some equal vertices" % self.nameFile #stop a first KO\r
-    return OK + " INFO: no equal vertices"\r
-\r
-  def getVertices(self, elem):\r
-    """functionnal raccourci to XXElem.getVertices(XXMesh)"""\r
-    return elem.getVertices(self)\r
-\r
-  def compareListOfVertices(self, v1s, v2s, ordered=False):\r
-    """not ordered for now"""\r
-    if ordered:\r
-      res = [i for i, j in zip(v1s, v2s) if i == j]\r
-      return len(res)==len(v1s)\r
-    else:       \r
-      res = 0\r
-      for i in v1s:\r
-        for j in v2s:\r
-          if i == j: \r
-            res += 1\r
-            break\r
-      return res==len(v1s)\r
-    \r
-    \r
-  def getCommonVerts(self, mesh, args):\r
-    res = []\r
-    for v1 in self.verts:\r
-      for v2 in mesh.verts:\r
-        if v1.compare(v2, args, withAll=False):\r
-          res.append((v1, v2))\r
-    return res\r
-\r
-  def getVertices(self, elem):\r
-    return elem.getVertices(self)\r
-\r
-  def getCommonEdges(self, mesh, args):\r
-    res = []\r
-    for e1 in self.edges:\r
-      v1s = self.getVertices(e1)\r
-      for e2 in mesh.edges:\r
-        v2s = mesh.getVertices(e2)\r
-        if self.compareListOfVertices(v1s, v2s):\r
-          res.append((e1, e2))\r
-    return res\r
-\r
-  def getCommonTriangles(self, mesh, args):\r
-    res = []\r
-    for e1 in self.trias:\r
-      v1s = self.getVertices(e1)\r
-      for e2 in mesh.trias:\r
-        v2s = mesh.getVertices(e2)\r
-        if self.compareListOfVertices(v1s, v2s):\r
-          res.append((e1, e2))\r
-    return res\r
-\r
-  def getCommonTetras(self, mesh, args):\r
-    res = []\r
-    for e1 in self.tetras:\r
-      v1s = self.getVertices(e1)\r
-      for e2 in mesh.tetras:\r
-        v2s = mesh.getVertices(e2)\r
-        if self.compareListOfVertices(v1s, v2s):\r
-          res.append((e1, e2))\r
-    return res\r
-\r
-  def areEdgesInTrias(self, args):\r
-    """stop a first KO"""\r
-    done = False\r
-    i = 0\r
-    edges = self.edges\r
-    trias = self.trias\r
-    res = OK + " INFO: %s all edges in trias" % self.nameFile\r
-    for e in edges:\r
-      i += 1\r
-      j = 0\r
-      found = False\r
-      for t in trias:\r
-        j += 1\r
-        if e.inTria(t, args):\r
-          #if verbose: print("INFO: %s edges[%i] in trias[%i]: edge=%s tria=%s" % (self.nameFile, i, j, e, t))\r
-          found = True\r
-          break\r
-      if not found:\r
-        print("ERROR: %s edges[%i] not in trias: edge=%s" % (self.nameFile, i, e))\r
-        if verbose and not done: \r
-          print("Triangles:\n%s" % PP.pformat(self.trias))\r
-          done = True\r
-        res = KO+" ERROR: %s some edges not in trias" % (self.nameFile)\r
-    return res\r
-\r
-\r
-  def areTriasInTetras(self, args):\r
-    """no stop a first KO"""\r
-    done = False\r
-    i = 0\r
-    trias = self.trias\r
+    if i != None:  # if not existing tetrahedra for example
+      resi = [ii.strip("\n") for ii in aList[i:i + 4]]
+      resi.append("...")
+      res.append(resi)
+  return res
+
+
+#########################################
+class XXVert:
+  """Vertices, Nodes"""
+  def __init__(self, x, y, z, color=0, indexglobal=0):
+    self.x = x
+    self.y = y
+    self.z = z
+    self.color = color
+    self.indexglobal = indexglobal
+
+  def compare(self, vb, args, withAll=True):
+    if self.x != vb.x: return False
+    if self.y != vb.y: return False
+    if self.z != vb.z: return False
+    if withAll:
+      if args.withColor:
+        if self.color != vb.color: return False
+      if args.withIndex:
+        if self.indexglobal != vb.indexglobal: return False
+    return True
+
+  def __eq__(self, vb):
+    """equality test without color or indexglobal"""
+    # print "vertice equality"
+    if self.x != vb.x: return False
+    if self.y != vb.y: return False
+    if self.z != vb.z: return False
+    return True
+
+  def __ne__(self, vb):
+    """inequality test without color or indexglobal"""
+    # print "vertice inequality"
+    if self.x == vb.x and self.y == vb.y and self.z != vb.z:
+      return True
+    return False
+
+  def __repr__(self):
+    return "XXVert(%.4f %.4f %.4f (%i %i))" % \
+           (self.x, self.y, self.z, self.color, self.indexglobal)
+
+  def __str__(self):
+    return "(%s %s %s (%i %i))" % \
+           (self.x, self.y, self.z, self.color, self.indexglobal)
+
+  def dist(self, vb):
+    res = (self.x - vb.x) ** 2 + (self.y - vb.y) ** 2 + (self.z - vb.z) ** 2
+    return res ** .5
+
+
+#########################################
+class XXEdge:
+  """Edges, 2 Nodes"""
+  def __init__(self, a, b, color=0, indexglobal=0):
+    self.a = a
+    self.b = b
+    self.color = color
+    self.indexglobal = indexglobal
+
+  def compare(self, eb, args):
+    res = self.a.compare(eb.a, args) and \
+          self.b.compare(eb.b, args)
+    if res:
+      if args.withColor:
+        if self.color != eb.color: return False
+      if args.withIndex:
+        if self.indexglobal != eb.indexglobal: return False
+    return res
+
+  def __repr__(self):
+    return "XXEdge(%i %i (%i %i))" % \
+           (self.a, self.b, self.color, self.indexglobal)
+
+  def __str__(self):
+    return "(%i %i (%i %i))" % \
+           (self.a, self.b, self.color, self.indexglobal)
+
+  def inTria(self, tria, args):
+    t = [tria.a, tria.b, tria.c]
+    if not self.a in t: return False
+    if not self.b in t: return False
+    return True
+
+  def getVertices(self, mesh):
+    v1 = mesh.verts[self.a - 1]
+    v2 = mesh.verts[self.b - 1]
+    return [v1, v2]
+
+
+#########################################
+class XXTria:
+  """Triangles, Faces, 3 nodes"""
+  def __init__(self, a, b, c, color=0, indexglobal=0):
+    self.a = a
+    self.b = b
+    self.c = c
+    self.color = color
+    self.indexglobal = indexglobal
+
+  def compare(self, trb, args):
+    res = self.a.compare(trb.a, args) and \
+          self.b.compare(trb.b, args) and \
+          self.c.compare(trb.c, args)
+    if res:
+      if args.withColor:
+        if self.color != trb.color: return False
+      if args.withIndex:
+        if self.indexglobal != trb.indexglobal: return False
+    return res
+
+  def __repr__(self):
+    return "XXTria(%i %i %i (%i %i))" % \
+           (self.a, self.b, self.c, self.color, self.indexglobal)
+
+  def __str__(self):
+    return "(%i %i %i (%i %i))" % \
+           (self.a, self.b, self.c, self.color, self.indexglobal)
+
+  def inTetra(self, tetra, args):
+    t = [tetra.a, tetra.b, tetra.c, tetra.d]
+    if not self.a in t: return False
+    if not self.b in t: return False
+    if not self.c in t: return False
+    return True
+
+  def getVertices(self, mesh):
+    v1 = mesh.verts[self.a - 1]
+    v2 = mesh.verts[self.b - 1]
+    v3 = mesh.verts[self.c - 1]
+    return [v1, v2, v3]
+
+
+#########################################
+class XXTetra:
+  """Tetra, 4 nodes"""
+  def __init__(self, a, b, c, d, color=0, indexglobal=0):
+    self.a = a
+    self.b = b
+    self.c = c
+    self.d = d
+    self.color = color
+    self.indexglobal = indexglobal
+
+  def compare(self, teb, args):
+    res = self.a.compare(teb.a, args) and \
+          self.b.compare(teb.b, args) and \
+          self.c.compare(teb.c, args) and \
+          self.d.compare(teb.d, args)
+    if res:
+      if args.withColor:
+        if self.color != teb.color: return False
+      if args.withIndex:
+        if self.indexglobal != teb.indexglobal: return False
+    return res
+
+  def __repr__(self):
+    return "XXTetra(%i %i %i %i (%i %i))" % \
+           (self.a, self.b, self.c, self.d, self.color, self.indexglobal)
+
+  def __str__(self):
+    return "(%i %i %i %i (%i %i))" % \
+           (self.a, self.b, self.c, self.d, self.color, self.indexglobal)
+
+  def getVertices(self, mesh):
+    v1 = mesh.verts[self.a - 1]
+    v2 = mesh.verts[self.b - 1]
+    v3 = mesh.verts[self.c - 1]
+    v4 = mesh.verts[self.d - 1]
+    return [v1, v2, v3, v4]
+
+
+#########################################
+class XXMesh:
+  """Mesh: vertices, edges, triangles, tetrahedra"""
+  def __init__(self):
+    self.nameFile = ""
+    self.verts = []
+    self.edges = []
+    self.trias = []
+    self.tetras = []
+
+  def initFromFileMesh(self, fileName, args, withGlobal=True):
+    if not os.path.isfile(fileName):
+      raise Exception("ERROR: inexisting file '%s'" % fileName)
+    with open(fileName, "r") as f:
+      lines = f.readlines()
+    iverts, iedges, itrias, itetras = self.getIndexInMeshFile(lines)
+    self.verts = self.getMeshVerts(lines, iverts)
+    self.edges = self.getMeshEdges(lines, iedges)
+    self.trias = self.getMeshTrias(lines, itrias)
+    self.tetras = self.getMeshTetras(lines, itetras)
+    self.nameFile = fileName
+    if args.globalNumerotation == True and withGlobal == True:
+      self.initFromFileGlobal(fileName, args)
+    if verbose:
+      print("\nINFO: initFromFileMesh: read file: %s" % str(self))
+      print(self.strResume())
+      print(PP.pformat(resumeLines(lines, [iverts, iedges, itrias, itetras])))
+
+  def initFromFileGlobal(self, fileNameMeshOrGlobal, args):
+    shortname, extension = os.path.splitext(fileNameMeshOrGlobal)
+    if extension == ".mesh":
+      fileName = shortname + ".global"
+    elif extension == "global":
+      fileName = fileNameMeshOrGlobal
+    else:
+      raise Exception("ERROR: initFromFileGlobal: unexpected file '%s'" % fileName)
+    if not os.path.isfile(fileName):
+      raise Exception("ERROR: initFromFileGlobal: inexisting file '%s'" % fileName)
+
+    with open(fileName, "r") as f:
+      lines = f.readlines()
+    nbverts, nbedges, nbtrias, nbtetras = [int(i) for i in lines[0].split()]
+    if verbose:
+      print("\nINFO: initFromFileGlobal: read file: %s" % str(self))
+      print("  nbverts %i\n  nbedges %i\n  nbtrias %i\n  nbtetras %i" % (nbverts, nbedges, nbtrias, nbtetras))
+    if nbverts != len(self.verts):
+      raise Exception("ERROR: in file '%s' unexpected number of Vertices %i<>%i" % (fileName, nbverts, len(self.verts)))
+    if nbedges != len(self.edges):
+      raise Exception("ERROR: in file '%s' unexpected number of Edges %i<>%i" % (fileName, nbedges, len(self.edges)))
+    if nbtrias != len(self.trias):
+      raise Exception("ERROR: in file '%s' unexpected number of Triangles %i<>%i" % (fileName, nbtrias, len(self.trias)))
+    if nbtetras != len(self.tetras):
+      raise Exception("ERROR: in file '%s' unexpected number of Tetrahedra %i<>%i" % (fileName, nbtetras, len(self.tetras)))
+    i = 1  # begin index line 1
+    for ii in range(nbverts):
+      self.verts[ii].indexglobal = int(lines[i])
+      i += 1
+    for ii in range(nbedges):
+      self.edges[ii].indexglobal = int(lines[i])
+      i += 1
+    for ii in range(nbtrias):
+      self.trias[ii].indexglobal = int(lines[i])
+      i += 1
+    for ii in range(nbtetras):
+      self.tetras[ii].indexglobal = int(lines[i])
+      i += 1
+
+
+  def __repr__(self):
+    return "XXMesh(nameFile='%s', nbverts=%i, nbedges=%i, nbtrias=%i, nbtetras=%i)" % \
+           (self.nameFile, len(self.verts), len(self.edges), len(self.trias), len(self.tetras))
+
+  def strResume(self):
+    res = str(self)
+    contents = {
+      "Vertices": resumeList(self.verts),
+      "Edges": resumeList(self.edges),
+      "Triangles": resumeList(self.trias),
+      "Tetrahedra": resumeList(self.tetras),
+    }
+    res = res + "\n" + PP.pformat(contents)
+    return res
+
+  def getIndexInMeshFile(self, lines):
+    res = []
+    for s in ["Vertices", "Edges", "Triangles", "Tetrahedra"]:
+      try:
+        i = lines.index(s + "\n")
+      except:
+        i = None
+      res.append(i)
+    return res
+
+  def getMeshVerts(self, lines, i):
+    res = []
+    try:
+      idep = i + 2
+      ilen = int(lines[i + 1])
+      ifin = idep + ilen
+      for line in lines[idep:ifin]:
+        li = line.split(" ")
+        x, y, z, color = float(li[0]), float(li[1]), float(li[2]), int(li[3])
+        res.append(XXVert(x, y, z, color))
+      return res
+    except:
+      return res
+
+  def getMeshEdges(self, lines, i):
+    res = []
+    try:
+      idep = i + 2
+      ilen = int(lines[i + 1])
+      ifin = idep + ilen
+      for line in lines[idep:ifin]:
+        li = line.split(" ")
+        a, b, color = int(li[0]), int(li[1]), int(li[2])
+        res.append(XXEdge(a, b, color))
+      return res
+    except:
+      return res
+
+  def getMeshTrias(self, lines, i):
+    res = []
+    try:
+      idep = i + 2
+      ilen = int(lines[i + 1])
+      ifin = idep + ilen
+      for line in lines[idep:ifin]:
+        li = line.split(" ")
+        a, b, c, color = int(li[0]), int(li[1]), int(li[2]), int(li[3])
+        res.append(XXTria(a, b, c, color))
+      return res
+    except:
+      return res
+
+  def getMeshTetras(self, lines, i):
+    res = []
+    try:
+      idep = i + 2
+      ilen = int(lines[i + 1])
+      ifin = idep + ilen
+      for line in lines[idep:ifin]:
+        li = line.split(" ")
+        a, b, c, d, color = int(li[0]), int(li[1]), int(li[2]), int(li[3]), int(li[4])
+        res.append(XXTetra(a, b, c, d, color))
+      return res
+    except:
+      return res
+
+  def haveVertsDistinct(self, args):
+    """stop a first KO"""
+    i = 0
+    verts = self.verts
+    for v1 in verts[:-1]:
+      i += 1
+      j = i
+      for v2 in verts[i:]:
+        j += 1
+        if v1.compare(v2, args):
+          # printing indices 1 to n
+          print("ERROR: %s vert[%i] equal vert[%i]: v1=%s v2=%s" % (self.nameFile, i, j, v1, v2))
+          return KO + " ERROR: %s some equal vertices" % self.nameFile  # stop a first KO
+    return OK + " INFO: no equal vertices"
+
+  def getVertices(self, elem):
+    """functionnal raccourci to XXElem.getVertices(XXMesh)"""
+    return elem.getVertices(self)
+
+  def compareListOfVertices(self, v1s, v2s, ordered=False):
+    """not ordered for now"""
+    if ordered:
+      res = [i for i, j in zip(v1s, v2s) if i == j]
+      return len(res) == len(v1s)
+    else:
+      res = 0
+      for i in v1s:
+        for j in v2s:
+          if i == j:
+            res += 1
+            break
+      return res == len(v1s)
+
+
+  def getCommonVerts(self, mesh, args):
+    res = []
+    for v1 in self.verts:
+      for v2 in mesh.verts:
+        if v1.compare(v2, args, withAll=False):
+          res.append((v1, v2))
+    return res
+
+  def getCommonEdges(self, mesh, args):
+    res = []
+    for e1 in self.edges:
+      v1s = self.getVertices(e1)
+      for e2 in mesh.edges:
+        v2s = mesh.getVertices(e2)
+        if self.compareListOfVertices(v1s, v2s):
+          res.append((e1, e2))
+    return res
+
+  def getCommonTriangles(self, mesh, args):
+    res = []
+    for e1 in self.trias:
+      v1s = self.getVertices(e1)
+      for e2 in mesh.trias:
+        v2s = mesh.getVertices(e2)
+        if self.compareListOfVertices(v1s, v2s):
+          res.append((e1, e2))
+    return res
+
+  def getCommonTetras(self, mesh, args):
+    res = []
+    for e1 in self.tetras:
+      v1s = self.getVertices(e1)
+      for e2 in mesh.tetras:
+        v2s = mesh.getVertices(e2)
+        if self.compareListOfVertices(v1s, v2s):
+          res.append((e1, e2))
+    return res
+
+  def areEdgesInTrias(self, args):
+    """stop a first KO"""
+    done = False
+    i = 0
+    edges = self.edges
+    trias = self.trias
+    res = OK + " INFO: %s all edges in trias" % self.nameFile
+    for e in edges:
+      i += 1
+      j = 0
+      found = False
+      for t in trias:
+        j += 1
+        if e.inTria(t, args):
+          # if verbose: print("INFO: %s edges[%i] in trias[%i]: edge=%s tria=%s" % (self.nameFile, i, j, e, t))
+          found = True
+          break
+      if not found:
+        print("ERROR: %s edges[%i] not in trias: edge=%s" % (self.nameFile, i, e))
+        if verbose and not done:
+          print("Triangles:\n%s" % PP.pformat(self.trias))
+          done = True
+        res = KO + " ERROR: %s some edges not in trias" % (self.nameFile)
+    return res
+
+
+  def areTriasInTetras(self, args):
+    """no stop a first KO"""
+    done = False
+    i = 0
+    trias = self.trias
     tetras = self.tetras
-    if tetras == []: #supposed skin without tetrahedra
-      res = OK +" WARNING: %s no tetrahedra in mesh" % (self.nameFile)
-      return res\r
-    res = OK + " INFO: %s all trias in tetras" % self.nameFile\r
-    for t in trias:\r
-      i += 1\r
-      j = 0\r
-      found = False\r
-      for h in tetras:\r
-        j += 1\r
-        if t.inTetra(h, args):\r
-          #if verbose: print("INFO: %s trias[%i] in tetras[%i]: tria=%s tetra=%s" % (self.nameFile, i, j, t, h))\r
-          found = True\r
-          break\r
-      if not found:\r
-        if verbose: print("ERROR: %s trias[%i] not in tetras: tria=%s" % (self.nameFile, i, t))\r
-        if verbose and not done: \r
-          print("INFO: Tetrahedra:\n%s" % PP.pformat(self.tetras))\r
-          done = True\r
-        res = KO+" ERROR: %s some trias not in tetras" % (self.nameFile)\r
-    return res\r
-\r
-  def testIntersection(self, mesh, args):\r
-    """intersection coherency between self and mesh"""\r
-\r
-    def storeAndInfoIntersection():\r
-      """used as macro: avoid duplicate code"""\r
-      #store info in args to use later...\r
-      args.intersections[title+name] = commons\r
-      if commons == []:\r
-        res.append(OK + " INFO: no %s" % title+name)\r
-      else:\r
-        res.append(OK + " INFO: existing %s" % title+name)\r
-      return\r
-      \r
-    res=[]\r
-    name = "%s<->%s" % (self.nameFile, mesh.nameFile)\r
-    \r
-    title = "Vertices intersection: "\r
-    commons = self.getCommonVerts(mesh, args)\r
-    storeAndInfoIntersection()\r
-\r
-    title = "Edges intersection: "\r
-    commons = self.getCommonEdges(mesh, args)\r
-    storeAndInfoIntersection()\r
-\r
-    title = "Triangles intersection: "\r
-    commons = self.getCommonTriangles(mesh, args)\r
-    storeAndInfoIntersection()\r
-\r
-    title = "Tetrahedra intersection: "\r
-    commons = self.getCommonTetras(mesh, args)\r
-    storeAndInfoIntersection()\r
-\r
-    return res\r
-      \r
-  def testIndexGlobal(self, mesh, args):\r
-    """global index coherency between self and mesh"""\r
-    \r
-    def storeAndInfoIndexGlobal():\r
-      """used as macro: avoid duplicate code"""\r
-      #store info in args to use later...\r
-      args.indexglobal[title+name] = problems\r
-      if verbose: print("\nINFO: %s\n%s" % (title+name, PP.pformat(problems)))\r
-      if problems == []:\r
-        res.append(OK + " INFO: coherent %s" % title+name)\r
-      else:\r
-        res.append(KO + " ERROR: some problems %s" % title+name)\r
-      return\r
-\r
-    def testIndexGlobal():\r
-      """used as macro: avoid duplicate code"""\r
-      nameElem = title.split(' ')[0]\r
-      #something like 'Vertices intersection: /tmp/GHS3DPRL_out.000002.mesh<->/tmp/GHS3DPRL_out.000003.mesh'\r
-      commonsTitle = nameElem + " intersection: "+ name\r
-      #if verbose: print "testIndexGlobal",title,commonsTitle\r
-      try:\r
-        intersection = args.intersections[commonsTitle]\r
-      except:\r
-        intersection = []\r
-      problems = []\r
-      for ii, jj in intersection:\r
-        if ii.indexglobal != jj.indexglobal:\r
-          problems.append((ii, jj))\r
-      return problems\r
-\r
-    res=[]\r
-    name = "%s<->%s" % (self.nameFile, mesh.nameFile)\r
-\r
-    title = "Vertices indexglobal: "\r
-    problems = testIndexGlobal()\r
-    storeAndInfoIndexGlobal()\r
-\r
-    title = "Edges indexglobal: "\r
-    problems = testIndexGlobal()\r
-    storeAndInfoIndexGlobal()\r
-\r
-    title = "Triangles indexglobal: "\r
-    problems = testIndexGlobal()\r
-    storeAndInfoIndexGlobal()\r
-\r
-    title = "Tetrahedra indexglobal: "\r
-    problems = testIndexGlobal()\r
-    storeAndInfoIndexGlobal()\r
-\r
-    return res\r
-\r
-\r
-#########################################\r
-# tests\r
\r
+    if tetras == []:  # supposed skin without tetrahedra
+      res = OK + " WARNING: %s no tetrahedra in mesh" % (self.nameFile)
+      return res
+    res = OK + " INFO: %s all trias in tetras" % self.nameFile
+    for t in trias:
+      i += 1
+      j = 0
+      found = False
+      for h in tetras:
+        j += 1
+        if t.inTetra(h, args):
+          # if verbose: print("INFO: %s trias[%i] in tetras[%i]: tria=%s tetra=%s" % (self.nameFile, i, j, t, h))
+          found = True
+          break
+      if not found:
+        if verbose: print("ERROR: %s trias[%i] not in tetras: tria=%s" % (self.nameFile, i, t))
+        if verbose and not done:
+          print("INFO: Tetrahedra:\n%s" % PP.pformat(self.tetras))
+          done = True
+        res = KO + " ERROR: %s some trias not in tetras" % (self.nameFile)
+    return res
+
+  def testIntersection(self, mesh, args):
+    """intersection coherency between self and mesh"""
+
+    def storeAndInfoIntersection():
+      """used as macro: avoid duplicate code"""
+      # store info in args to use later...
+      args.intersections[title + name] = commons
+      if commons == []:
+        res.append(OK + " INFO: no %s" % title + name)
+      else:
+        res.append(OK + " INFO: existing %s" % title + name)
+      return
+
+    res = []
+    name = "%s<->%s" % (self.nameFile, mesh.nameFile)
+
+    title = "Vertices intersection: "
+    commons = self.getCommonVerts(mesh, args)
+    storeAndInfoIntersection()
+
+    title = "Edges intersection: "
+    commons = self.getCommonEdges(mesh, args)
+    storeAndInfoIntersection()
+
+    title = "Triangles intersection: "
+    commons = self.getCommonTriangles(mesh, args)
+    storeAndInfoIntersection()
+
+    title = "Tetrahedra intersection: "
+    commons = self.getCommonTetras(mesh, args)
+    storeAndInfoIntersection()
+
+    return res
+
+  def testIndexGlobal(self, mesh, args):
+    """global index coherency between self and mesh"""
+
+    def storeAndInfoIndexGlobal():
+      """used as macro: avoid duplicate code"""
+      # store info in args to use later...
+      args.indexglobal[title + name] = problems
+      if verbose: print("\nINFO: %s\n%s" % (title + name, PP.pformat(problems)))
+      if problems == []:
+        res.append(OK + " INFO: coherent %s" % title + name)
+      else:
+        res.append(KO + " ERROR: some problems %s" % title + name)
+      return
+
+    def testIndexGlobal():
+      """used as macro: avoid duplicate code"""
+      nameElem = title.split(' ')[0]
+      # something like 'Vertices intersection: /tmp/GHS3DPRL_out.000002.mesh<->/tmp/GHS3DPRL_out.000003.mesh'
+      commonsTitle = nameElem + " intersection: " + name
+      # if verbose: print "testIndexGlobal",title,commonsTitle
+      try:
+        intersection = args.intersections[commonsTitle]
+      except:
+        intersection = []
+      problems = []
+      for ii, jj in intersection:
+        if ii.indexglobal != jj.indexglobal:
+          problems.append((ii, jj))
+      return problems
+
+    res = []
+    name = "%s<->%s" % (self.nameFile, mesh.nameFile)
+
+    title = "Vertices indexglobal: "
+    problems = testIndexGlobal()
+    storeAndInfoIndexGlobal()
+
+    title = "Edges indexglobal: "
+    problems = testIndexGlobal()
+    storeAndInfoIndexGlobal()
+
+    title = "Triangles indexglobal: "
+    problems = testIndexGlobal()
+    storeAndInfoIndexGlobal()
+
+    title = "Tetrahedra indexglobal: "
+    problems = testIndexGlobal()
+    storeAndInfoIndexGlobal()
+
+    return res
+
+
+#########################################
+# tests
+
 def testAll(args):
-  """test all on meshes from tetra_hpc_mpi"""\r
-  res = [] 
+  """test all on meshes from tetra_hpc_mpi"""
+  res = []
   if verbose: print("\n*****testAll*****\n")
   args.skinMesh = None
   if args.skinInputFile != None:
     args.skinMesh = XXMesh()
-    #a priori no global numerotation file.global for input tetra_hpc_mpi mesh\r
+    # a priori no global numerotation file.global for input tetra_hpc_mpi mesh
     args.skinMesh.initFromFileMesh(args.skinInputFile, args, withGlobal=False)
     res.append(testStandaloneMesh(args.skinMesh, args))
-    print("\nINFO: testAll skin input file:\n%s" % (PP.pformat(args.skinMesh)))\r
-    \r
-  meshes = []\r
-  for fileName in args.files:\r
-    xxmesh = XXMesh()\r
-    xxmesh.initFromFileMesh(fileName, args)\r
-    meshes.append(xxmesh)\r
-  print("\nINFO: testAll ouput files:\n%s\n" % (PP.pformat(meshes)))\r
-  #test coherence of one by one meshes\r
-  for mesh in meshes:\r
-    res.append(testStandaloneMesh(mesh, args))\r
-  #test coherence of intersections an global numerotation of tetra_hpc_mpi output meshes
+    print("\nINFO: testAll skin input file:\n%s" % (PP.pformat(args.skinMesh)))
+
+  meshes = []
+  for fileName in args.files:
+    xxmesh = XXMesh()
+    xxmesh.initFromFileMesh(fileName, args)
+    meshes.append(xxmesh)
+  print("\nINFO: testAll ouput files:\n%s\n" % (PP.pformat(meshes)))
+  # test coherence of one by one meshes
+  for mesh in meshes:
+    res.append(testStandaloneMesh(mesh, args))
+  # test coherence of intersections an global numerotation of tetra_hpc_mpi output meshes
   res.append(testParallelMesh(meshes, args))
-  res.append(testParallelMeshAndSkin(meshes, args))\r
-  res.append(testParallelMeshAndSkinColor(meshes, args))\r
-  return res\r
+  res.append(testParallelMeshAndSkin(meshes, args))
+  res.append(testParallelMeshAndSkinColor(meshes, args))
+  return res
+
 
-  \r
 def testStandaloneMesh(mesh, args):
-  """test coherence of one mesh alone"""\r
-  if verbose: print("\nINFO: testStandaloneMesh:\n%s" % PP.pformat(mesh))\r
-  res = []\r
-  res.append(mesh.haveVertsDistinct(args))\r
-  res.append(mesh.areEdgesInTrias(args))\r
-  res.append(mesh.areTriasInTetras(args))\r
-  return res\r
-
-\r
-def testParallelMesh(meshes, args):\r
-  """test intersection and overriding in tetra_hpc_mpi outputs GHS3DPRL_out.00000?.mesh"""\r
-  i = 0\r
-  res = []\r
-  args.intersections = {}\r
-  args.indexglobal = {}\r
-  for m1 in meshes[:-1]:\r
-    i += 1\r
-    for m2 in meshes[i:]:\r
-      res.append(m1.testIntersection(m2, args))\r
-      res.append(m1.testIndexGlobal(m2, args))\r
-  if verbose: \r
-    print("\nINFO: intersections\n%s" % PP.pformat(args.intersections))\r
-    print("\nINFO: indexglobal\n%s" % PP.pformat(args.indexglobal))\r
-  return res\r
-\r
-def testParallelMeshAndSkin(meshes, args):\r
-  """test coherency between input skin and tetra_hpc_mpi outputs GHS3DPRL_out.00000?.mesh"""\r
-  res = []\r
+  """test coherence of one mesh alone"""
+  if verbose: print("\nINFO: testStandaloneMesh:\n%s" % PP.pformat(mesh))
+  res = []
+  res.append(mesh.haveVertsDistinct(args))
+  res.append(mesh.areEdgesInTrias(args))
+  res.append(mesh.areTriasInTetras(args))
+  return res
+
+
+def testParallelMesh(meshes, args):
+  """test intersection and overriding in tetra_hpc_mpi outputs GHS3DPRL_out.00000?.mesh"""
+  i = 0
+  res = []
+  args.intersections = {}
+  args.indexglobal = {}
+  for m1 in meshes[:-1]:
+    i += 1
+    for m2 in meshes[i:]:
+      res.append(m1.testIntersection(m2, args))
+      res.append(m1.testIndexGlobal(m2, args))
+  if verbose:
+    print("\nINFO: intersections\n%s" % PP.pformat(args.intersections))
+    print("\nINFO: indexglobal\n%s" % PP.pformat(args.indexglobal))
+  return res
+
+def testParallelMeshAndSkin(meshes, args):
+  """test coherency between input skin and tetra_hpc_mpi outputs GHS3DPRL_out.00000?.mesh"""
+  res = []
   if args.skinMesh == None:
     print("INFO: no skin Mesh for testing intersectionsSkin\n")
     res = OK + "INFO: no skin Mesh for testing intersectionsSkin"
     return res
-  nbtriasskin = len(args.skinMesh.trias)\r
-  for m1 in meshes:\r
-    res.append(args.skinMesh.testIntersection(m1, args))\r
+  nbtriasskin = len(args.skinMesh.trias)
+  for m1 in meshes:
+    res.append(args.skinMesh.testIntersection(m1, args))
     res.append(args.skinMesh.testIndexGlobal(m1, args))
-  
-  #test total Triangles in output parallel meshes vs input skin mesh\r
+
+  # test total Triangles in output parallel meshes vs input skin mesh
   if True:
-    kk = {} 
+    kk = {}
     nbtriaspara = 0
-    for k in args.intersections.keys():
+    for k in list(args.intersections.keys()):
       if args.skinMesh.nameFile in k:
         ll = len(args.intersections[k])
-        if "Triangles intersection" in k: 
+        if "Triangles intersection" in k:
           nbtriaspara += ll
-        kk[k] = len(args.intersections[k])\r
-    print("INFO: skin intersections\n%s\n" % PP.pformat(kk))\r
+        kk[k] = len(args.intersections[k])
+    print("INFO: skin intersections\n%s\n" % PP.pformat(kk))
     if nbtriaspara < nbtriasskin:
-      res.append(KO + " ERROR: problem all skin triangles not in parallel meshes: %i<->%i" % (nbtriasskin, nbtriaspara))\r
-  return res\r
+      res.append(KO + " ERROR: problem all skin triangles not in parallel meshes: %i<->%i" % (nbtriasskin, nbtriaspara))
+  return res
 
-def testParallelMeshAndSkinColor(meshes, args):\r
+def testParallelMeshAndSkinColor(meshes, args):
   """test coherency between color input skin and tetra_hpc_mpi outputs GHS3DPRL_out.00000?.mesh"""
   res = []
-  if args.color == True:\r
+  if args.color == True:
     res.append(KO + " ERROR: test color TODO!!!")
   else:
     res.append(OK + " WARNING: test color not done")
-  return res\r
-\r
-if __name__ == '__main__':\r
-  parser = AP.ArgumentParser(description='launch test(s) on tetra_hpc_mpi mesh(es)', argument_default=None)\r
-  parser.add_argument(\r
-    '-a', '--testAll', \r
-    help='test all on all meshes',\r
-    action='store_true',\r
-  )\r
-  parser.add_argument(\r
-    '-v', '--verbose', \r
-    help='set verbose, for deep debug',\r
-    action='store_true',\r
-  )\r
-  parser.add_argument(\r
-    '-g', '--globalNumerotation', \r
-    help='read and set files .global, if associated',\r
-    action='store_true',\r
-  )\r
-  parser.add_argument(\r
-    '-c', '--color', \r
-    help='read and test with color',\r
-    action='store_true',\r
-  )\r
-  parser.add_argument(\r
-    '-f', '--files', \r
-    help='launch test(s) on file(s)',\r
-    nargs='*',\r
-    metavar='.../file.mesh'\r
-  )\r
-  parser.add_argument(\r
-    '-s', '--skinInputFile', \r
-    help='launch test(s) on tetra_hpc_mpi input file',\r
-    nargs='?',\r
-    metavar='.../skinInputFile.mesh'\r
-  )\r
-  """\r
-  parser.add_argument(\r
-    '-x', '--xoneargument', \r
-    nargs='?',\r
-    metavar='0|1',\r
-    choices=['0', '1'],\r
-    help='one argument, for example',\r
-    default='0'\r
-  )\r
-  """\r
-  \r
-    \r
+  return res
+
+if __name__ == '__main__':
+  parser = AP.ArgumentParser(description='launch test(s) on tetra_hpc_mpi mesh(es)', argument_default=None)
+  parser.add_argument(
+    '-a', '--testAll',
+    help='test all on all meshes',
+    action='store_true',
+  )
+  parser.add_argument(
+    '-v', '--verbose',
+    help='set verbose, for deep debug',
+    action='store_true',
+  )
+  parser.add_argument(
+    '-g', '--globalNumerotation',
+    help='read and set files .global, if associated',
+    action='store_true',
+  )
+  parser.add_argument(
+    '-c', '--color',
+    help='read and test with color',
+    action='store_true',
+  )
+  parser.add_argument(
+    '-f', '--files',
+    help='launch test(s) on file(s)',
+    nargs='*',
+    metavar='.../file.mesh'
+  )
+  parser.add_argument(
+    '-s', '--skinInputFile',
+    help='launch test(s) on tetra_hpc_mpi input file',
+    nargs='?',
+    metavar='.../skinInputFile.mesh'
+  )
+  """
+  parser.add_argument(
+    '-x', '--xoneargument',
+    nargs='?',
+    metavar='0|1',
+    choices=['0', '1'],
+    help='one argument, for example',
+    default='0'
+  )
+  """
+
+
   """
-  args is Namespace, use it as global to store 
+  args is Namespace, use it as global to store
   parameters, data, used arrays and results and other...
-  """\r
+  """
   args = parser.parse_args()
-  \r
-  verbose = args.verbose\r
-  if verbose: print("INFO: args:\n%s" % PP.pformat(args))\r
-\r
-  if len(sys.argv) == 1: #no args as --help\r
-    parser.print_help()\r
-    sys.exit(KOSYS)\r
-\r
-  if args.files == None:\r
-    print("\nERROR: Nothing to do: no files\n%s" % PP.pformat(args))\r
-    parser.print_help()\r
-    sys.exit(KOSYS)\r
-  \r
-  if args.testAll: \r
-    result = testAll(args)\r
-  else:\r
-    result = KO\r
-    print("\nERROR: Nothing to do:\n%s" % PP.pformat(args))\r
-  sys.exit(okToSys(result, verbose=True))\r
-  \r
+
+  verbose = args.verbose
+  if verbose: print("INFO: args:\n%s" % PP.pformat(args))
+
+  if len(sys.argv) == 1:  # no args as --help
+    parser.print_help()
+    sys.exit(KOSYS)
+
+  if args.files == None:
+    print("\nERROR: Nothing to do: no files\n%s" % PP.pformat(args))
+    parser.print_help()
+    sys.exit(KOSYS)
+
+  if args.testAll:
+    result = testAll(args)
+  else:
+    result = KO
+    print("\nERROR: Nothing to do:\n%s" % PP.pformat(args))
+  sys.exit(okToSys(result, verbose=True))
+
index 4930a556f8dc2c778297fe210317162f6e490a54..33288a0f059940a8570dc122aedb403b4ebcee22 100644 (file)
@@ -3,74 +3,76 @@
 
 # %% LICENSE_SALOME_CEA_BEGIN
 # Copyright (C) 2008-2016  CEA/DEN
-# 
+#
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
 # version 2.1 of the License, or (at your option) any later version.
-# 
+#
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU Lesser General Public
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-# 
+#
 # See http://www.salome-platform.org or email : webmaster.salome@opencascade.com
 # %% LICENSE_END
 
 
 import unittest
+
 import testMesh as TM
-from argparse import Namespace
-    
+
+
 verbose = False
 
+
 class TestCase(unittest.TestCase):
 
-  def test_010(self):
-    self.failUnlessEqual(TM.okToSys([]), TM.KOSYS)
-    self.failUnlessEqual(TM.okToSys([[]]), TM.KOSYS)
-    
-    res = TM.OK + " blah blah 0"
-    self.failUnlessEqual(TM.okToSys([[res]]), TM.OKSYS)
-    self.failUnlessEqual(TM.okToSys(res), TM.OKSYS)
-    res = [res]
-    self.failUnlessEqual(TM.okToSys(res), TM.OKSYS)
-    res.append(TM.OK + " blah blah 1")
-    self.failUnlessEqual(TM.okToSys(res), TM.OKSYS)  
-    res.append([TM.OK + " blah blah 2"])
-    self.failUnlessEqual(TM.okToSys(res), TM.OKSYS) 
-    res.append([TM.KO + " blah blah 3"])
-    self.failUnlessEqual(TM.okToSys(res), TM.KOSYS)
-    self.failUnlessEqual(TM.okToSys([]), TM.KOSYS)
-    res = [[[res]],[TM.OK + " blah blah 4"],[]]
-    self.failUnlessEqual(TM.okToSys(res), TM.KOSYS)
-
-  def test_030(self):
-    a = TM.XXVert(1, 1, 1)
-    b = TM.XXVert(2, 2, 2)
-    c = TM.XXVert(1., 1., 1., 3, 4)
-    self.failUnlessEqual(a==c, True)
-    
-    from argparse import Namespace
-    args = Namespace(withColor=True, withIndex=True)
-    self.failUnlessEqual(a.compare(c, args, withAll=True), False)
-    self.failUnlessEqual(a.compare(c, args, withAll=False), True)
-    
-    args = Namespace(withColor=False, withIndex=False)
-    self.failUnlessEqual(a.compare(c, args, withAll=True), True)
-    
-    self.failUnlessEqual(a==b, False)
-    self.failUnlessEqual(a.dist(b), 3**.5)
-    
-    self.failUnlessEqual(str(c), '(1.0 1.0 1.0 (3 4))')
-    self.failUnlessEqual(c.__repr__(), 'XXVert(1.0000 1.0000 1.0000 (3 4))')
+    def test_010(self):
+        self.assertEqual(TM.okToSys([]), TM.KOSYS)
+        self.assertEqual(TM.okToSys([[]]), TM.KOSYS)
+
+        res = TM.OK + " blah blah 0"
+        self.assertEqual(TM.okToSys([[res]]), TM.OKSYS)
+        self.assertEqual(TM.okToSys(res), TM.OKSYS)
+        res = [res]
+        self.assertEqual(TM.okToSys(res), TM.OKSYS)
+        res.append(TM.OK + " blah blah 1")
+        self.assertEqual(TM.okToSys(res), TM.OKSYS)
+        res.append([TM.OK + " blah blah 2"])
+        self.assertEqual(TM.okToSys(res), TM.OKSYS)
+        res.append([TM.KO + " blah blah 3"])
+        self.assertEqual(TM.okToSys(res), TM.KOSYS)
+        self.assertEqual(TM.okToSys([]), TM.KOSYS)
+        res = [[[res]], [TM.OK + " blah blah 4"], []]
+        self.assertEqual(TM.okToSys(res), TM.KOSYS)
+
+    def test_030(self):
+        a = TM.XXVert(1, 1, 1)
+        b = TM.XXVert(2, 2, 2)
+        c = TM.XXVert(1., 1., 1., 3, 4)
+        self.assertEqual(a == c, True)
+
+        from argparse import Namespace
+        args = Namespace(withColor=True, withIndex=True)
+        self.assertEqual(a.compare(c, args, withAll=True), False)
+        self.assertEqual(a.compare(c, args, withAll=False), True)
+
+        args = Namespace(withColor=False, withIndex=False)
+        self.assertEqual(a.compare(c, args, withAll=True), True)
+
+        self.assertEqual(a == b, False)
+        self.assertEqual(a.dist(b), 3 ** .5)
+
+        self.assertEqual(str(c), '(1.0 1.0 1.0 (3 4))')
+        self.assertEqual(c.__repr__(), 'XXVert(1.0000 1.0000 1.0000 (3 4))')
 
 
 if __name__ == '__main__':
-  verbose = False
-  unittest.main()
-  pass
+    verbose = False
+    unittest.main()
+    pass