import sys, os
-sys.path.append(os.path.join(os.environ['MEDFILE_ROOT_DIR'], 'lib/python2.7/site-packages/med'))
+#sys.path.append(os.path.join(os.environ['MEDFILE_ROOT_DIR'], 'lib/python2.7/site-packages/med'))
+#sys.path.append(os.path.join(os.environ['MEDFICHIER_INSTALL_DIR'], 'lib/python2.7/site-packages/med'))
hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome', 'salome', 'hydro')
-sys.path.append(hydro_solver_root)
+#sys.path.append(hydro_solver_root)
import salome
salome.salome_init()
-import MEDLoader
+import SMESH
+from salome.smesh import smeshBuilder
+smesh = smeshBuilder.New(salome.myStudy)
+
+#import MEDLoader
import HYDROPy
-from PyQt4 import QtCore, QtGui, uic
+from PyQt5.QtWidgets import QDialog, QFileDialog, QTableWidgetItem, QComboBox, QMessageBox
+from PyQt5 import uic
import SalomePyQt
import libSALOME_Swig
def get_med_groups( file_path ):
#print "get_med_groups", file_path
try:
- meshes = MEDLoader.MEDLoader_GetMeshNames(file_path)
+ #meshes = MEDLoader.GetMeshNames(file_path)
+ (meshes, status) = smesh.CreateMeshesFromMED(file_path)
except:
+ print 'No meshes found'
return []
if len(meshes)==0:
+ print 'No mesh found'
return []
mesh1 = meshes[0]
+ print 'Found mesh:', mesh1
try:
- groups = list(MEDLoader.MEDLoader_GetMeshGroupsNames(file_path, mesh1))
+ #groups = list(MEDLoader.GetMeshGroupsNames(file_path, mesh1))
+ grps = mesh1.GetGroups()
+ groups = [grp.GetName() for grp in grps if grp.GetType() == SMESH.NODE]
+ if len(groups) == 0:
+ print "Problem! There are no groups of nodes in the mesh!"
+ print "Please create at least the groups of nodes corresponding to each region of the HYDRO case"
+ return []
+ print 'Found groups:', groups
except:
+ print 'No groups found'
return []
return groups
for r in regions:
rname = r.GetName()
regions_names.append( str(rname) )
-
- shape_groups = case.GetGeometryGroups()
- for sg in shape_groups:
- sgname = sg.GetName()
- regions_names.append( sgname )
-
+
+# shape_groups = case.GetGeometryGroups()
+# for sg in shape_groups:
+# sgname = sg.GetName()
+# regions_names.append( sgname )
+
return regions_names
else:
return []
doc = HYDROPy.HYDROData_Document.Document( aStudyId )
for i in ind:
if i.column()==0:
- name = i.data().toString()
+ name = str(i.data())
case = doc.FindObjectByName( name )
if isinstance(case, HYDROPy.HYDROData_CalculationCase):
return name
return None
-
-class InterpolzDlg( QtGui.QDialog ):
+
+class InterpolzDlg( QDialog ):
def __init__(self, parent = None):
- QtGui.QDialog.__init__( self, parent )
+ QDialog.__init__( self, parent )
p = hydro_solver_root
uic.loadUi( p+'/interpolz.ui', self )
self.setWindowTitle( 'Generate interpolz script' )
- self.connect( SalomePyQt.SalomePyQt.getObjectBrowser(), QtCore.SIGNAL("selectionChanged()"), self.onSelectionChanged )
- self.connect( self.btnOutputPath, QtCore.SIGNAL( "clicked()" ), self.onOutputFile )
- self.connect( self.btnMEDFile, QtCore.SIGNAL( "clicked()" ), self.onMEDFile )
- self.connect( self.CalcCase, QtCore.SIGNAL( "textChanged( const QString& )" ), self.onCalcCaseChanged )
- self.connect( self.MEDFile, QtCore.SIGNAL( "textChanged( const QString& )" ), self.onMEDChanged )
+ SalomePyQt.SalomePyQt.getObjectBrowser().selectionChanged.connect(self.onSelectionChanged)
+ self.btnOutputPath.clicked.connect(self.onOutputFile)
+ self.btnMEDFile.clicked.connect(self.onMEDFile)
+ self.CalcCase.textChanged.connect(self.onCalcCaseChanged)
+ self.MEDFile.textChanged.connect(self.onMEDChanged)
self.UndefZ.setRange( -100000, 100000 )
self.UndefZ.setValue( -9999 )
self.InterpMethod.addItem( "Interpolation at the nearest point" )
- self.connect( self.ApplyClose, QtCore.SIGNAL( "clicked()" ), self.onApplyClose )
- self.connect( self.Apply, QtCore.SIGNAL( "clicked()" ), self.onApply )
- self.connect( self.Close, QtCore.SIGNAL( "clicked()" ), self.onClose )
- self.connect( self.Help, QtCore.SIGNAL( "clicked()" ), self.onHelp )
-
+ self.InterpMethod.addItem( "Linear interpolation on a cloud triangulation" )
+ self.ApplyClose.clicked.connect(self.onApplyClose)
+ self.Apply.clicked.connect(self.onApply)
+ self.Close.clicked.connect(self.onClose)
+ self.Help.clicked.connect(self.onHelp)
+
def onSelectionChanged( self ):
calc_case_name = get_selected_calc_case()
if calc_case_name is not None:
self.CalcCase.setText( calc_case_name )
-
+
def onOutputFile( self ):
caption = "Python file"
mask = "*.py"
- f = QtGui.QFileDialog.getSaveFileName( self, caption, ".", mask )
- if f!=None and f!="":
- self.OutputPath.setText( f )
-
+ fname, filt = QFileDialog.getSaveFileName( self, caption, ".", mask )
+ if fname!=None and fname!="":
+ self.OutputPath.setText( fname )
+
def onMEDFile( self ):
caption = "MED file"
mask = "*.med"
- f = QtGui.QFileDialog.getOpenFileName( self, caption, ".", mask )
- if f!=None and f!="":
- self.MEDFile.setText( f )
-
+ fname, filt = QFileDialog.getOpenFileName( self, caption, ".", mask )
+ if fname!=None and fname!="":
+ self.MEDFile.setText( fname )
+
def onCalcCaseChanged( self ):
self.regions = get_hydro_regions( str(self.CalcCase.text()) )
self.onMEDChanged()
-
+
def onMEDChanged( self ):
self.med_groups = get_med_groups( str(self.MEDFile.text()) )
- #print self.med_groups
+ print self.med_groups
n = len( self.med_groups )
self.Groups.setRowCount( n )
for i in range( 0, n ):
if self.Groups.item( i, 0 ) is None:
- self.Groups.setItem( i, 0, QtGui.QTableWidgetItem() )
- self.Groups.setItem( i, 1, QtGui.QTableWidgetItem() )
+ self.Groups.setItem( i, 0, QTableWidgetItem() )
+ self.Groups.setItem( i, 1, QTableWidgetItem() )
self.Groups.item( i, 0 ).setText( self.med_groups[i] )
-
- cb = QtGui.QComboBox( self.Groups )
+
+ cb = QComboBox( self.Groups )
+ cb.addItem( 'None' )
for r in self.regions:
cb.addItem( r )
self.Groups.setCellWidget( i, 1, cb )
def onApplyClose( self ):
if self.onApply():
self.onClose()
-
+
def onApply( self ):
path = str(self.OutputPath.text())
calc_case = str(self.CalcCase.text())
for i in range( 0, self.Groups.rowCount() ):
med_group = str( self.Groups.item( i, 0 ).text() )
hydro_reg = str( self.Groups.cellWidget( i, 1 ).currentText() )
- if len(med_group)>0 and len(hydro_reg)>0:
+ if len(med_group)>0 and len(hydro_reg)>0 and hydro_reg != 'None' :
med_groups_regions[med_group] = hydro_reg
z_undef = self.UndefZ.value()
interp = str(self.InterpMethod.currentText())
-
+
msg = ""
if len(path)==0:
msg = "Please input the output path"
msg = "Please fill groups table"
elif len(interp)==0:
msg = "Please choose interpolation method"
-
+
result = False
if len(msg)==0:
- generate( path, calc_case, med_file, med_groups_regions, z_undef, interp )
+ iinterp = 0
+ if 'Linear' in interp:
+ iinterp = 1
+ generate( path, calc_case, med_file, med_groups_regions, z_undef, iinterp )
msg = "InterpolZ script is successfully generated"
result = True
-
- QtGui.QMessageBox.information( self, "", msg )
+
+ QMessageBox.information( self, "", msg )
return result
-
+
def onClose( self ):
- self.close()
+ self.close()
"""Shows help page"""
def onHelp( self ):
When the data is input, the user clicks on "Apply" or "Apply and Close" button to perform the script generation.
"""
- QtGui.QMessageBox.about(self, self.tr("About boundary conditions dialog"), msg);
+ QMessageBox.about(self, self.tr("About boundary conditions dialog"), msg);
if __name__=='__main__':