From: Paul RASCLE Date: Sat, 25 Mar 2017 22:38:17 +0000 (+0100) Subject: correction generate interpolz.py X-Git-Tag: Salome_8_3_Hydro_2_0rc1~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0325420c95519b6e742210d63ab6afc26f310712;p=modules%2Fhydrosolver.git correction generate interpolz.py --- diff --git a/src/salome_hydro/interpolz_gui.py b/src/salome_hydro/interpolz_gui.py index 22510d5..978c1f1 100644 --- a/src/salome_hydro/interpolz_gui.py +++ b/src/salome_hydro/interpolz_gui.py @@ -8,7 +8,11 @@ hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'pyt import salome salome.salome_init() -import MEDLoader +import SMESH +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + +#import MEDLoader import HYDROPy from PyQt5.QtWidgets import QDialog, QFileDialog, QTableWidgetItem, QComboBox, QMessageBox @@ -23,7 +27,8 @@ from generate_interpolz import generate def get_med_groups( file_path ): #print "get_med_groups", file_path try: - meshes = MEDLoader.GetMeshNames(file_path) + #meshes = MEDLoader.GetMeshNames(file_path) + (meshes, status) = smesh.CreateMeshesFromMED(file_path) except: print 'No meshes found' return [] @@ -33,7 +38,13 @@ def get_med_groups( file_path ): mesh1 = meshes[0] print 'Found mesh:', mesh1 try: - groups = list(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' @@ -51,10 +62,10 @@ def get_hydro_regions( calc_case_name ): 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: @@ -86,6 +97,7 @@ class InterpolzDlg( QDialog ): self.UndefZ.setRange( -100000, 100000 ) self.UndefZ.setValue( -9999 ) self.InterpMethod.addItem( "Interpolation at the nearest point" ) + 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) @@ -126,6 +138,7 @@ class InterpolzDlg( QDialog ): self.Groups.item( i, 0 ).setText( self.med_groups[i] ) cb = QComboBox( self.Groups ) + cb.addItem( 'None' ) for r in self.regions: cb.addItem( r ) self.Groups.setCellWidget( i, 1, cb ) @@ -142,7 +155,7 @@ class InterpolzDlg( QDialog ): 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()) @@ -161,7 +174,10 @@ class InterpolzDlg( QDialog ): 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