Salome HOME
Copyright update 2022
[modules/smesh.git] / src / Tools / ZCracksPlug / Zset.py
index 464619e2b93e5214bd6a7822836a3d66c23fbafe..9b7091b18b2afb17e6fe8fcecac431cc6f344875 100644 (file)
@@ -1,7 +1,25 @@
+# Copyright (C) 2016-2022  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
+# 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
+#
 
 import os, tempfile, shutil
-import utilityFunctions as uF
-from output import message
+from . import utilityFunctions as uF
+from .output import message
 
 def medToGeo(medFile, geoFile, tmpdir, opt=[], verbose=0):
   medLoc=os.path.dirname(medFile)
@@ -74,10 +92,10 @@ def launchZcrack(minS, maxS,
   zfile.write('   convert_surface("%s");\n' %crackN.replace('.geo',''))
   zfile.write('   cracked_name="%s";\n' %crackedN.replace('.geo',''))
 
-  if Gfac!='': zfile.write('   faset_names="%s";\n' %(Gfac[0] if type(Gfac)==list else Gfac))
-  if Gnod!='': zfile.write('   nset_names="%s";\n' %(Gnod[0] if type(Gnod)==list else Gnod))
-  if Gvol!='': zfile.write('   elset_names="%s";\n' %(Gvol[0] if type(Gvol)==list else Gvol))
-  if Gedg!='': zfile.write('   liset_names="%s";\n' %(Gedg[0] if type(Gedg)==list else Gedg))
+  if Gfac!='': zfile.write('   faset_names="%s";\n' %(Gfac[0] if isinstance(Gfac, list) else Gfac))
+  if Gnod!='': zfile.write('   nset_names="%s";\n' %(Gnod[0] if isinstance(Gnod, list) else Gnod))
+  if Gvol!='': zfile.write('   elset_names="%s";\n' %(Gvol[0] if isinstance(Gvol, list) else Gvol))
+  if Gedg!='': zfile.write('   liset_names="%s";\n' %(Gedg[0] if isinstance(Gedg, list) else Gedg))
   if surfOpt!='':
     zfile.write('   yams_options="%s";\n' %surfOpt)
 
@@ -114,18 +132,18 @@ def insertCrack(data, names, tmpdir='./zcracks_temp', verbose=0):
   maxS=data['maxSize'][0]
   extrL=data['extractLength'][0]
 
-  grad = data['gradation'][0] if 'gradation' in data.keys() else 1.3
-  quad = data['quad'] if 'quad' in data.keys() else False
-  cas2D = data['is2D'] if 'is2D' in data.keys() else False
-  refine = data['refine'] if 'refine' in data.keys() else False
-  nbLay = data['layers'][0] if 'layers' in data.keys() else 5
-  nbIter = data['iterations'][0] if 'iterations' in data.keys() else 2
-
-  Gvol = data['grVol'] if 'grVol' in data.keys() else ''
-  Gfac = data['grFace'] if 'grFace' in data.keys() else ''
-  Gedg = data['grEdge'] if 'grEdge' in data.keys() else ''
-  Gnod = data['grNodes'] if 'grNodes' in data.keys() else ''
-  surfOpt = data['surfopt'] if 'surfopt' in data.keys() else ''
+  grad = data['gradation'][0] if 'gradation' in list(data.keys()) else 1.3
+  quad = data['quad'] if 'quad' in list(data.keys()) else False
+  cas2D = data['is2D'] if 'is2D' in list(data.keys()) else False
+  refine = data['refine'] if 'refine' in list(data.keys()) else False
+  nbLay = data['layers'][0] if 'layers' in list(data.keys()) else 5
+  nbIter = data['iterations'][0] if 'iterations' in list(data.keys()) else 2
+
+  Gvol = data['grVol'] if 'grVol' in list(data.keys()) else ''
+  Gfac = data['grFace'] if 'grFace' in list(data.keys()) else ''
+  Gedg = data['grEdge'] if 'grEdge' in list(data.keys()) else ''
+  Gnod = data['grNodes'] if 'grNodes' in list(data.keys()) else ''
+  surfOpt = data['surfopt'] if 'surfopt' in list(data.keys()) else ''
 
 
   if not os.path.isdir(tmpdir): os.mkdir(tmpdir)