1 import sys, os, shutil, pickle, tempfile
2 import main, genereCrack, Zset
3 import utilityFunctions as uF
5 os.environ['QT_QPA_PLATFORM_PLUGIN_PATH']=os.path.join(os.environ['QTDIR'],'plugins','platforms')
7 if 'MESHGEMSHOME' in os.environ:
8 meshgemsdir=os.environ['MESHGEMSHOME']
9 if len(meshgemsdir) > 0:
10 meshgems=meshgemsdir.split(os.sep)[-1]
11 uF.removeFromSessionPath('LD_LIBRARY_PATH', meshgems)
13 #commande="/bin/bash -c ""source $HOME/zebulon/Z8.6.6_NEW/do_config_bash"""
18 from PyQt5.QtWidgets import QApplication
20 app = QApplication(sys.argv)
21 myapp = main.ShipHolderApplication()
26 def SCRIPT(dataFile=None, data=None, dim=3, names=None):
31 if dataFile==None and data==None:
32 print 'One of dataFile or data is mandatory'
35 if data==None: data=pickle.load(open(dataFile,'r'))
39 tmpdir=tempfile.mkdtemp(prefix='tmpZcracks')
41 if names==None: names={'saneGeoName':'salome_sane', 'crackGeoName':'salome_crack', 'crackedGeoName':'salome_cracked'}
43 crackedMed=data['crackedName']
44 crackMed=os.path.join(tmpdir,'crackMed.med')
45 saneMed=data['saneName']
47 saneGeo=os.path.join(tmpdir,names['saneGeoName']+'.geo')
48 crackGeo=os.path.join(tmpdir,names['crackGeoName']+'.geo')
49 crackedGeo=os.path.join(tmpdir,names['crackedGeoName']+'.geo')
51 for f in [crackMed, crackedMed, saneGeo, crackGeo, crackedGeo]:
52 if os.path.isfile(f): os.remove(f)
55 genereCrack.main(data, crackMed)
56 goOn=os.path.isfile(crackMed)
58 if goOn: Zset.medToGeo(crackMed, crackGeo, tmpdir)
59 goOn=os.path.isfile(crackGeo)
62 if goOn: Zset.medToGeo(saneMed,saneGeo, tmpdir)
64 if goOn: Zset.medToGeo(saneMed,saneGeo, tmpdir, opt=[' **to_3d'])
65 goOn=os.path.isfile(saneGeo)
67 if goOn: Zset.insertCrack(data, names, tmpdir)
68 goOn=os.path.isfile(crackedGeo)
70 if goOn: Zset.geoToMed(crackedMed, crackedGeo, tmpdir)
71 goOn=os.path.isfile(crackedMed)
73 if goOn: maxAR=uF.extendElsets(crackedMed)
77 return([os.path.isfile(crackedMed), maxAR])