From: asl Date: Wed, 12 Oct 2016 07:10:39 +0000 (+0300) Subject: Lot 6: generation of the interpolz X-Git-Tag: v1.6~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b180ba7de75c60451c255c42aade5eb86a7d27b1;p=modules%2Fhydrosolver.git Lot 6: generation of the interpolz --- diff --git a/.gitignore b/.gitignore index 24743af..913ee4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .svn .yamm +*.pyc diff --git a/src/salome_hydro/interpolz.template b/src/salome_hydro/interpolz.template index 1596f43..102b67f 100644 --- a/src/salome_hydro/interpolz.template +++ b/src/salome_hydro/interpolz.template @@ -1,5 +1,4 @@ -”””Z interpolation with HYDRO””” - +# Z interpolation with HYDRO from salome.hydrotools.interpolZ import interpolZ # Calculation case name in HYDRO @@ -11,7 +10,7 @@ medFile = # Dictionary [med group name] = region name -# Value to use for Z when the node is not in a region (used to detect problems) +# Value to use for Z when the node is not in a region (used to detect problems) zUndef = # Interpolation method diff --git a/src/salome_hydro/interpolz.ui b/src/salome_hydro/interpolz.ui index f3b1c17..eac1873 100644 --- a/src/salome_hydro/interpolz.ui +++ b/src/salome_hydro/interpolz.ui @@ -1,6 +1,6 @@ - Dialog + InterpolZ diff --git a/src/salome_hydro/interpolzUI.py b/src/salome_hydro/interpolzUI.py new file mode 100644 index 0000000..860581c --- /dev/null +++ b/src/salome_hydro/interpolzUI.py @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'interpolz.ui' +# +# Created: Wed Oct 12 08:40:47 2016 +# by: PyQt4 UI code generator 4.9.6 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + def _fromUtf8(s): + return s + +try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig, _encoding) +except AttributeError: + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig) + +class Ui_InterpolZ(object): + def setupUi(self, Dialog): + Dialog.setObjectName(_fromUtf8("Dialog")) + Dialog.setGeometry(QtCore.QRect(0, 0, 656, 500)) + self.gridLayout_2 = QtGui.QGridLayout(Dialog) + self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) + self.gridLayout = QtGui.QGridLayout() + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + self.lblCalcCase = QtGui.QLabel(Dialog) + self.lblCalcCase.setObjectName(_fromUtf8("lblCalcCase")) + self.gridLayout.addWidget(self.lblCalcCase, 0, 1, 1, 1) + self.CalcCase = QtGui.QLineEdit(Dialog) + self.CalcCase.setObjectName(_fromUtf8("CalcCase")) + self.gridLayout.addWidget(self.CalcCase, 0, 2, 1, 1) + self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1) + self.grpPaths = QtGui.QGroupBox(Dialog) + self.grpPaths.setObjectName(_fromUtf8("grpPaths")) + self.gridLayout_4 = QtGui.QGridLayout(self.grpPaths) + self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) + self.gridLayout_3 = QtGui.QGridLayout() + self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) + self.lblOutputPath = QtGui.QLabel(self.grpPaths) + self.lblOutputPath.setObjectName(_fromUtf8("lblOutputPath")) + self.gridLayout_3.addWidget(self.lblOutputPath, 0, 0, 1, 1) + self.OutputPath = QtGui.QLineEdit(self.grpPaths) + self.OutputPath.setObjectName(_fromUtf8("OutputPath")) + self.gridLayout_3.addWidget(self.OutputPath, 0, 2, 1, 1) + self.lblMEDFile = QtGui.QLabel(self.grpPaths) + self.lblMEDFile.setObjectName(_fromUtf8("lblMEDFile")) + self.gridLayout_3.addWidget(self.lblMEDFile, 1, 0, 1, 1) + self.MEDFile = QtGui.QLineEdit(self.grpPaths) + self.MEDFile.setObjectName(_fromUtf8("MEDFile")) + self.gridLayout_3.addWidget(self.MEDFile, 1, 2, 1, 1) + self.btnOutputPath = QtGui.QToolButton(self.grpPaths) + self.btnOutputPath.setObjectName(_fromUtf8("btnOutputPath")) + self.gridLayout_3.addWidget(self.btnOutputPath, 0, 3, 1, 1) + self.btnMEDFile = QtGui.QToolButton(self.grpPaths) + self.btnMEDFile.setObjectName(_fromUtf8("btnMEDFile")) + self.gridLayout_3.addWidget(self.btnMEDFile, 1, 3, 1, 1) + self.gridLayout_4.addLayout(self.gridLayout_3, 0, 0, 1, 1) + self.gridLayout_2.addWidget(self.grpPaths, 1, 0, 1, 1) + self.grpParams = QtGui.QGroupBox(Dialog) + self.grpParams.setObjectName(_fromUtf8("grpParams")) + self.gridLayout_6 = QtGui.QGridLayout(self.grpParams) + self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6")) + self.gridLayout_5 = QtGui.QGridLayout() + self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5")) + self.lblUndefZ = QtGui.QLabel(self.grpParams) + self.lblUndefZ.setObjectName(_fromUtf8("lblUndefZ")) + self.gridLayout_5.addWidget(self.lblUndefZ, 0, 0, 1, 1) + self.UndefZ = QtGui.QLineEdit(self.grpParams) + self.UndefZ.setObjectName(_fromUtf8("UndefZ")) + self.gridLayout_5.addWidget(self.UndefZ, 0, 1, 1, 1) + self.lblInterpMethod = QtGui.QLabel(self.grpParams) + self.lblInterpMethod.setObjectName(_fromUtf8("lblInterpMethod")) + self.gridLayout_5.addWidget(self.lblInterpMethod, 1, 0, 1, 1) + self.InterpMethod = QtGui.QComboBox(self.grpParams) + self.InterpMethod.setObjectName(_fromUtf8("InterpMethod")) + self.gridLayout_5.addWidget(self.InterpMethod, 1, 1, 1, 1) + self.gridLayout_6.addLayout(self.gridLayout_5, 0, 0, 1, 1) + self.Groups = QtGui.QTableWidget(self.grpParams) + self.Groups.setObjectName(_fromUtf8("Groups")) + self.Groups.setColumnCount(0) + self.Groups.setRowCount(0) + self.gridLayout_6.addWidget(self.Groups, 1, 0, 1, 1) + self.gridLayout_2.addWidget(self.grpParams, 2, 0, 1, 1) + self.frame = QtGui.QFrame(Dialog) + self.frame.setFrameShape(QtGui.QFrame.StyledPanel) + self.frame.setFrameShadow(QtGui.QFrame.Raised) + self.frame.setObjectName(_fromUtf8("frame")) + self.horizontalLayout_2 = QtGui.QHBoxLayout(self.frame) + self.horizontalLayout_2.setSpacing(0) + self.horizontalLayout_2.setMargin(0) + self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) + self.ApplyClose = QtGui.QPushButton(self.frame) + self.ApplyClose.setObjectName(_fromUtf8("ApplyClose")) + self.horizontalLayout_2.addWidget(self.ApplyClose) + self.Apply = QtGui.QPushButton(self.frame) + self.Apply.setObjectName(_fromUtf8("Apply")) + self.horizontalLayout_2.addWidget(self.Apply) + self.Close = QtGui.QPushButton(self.frame) + self.Close.setObjectName(_fromUtf8("Close")) + self.horizontalLayout_2.addWidget(self.Close) + spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout_2.addItem(spacerItem) + self.Help = QtGui.QPushButton(self.frame) + self.Help.setObjectName(_fromUtf8("Help")) + self.horizontalLayout_2.addWidget(self.Help) + self.gridLayout_2.addWidget(self.frame, 3, 0, 1, 1) + + self.retranslateUi(Dialog) + QtCore.QMetaObject.connectSlotsByName(Dialog) + + def retranslateUi(self, Dialog): + Dialog.setWindowTitle(_translate("InterpolZ", "Dialog", None)) + self.lblCalcCase.setText(_translate("InterpolZ", "Calculation case:", None)) + self.grpPaths.setTitle(_translate("InterpolZ", "Paths", None)) + self.lblOutputPath.setText(_translate("InterpolZ", "Output path:", None)) + self.lblMEDFile.setText(_translate("InterpolZ", "MED file:", None)) + self.btnOutputPath.setText(_translate("InterpolZ", "...", None)) + self.btnMEDFile.setText(_translate("InterpolZ", "...", None)) + self.grpParams.setTitle(_translate("InterpolZ", "Parameters", None)) + self.lblUndefZ.setText(_translate("InterpolZ", "Undefined Z:", None)) + self.lblInterpMethod.setText(_translate("InterpolZ", "Interpolation method:", None)) + self.ApplyClose.setText(_translate("InterpolZ", "Apply and Close", None)) + self.Apply.setText(_translate("InterpolZ", "Apply", None)) + self.Close.setText(_translate("InterpolZ", "Close", None)) + self.Help.setText(_translate("InterpolZ", "Help", None)) + diff --git a/src/salome_hydro/interpolz_gui.py b/src/salome_hydro/interpolz_gui.py index 7e507f0..91e4adc 100644 --- a/src/salome_hydro/interpolz_gui.py +++ b/src/salome_hydro/interpolz_gui.py @@ -1,23 +1,48 @@ import sys, os +sys.path.append(os.path.join(os.environ['MEDFILE_ROOT_DIR'], 'lib\python2.7\site-packages\med')) + +import salome +salome.salome_init() + +import MEDLoader +import HYDROPy + from PyQt4 import QtCore, QtGui +#from interpolzUI import Ui_InterpolZ + +def get_med_groups( file_path ): + meshes = MEDLoader.MEDLoader_GetMeshNames(file_path) + if len(meshes)==0: + return [] + mesh1 = meshes[0] + groups = list(MEDLoader.MEDLoader_GetMeshGroupsNames(file_path, mesh1)) + return groups + +def get_hydro_regions( calc_case_name ): + aStudyId = salome.myStudyId + doc = HYDROPy.HYDROData_Document.Document( aStudyId ) + case = doc.FindObjectByName( calc_case_name ) + if isinstance(case, HYDROPy.HYDROData_CalculationCase): + regions = case.GetRegions() + regions_names = [] + for r in regions: + rname = r.GetName() + regions_names.append( str(rname) ) + return regions_names + else: + return [] class InterpolzDlg( QtGui.QDialog ): def __init__(self, parent = None): QtGui.QDialog.__init__( self, parent ) - + #app = QtGui.QApplication( sys.argv ) #dlg = InterpolzDlg() #dlg.show() #app.exec_() -sys.path.append(os.path.join(os.environ['MEDFILE_ROOT_DIR'], 'lib\python2.7\site-packages\med')) -import medfile -import medmesh -import medenum - -file_path = "c:/hydro/channel.med" -f = medfile.MEDfileOpen(str(file_path), medenum.MED_ACC_RDEXT) -print medmesh.MEDmeshInfo(fid, 1) +#print get_med_groups( "/dn26/HYDRO/channel.med" ) +print get_hydro_regions( "Case_1" )