1 # Copyright (C) 2016-2019 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 import sys, os, shutil, pickle, tempfile
21 from Zcracks import main, genereCrack, Zset
22 from Zcracks import utilityFunctions as uF
24 os.environ['QT_QPA_PLATFORM_PLUGIN_PATH']=os.path.join(os.environ['QTDIR'],'plugins','platforms')
26 #commande="/bin/bash -c ""source $HOME/zebulon/Z8.6.6_NEW/do_config_bash"""
31 from PyQt5.QtWidgets import QApplication
33 app = QApplication(sys.argv)
34 myapp = main.ShipHolderApplication()
39 def SCRIPT(dataFile=None, data=None, dim=3, names=None):
44 if dataFile==None and data==None:
45 print('One of dataFile or data is mandatory')
48 if data==None: data=pickle.load(open(dataFile,'r'))
52 tmpdir=tempfile.mkdtemp(prefix='tmpZcracks')
54 if names==None: names={'saneGeoName':'salome_sane', 'crackGeoName':'salome_crack', 'crackedGeoName':'salome_cracked'}
56 crackedMed=data['crackedName']
57 crackMed=os.path.join(tmpdir,'crackMed.med')
58 saneMed=data['saneName']
60 saneGeo=os.path.join(tmpdir,names['saneGeoName']+'.geo')
61 crackGeo=os.path.join(tmpdir,names['crackGeoName']+'.geo')
62 crackedGeo=os.path.join(tmpdir,names['crackedGeoName']+'.geo')
64 for f in [crackMed, crackedMed, saneGeo, crackGeo, crackedGeo]:
65 if os.path.isfile(f): os.remove(f)
68 genereCrack.main(data, crackMed)
69 goOn=os.path.isfile(crackMed)
71 if goOn: Zset.medToGeo(crackMed, crackGeo, tmpdir)
72 goOn=os.path.isfile(crackGeo)
75 if goOn: Zset.medToGeo(saneMed,saneGeo, tmpdir)
77 if goOn: Zset.medToGeo(saneMed,saneGeo, tmpdir, opt=[' **to_3d'])
78 goOn=os.path.isfile(saneGeo)
80 if goOn: Zset.insertCrack(data, names, tmpdir)
81 goOn=os.path.isfile(crackedGeo)
83 if goOn: Zset.geoToMed(crackedMed, crackedGeo, tmpdir)
84 goOn=os.path.isfile(crackedMed)
86 if goOn: maxAR=uF.extendElsets(crackedMed)
90 return([os.path.isfile(crackedMed), maxAR])